/* ============================================================
   chat.css — Conversas (chat) + Gestão de conversas.
   UI própria sobre back-end Mattermost. Sidebar escura (verde
   profundo) no estilo "app de chat"; admin reusa a casca .acc-/.eq-.
   Sobre tokens + components + app + accounting + secretaria + equipe.
   ============================================================ */

/* Tipografia global em sans-serif (sem serifa no corpo) */
:root { --font-body: "Manrope", "Segoe UI", system-ui, sans-serif; }

/* ============================================================
   ÁREA DE CHAT (membro)
   ============================================================ */
.chat { display: flex; height: calc(100vh - 128px); min-height: 520px; border: 1px solid var(--color-border); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-sm); background: var(--color-surface); position: relative; }
body[data-density="compacta"] .chat { height: calc(100vh - 112px); }

/* ── Sidebar de canais (escura) ── */
.chat-sidebar { width: 266px; flex: none; display: flex; flex-direction: column; background: var(--green-900); color: var(--stone-50); border-right: 1px solid color-mix(in srgb, #000 24%, var(--green-900)); font-family: "Manrope", system-ui, sans-serif; }
.chat-ws { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-4) var(--space-4); border-bottom: 1px solid color-mix(in srgb, var(--stone-50) 12%, transparent); }
.chat-ws-mark { width: 38px; height: 38px; border-radius: var(--radius-md); flex: none; display: flex; align-items: center; justify-content: center; background: color-mix(in srgb, var(--lime-300) 22%, transparent); color: var(--lime-300); }
.chat-ws-tx { display: flex; flex-direction: column; min-width: 0; }
.chat-ws-tx strong { font-family: var(--font-heading); font-weight: 800; font-size: var(--text-base); color: var(--stone-50); }
.chat-ws-tx span { font-size: 11px; color: color-mix(in srgb, var(--stone-50) 62%, transparent); display: inline-flex; align-items: center; gap: 5px; }
.chat-ws-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--lime-500); flex: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--lime-500) 24%, transparent); }

