/* ═══════════════════════════════════════════════════════════════════════════
   CENTRAL DE ATENDIMENTO — visual Nexus Core (fundo escuro, roxo como detalhe)
   ═══════════════════════════════════════════════════════════════════════════ */

.hd-root {
    --hd-bg: #0c0c11; --hd-s1: #131319; --hd-s2: #1a1a22; --hd-s3: #23232d;
    --hd-line: rgba(255,255,255,.07); --hd-line2: rgba(255,255,255,.12);
    --hd-tx: #ededf2; --hd-mut: #9b9bab; --hd-dim: #6c6c7c;
    --hd-acc: #7c6fd6; --hd-acc2: #b3aae6; --hd-ok: #34d399; --hd-warn: #fbbf24; --hd-err: #f87171;
    position: relative;
    display: grid; grid-template-columns: 330px minmax(0, 1fr) 280px;
    height: calc(100vh - 130px); min-height: 520px;
    background: var(--hd-bg); color: var(--hd-tx);
    border: 1px solid var(--hd-line2); border-radius: 18px; overflow: hidden;
    box-shadow: 0 20px 60px rgba(0,0,0,.45);
    font-size: 14px; line-height: 1.45;
}
:where(.hd-root) *, :where(.hd-root) *::before, :where(.hd-root) *::after { box-sizing: border-box; }
:where(.hd-root) :where(button, input, textarea) { font: inherit; color: inherit; margin: 0; -webkit-appearance: none; appearance: none; }
:where(.hd-root) :where(button) { background: none; border: 0; cursor: pointer; padding: 0; }
:where(.hd-root) [hidden] { display: none !important; }
:where(.hd-root) :where(button, a):focus-visible { outline: 2px solid var(--hd-acc2); outline-offset: 2px; }
:where(.hd-root) :where(textarea, input) { outline: none !important; }

/* Controles marcados com .orion-hd (via JS) saem das regras globais do main.css. */
.orion-hd { font: inherit; color: inherit; margin: 0; -webkit-appearance: none; appearance: none; box-shadow: none; transform: none; min-height: 0; text-transform: none; }
:where(button).orion-hd { background: none; border: 0; padding: 0; border-radius: 0; cursor: pointer; gap: normal; }
:where(input, textarea).orion-hd { background: transparent; border: 0; border-radius: 0; padding: 0; resize: none; outline: none; }
@media (max-width: 768px) { .hd-root .orion-hd { min-height: 0 !important; } }
.hd-muted { color: var(--hd-mut); font-size: 12.5px; }
.hd-link { color: var(--hd-acc2); font-weight: 600; text-decoration: underline; }

