/* ==========================================================================
   Support — the tenant's conversation with Vava Support (support.html)

   One page, two channels: General (the whole team) and Admin (tenant admins
   only). The shell is a card on the page ground; inside it a rail of channels
   and, to the right, the conversation itself.

   THEMEABLE THROUGHOUT. Every surface, ink and border here is a token, so the
   page follows the palette instead of pinning a light one. What stays literal
   is the file-type badge colours on the attachment chips, which are the same
   red / green / blue / violet in every theme because they identify a format,
   not a state, and always carry white glyphs.
   ========================================================================== */

/* ===================== Support (tenant ↔ Vava Support) chat ===================== */
/* Gray page with a visible gutter, matching the other pages */
.chat-page { padding: 16px 20px 18px; overflow: hidden; display: flex; flex-direction: column; background: var(--color-bg); }
.chat-topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.chat-topbar .page-title { font-size: 20px; }
/* The whole chat sits as one white card floating on the gray page (border + shadow like .card) */
.chat-shell { flex: 1; min-height: 0; display: grid; grid-template-columns: 250px 1fr; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md); box-shadow: var(--shadow-sm); overflow: hidden; }

/* ---------- Left rail: support channels ---------- */
.chat-rail { border-right: 1px solid var(--color-border); background: var(--color-surface-alt); display: flex; flex-direction: column; min-height: 0; }
.chat-rail-head { padding: 14px 14px 6px; }
.chat-rail-title { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--color-text-subtle); font-weight: 600; }
/* In-conversation search — compact, always open, in the thread header (active thread only) */
.chat-thread-head-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.chat-head-search { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 8px; background: var(--color-search-bg); border: 1px solid var(--color-border); border-radius: 5px; width: 300px; }
.chat-head-search:focus-within { border-color: var(--color-primary); }
.chat-notes-badge { margin-left: 5px; font-size: 11px; color: var(--color-primary-700); background: var(--color-primary-50); border-radius: 5px; padding: 0 6px; }
.chat-notes-badge:empty { display: none; }
.chat-head-search svg { width: 14px; height: 14px; color: var(--color-text-subtle); flex-shrink: 0; }
.chat-head-search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font: inherit; font-size: 13px; color: var(--color-text); }
.chat-search-count { font-size: 11px; color: var(--color-text-subtle); white-space: nowrap; flex-shrink: 0; }
.chat-hit { background: color-mix(in oklab, var(--color-warn) 55%, var(--color-surface)); color: var(--color-text); border-radius: 2px; padding: 0 1px; }
.chat-threads { flex: 1; overflow-y: auto; padding: 2px 10px 12px; }
.thread-group { margin-top: 10px; }
.thread-group.is-role-hidden { display: none; }
.thread-group-title { display: flex; align-items: center; gap: 6px; padding: 4px 6px 4px; font-size: 10px; text-transform: uppercase; letter-spacing: .08em; font-weight: 600; color: var(--color-text-subtle); }
.thread-group-title svg { width: 12px; height: 12px; }
.thread-group--admin .thread-group-title { color: var(--color-warn); }
.thread-item { display: block; padding: 9px 10px; border: 1px solid var(--color-control-border); border-left: 3px solid transparent; border-radius: 5px; background: var(--color-control); margin-bottom: 6px; cursor: pointer; text-decoration: none; color: var(--color-text); transition: background .12s, border-color .12s; }
.thread-item:hover { background: var(--color-surface); }
.thread-item.is-active { background: var(--color-primary-50); border-color: var(--color-primary); border-left-color: var(--color-primary); }
.thread-group--admin .thread-item.is-active { background: var(--color-warn-50); border-color: var(--color-warn); border-left-color: var(--color-warn); }
.thread-top { display: flex; align-items: center; gap: 6px; margin-bottom: 2px; }
.thread-name { font-size: 13px; font-weight: 600; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread-lock { width: 12px; height: 12px; color: var(--color-warn); flex-shrink: 0; }
.thread-unread { font-size: 10px; font-weight: 600; color: #fff; background: var(--color-danger); border-radius: 999px; padding: 1px 6px; min-width: 16px; text-align: center; }
.thread-meta { display: flex; justify-content: space-between; gap: 6px; font-size: 11px; color: var(--color-text-subtle); }
.thread-scope { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Right panel ---------- */
.chat-main { position: relative; display: flex; flex-direction: column; min-height: 0; background: var(--color-bg); }
.chat-thread-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 18px; background: var(--color-surface); border-bottom: 1px solid var(--color-border); }
.chat-thread-title { font-family: 'Schibsted Grotesk', sans-serif; font-size: 15px; font-weight: 600; color: var(--color-text); letter-spacing: -0.01em; }
.chat-thread-sub { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--color-text-subtle); margin-top: 2px; }
.chat-thread-sub svg { width: 13px; height: 13px; }
.chat-thread-actions { display: flex; align-items: center; gap: 10px; }
.chat-presence { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--color-success); font-weight: 500; }
.chat-presence .dot { width: 7px; height: 7px; border-radius: 999px; background: var(--color-success); }

