/* community.agilehri.org: platform layout in FIWARE colours. */

:root {
  --navy: #002e67;
  --navy-2: #1a4a82;
  --cyan: #5dc0cf;
  --light: #c7e9ee;
  --pale: #eef7f9;
  --border: #e3e3e4;
  --grey: #6a6a6c;
  --text: #1d1f24;
  --bg: #f4f7f9;
  --amber: #fff1c7;
  --amber-line: #e0a800;
  --sidebar-w: 240px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: Montserrat, system-ui, sans-serif; font-size: 14px; color: var(--text); background: var(--bg); }
a { color: var(--navy-2); }
h1 { font-size: 1.4rem; color: var(--navy); margin: 0 0 .4rem; }
h2 { font-size: 1rem; color: var(--navy); margin: 0 0 .5rem; }
.muted { color: var(--grey); font-size: .9rem; }
.note { margin-top: .75rem; }
.icon { width: 18px; height: 18px; flex: none; }

/* --- Layout ------------------------------------------------------------------ */

.app { display: flex; min-height: 100vh; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.workspace { flex: 1; display: flex; min-height: 0; }
.content { flex: 1; min-width: 0; padding: 24px; }

/* Sidebar */
.sidebar { width: var(--sidebar-w); flex: none; background: var(--navy); color: #fff; display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; }
.server { display: flex; align-items: center; gap: 10px; padding: 18px 16px; border-bottom: 1px solid rgba(255, 255, 255, .12); }
.server img, .server-dot { width: 36px; height: 36px; border-radius: 10px; background: var(--cyan); flex: none; }
.server-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--light); }
.server-name { font-weight: 700; }
.nav { padding: 12px 8px; display: flex; flex-direction: column; gap: 2px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; color: var(--light);
  text-decoration: none; font-weight: 600; }