.chat-search { display: flex; align-items: center; gap: var(--space-2); margin: var(--space-3) var(--space-3) var(--space-2); padding: 0.5rem var(--space-3); background: color-mix(in srgb, #000 22%, transparent); border-radius: var(--radius-md); color: color-mix(in srgb, var(--stone-50) 60%, transparent); }
.chat-search input { flex: 1; border: none; outline: none; background: none; color: var(--stone-50); font-family: "Manrope", system-ui, sans-serif; font-size: var(--text-sm); min-width: 0; }
.chat-search input::placeholder { color: color-mix(in srgb, var(--stone-50) 45%, transparent); }

.chat-chan-scroll { flex: 1; overflow-y: auto; padding: var(--space-2) var(--space-2) var(--space-3); scrollbar-width: none; -ms-overflow-style: none; }
.chat-chan-scroll::-webkit-scrollbar { width: 0; height: 0; display: none; }
.chat-cat { margin-bottom: var(--space-3); }
.chat-cat-label { display: flex; align-items: center; gap: 6px; padding: var(--space-2) var(--space-3) var(--space-1); font-family: var(--font-heading); font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; color: color-mix(in srgb, var(--stone-50) 50%, transparent); }
.chat-cat-label svg { color: var(--lime-300); opacity: .8; }
.chat-chan { display: flex; align-items: center; gap: var(--space-2); width: 100%; border: none; background: none; cursor: pointer; padding: 0.42rem var(--space-3); border-radius: var(--radius-sm); color: color-mix(in srgb, var(--stone-50) 78%, transparent); font-family: "Manrope", system-ui, sans-serif; font-size: var(--text-sm); text-align: left; transition: background var(--dur-fast), color var(--dur-fast); }
.chat-chan-ic { flex: none; opacity: .7; display: inline-flex; }
.chat-chan-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-chan:hover { background: color-mix(in srgb, var(--stone-50) 9%, transparent); color: var(--stone-50); }
.chat-chan.unread { color: var(--stone-50); font-weight: 600; }
.chat-chan.active { background: var(--lime-500); color: var(--green-900); font-weight: 700; }
.chat-chan.active .chat-chan-ic { opacity: 1; }
.chat-chan-badge { flex: none; min-width: 18px; height: 18px; padding: 0 5px; border-radius: var(--radius-pill); background: var(--lime-300); color: var(--green-900); font-family: var(--font-heading); font-weight: 800; font-size: 10px; display: flex; align-items: center; justify-content: center; }
.chat-chan.active .chat-chan-badge { background: var(--green-900); color: var(--lime-300); }

.chat-side-foot { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-3) var(--space-4); border-top: 1px solid color-mix(in srgb, var(--stone-50) 12%, transparent); }
.chat-side-foot .eq-avatar { background: color-mix(in srgb, var(--lime-300) 24%, transparent); color: var(--lime-300); }
.chat-side-foot-tx { display: flex; flex-direction: column; min-width: 0; }
.chat-side-foot-tx strong { font-family: var(--font-heading); font-size: var(--text-sm); color: var(--stone-50); }
.chat-side-foot-tx span { font-size: 11px; color: color-mix(in srgb, var(--stone-50) 58%, transparent); }

/* ── Coluna da conversa ── */
.chat-main { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--color-surface); }
.chat-head { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-5); border-bottom: 1px solid var(--color-border); }
.chat-burger { display: none; background: none; border: none; cursor: pointer; color: var(--color-text-muted); padding: 4px; }
.chat-head-ic { width: 34px; height: 34px; border-radius: var(--radius-sm); flex: none; display: flex; align-items: center; justify-content: center; background: var(--green-100); color: var(--green-700); }
.chat-head-tx { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.chat-head-tx strong { font-family: var(--font-heading); font-weight: 800; font-size: var(--text-lg); color: var(--color-text); line-height: 1.15; }
.chat-head-tx span { font-size: var(--text-xs); color: var(--color-text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-head-meta { display: flex; align-items: center; gap: var(--space-3); flex: none; }
.chat-head-people { display: inline-flex; align-items: center; gap: 5px; font-family: var(--font-heading); font-weight: 700; font-size: var(--text-sm); color: var(--color-text-muted); }

.chat-stream { flex: 1; overflow-y: auto; padding: var(--space-4) var(--space-5); display: flex; flex-direction: column; gap: 2px; scrollbar-width: thin; }
.chat-intro { padding: var(--space-5) 0 var(--space-5); border-bottom: 1px solid var(--color-border); margin-bottom: var(--space-4); }
.chat-intro-ic { width: 52px; height: 52px; border-radius: var(--radius-md); display: flex; align-items: center; justify-content: center; background: var(--green-100); color: var(--green-700); margin-bottom: var(--space-3); }
.chat-intro h3 { font-size: var(--text-h3); margin: 0 0 4px; }
.chat-intro p { font-size: var(--text-sm); color: var(--color-text-muted); margin: 0; }

.chat-msg { display: flex; gap: var(--space-3); padding: var(--space-2) var(--space-3); border-radius: var(--radius-md); margin: 0 calc(-1 * var(--space-3)); transition: background var(--dur-fast); }
.chat-msg:hover { background: var(--stone-50); }
.chat-msg-av { width: 38px; height: 38px; border-radius: var(--radius-md); flex: none; display: flex; align-items: center; justify-content: center; background: var(--green-100); color: var(--green-700); font-family: var(--font-heading); font-weight: 700; font-size: var(--text-sm); }
.chat-msg.is-self .chat-msg-av { background: var(--green-700); color: var(--stone-50); }
.chat-msg-av.is-bot { background: var(--stone-800); color: var(--lime-300); }
.chat-msg-body { flex: 1; min-width: 0; }
.chat-msg-top { display: flex; align-items: baseline; gap: var(--space-2); flex-wrap: wrap; }
.chat-msg-top strong { font-family: var(--font-heading); font-weight: 700; font-size: var(--text-sm); color: var(--color-text); }
.chat-msg-papel { font-size: 11px; color: var(--color-text-faint); }
.chat-msg-when { font-size: 11px; color: var(--color-text-faint); }
.chat-bot-tag { font-family: var(--font-heading); font-weight: 800; font-size: 9px; letter-spacing: .08em; padding: 1px 5px; border-radius: 4px; background: var(--stone-800); color: var(--lime-300); }
.chat-msg-text { font-size: var(--text-base); color: var(--color-text); line-height: var(--leading-normal); margin: 2px 0 0; text-wrap: pretty; }
.chat-msg.is-bot .chat-msg-text { color: var(--color-text); }
.chat-msg-actions { display: flex; gap: var(--space-3); margin-top: 4px; opacity: 0; transition: opacity var(--dur-fast); }
.chat-msg-link { display: inline-flex; align-items: center; gap: 6px; margin-top: 8px; padding: 7px 12px; background: var(--color-surface); border: 1px solid var(--color-border-strong); border-radius: var(--radius-md); font-family: var(--font-heading); font-weight: var(--weight-semibold); font-size: var(--text-sm); color: var(--green-700); cursor: pointer; transition: background var(--dur-fast), border-color var(--dur-fast); }
.chat-msg-link:hover { background: var(--green-50); border-color: var(--green-400); }
.chat-msg-link svg:last-child { color: var(--color-text-faint); }
.chat-msg:hover .chat-msg-actions { opacity: 1; }
.chat-react { display: inline-flex; align-items: center; gap: 5px; background: none; border: none; cursor: pointer; font-family: var(--font-heading); font-weight: 600; font-size: var(--text-xs); color: var(--color-text-muted); padding: 0; }
.chat-react:hover, .chat-react.on { color: var(--green-700); }

.chat-composer { display: flex; align-items: flex-end; gap: var(--space-2); margin: var(--space-3) var(--space-5) var(--space-5); padding: var(--space-2) var(--space-3); border: 1px solid var(--color-border-strong); border-radius: var(--radius-lg); background: var(--color-surface); box-shadow: var(--shadow-xs); }
.chat-composer:focus-within { border-color: var(--green-400); box-shadow: 0 0 0 3px var(--green-50); }
.chat-composer textarea { flex: 1; border: none; outline: none; background: none; resize: none; font-family: var(--font-body); font-size: var(--text-base); color: var(--color-text); line-height: var(--leading-normal); min-height: 24px; max-height: 120px; padding: 6px 0; }
.chat-composer textarea:focus, .chat-composer textarea:focus-visible { box-shadow: none; outline: none; }
.chat-comp-btn { flex: none; background: none; border: none; cursor: pointer; color: var(--color-text-faint); padding: 6px; border-radius: var(--radius-sm); display: inline-flex; }
.chat-comp-btn:hover { background: var(--stone-100); color: var(--green-700); }
.chat-comp-send { flex: none; width: 38px; height: 38px; border-radius: var(--radius-md); border: none; background: var(--green-700); color: var(--stone-50); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; transition: background var(--dur-fast); }
.chat-comp-send:hover:not(:disabled) { background: var(--green-800); }
.chat-comp-send:disabled { background: var(--stone-300); cursor: default; }
.chat-composer.is-locked { justify-content: center; align-items: center; gap: var(--space-2); color: var(--color-text-muted); font-size: var(--text-sm); font-family: var(--font-heading); font-weight: 600; background: var(--stone-50); padding: var(--space-4); }

/* responsivo: sidebar off-canvas */
.chat-scrim { display: none; }
@container portal (max-width: 760px) {
  .chat-sidebar { position: absolute; inset: 0 auto 0 0; z-index: 20; transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  .chat.nav-open .chat-sidebar { transform: none; }
  .chat-burger { display: inline-flex; }
}

/* ============================================================
   GESTÃO DE CONVERSAS (admin)
   ============================================================ */
.conv-server { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); box-shadow: var(--shadow-xs); padding: var(--space-5); }
.conv-server-l { display: flex; align-items: center; gap: var(--space-3); padding-bottom: var(--space-4); border-bottom: 1px solid var(--color-border); margin-bottom: var(--space-4); }
.conv-server-ic { width: 52px; height: 52px; border-radius: var(--radius-md); flex: none; display: flex; align-items: center; justify-content: center; background: linear-gradient(150deg, var(--green-700), var(--green-900)); color: var(--lime-300); }
.conv-server-name { font-family: var(--font-mono); font-weight: 600; font-size: var(--text-base); color: var(--color-text); display: inline-flex; align-items: center; gap: 8px; }
.conv-server-sub { font-size: var(--text-sm); color: var(--color-text-muted); }
.conv-server-sub strong { color: var(--green-700); font-family: var(--font-heading); }
.conv-server-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-4); }
.conv-server-grid div { display: flex; flex-direction: column; gap: 2px; }
.conv-server-grid span { font-family: var(--font-heading); font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--color-text-faint); }
.conv-server-grid strong { font-family: var(--font-heading); font-weight: 700; font-size: var(--text-sm); color: var(--color-text); }