/* Conversation Summary — a slide-over drawer that overlays the conversation.
   The chat stays visible (dimmed by a scrim) behind it, so it clearly reads as a layer on top. */
.csum-scrim { position: absolute; inset: 0; background: rgba(20, 30, 50, 0.28); opacity: 0; visibility: hidden; transition: opacity .2s ease; z-index: 5; }
.chat-main.is-summary .csum-scrim { opacity: 1; visibility: visible; }
/* Floats inside the conversation with a gap on all four sides — the drawer reads as a panel over the chat, not a second column welded to it. */
.csum-drawer { position: absolute; top: 12px; right: 12px; bottom: 12px; width: min(780px, 70%); display: flex; flex-direction: column; min-height: 0; background: var(--color-surface); border: 1px solid var(--color-border-strong); border-radius: 7px; overflow: hidden; box-shadow: -10px 0 40px rgba(20, 30, 50, 0.28); transform: translateX(calc(100% + 14px)); transition: transform .22s ease; z-index: 6; }
.chat-main.is-summary .csum-drawer { transform: translateX(0); }
.csum-drawer-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 14px; background: var(--color-primary-50); border-bottom: 1px solid color-mix(in oklab, var(--color-primary) 30%, var(--color-primary-50)); }
.csum-drawer-title { display: inline-flex; align-items: center; gap: 7px; font-family: 'Schibsted Grotesk', sans-serif; font-size: 14px; font-weight: 600; color: var(--color-primary-700); letter-spacing: -0.01em; }
.csum-drawer-title svg { width: 15px; height: 15px; }
.csum-drawer-close { width: 30px; height: 30px; flex: none; display: grid; place-items: center; border: 1px solid color-mix(in oklab, var(--color-primary) 30%, var(--color-primary-50)); border-radius: 999px; background: var(--color-surface); color: var(--color-primary-700); font-size: 22px; line-height: 1; cursor: pointer; padding: 0; box-shadow: var(--shadow-sm); }
.csum-drawer-close:hover { background: var(--color-primary-700); border-color: var(--color-primary-700); color: #fff; }
.csum-drawer-note { font-size: 11.5px; color: var(--color-text-muted); padding: 9px 14px 0; }
/* Real tabs: a strip sitting on a bottom border; the active tab has a primary underline */
.csum-tabs { display: flex; gap: 4px; padding: 0 14px; border-bottom: 1px solid var(--color-border); }
.csum-tab { position: relative; display: inline-flex; align-items: center; gap: 6px; font: inherit; font-size: 13px; font-weight: 600; padding: 10px 12px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--color-text-muted); cursor: pointer; margin-bottom: -1px; }
.csum-tab:hover { color: var(--color-text); }
.csum-tab.is-active { color: var(--color-primary-700); border-bottom-color: var(--color-primary); }
.csum-tab-count { font-size: 10px; font-weight: 700; background: var(--color-control); border-radius: 999px; padding: 0 5px; color: inherit; }
.csum-tab.is-active .csum-tab-count { background: var(--color-primary-50); color: var(--color-primary-700); }
.csum-tabpanel { flex: 1; min-height: 0; overflow-y: auto; padding: 14px; }
.csum-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.csum-list li { position: relative; padding: 10px 12px 10px 34px; background: var(--color-surface-alt); border: 1px solid var(--color-border); border-radius: 5px; font-size: 13.5px; line-height: 1.5; color: var(--color-text); }
.csum-list li::before { content: ''; position: absolute; left: 14px; top: 16px; width: 7px; height: 7px; border-radius: 999px; background: var(--color-text-subtle); }
.csum-list--agreed li { border-left: 3px solid var(--color-success); }
.csum-list--agreed li::before { content: '✓'; top: 8px; left: 13px; width: auto; height: auto; background: transparent; color: var(--color-success); font-weight: 700; font-size: 13px; }
/* Action items: text on the left, owner/ETA tags on the right; done items are checked + struck */
.csum-list--todo li { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.csum-list--todo li::before { content: ''; top: 12px; left: 12px; width: 12px; height: 12px; border-radius: 3px; background: transparent; border: 1.5px solid var(--color-text-subtle); }
.csum-list--todo li.is-done::before { content: '✓'; background: var(--color-success); border-color: var(--color-success); color: #fff; font-size: 10px; font-weight: 700; line-height: 12px; text-align: center; }
.csum-list--todo li.is-done .csum-li-text { text-decoration: line-through; color: var(--color-text-subtle); }
.csum-li-text { flex: 1; min-width: 0; }
.csum-tags { display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0; padding-top: 1px; }
.csum-owner { font-size: 10px; text-transform: uppercase; letter-spacing: .04em; font-weight: 700; padding: 2px 7px; border-radius: 999px; white-space: nowrap; }
.csum-owner--you { background: var(--color-primary-50); color: var(--color-primary-700); border: 1px solid color-mix(in oklab, var(--color-primary) 30%, var(--color-primary-50)); }
.csum-owner--support { background: var(--color-surface-alt); color: var(--color-text-muted); border: 1px solid var(--color-border); }
.csum-eta { font-size: 11px; color: var(--color-text-subtle); white-space: nowrap; }
/* Files shared: chips with type icons */
.csum-files { display: flex; flex-wrap: wrap; gap: 8px; }
.csum-file { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px 6px 6px; background: var(--color-surface-alt); border: 1px solid var(--color-border); border-radius: 5px; cursor: pointer; }
.csum-file:hover { border-color: var(--color-primary); }
.csum-file .att-ico { width: 26px; height: 26px; border-radius: 5px; display: grid; place-items: center; color: #fff; }
.csum-file .att-ico svg { width: 14px; height: 14px; }
.csum-file[data-ft="pdf"] .att-ico { background: #B91C1C; }
.csum-file[data-ft="xlsx"] .att-ico { background: #15803D; }
.csum-file[data-ft="doc"] .att-ico { background: #1D4ED8; }
.csum-file[data-ft="img"] .att-ico { background: #7C3AED; }
.csum-file[data-ft="file"] .att-ico { background: var(--color-text-muted); }
.csum-file .att-name { color: var(--color-text); }
/* Team Notes — internal (only your team); lives in the first summary tab (Notes) */
.csum-tabpanel.is-notes { display: flex; flex-direction: column; padding: 0; overflow: hidden; }
.csum-notes-head { display: flex; align-items: center; gap: 8px; padding: 10px 14px 4px; }
.csum-notes-hint { font-size: 11px; color: var(--color-text-subtle); }
.csum-notes-list { flex: 1; min-height: 0; overflow-y: auto; padding: 8px 14px; display: flex; flex-direction: column; gap: 6px; }
.csum-note { background: var(--color-surface-alt); border: 1px solid var(--color-border); border-radius: 5px; padding: 7px 10px; }
.csum-note-meta { display: flex; align-items: baseline; gap: 6px; margin-bottom: 2px; }
.csum-note-author { font-size: 12px; font-weight: 600; color: var(--color-text); }
.csum-note-time { font-size: 10px; color: var(--color-text-subtle); margin-left: auto; }
.csum-note-text { font-size: 12.5px; line-height: 1.4; color: var(--color-text); word-wrap: break-word; }
.csum-notes-empty { font-size: 12px; color: var(--color-text-subtle); padding: 4px 2px; }
.csum-note.is-new { border-style: dashed; }
.csum-note-acts { display: inline-flex; gap: 2px; margin-left: 6px; }
.csum-note-act { border: 0; background: transparent; padding: 2px; border-radius: 4px; color: var(--color-text-subtle); cursor: pointer; display: inline-grid; place-items: center; }
.csum-note-act svg { width: 13px; height: 13px; }
.csum-note-act:hover { background: var(--color-control); color: var(--color-text); }
.csum-note-act[data-act="delete"]:hover { color: var(--color-danger); }
.csum-note-editor { width: 100%; box-sizing: border-box; font: inherit; font-size: 12.5px; line-height: 1.4; color: var(--color-text); background: var(--color-control); border: 1px solid var(--color-control-border); border-radius: 5px; padding: 6px 8px; resize: vertical; min-height: 54px; }
.csum-note-editor:focus { outline: 0; border-color: var(--color-primary); }
.csum-note-editacts { display: flex; justify-content: flex-end; gap: 6px; margin-top: 6px; }

/* Private-channel strip — the Admin conversation says so on the conversation itself,
   not only in the rail, so the reminder is there while you are typing into it. */
.chat-private { align-self: center; display: inline-flex; align-items: center; gap: 7px; margin: 12px 0 0; padding: 4px 12px; background: var(--color-warn-50); border: 1px solid var(--color-warn); border-radius: 7px; color: var(--color-text); font-size: 12px; }
.chat-private[hidden] { display: none; }
.chat-private svg { width: 13px; height: 13px; flex-shrink: 0; color: var(--color-warn); }
.chat-private strong { font-weight: 600; }

/* Messages */
.chat-messages { flex: 1; overflow-y: auto; display: flex; flex-direction: column; padding: 12px 0 18px; }
.msg-day { align-self: center; margin: 10px 0 8px; padding: 3px 12px; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: 999px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--color-text-muted); }
.msg { display: grid; grid-template-columns: 34px minmax(0, 1fr) 34px; column-gap: 10px; padding: 0 18px; margin-bottom: 12px; align-items: start; }
.chat-ava { width: 32px; height: 32px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; color: #fff; font-size: 11px; font-weight: 600; line-height: 1; grid-row: 1; box-shadow: var(--shadow-sm); background: var(--avatar-bg, var(--color-primary)); }
.chat-ava.is-face { background-size: cover; background-position: center 30%; background-repeat: no-repeat; color: transparent; font-size: 0; }
.chat-ava--support { background: var(--color-primary); }
.chat-ava--support svg { width: 17px; height: 17px; color: #fff; }
.msg[data-side="them"] .chat-ava { grid-column: 1; }
.msg[data-side="us"] .chat-ava { grid-column: 3; }
.msg-bubble { grid-column: 2; max-width: 82%; padding: 7px 11px 6px; border-radius: 7px; background: var(--color-surface); border: 1px solid var(--color-border-strong); box-shadow: var(--shadow-sm); }
.msg[data-side="them"] .msg-bubble { justify-self: start; border-top-left-radius: 2px; }
.msg[data-side="us"] .msg-bubble { justify-self: end; background: var(--color-primary-50); border-color: color-mix(in oklab, var(--color-primary) 30%, var(--color-primary-50)); border-top-right-radius: 2px; }
.msg-head { display: flex; align-items: baseline; gap: 6px; margin-bottom: 2px; flex-wrap: wrap; }
.msg-sender { font-size: 13px; font-weight: 600; color: var(--color-text); }
.msg[data-side="them"] .msg-sender { color: var(--color-primary-700); }
.msg-time { margin-left: auto; font-size: 11px; color: var(--color-text-subtle); display: inline-flex; align-items: center; gap: 3px; white-space: nowrap; padding-left: 10px; }
.msg-check { color: var(--color-primary); font-weight: 700; letter-spacing: -1px; }
.msg-text { font-size: 13.5px; line-height: 1.45; color: var(--color-text); word-wrap: break-word; }

/* Internal note (team-only, support can't see) */
.msg--note .msg-bubble { background: var(--color-warn-50) !important; border-color: color-mix(in oklab, var(--color-warn) 34%, var(--color-warn-50)); border-left: 3px solid var(--color-warn); }
.msg-note-label { font-size: 10px; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; color: var(--color-warn-ink); margin-bottom: 3px; }

/* System line */
.msg--system { grid-template-columns: 1fr; justify-items: center; margin-bottom: 8px; }
.msg-sys { font-size: 11px; color: var(--color-text-subtle); background: var(--color-surface); border: 1px solid var(--color-border); border-radius: 999px; padding: 3px 10px; }

/* Attachment inside a bubble */
.msg-attach { display: inline-flex; align-items: center; gap: 8px; margin-top: 5px; padding: 4px 8px 4px 4px; border-radius: 5px; text-decoration: none; color: var(--color-text); cursor: pointer; }
.msg-attach:hover { background: var(--color-surface-alt); }
.msg-attach .att-ico { width: 26px; height: 26px; border-radius: 5px; display: grid; place-items: center; color: #fff; flex-shrink: 0; }
.msg-attach .att-ico svg { width: 14px; height: 14px; }
.msg-attach[data-ft="pdf"] .att-ico { background: #B91C1C; }
.msg-attach[data-ft="xlsx"] .att-ico { background: #15803D; }
.msg-attach[data-ft="doc"] .att-ico { background: #1D4ED8; }
.msg-attach[data-ft="img"] .att-ico { background: #7C3AED; }
.msg-attach[data-ft="file"] .att-ico { background: var(--color-text-muted); }
.att-body { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.att-name { font-size: 12px; font-weight: 600; }
.att-meta { font-size: 11px; color: var(--color-text-subtle); }

/* Composer */
.chat-composer { border-top: 1px solid var(--color-border); background: var(--color-surface); padding: 10px 16px 12px; }
.chat-attachments { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.chat-attachments[hidden] { display: none; }
.att-chip { display: inline-flex; align-items: center; gap: 6px; background: var(--color-surface-alt); border: 1px solid var(--color-border); border-radius: 5px; padding: 4px 8px; font-size: 12px; color: var(--color-text-muted); }
.att-chip svg { width: 12px; height: 12px; color: var(--color-primary); }
.att-chip button { border: 0; background: transparent; color: var(--color-text-subtle); cursor: pointer; font-size: 14px; line-height: 1; padding: 0 0 0 2px; }
.att-chip button:hover { color: var(--color-danger); }
.chat-composer-row { display: flex; align-items: flex-end; gap: 8px; }
.chat-reply { flex: 1; font: inherit; font-size: 13px; color: var(--color-text); background: var(--color-search-bg); border: 1px solid var(--color-control-border); border-radius: 5px; padding: 9px 11px; resize: vertical; min-height: 40px; max-height: 180px; line-height: 1.4; }
.chat-reply:focus { outline: 0; border-color: var(--color-primary); }
.chat-emoji { display: grid; grid-template-columns: repeat(5, 24px); grid-auto-rows: 22px; gap: 2px; align-self: stretch; align-content: center; }
.chat-emoji button { border: 0; background: transparent; font-size: 15px; line-height: 1; cursor: pointer; border-radius: 4px; padding: 0; }
.chat-emoji button:hover { background: var(--color-surface-alt); }
.chat-iconbtn { width: 38px; align-self: stretch; display: grid; place-items: center; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: 5px; color: var(--color-text-muted); cursor: pointer; flex-shrink: 0; }
.chat-iconbtn:hover { background: var(--color-surface-alt); color: var(--color-primary); }
.chat-iconbtn svg { width: 16px; height: 16px; }
.chat-send { align-self: stretch; }

/* Sidebar nav unread badge (sample) */
.nav-badge { display: inline-flex; justify-content: center; margin-left: 6px; font-size: 10px; font-weight: 700; color: #fff; background: var(--color-danger); border-radius: 999px; padding: 1px 6px; min-width: 16px; }
.nav-badge[hidden] { display: none; }

/* Empty channel state */
.chat-empty { margin: auto; text-align: center; color: var(--color-text-subtle); padding: 30px 20px; }
.chat-empty svg { width: 34px; height: 34px; margin-bottom: 10px; }
.chat-empty-title { font-size: 14px; font-weight: 600; color: var(--color-text-muted); margin-bottom: 3px; }
.chat-empty-sub { font-size: 12.5px; }

/* Compact channel switcher — replaces the rail when it is hidden (≤900px) */
.chat-mobile-switch { display: none; gap: 6px; padding: 8px 12px; background: var(--color-surface); border-bottom: 1px solid var(--color-border); }
.chat-mobile-switch button { flex: 1; font: inherit; font-size: 12px; font-weight: 600; min-height: 34px; padding: 5px 10px; border: 1px solid var(--color-border); border-radius: 5px; background: var(--color-surface); color: var(--color-text-muted); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 5px; }
.chat-mobile-switch button.is-active { background: var(--color-primary-50); border-color: var(--color-primary); color: var(--color-primary-700); }
.chat-mobile-switch button svg { width: 12px; height: 12px; }

@media (max-width: 900px) {
  .chat-shell { grid-template-columns: 1fr; }
  .chat-rail { display: none; }
  .chat-emoji { display: none; }
  .chat-mobile-switch { display: flex; }
  .chat-mobile-switch button { min-height: 44px; }
}
.chat-mobile-switch button.is-role-hidden { display: none; }