/* avatar */
.hd-av { width: 38px; height: 38px; flex: none; border-radius: 12px; display: grid; place-items: center; font-weight: 700; font-size: 14px; background: var(--hd-s3); color: var(--hd-tx); }
.hd-av.lg { width: 40px; height: 40px; }
.hd-av.xl { width: 64px; height: 64px; border-radius: 20px; font-size: 22px; background: linear-gradient(135deg, #2a2140, #1a1a22); border: 1px solid var(--hd-line2); }

/* pílulas de status */
.hd-pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; background: var(--hd-s3); color: var(--hd-mut); white-space: nowrap; }
.hd-pill i { font-size: 9.5px; }
.hd-pill.ai { color: var(--hd-acc2); background: rgba(139,92,246,.13); }
.hd-pill.wait { color: var(--hd-warn); background: rgba(251,191,36,.13); }
.hd-pill.human { color: var(--hd-ok); background: rgba(52,211,153,.12); }
.hd-pill.done { color: var(--hd-dim); }

/* ─── Fila ─────────────────────────────────────────────────────────────── */
.hd-queue { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--hd-line); background: var(--hd-s1); }
.hd-queue-hd { padding: 18px 16px 12px; border-bottom: 1px solid var(--hd-line); }
.hd-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.hd-title h1 { margin: 0; font-size: 19px; font-weight: 700; letter-spacing: -.01em; }
.hd-live { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--hd-mut); }
.hd-live i { width: 7px; height: 7px; border-radius: 50%; background: var(--hd-ok); box-shadow: 0 0 0 3px rgba(52,211,153,.18); }
.hd-search { display: flex; align-items: center; gap: 10px; height: 40px; padding: 0 12px; border-radius: 11px; background: var(--hd-bg); border: 1px solid var(--hd-line2); color: var(--hd-dim); }
.hd-search:focus-within { border-color: rgba(255,255,255,.22); }
.hd-search input { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; font-size: 13px; color: var(--hd-tx); }
.hd-search input::placeholder { color: var(--hd-dim); }
.hd-filters { display: flex; gap: 6px; margin-top: 12px; overflow-x: auto; scrollbar-width: none; margin-right: -16px; padding-right: 16px; }
.hd-filters::-webkit-scrollbar { display: none; }
.hd-filters { -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent); mask-image: linear-gradient(90deg, #000 85%, transparent); }
.hd-filter { display: inline-flex; align-items: center; gap: 6px; flex: none; height: 26px; padding: 0 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; white-space: nowrap; color: var(--hd-mut); border: 1px solid var(--hd-line) !important; transition: background .15s, color .15s; }
.hd-filter b { min-width: 18px; padding: 0 5px; height: 17px; border-radius: 9px; display: grid; place-items: center; font-size: 10.5px; background: var(--hd-s3); color: var(--hd-mut); }
.hd-filter:hover { color: var(--hd-tx); background: var(--hd-s2); }
.hd-filter.active { background: #f1f0f7 !important; color: #14141b; border-color: transparent !important; }
.hd-filter.active b { background: rgba(0,0,0,.1); color: #14141b; }
.hd-filter.alert b { background: var(--hd-warn); color: #1a1405; }

.hd-list { flex: 1; min-height: 0; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 4px; scrollbar-width: thin; scrollbar-color: var(--hd-s3) transparent; }
.hd-loading, .hd-list-empty { padding: 28px 16px; text-align: center; color: var(--hd-mut); font-size: 13px; }
.hd-item { position: relative; width: 100%; display: flex; gap: 11px; align-items: flex-start; text-align: left; padding: 11px 10px; border-radius: 12px; border: 1px solid transparent !important; transition: background .12s; }
.hd-item:hover { background: var(--hd-s2); }
.hd-item.active { background: var(--hd-s2); border-color: var(--hd-line2) !important; }
.hd-item.active::before { content: ''; position: absolute; left: -8px; top: 12px; bottom: 12px; width: 3px; border-radius: 0 3px 3px 0; background: var(--hd-acc); }
.hd-item.st-wait .hd-av { background: rgba(251,191,36,.14); color: var(--hd-warn); }
.hd-item-tx { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.hd-item-top { display: flex; align-items: baseline; gap: 8px; }
.hd-item-top b { flex: 1; min-width: 0; font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hd-item-top time { flex: none; font-size: 11px; color: var(--hd-dim); }
.hd-item-prev { font-size: 12.5px; color: var(--hd-mut); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hd-item-prev em { font-style: normal; color: var(--hd-acc2); }
.hd-item-meta { display: flex; align-items: center; gap: 8px; margin-top: 2px; }
.hd-num { font-size: 11px; color: var(--hd-dim); }

/* ─── Conversa ─────────────────────────────────────────────────────────── */
.hd-chat { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--hd-bg); }
.hd-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 32px; text-align: center; color: var(--hd-mut); }
.hd-empty-ic { width: 64px; height: 64px; border-radius: 20px; display: grid; place-items: center; font-size: 26px; color: var(--hd-acc2); background: var(--hd-s1); border: 1px solid var(--hd-line2); margin-bottom: 6px; }
.hd-empty b { font-size: 16px; color: var(--hd-tx); }
.hd-empty p { max-width: 360px; margin: 0; font-size: 13px; }
.hd-empty em { font-style: normal; color: var(--hd-warn); }

.hd-chat-hd { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--hd-line); background: var(--hd-bg); }
.hd-chat-who { display: flex; align-items: center; gap: 11px; min-width: 0; }
.hd-chat-who > div { min-width: 0; display: flex; flex-direction: column; }
.hd-chat-who b { font-size: 15px; }
.hd-chat-who .hd-muted { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hd-chat-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.hd-seg { display: inline-flex; padding: 3px; border-radius: 11px; background: var(--hd-s1); border: 1px solid var(--hd-line2); }
.hd-seg button { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border-radius: 8px; font-size: 12.5px; font-weight: 600; color: var(--hd-mut); transition: background .15s, color .15s; }
.hd-seg button i { font-size: 11px; }
.hd-seg button:hover { color: var(--hd-tx); }
.hd-seg button.on { background: var(--hd-s3); color: var(--hd-tx); box-shadow: 0 1px 0 rgba(255,255,255,.06) inset; }
.hd-seg button.on[data-mode="ai"] i { color: var(--hd-acc2); }
.hd-seg button.on[data-mode="human"] i { color: var(--hd-ok); }
.hd-btn { display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 14px; border-radius: 10px; font-size: 12.5px; font-weight: 600; background: var(--hd-s2) !important; border: 1px solid var(--hd-line2) !important; transition: background .15s; }
.hd-btn:hover { background: var(--hd-s3) !important; }
.hd-btn.confirm { background: rgba(52,211,153,.16) !important; border-color: rgba(52,211,153,.35) !important; color: var(--hd-ok); }

.hd-msgs { flex: 1; min-height: 0; overflow-y: auto; padding: 20px 22px 10px; display: flex; flex-direction: column; gap: 10px; scrollbar-width: thin; scrollbar-color: var(--hd-s3) transparent; }
.hd-day { display: flex; justify-content: center; margin: 4px 0; }
.hd-day span { font-size: 11px; color: var(--hd-dim); padding: 3px 10px; border-radius: 999px; background: var(--hd-s1); border: 1px solid var(--hd-line); }
.hd-msg { display: flex; }
.hd-msg.ai, .hd-msg.agent { justify-content: flex-end; }  /* nosso lado à direita */
.hd-bubble { max-width: min(72%, 560px); padding: 10px 13px; border-radius: 16px; font-size: 14px; line-height: 1.5; overflow-wrap: anywhere; background: var(--hd-s2); border: 1px solid var(--hd-line); border-bottom-left-radius: 6px; }
.hd-msg.ai .hd-bubble { background: #17161f; border-color: rgba(255,255,255,.09); border-bottom-left-radius: 16px; border-bottom-right-radius: 6px; }
.hd-msg.agent .hd-bubble { background: #10201a; border-color: rgba(52,211,153,.2); border-bottom-left-radius: 16px; border-bottom-right-radius: 6px; }
.hd-from { display: block; margin-bottom: 3px; font-size: 11.5px; font-weight: 600; color: var(--hd-mut); }
.hd-msg.ai .hd-from { color: var(--hd-acc2); }
.hd-msg.agent .hd-from { color: var(--hd-ok); }
.hd-bubble time { display: block; margin-top: 4px; font-size: 10.5px; color: var(--hd-dim); text-align: right; }
.hd-bubble a { color: var(--hd-acc2); }
.hd-att-img { display: block; margin-top: 8px; max-width: 280px; border-radius: 10px; overflow: hidden; }
.hd-att-img img { display: block; width: 100%; height: auto; }
.hd-att { display: inline-flex; align-items: center; gap: 7px; margin-top: 8px; padding: 6px 10px; border-radius: 8px; background: rgba(0,0,0,.25); font-size: 12.5px; text-decoration: none; }
.hd-msg.typing .hd-bubble { display: flex; gap: 4px; padding: 13px 14px; }
.hd-msg.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--hd-acc2); animation: hd-dot 1.2s infinite ease-in-out; }
.hd-msg.typing i:nth-child(2) { animation-delay: .15s; }
.hd-msg.typing i:nth-child(3) { animation-delay: .3s; }
@keyframes hd-dot { 0%, 60%, 100% { opacity: .3; transform: none; } 30% { opacity: 1; transform: translateY(-3px); } }

.hd-compose { flex: none; padding: 10px 16px 12px; border-top: 1px solid var(--hd-line); }
.hd-compose-box { display: flex; align-items: flex-end; gap: 6px; padding: 6px; border-radius: 14px; background: var(--hd-s1); border: 1px solid var(--hd-line2); transition: border-color .15s, box-shadow .15s; }
.hd-compose-box:focus-within { border-color: rgba(255,255,255,.22); }
.hd-compose textarea { flex: 1; min-width: 0; resize: none; border: 0; outline: none; background: transparent; padding: 8px 4px; font-size: 14px; line-height: 1.45; max-height: 160px; color: var(--hd-tx); }
.hd-compose textarea::placeholder { color: var(--hd-dim); }
.hd-ic { width: 36px; height: 36px; flex: none; border-radius: 10px; display: grid; place-items: center; color: var(--hd-mut); }
.hd-ic:hover { background: var(--hd-s2); color: var(--hd-tx); }
.hd-send { flex: none; display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 14px; border-radius: 10px; background: #f1f0f7 !important; color: #14141b !important; font-weight: 700; font-size: 13px; transition: transform .12s, opacity .15s; }
.hd-send:hover { transform: translateY(-1px); }
.hd-send:disabled { opacity: .5; cursor: default; transform: none; }
.hd-compose-hint { margin: 7px 2px 0; font-size: 11.5px; color: var(--hd-dim); }
.hd-file { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; padding: 7px 10px; border-radius: 10px; background: var(--hd-s2); border: 1px solid var(--hd-line); font-size: 12.5px; color: var(--hd-mut); }
.hd-file span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--hd-tx); }
.hd-file button { width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center; }

/* ─── Cliente ──────────────────────────────────────────────────────────── */
.hd-info { min-height: 0; overflow-y: auto; padding: 20px 16px; border-left: 1px solid var(--hd-line); background: var(--hd-s1); }
.hd-info-empty { padding-top: 30px; text-align: center; }
.hd-client { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; padding-bottom: 18px; }
.hd-client .hd-av { margin-bottom: 8px; }
.hd-client b { font-size: 15.5px; }
.hd-client a.hd-muted { text-decoration: none; word-break: break-all; }
.hd-client a.hd-muted:hover { color: var(--hd-tx); }
.hd-card { border-radius: 14px; background: var(--hd-bg); border: 1px solid var(--hd-line); }
.hd-kv { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; font-size: 12.5px; }
.hd-kv + .hd-kv { border-top: 1px solid var(--hd-line); }
.hd-kv > span { color: var(--hd-mut); flex: none; }
.hd-kv > b { font-weight: 600; text-align: right; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.hd-kv code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11.5px; color: var(--hd-acc2); }

/* ─── Toast ────────────────────────────────────────────────────────────── */
.hd-toast { position: absolute; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 5; padding: 9px 14px; border-radius: 12px; font-size: 13px; font-weight: 500; background: #f1f0f7; color: #14141b; box-shadow: 0 12px 30px rgba(0,0,0,.45); }
.hd-toast.err { background: #3a1518; color: #fecaca; border: 1px solid rgba(248,113,113,.35); }
.hd-toast.ok { background: #0f2a20; color: #a7f3d0; border: 1px solid rgba(52,211,153,.3); }

/* ─── Sem permissão ────────────────────────────────────────────────────── */
.hd-root.hd-denied { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; text-align: center; padding: 40px; }
.hd-denied i { font-size: 28px; color: var(--hd-acc2); }
.hd-denied h2 { margin: 6px 0 0; font-size: 20px; }
.hd-denied p { max-width: 380px; margin: 0; color: var(--hd-mut); }

/* ─── Responsivo ───────────────────────────────────────────────────────── */
@media (max-width: 1280px) { .hd-root { grid-template-columns: 300px minmax(0, 1fr); } .hd-info { display: none; } }
@media (max-width: 1024px) { .hd-root { grid-template-columns: 270px minmax(0, 1fr); } }
/* ≤820px: uma coluna por vez (fila OU conversa) — regras em mobile.css, seção 27. */
@media (max-width: 820px) {
    .hd-root { grid-template-columns: 1fr; }
    .hd-queue { border-right: 0; }
    .hd-chat-hd { flex-wrap: wrap; padding: 10px 12px; }
    .hd-seg button { padding: 0 10px; }
    .hd-msgs { padding: 14px 12px 8px; }
    .hd-bubble { max-width: 86%; }
    .hd-att-img { max-width: 100%; }
    .hd-compose { padding: 8px 10px calc(10px + env(safe-area-inset-bottom, 0px)); }
    .hd-send span { display: none; }               /* só a seta no celular */
    .hd-send { width: 44px; padding: 0; justify-content: center; }
    .hd-queue-hd { padding: 14px 12px 10px; }
    .hd-list { padding: 6px; }
    .hd-toast { left: 12px; right: 12px; transform: none; text-align: center; bottom: 90px; }
}

/* ─── Correções de convivência com o main.css/mobile.css ──────────────────
   1) Itens da fila SOBREPOSTOS no celular: a .hd-list é flex-column com altura
      fixa e o mobile.css zera o min-height dos controles .orion-hd — o flexbox
      então ENCOLHIA cada <button> da fila abaixo do conteúdo, e a pílula de
      status de um item invadia o nome do seguinte. Itens não encolhem mais.
   2) Campo de resposta e busca ganhavam a borda/anel roxo global de
      `textarea:focus` / `input:focus` (especificidade maior que .orion-hd),
      desenhando uma caixa dentro da caixa. */
.hd-root .hd-item, .hd-root .hd-day, .hd-root .hd-msg { flex-shrink: 0; }
.hd-root .hd-item { min-height: 64px; }
.hd-root .hd-compose textarea,
.hd-root .hd-compose textarea:focus,
.hd-root .hd-search input,
.hd-root .hd-search input:focus {
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
    min-height: 0 !important;
    border-radius: 0 !important;
}
.hd-root .hd-compose textarea { padding: 8px 4px !important; }
.hd-root .hd-search input { padding: 0 !important; height: 100%; }
.hd-root .hd-compose-box:focus-within,
.hd-root .hd-search:focus-within { border-color: var(--hd-acc) !important; box-shadow: 0 0 0 3px rgba(124,111,214,.18); }

/* ═══════════════════════════════════════════════════════════════════════════
   MODO CLARO — a central era só escura e ficava um bloco preto no tema claro.
   ═══════════════════════════════════════════════════════════════════════════ */
html[data-theme="light"] .hd-root {
    --hd-bg: #ffffff; --hd-s1: #f7f6fc; --hd-s2: #f0eef8; --hd-s3: #e6e3f3;
    --hd-line: rgba(20, 18, 37, .08); --hd-line2: rgba(20, 18, 37, .13);
    --hd-tx: #141225; --hd-mut: #5b5873; --hd-dim: #87849c;
    --hd-acc: #6d5fd6; --hd-acc2: #5b4fc4; --hd-ok: #059669; --hd-warn: #b45309; --hd-err: #dc2626;
    box-shadow: 0 1px 2px rgba(20, 18, 37, .04), 0 16px 40px rgba(91, 79, 196, .08);
}
html[data-theme="light"] .hd-filter.active,
html[data-theme="light"] .hd-send { background: #141225 !important; color: #fff !important; }
html[data-theme="light"] .hd-filter.active b { background: rgba(255, 255, 255, .18); color: #fff; }
html[data-theme="light"] .hd-filter.alert b { color: #fff; background: #d97706; }
html[data-theme="light"] .hd-search { background: #fff; }
html[data-theme="light"] .hd-search:focus-within { border-color: rgba(91, 79, 196, .45); }
html[data-theme="light"] .hd-bubble { background: var(--hd-s1); }
html[data-theme="light"] .hd-msg.ai .hd-bubble { background: #f1effc; border-color: rgba(109, 95, 214, .18); }
html[data-theme="light"] .hd-msg.agent .hd-bubble { background: #ecfdf5; border-color: rgba(5, 150, 105, .22); }
html[data-theme="light"] .hd-att { background: rgba(20, 18, 37, .05); }
html[data-theme="light"] .hd-av.xl { background: linear-gradient(135deg, #ece8fb, #f7f6fc); }
html[data-theme="light"] .hd-pill.ai { background: rgba(109, 95, 214, .1); }
html[data-theme="light"] .hd-pill.wait { background: rgba(217, 119, 6, .1); }
html[data-theme="light"] .hd-pill.human { background: rgba(5, 150, 105, .1); }
html[data-theme="light"] .hd-item.st-wait .hd-av { background: rgba(217, 119, 6, .12); }
html[data-theme="light"] .hd-seg button.on { background: #fff; box-shadow: 0 1px 2px rgba(20, 18, 37, .1); }
html[data-theme="light"] .hd-toast { background: #141225; color: #fff; box-shadow: 0 12px 30px rgba(20, 18, 37, .2); }
html[data-theme="light"] .hd-toast.err { background: #fef2f2; color: #b91c1c; border-color: rgba(220, 38, 38, .3); }
html[data-theme="light"] .hd-toast.ok { background: #ecfdf5; color: #047857; border-color: rgba(5, 150, 105, .3); }