.nav-item:hover { background: var(--navy-2); color: #fff; }
.nav-item.on { background: rgba(93, 192, 207, .22); color: #fff; }
.nav-bottom { margin-top: auto; padding: 12px 8px; border-top: 1px solid rgba(255, 255, 255, .12); }

/* Top bar */
.topbar { height: 60px; flex: none; display: flex; align-items: center; gap: 20px; padding: 0 24px; background: #fff;
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
.topbar-title { font-weight: 700; font-size: 1.05rem; color: var(--navy); white-space: nowrap; flex: none; }
.tabs { display: flex; gap: 4px; height: 100%; overflow-x: auto; flex: 1; min-width: 0; scrollbar-width: none; }
.tab { display: flex; align-items: center; padding: 0 12px; color: var(--grey); text-decoration: none; font-weight: 600;
  border-bottom: 2px solid transparent; white-space: nowrap; }
.tab:hover { color: var(--navy); }
.tab.on { color: var(--navy); border-bottom-color: var(--cyan); }
.topbar-user { margin-left: auto; flex: none; }
.user { display: flex; align-items: center; gap: 10px; }
.user img { width: 32px; height: 32px; border-radius: 50%; }
.user-name { font-weight: 600; color: var(--navy); }
.user form { margin: 0; }
.menu-button { display: none; background: none; border: 0; color: var(--navy); cursor: pointer; padding: 4px; }

/* Secondary sidebar */
.secondary { width: 240px; flex: none; background: #fff; border-right: 1px solid var(--border); padding: 16px 8px; overflow-y: auto; }
.secondary-title { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--grey); font-weight: 700;
  padding: 0 10px 8px; }
.sec-item { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 8px; color: var(--text); text-decoration: none; }
.sec-item:hover { background: var(--pale); }
.sec-item.on { background: var(--light); color: var(--navy); font-weight: 600; }
.sec-item .dot { width: 14px; text-align: center; color: var(--grey); }
.sec-item .custom { margin-left: auto; color: var(--cyan); font-weight: 700; }

/* --- Content ------------------------------------------------------------------- */

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.card { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 18px 20px; }
.card.wide { grid-column: 1 / -1; }
.content > .card + .card, .content > .card + .grid { margin-top: 16px; }

.banner { background: var(--pale); border-radius: 10px; padding: 12px 16px; margin-bottom: 16px; }
.banner.viewas { background: var(--amber); border: 1px solid var(--amber-line); }
.banner.bad { background: #fcecec; color: #9b1c1c; }
.banner.ok { background: #e7f6ec; color: #1a7f37; margin: .75rem 0 0; }
.banner .chips { margin: .5rem 0; }

.button { display: inline-block; padding: 8px 14px; border: 0; border-radius: 8px; background: var(--navy); color: #fff;
  text-decoration: none; font: inherit; font-weight: 600; cursor: pointer; }
.button:hover { background: var(--navy-2); }
.button.quiet { background: var(--pale); color: var(--navy); }
.button.quiet:hover { background: var(--light); }
.button.small { padding: 5px 10px; font-size: .85rem; }

.pill { display: inline-block; margin-top: .4rem; padding: 2px 10px; border-radius: 999px; background: var(--cyan); color: var(--navy);
  font-size: .75rem; font-weight: 700; }

.chips { display: flex; flex-wrap: wrap; gap: .4rem; padding: 0; margin: .5rem 0 0; list-style: none; }
.chip { display: inline-block; padding: .2rem .6rem; border-radius: 999px; background: var(--pale); border-left: 4px solid var(--c, #99aab5);
  font-size: .85rem; color: inherit; text-decoration: none; }
a.chip:hover { background: var(--light); }
.chip.on { background: var(--light); font-weight: 600; }

.welcome { display: flex; align-items: center; gap: 14px; }
.welcome img { width: 56px; height: 56px; border-radius: 14px; }
.welcome h1 { margin: 0; }
.profile { display: flex; align-items: center; gap: 16px; }
.profile img { width: 72px; height: 72px; border-radius: 50%; }
.profile h1 { margin: 0; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-top: .75rem; }
.tile { background: var(--pale); border-radius: 10px; padding: 12px 14px; }
.tile b { display: block; font-size: 1.6rem; color: var(--navy); }
.tile span { color: var(--grey); font-size: .8rem; }

.bars { display: flex; align-items: flex-end; gap: 3px; height: 140px; margin-top: .75rem; }
.bars div { flex: 1; background: var(--navy); border-radius: 3px 3px 0 0; min-height: 1px; }
.axis { display: flex; justify-content: space-between; color: var(--grey); font-size: .75rem; margin-top: .3rem; }
.ranking { list-style: none; padding: 0; margin: .75rem 0 0; }
.ranking li { display: flex; align-items: center; gap: .6rem; margin: .4rem 0; }
.ranking .name { width: 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ranking .meter { flex: 1; height: .55rem; background: var(--pale); border-radius: 999px; overflow: hidden; }
.ranking .meter div { height: 100%; background: var(--cyan); }
.ranking .n { width: 3.5rem; text-align: right; color: var(--grey); }

.admin-form fieldset { border: 1px solid var(--border); border-radius: 10px; margin: 0 0 .75rem; padding: .6rem .9rem; }
.admin-form fieldset label { display: block; margin: .25rem 0; }
.admin-form .kpis { margin-left: 1.5rem; columns: 2; }
.admin-form .inherited { color: #8a8f98; }
.admin-form .actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 1rem; }
.sticky-actions { position: sticky; bottom: 0; background: #fff; padding: 12px 0; border-top: 1px solid var(--border); z-index: 2; }
.unsaved { color: #b45309; font-weight: 600; font-size: .85rem; }
.vis-group { margin: 1rem 0 1.25rem; }
.vis-group-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: .5rem;
  border-bottom: 1px solid var(--border); padding-bottom: .35rem; }
.vis-group-head h3 { margin: 0; font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--grey); }
.vis-group-tools { display: flex; gap: 6px; }
.trail { font-size: .8rem; margin-bottom: .3rem; }

.table { width: 100%; border-collapse: collapse; margin-top: .75rem; }
.table th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--grey); padding: 8px; }
.table td { padding: 8px; border-top: 1px solid var(--border); }

/* Language selector (bottom of the sidebar) and counters */
.languages { display: flex; align-items: center; gap: 2px; padding: 8px 12px; color: var(--light); }
.languages .icon { margin-right: 6px; width: 16px; height: 16px; }
.languages a { color: var(--light); text-decoration: none; font-size: .75rem; font-weight: 700; padding: 3px 5px; border-radius: 5px; }
.languages a:hover { background: var(--navy-2); color: #fff; }
.languages a.on { background: rgba(93, 192, 207, .22); color: #fff; }
.badge { display: inline-block; min-width: 1.4em; padding: 0 .4em; border-radius: 999px; background: var(--cyan); color: var(--navy);
  font-size: .72rem; font-weight: 700; text-align: center; line-height: 1.5; }
.nav-item .badge { margin-left: auto; }

/* "New messages!" under Latest mentions in the sidebar */
.nav-label { display: flex; flex-direction: column; min-width: 0; }
.flag { align-self: flex-start; margin-top: 3px; padding: 0 .5em; border-radius: 999px; font-size: .68rem; font-weight: 700;
  line-height: 1.6; white-space: nowrap; }
.flag.you { background: var(--cyan); color: var(--navy); }
.flag.roles { border: 1px solid rgba(199, 233, 238, .55); color: var(--light); }

/* Latest mentions: secondary panel */
.secondary-title.section { margin-top: 14px; }
.sec-item .count { margin-left: auto; min-width: 1.5em; padding: 0 .45em; border-radius: 999px; background: var(--cyan); color: var(--navy);
  font-size: .72rem; font-weight: 700; text-align: center; line-height: 1.6; }
.sec-item .dot .icon { width: 14px; height: 14px; vertical-align: -2px; }
.sec-note { padding: 0 10px; margin: 0; }

/* Latest mentions */
.mentions { list-style: none; padding: 0; margin: 1rem 0 0; }
.mention { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; margin-bottom: 10px; background: #fff;
  transition: background-color .2s, border-color .2s; }
.mention-form { display: grid; grid-template-columns: 18px 1fr auto; gap: 12px; align-items: start; margin: 0; }
.mention-head { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.mention-head strong { font-weight: 600; }
.mention .excerpt { margin: .35rem 0 .45rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.open-link { font-size: .85rem; font-weight: 600; text-decoration: none; }
.open-links { display: flex; gap: 16px; flex-wrap: wrap; }
.open-link.here { color: var(--navy); }
.open-link:hover { text-decoration: underline; }

/* Unread: highlighted, bold, filled dot. Read: white, grey, hollow dot. */
.mention.unread { border-color: var(--cyan); background: var(--pale); }
.mention.unread .mention-head strong { font-weight: 700; color: var(--navy); }
.mention:not(.unread) .mention-head strong, .mention:not(.unread) .excerpt { color: var(--grey); }
.state-dot { width: 14px; height: 14px; margin-top: 3px; padding: 0; border-radius: 50%; border: 2px solid #b8bcc4; background: transparent;
  cursor: pointer; transition: background-color .2s, border-color .2s, transform .1s; }
.state-dot:hover { transform: scale(1.25); }
.state-dot:focus-visible, .toggle:focus-visible { outline: 3px solid var(--cyan); outline-offset: 2px; }
.mention.unread .state-dot { background: var(--cyan); border-color: var(--cyan); }
.toggle { white-space: nowrap; }

.disclaimer { background: var(--pale); border-radius: 8px; padding: 8px 12px; margin: .6rem 0; font-size: .85rem; color: var(--grey); }
.list-tools { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin: .6rem 0; }
.list-tools form { margin: 0; }
.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.segmented a { padding: 5px 12px; font-size: .85rem; font-weight: 600; color: var(--grey); text-decoration: none; }
.segmented a.on { background: var(--light); color: var(--navy); }
.arrivals { margin: .6rem 0; background: var(--amber); border: 1px solid var(--amber-line); }
.mention-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.mention-head .icon { color: var(--cyan); }
.mention-head .pill { margin: 0; }
.mention .excerpt { margin: .5rem 0 .6rem; white-space: pre-wrap; overflow-wrap: anywhere; }

/* "View this site as": banner and role chips */
.viewas .chips.inline { display: inline-flex; margin: 0 0 0 .3rem; vertical-align: middle; }
.viewas-actions { margin: .4rem 0; font-weight: 600; }
.viewas-picker .chips { margin: .75rem 0; }
.chip.pick { cursor: pointer; user-select: none; }
.chip.pick input { position: absolute; opacity: 0; pointer-events: none; }
.chip.pick:has(input:checked) { background: var(--light); font-weight: 700; box-shadow: inset 0 0 0 2px var(--c, var(--navy-2)); }
.chip.pick:has(input:focus-visible) { outline: 3px solid var(--cyan); outline-offset: 2px; }
.state-dot:disabled, .toggle:disabled { cursor: default; opacity: .6; }

/* Chat (read only) */
.secondary.tree .sec-item { padding: 5px 10px; }
.secondary.tree .sec-item .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.secondary.tree .sec-item.thread { padding-left: 22px; font-size: .9rem; }
.secondary.tree .sec-item.disabled { color: #a0a4ab; cursor: not-allowed; }
.secondary.tree .lock, .secondary.tree .threads-count { margin-left: auto; font-size: .72rem; color: var(--grey); }
.secondary.tree .threads-count { padding: 0 .45em; border-radius: 999px; background: var(--pale); font-weight: 700; }
.chat-tools { display: flex; gap: 8px; margin: 0 0 .6rem; }
.chat-log { list-style: none; padding: 0; margin: .5rem 0; }
.msg { display: grid; grid-template-columns: 40px 1fr; gap: 12px; padding: 6px 4px; border-radius: 6px; }
.msg:hover { background: var(--bg); }
.msg:not(.grouped) { margin-top: 10px; }
.msg.grouped { padding-top: 1px; padding-bottom: 1px; }
.msg.grouped .avatar { height: 0; }
.msg.target { background: var(--amber); box-shadow: inset 3px 0 0 var(--amber-line); }
.msg.target:hover { background: var(--amber); }
.msg.system { display: block; padding-left: 56px; font-size: .85rem; }
.avatar { width: 40px; height: 40px; border-radius: 50%; }
.msg-body { min-width: 0; }
.msg-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.msg-head strong { color: var(--navy); }
.msg .text { overflow-wrap: anywhere; line-height: 1.45; }
.msg .text pre { background: var(--pale); padding: 8px 10px; border-radius: 6px; overflow-x: auto; margin: .3rem 0; }
.msg .text code { background: var(--pale); padding: 0 .3em; border-radius: 4px; font-size: .9em; }
.msg .text pre code { padding: 0; background: none; }
.msg .quote { display: block; border-left: 3px solid var(--border); padding-left: 8px; color: var(--grey); }
.msg .spoiler { background: #2f3136; color: transparent; border-radius: 3px; cursor: pointer; }
.msg .spoiler:hover, .msg .spoiler:focus { background: var(--pale); color: inherit; }
.ment { background: rgba(93, 192, 207, .2); color: var(--navy); border-radius: 4px; padding: 0 3px; font-weight: 600; text-decoration: none;
  border-bottom: 2px solid var(--c, transparent); }
.reply { font-size: .8rem; color: var(--grey); margin-bottom: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag { background: var(--navy-2); color: #fff; font-size: .62rem; font-weight: 700; padding: 1px 4px; border-radius: 3px; }
.att-img { display: block; max-width: min(400px, 100%); max-height: 300px; border-radius: 8px; margin-top: 6px; }
.att { display: inline-block; margin-top: 6px; padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px; text-decoration: none; }
.embed { border-left: 4px solid var(--cyan); background: var(--bg); border-radius: 4px; padding: 8px 10px; margin-top: 6px; max-width: 520px; }
.posts { list-style: none; padding: 0; }
.posts li { padding: 8px 0; border-top: 1px solid var(--border); }
.posts a { text-decoration: none; font-weight: 600; }

/* --- Discord mark (D-033) ------------------------------------------------------ */

.dmark { width: 1em; height: 1em; flex: none; vertical-align: -.125em; }
.nav-item .dmark { width: 18px; height: 18px; }
.nav-item .ext { margin-left: auto; opacity: .7; }
.to-discord { margin-left: auto; display: inline-flex; align-items: center; gap: 2px; color: #a0a4ab; font-size: .78rem; font-weight: 700; }
.sec-item:hover .to-discord, .sec-item.on .to-discord { color: #5865f2; }
.sec-item.only-discord .name { color: var(--grey); }
.sec-item.only-discord.on .name { color: var(--navy); }
.open-link.to-app { display: inline-flex; align-items: center; gap: 5px; }
.button.discord { display: inline-flex; align-items: center; gap: 8px; background: #5865f2; }
.button.discord:hover { background: #4752c4; }
.button.discord .dmark { width: 18px; height: 18px; }

/* --- Discord Channels: the page fills the window; the panes scroll ------------- */

.app.fixed { height: 100vh; height: 100dvh; min-height: 0; overflow: hidden; }
.app.fixed .main { height: 100%; min-height: 0; }
.app.fixed .workspace { min-height: 0; overflow: hidden; }
.app.fixed .secondary { overflow-y: auto; }
.app.fixed .content { display: flex; flex-direction: column; min-height: 0; padding: 16px 24px; }
.app.fixed .content > .banner { flex: none; }

.pane { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; background: #fff;
  border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.pane-head { flex: none; display: flex; align-items: flex-start; gap: 16px; padding: 14px 20px; border-bottom: 1px solid var(--border); }
.pane-title { flex: 1; min-width: 0; }
.pane-head h1 { margin: 0; font-size: 1.2rem; overflow-wrap: anywhere; }
.pane-head .topic { margin: .25rem 0 0; color: var(--grey); font-size: .85rem; overflow-wrap: anywhere; }
.open-discord { flex: none; display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 8px;
  color: #5865f2; background: #eef0fe; font-weight: 600; font-size: .85rem; text-decoration: none; white-space: nowrap; }
.open-discord:hover { background: #e0e3fd; }
.pane-body { flex: 1; min-height: 0; overflow-y: auto; padding: 8px 20px 16px; scroll-behavior: auto; }
.pane-foot { flex: none; display: flex; align-items: center; justify-content: center; padding: 10px 20px; border-top: 1px solid var(--border);
  background: var(--bg); font-size: .85rem; }
.pane-pad { padding-top: 8px; }
.pane .arrivals { position: absolute; left: 50%; transform: translateX(-50%); bottom: 56px; border: 0; border-radius: 999px;
  padding: 6px 14px; background: var(--navy); color: #fff; font: inherit; font-weight: 700; font-size: .85rem; cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .2); }
.pane .arrivals[hidden] { display: none; }

/* A card in the middle of the pane */
.pane-centre { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 24px 0; }
.centre-card { max-width: 440px; text-align: center; line-height: 1.5; }
.centre-card p { margin: .4rem 0; }
.centre-mark { color: #5865f2; font-size: 44px; line-height: 1; margin-bottom: .5rem; }
.centre-actions { margin-top: 1rem; }
.bad-text { color: #9b1c1c; }

/* Day separators */
.chat-log .day { display: flex; align-items: center; gap: 12px; margin: 16px 0 6px; color: var(--grey); font-size: .75rem; font-weight: 700; }
.chat-log .day::before, .chat-log .day::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.chat-log .empty { color: var(--grey); padding: 24px 0; text-align: center; }

/* --- Small screens: the sidebar slides in from the left -------------------------- */

@media (max-width: 900px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 20; transform: translateX(-100%); transition: transform .2s; }
  body.nav-open .sidebar { transform: none; }
  .scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 15; }
  .menu-button { display: block; }
  .topbar { padding: 0 12px; gap: 10px; }
  .user-name { display: none; }
  .user img { display: none; }
  .tab { padding: 0 8px; }
  .workspace { flex-direction: column; }
  .secondary { width: auto; border-right: 0; border-bottom: 1px solid var(--border); display: flex; overflow-x: auto; gap: 4px; padding: 8px; }
  .secondary-title { display: none; }
  .sec-item { white-space: nowrap; }
  .content { padding: 16px; }
  .grid { grid-template-columns: 1fr; }
  .admin-form .kpis { columns: 1; }
  .mention-form { grid-template-columns: 18px 1fr; }
  .mention-form .toggle { grid-column: 2; justify-self: start; }
  /* The channel tree stays a list (scrolls inside) instead of a strip; the
     message pane takes the rest of the screen. */
  .secondary.tree { display: block; max-height: 30vh; flex: none; }
  .app.fixed .content { padding: 10px; }
  .pane-head { padding: 10px 12px; gap: 10px; }
  .open-discord span { display: none; }
  .pane-body { padding: 6px 12px 12px; }
  .pane-foot { padding: 8px 12px; font-size: .78rem; }
  .secondary.tree .secondary-title { display: block; }
  .msg { grid-template-columns: 32px 1fr; gap: 8px; }
  .avatar { width: 32px; height: 32px; }
  .msg.system { padding-left: 44px; }
}