.conv-chan-name { display: flex; align-items: center; gap: var(--space-3); }
.conv-chan-ic { width: 32px; height: 32px; border-radius: var(--radius-sm); flex: none; display: flex; align-items: center; justify-content: center; background: var(--green-100); color: var(--green-700); }
.conv-vis-btn { background: none; border: none; cursor: pointer; padding: 0; }
.conv-mod { display: flex; align-items: center; gap: var(--space-2); }

.conv-mod-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: var(--space-4); }
.conv-mod-card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); box-shadow: var(--shadow-xs); padding: var(--space-4) var(--space-5); }
.conv-mod-card-head { display: flex; align-items: center; gap: var(--space-3); padding-bottom: var(--space-3); margin-bottom: var(--space-3); border-bottom: 1px solid var(--color-border); }
.conv-mod-card-id { display: flex; flex-direction: column; min-width: 0; }
.conv-mod-card-id strong { font-family: var(--font-heading); font-weight: 700; font-size: var(--text-base); color: var(--color-text); }
.conv-mod-card-id span { font-size: var(--text-xs); color: var(--color-text-muted); }
.conv-mod-chips { display: flex; flex-wrap: wrap; gap: 6px; }

.conv-int-list { display: flex; flex-direction: column; gap: var(--space-3); }
.conv-int { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4); border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--stone-50); transition: opacity var(--dur-base); }
.conv-int.is-off { opacity: .56; }
.conv-int-ic { width: 40px; height: 40px; border-radius: var(--radius-md); flex: none; display: flex; align-items: center; justify-content: center; background: var(--green-100); color: var(--green-700); }
.conv-int-ic.is-out { background: var(--sun-100); color: var(--sun-700); }
.conv-int-tx { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.conv-int-tx strong { font-family: var(--font-heading); font-weight: 700; font-size: var(--text-sm); color: var(--color-text); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.conv-int-tx span { font-size: var(--text-xs); color: var(--color-text-muted); line-height: var(--leading-snug); }
.conv-handle { font-family: var(--font-mono); font-weight: 500; font-size: 11px; color: var(--green-700); }
.conv-int-canal { display: inline-flex; align-items: center; gap: 4px; margin-top: 2px; color: var(--color-text-faint) !important; }

.conv-switch { flex: none; width: 42px; height: 24px; border-radius: var(--radius-pill); border: none; background: var(--stone-300); cursor: pointer; position: relative; transition: background var(--dur-fast); }
.conv-switch i { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: left var(--dur-fast); }
.conv-switch.on { background: var(--green-600); }
.conv-switch.on i { left: 21px; }

.conv-slash-list { display: flex; flex-direction: column; gap: var(--space-2); }
.conv-slash { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-2) var(--space-3); border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--stone-50); }
.conv-slash code { font-family: var(--font-mono); font-weight: 600; font-size: var(--text-sm); color: var(--green-800); background: var(--green-50); border: 1px solid var(--green-200); padding: 2px 8px; border-radius: var(--radius-sm); flex: none; }
.conv-slash span { font-size: var(--text-sm); color: var(--color-text-muted); }

.conv-slug-input { display: flex; align-items: center; gap: 4px; border: 1px solid var(--color-border-strong); border-radius: var(--radius-md); padding: 0 var(--space-3); background: var(--color-surface); }
.conv-slug-input:focus-within { border-color: var(--green-400); box-shadow: 0 0 0 3px var(--green-50); }
.conv-slug-input span { font-family: var(--font-mono); font-weight: 700; color: var(--color-text-faint); }
.conv-slug-input input { border: none !important; box-shadow: none !important; padding-left: 0; }

@container portal (max-width: 720px) {
  .conv-server-grid { grid-template-columns: 1fr; gap: var(--space-2); }
  .conv-mod-grid { grid-template-columns: 1fr; }
}

/* ---- Moderação inline ---- */
.conv-mod-swap { background: none; border: none; cursor: pointer; color: var(--color-text-faint); padding: 3px; border-radius: var(--radius-sm); display: inline-flex; }
.conv-mod-swap:hover { background: var(--green-50); color: var(--green-700); }

/* ---- Webhooks (gestão completa) ---- */
.conv-wh-list { display: flex; flex-direction: column; gap: var(--space-3); }
.conv-wh { display: flex; align-items: flex-start; gap: var(--space-3); padding: var(--space-4); border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--stone-50); transition: opacity var(--dur-base); }
.conv-wh.is-off { opacity: .58; }
.conv-wh-ic { width: 40px; height: 40px; border-radius: var(--radius-md); flex: none; display: flex; align-items: center; justify-content: center; }
.conv-wh-ic.is-in { background: var(--green-100); color: var(--green-700); }
.conv-wh-ic.is-out { background: var(--sun-100); color: var(--sun-700); }
.conv-wh-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.conv-wh-top { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.conv-wh-top strong { font-family: var(--font-heading); font-weight: 700; font-size: var(--text-sm); color: var(--color-text); }
.conv-wh-badge { font-family: var(--font-heading); font-weight: 700; font-size: 10px; padding: 1px 7px; border-radius: var(--radius-pill); }
.conv-wh-badge.is-in { background: var(--green-100); color: var(--green-800); }
.conv-wh-badge.is-out { background: var(--sun-100); color: #8a5a12; }
.conv-wh-canal { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; color: var(--color-text-faint); font-family: var(--font-heading); font-weight: 600; }
.conv-wh-desc { font-size: var(--text-xs); color: var(--color-text-muted); margin: 0; line-height: var(--leading-snug); }
.conv-wh-summary { display: flex; flex-wrap: wrap; gap: var(--space-3); }
.conv-wh-summary span { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; color: var(--color-text-muted); }
.conv-wh-summary svg { color: var(--color-text-faint); }
.conv-wh-summary code, .conv-wh-secret code { font-family: var(--font-mono); font-size: 10.5px; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: 4px; padding: 1px 5px; color: var(--green-800); }
.conv-wh-secret { display: flex; align-items: center; gap: var(--space-2); margin-top: 2px; }
.conv-wh-secret code { color: var(--color-text-muted); }
.conv-wh-mini { width: 26px; height: 26px; border: 1px solid var(--color-border-strong); background: var(--color-surface); border-radius: var(--radius-sm); cursor: pointer; color: var(--color-text-muted); display: inline-flex; align-items: center; justify-content: center; flex: none; }
.conv-wh-mini:hover { border-color: var(--green-300); color: var(--green-700); background: var(--green-50); }
.conv-wh-actions { display: flex; flex-direction: column; align-items: center; gap: var(--space-2); flex: none; }

/* ---- Form de webhook ---- */
.conv-hint { font-size: 11px; color: var(--color-text-muted); margin: 4px 0 0; line-height: var(--leading-snug); }
.conv-hint-inline { font-family: var(--font-body); font-weight: 400; font-size: 11px; color: var(--color-text-faint); text-transform: none; letter-spacing: 0; }
.conv-check { display: flex; align-items: flex-start; gap: var(--space-3); width: 100%; text-align: left; border: 1px solid var(--color-border-strong); background: var(--color-surface); border-radius: var(--radius-md); padding: var(--space-3) var(--space-4); cursor: pointer; transition: all var(--dur-fast); }
.conv-check:hover { border-color: var(--green-300); }
.conv-check.on { border-color: var(--green-400); background: var(--green-50); }
.conv-check-box { width: 20px; height: 20px; border-radius: 6px; border: 1.5px solid var(--color-border-strong); flex: none; display: flex; align-items: center; justify-content: center; color: #fff; margin-top: 1px; }
.conv-check.on .conv-check-box { background: var(--green-600); border-color: var(--green-600); }
.conv-check span:last-child { display: flex; flex-direction: column; }
.conv-check strong { font-family: var(--font-heading); font-size: var(--text-sm); color: var(--color-text); }
.conv-check em { font-style: normal; font-size: var(--text-xs); color: var(--color-text-muted); }
.conv-tokenbox { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-3) var(--space-4); background: var(--stone-100); border: 1px solid var(--color-border); border-radius: var(--radius-md); flex-wrap: wrap; }
.conv-tokenbox-tx { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.conv-tokenbox-tx span { font-family: var(--font-heading); font-weight: 700; font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: var(--color-text-faint); }
.conv-tokenbox-tx code { font-family: var(--font-mono); font-size: 11px; color: var(--color-text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
