/* ═══════════════════════════════════════════════════════════════════════════
   ORION SUPPORT WIDGET v3 — visual Nexus Core
   Fundo escuro sólido, ondas de luz roxas no cabeçalho, roxo só como detalhe.
   ═══════════════════════════════════════════════════════════════════════════ */

#orion-support-root {
    --osw-bg: #0c0c11;
    --osw-s1: #131319;
    --osw-s2: #1a1a22;
    --osw-s3: #23232d;
    --osw-line: rgba(255, 255, 255, .07);
    --osw-line2: rgba(255, 255, 255, .12);
    --osw-tx: #ededf2;
    --osw-mut: #9b9bab;
    --osw-dim: #6c6c7c;
    --osw-acc: #7c6fd6;
    --osw-acc2: #b3aae6;
    --osw-ok: #34d399;
    --osw-warn: #fbbf24;
    --osw-err: #f87171;
    --osw-r: 14px;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* resets com especificidade zero (:where) para não brigar com as classes abaixo */
:where(#orion-support-root) *, :where(#orion-support-root) *::before, :where(#orion-support-root) *::after { box-sizing: border-box; }
:where(#orion-support-root) :where(button, input, textarea) {
    font: inherit; color: inherit; margin: 0; -webkit-appearance: none; appearance: none;
    text-transform: none; letter-spacing: normal;
}
:where(#orion-support-root) :where(button) { background: none; border: 0; cursor: pointer; padding: 0; }
#orion-support-root [hidden] { display: none !important; }
:where(#orion-support-root) :where(button, a):focus-visible { outline: 2px solid var(--osw-acc2); outline-offset: 2px; }
:where(#orion-support-root) :where(textarea, input) { outline: none !important; box-shadow: none; }
:where(#orion-support-root) img { display: block; max-width: 100%; }

/* Controles marcados com .orion-w (via JS) saem das regras globais do main.css,
   que pintam todo <button> de roxo com !important. Aqui zera o resto. */
.orion-w {
    font: inherit; color: inherit; margin: 0; -webkit-appearance: none; appearance: none;
    box-shadow: none; transform: none; min-height: 0; text-transform: none; letter-spacing: normal;
}
:where(button).orion-w { background: none; border: 0; padding: 0; border-radius: 0; cursor: pointer; gap: normal; }
:where(input, textarea).orion-w { background: transparent; border: 0; border-radius: 0; padding: 0; resize: none; outline: none; }
@media (max-width: 768px) { #orion-support-root .orion-w { min-height: 0 !important; } }

/* ─── Launcher ─────────────────────────────────────────────────────────── */
#orion-support-launcher {
    position: fixed; right: 24px; bottom: 24px; z-index: 99998;
    width: 56px; height: 56px; border-radius: 50%;
    display: grid; place-items: center;
    background: #15151c !important;
    border: 1px solid var(--osw-line2) !important;
    color: #fff; font-size: 21px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .5), 0 0 0 1px rgba(139, 92, 246, .15), 0 0 28px rgba(139, 92, 246, .22);
    transition: transform .2s ease, box-shadow .2s ease, background .2s;
}
#orion-support-launcher:hover { transform: translateY(-2px); box-shadow: 0 14px 34px rgba(0,0,0,.55), 0 0 0 1px rgba(139,92,246,.35), 0 0 36px rgba(139,92,246,.35); }
#orion-support-launcher i { position: absolute; transition: transform .25s ease, opacity .2s; }
#orion-support-launcher .osw-l-close { opacity: 0; transform: rotate(-90deg) scale(.6); }
#orion-support-launcher.active .osw-l-open { opacity: 0; transform: rotate(90deg) scale(.6); }
#orion-support-launcher.active .osw-l-close { opacity: 1; transform: none; }
.osw-badge {
    position: absolute; top: -3px; right: -3px; min-width: 20px; height: 20px; padding: 0 5px;
    border-radius: 10px; background: var(--osw-err); color: #fff; font-size: 11px; font-weight: 700;
    display: grid; place-items: center; border: 2px solid var(--osw-bg);
}

/* ─── Janela ───────────────────────────────────────────────────────────── */
#orion-support-widget {
    position: fixed; right: 24px; bottom: 92px; z-index: 99999;
    width: 392px; height: min(680px, calc(100vh - 116px));
    display: flex; flex-direction: column; overflow: hidden;
    background: var(--osw-bg); color: var(--osw-tx);
    border: 1px solid var(--osw-line2); border-radius: 22px;
    box-shadow: 0 24px 70px rgba(0, 0, 0, .6), 0 0 0 1px rgba(139, 92, 246, .08), 0 0 60px rgba(139, 92, 246, .12);
    font-size: 14px; line-height: 1.45;
    opacity: 0; visibility: hidden; transform: translateY(14px) scale(.98); transform-origin: bottom right;
    transition: opacity .22s ease, transform .22s ease, visibility 0s linear .22s;
}
#orion-support-widget.open { opacity: 1; visibility: visible; transform: none; transition: opacity .22s ease, transform .22s ease; }

/* ─── Cabeçalho com ondas ──────────────────────────────────────────────── */
.osw-head {
    position: relative; flex: none; overflow: hidden;
    padding: 18px 20px 20px;
    background: radial-gradient(120% 90% at 20% 0%, #1a1030 0%, #0e0b17 55%, var(--osw-bg) 100%);
    border-bottom: 1px solid var(--osw-line);
    transition: padding .25s ease;
}
.osw-waves { position: absolute; inset: 0; width: 100%; height: 100%; opacity: .95; pointer-events: none; filter: blur(.4px); }
.osw-head::after {
    content: ''; position: absolute; inset: 0; pointer-events: none;
    background: linear-gradient(180deg, rgba(12,12,17,0) 45%, rgba(12,12,17,.75) 100%);
}
.osw-head > *:not(.osw-waves) { position: relative; z-index: 1; }
.osw-head-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.osw-logo { height: 26px; width: auto; filter: drop-shadow(0 2px 10px rgba(0,0,0,.5)); }
.osw-head-actions { display: flex; align-items: center; gap: 6px; }
.osw-team-btn {
    display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 12px;
    border-radius: 999px; font-size: 12px; font-weight: 600; color: var(--osw-tx);
    background: rgba(255,255,255,.08) !important; border: 1px solid var(--osw-line2) !important;
    backdrop-filter: blur(8px); transition: background .15s;
}
.osw-team-btn:hover { background: rgba(255,255,255,.14) !important; }
.osw-icon-btn {
    width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: none;
    color: var(--osw-tx); background: rgba(255,255,255,.06) !important; transition: background .15s, color .15s;
}
.osw-icon-btn:hover { background: rgba(255,255,255,.12) !important; }
.osw-icon-btn.ghost { background: transparent !important; color: var(--osw-mut); }
.osw-icon-btn.ghost:hover { color: var(--osw-tx); background: rgba(255,255,255,.06) !important; }
.osw-hello { margin-top: 26px; }
.osw-hello span { display: block; font-size: 15px; color: var(--osw-mut); font-weight: 500; }
.osw-hello h2 { margin: 2px 0 0; font-size: 25px; line-height: 1.15; font-weight: 700; letter-spacing: -.02em; color: #fff; }
.osw-online { margin-top: 12px; display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--osw-mut); }
.osw-online i { width: 7px; height: 7px; border-radius: 50%; background: var(--osw-ok); box-shadow: 0 0 0 3px rgba(52,211,153,.18); }

/* compacto (outras abas e conversa) */
#orion-support-widget.compact .osw-head { padding: 14px 16px; }
#orion-support-widget.compact .osw-hello,
#orion-support-widget.compact .osw-online { display: none; }
#orion-support-widget.compact .osw-logo { height: 22px; }
#orion-support-widget.in-chat .osw-head { display: none; }
#orion-support-widget.in-chat .osw-nav { display: none; }

/* ─── Corpo e abas ─────────────────────────────────────────────────────── */
.osw-body { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.osw-pane { display: none; flex: 1; min-height: 0; overflow-y: auto; padding: 16px 16px 20px; scrollbar-width: thin; scrollbar-color: var(--osw-s3) transparent; }
.osw-pane.active { display: block; animation: osw-in .2s ease; }
@keyframes osw-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.osw-sec-hd { display: flex; align-items: center; justify-content: space-between; margin: 22px 2px 10px; }
.osw-sec-hd.first { margin-top: 2px; }
.osw-sec-hd > span { font-size: 11.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--osw-dim); }
.osw-link { font-size: 12.5px; font-weight: 600; color: var(--osw-acc2) !important; }
.osw-link:hover { text-decoration: underline; }
.osw-btn-soft {
    display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border-radius: 999px;
    font-size: 12.5px; font-weight: 600; background: var(--osw-s2) !important; border: 1px solid var(--osw-line2) !important; color: var(--osw-tx);
}
.osw-btn-soft:hover { background: var(--osw-s3) !important; }
.osw-list { display: flex; flex-direction: column; gap: 8px; }
.osw-empty { margin: 4px 0; padding: 16px; text-align: center; font-size: 13px; color: var(--osw-mut); background: var(--osw-s1); border: 1px dashed var(--osw-line2); border-radius: var(--osw-r); }

/* caixa de pergunta */
.osw-ask {
    background: var(--osw-s1); border: 1px solid var(--osw-line2); border-radius: 16px; padding: 12px 12px 8px;
    transition: border-color .15s, box-shadow .15s;
}
.osw-ask:focus-within { border-color: rgba(255,255,255,.22); }
.osw-ask textarea {
    display: block; width: 100%; resize: none; border: 0; background: transparent; outline: none;
    font-size: 14.5px; line-height: 1.45; color: var(--osw-tx); padding: 2px 2px 6px; min-height: 44px;
}
.osw-ask textarea::placeholder, .osw-input textarea::placeholder { color: var(--osw-dim); }
.osw-ask-bar { display: flex; align-items: center; gap: 8px; }
.osw-ask-bar .osw-send { margin-left: auto; }
.osw-hint { flex: 1; font-size: 11px; color: var(--osw-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.osw-send {
    width: 34px; height: 34px; border-radius: 10px; flex: none; display: grid; place-items: center;
    background: #fff !important; color: #0c0c11 !important; font-size: 14px; transition: transform .12s, opacity .15s;
}
.osw-send:hover { transform: translateY(-1px); }
.osw-send:active { transform: scale(.94); }

.osw-file-chip {
    display: flex; align-items: center; gap: 8px; margin: 6px 0; padding: 7px 10px; border-radius: 10px;
    background: var(--osw-s2); border: 1px solid var(--osw-line); font-size: 12.5px; color: var(--osw-mut);
}
.osw-file-chip span { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--osw-tx); }
.osw-file-chip button { width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center; color: var(--osw-mut); }
.osw-file-chip button:hover { background: var(--osw-s3); color: var(--osw-tx); }

/* cartões (artigos, passos, conversas) */
.osw-article, .osw-step, .osw-ticket {
    width: 100%; display: flex; align-items: center; gap: 12px; text-align: left;
    padding: 12px; border-radius: var(--osw-r);
    background: var(--osw-s1) !important; border: 1px solid var(--osw-line) !important;
    transition: background .15s, border-color .15s, transform .15s;
}
.osw-article:hover, .osw-step:hover, .osw-ticket:hover { background: var(--osw-s2) !important; border-color: var(--osw-line2) !important; }
.osw-article-ic, .osw-step-n {
    width: 36px; height: 36px; flex: none; border-radius: 10px; display: grid; place-items: center;
    background: var(--osw-s3); color: var(--osw-acc2); font-size: 15px;
}
.osw-step-n { font-weight: 700; font-size: 14px; color: var(--osw-tx); }
.osw-article-tx { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.osw-article-tx b { font-size: 13.5px; font-weight: 600; color: var(--osw-tx); }
.osw-article-tx em { font-style: normal; font-size: 12px; color: var(--osw-mut); line-height: 1.35; }
.osw-chev { flex: none; font-size: 11px; color: var(--osw-dim); transition: transform .15s, color .15s; }
.osw-article:hover .osw-chev, .osw-step:hover .osw-chev { transform: translateX(2px); color: var(--osw-tx); }

.osw-ticket-tx { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.osw-ticket-meta { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.osw-ticket-meta b { color: var(--osw-mut); font-weight: 600; }
.osw-ticket-prev { font-size: 13.5px; color: var(--osw-tx); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.osw-ticket-time { flex: none; align-self: flex-start; font-size: 11px; color: var(--osw-dim); padding-top: 2px; }
.osw-st { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; background: var(--osw-s3); color: var(--osw-mut); }
.osw-st i { font-size: 9.5px; }
.osw-st.ai { color: var(--osw-acc2); background: rgba(139,92,246,.12); }
.osw-st.wait { color: var(--osw-warn); background: rgba(251,191,36,.12); }
.osw-st.human { color: var(--osw-ok); background: rgba(52,211,153,.12); }
.osw-st.done { color: var(--osw-dim); }

/* avatares */
.osw-avatar {
    width: 38px; height: 38px; flex: none; border-radius: 12px; overflow: hidden;
    display: grid; place-items: center; font-weight: 700; font-size: 14px;
    background: var(--osw-s3); color: var(--osw-tx); border: 1px solid var(--osw-line);
}
.osw-avatar.ai { background: #15101f; }
.osw-avatar.ai img { width: 24px; height: 20px; max-width: none; object-fit: cover; object-position: left center; } /* só o símbolo "N" da logo */
.osw-avatar.sm.ai img { width: 18px; height: 15px; }
.osw-avatar.human { background: #10251d; color: var(--osw-ok); }
.osw-avatar.sm { width: 28px; height: 28px; border-radius: 9px; font-size: 12px; }

/* novidades */
.osw-news { padding: 14px; border-radius: var(--osw-r); background: var(--osw-s1); border: 1px solid var(--osw-line); }
.osw-news b { display: block; margin-top: 8px; font-size: 14px; font-weight: 600; }
.osw-news p { margin: 4px 0 0; font-size: 12.5px; color: var(--osw-mut); }
.osw-tag { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 10.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.osw-tag.new { background: rgba(139,92,246,.14); color: var(--osw-acc2); }
.osw-tag.upd { background: rgba(52,211,153,.12); color: var(--osw-ok); }

/* busca */
.osw-search {
    display: flex; align-items: center; gap: 10px; height: 42px; padding: 0 14px; margin-bottom: 12px;
    border-radius: 12px; background: var(--osw-s1); border: 1px solid var(--osw-line2); color: var(--osw-dim);
}
.osw-search:focus-within { border-color: rgba(255,255,255,.22); }
.osw-search input { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; font-size: 13.5px; color: var(--osw-tx); }

/* ─── Navegação inferior ───────────────────────────────────────────────── */
.osw-nav { flex: none; display: grid; grid-template-columns: repeat(5, 1fr); padding: 6px 8px 8px; background: var(--osw-bg); border-top: 1px solid var(--osw-line); }
.osw-nav-btn {
    position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
    height: 46px; padding: 0 2px; border-radius: 10px;
    color: var(--osw-dim); font-size: 10.5px; font-weight: 500; transition: color .15s;
}
.osw-nav-btn i { font-size: 16px; line-height: 1; }
.osw-nav-btn:hover { color: var(--osw-tx); }
.osw-nav-btn.active { color: var(--osw-tx); font-weight: 600; }
.osw-nav-btn.active i { color: var(--osw-acc2); }
.osw-dot { position: absolute; top: 6px; left: calc(50% + 7px); width: 8px; height: 8px; border-radius: 50%; background: var(--osw-err); }

/* ─── Conversa ─────────────────────────────────────────────────────────── */
.osw-chat { display: none; flex: 1; min-height: 0; flex-direction: column; }
#orion-support-widget.in-chat .osw-chat { display: flex; }
.osw-chat-top {
    position: relative; flex: none; display: flex; align-items: center; gap: 10px; padding: 12px 12px;
    background: radial-gradient(120% 140% at 10% 0%, #1a1030 0%, var(--osw-bg) 70%); border-bottom: 1px solid var(--osw-line);
}
.osw-chat-who { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; }
.osw-chat-who > span:last-child { min-width: 0; display: flex; flex-direction: column; }
.osw-chat-who b { font-size: 14.5px; font-weight: 600; }
.osw-chat-who em { font-style: normal; font-size: 11.5px; color: var(--osw-mut); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#orion-chat-close-ticket.confirm { background: rgba(52,211,153,.18) !important; color: var(--osw-ok); }

.osw-msgs { flex: 1; min-height: 0; overflow-y: auto; padding: 16px 14px 8px; display: flex; flex-direction: column; gap: 10px; scrollbar-width: thin; scrollbar-color: var(--osw-s3) transparent; }
.osw-day { display: flex; justify-content: center; margin: 4px 0; }
.osw-day span { font-size: 11px; color: var(--osw-dim); padding: 3px 10px; border-radius: 999px; background: var(--osw-s1); border: 1px solid var(--osw-line); }
.osw-row { display: flex; align-items: flex-end; gap: 8px; max-width: 100%; animation: osw-in .18s ease; }
.osw-row.user { justify-content: flex-end; }
.osw-row.sending { opacity: .7; }
.osw-bubble {
    max-width: 80%; padding: 10px 13px; border-radius: 16px; font-size: 14px; line-height: 1.5;
    word-wrap: break-word; overflow-wrap: anywhere;
    background: var(--osw-s2); border: 1px solid var(--osw-line); border-bottom-left-radius: 6px;
}
.osw-row.user .osw-bubble { background: #f1f0f7; color: #14141b; border-color: transparent; border-bottom-left-radius: 16px; border-bottom-right-radius: 6px; }
.osw-row.agent .osw-bubble { background: #10201a; border-color: rgba(52,211,153,.18); }
.osw-bubble a { color: var(--osw-acc2); text-decoration: underline; }
.osw-row.user .osw-bubble a { color: #5b21b6; }
.osw-from { display: block; margin-bottom: 3px; font-size: 11.5px; font-weight: 600; color: var(--osw-acc2); }
.osw-row.agent .osw-from { color: var(--osw-ok); }
.osw-time { display: block; margin-top: 4px; font-size: 10.5px; color: var(--osw-dim); text-align: right; }
.osw-row.user .osw-time { color: #6d6d7d; }
.osw-att-img { display: block; margin-top: 8px; border-radius: 10px; overflow: hidden; max-width: 220px; }
.osw-att-img img { width: 100%; height: auto; }
.osw-att { display: inline-flex; align-items: center; gap: 7px; margin-top: 8px; padding: 6px 10px; border-radius: 8px; background: rgba(0,0,0,.2); font-size: 12.5px; text-decoration: none !important; }
.osw-closed { display: flex; align-items: center; gap: 8px; justify-content: center; margin: 8px 0; padding: 10px 12px; border-radius: 12px; font-size: 12.5px; color: var(--osw-mut); background: var(--osw-s1); border: 1px dashed var(--osw-line2); text-align: center; }
.osw-closed i { color: var(--osw-ok); }

.osw-typing .osw-bubble { display: flex; gap: 4px; padding: 13px 14px; }
.osw-typing .osw-bubble i { width: 6px; height: 6px; border-radius: 50%; background: var(--osw-mut); animation: osw-dot 1.2s infinite ease-in-out; }
.osw-typing .osw-bubble i:nth-child(2) { animation-delay: .15s; }
.osw-typing .osw-bubble i:nth-child(3) { animation-delay: .3s; }
@keyframes osw-dot { 0%, 60%, 100% { opacity: .3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

.osw-chat-foot { flex: none; padding: 8px 12px 12px; border-top: 1px solid var(--osw-line); background: var(--osw-bg); }
.osw-foot-row { display: flex; gap: 8px; margin-bottom: 8px; }
.osw-foot-row:not(:has(> :not([hidden]))) { display: none; }
.osw-chip-btn {
    display: inline-flex; align-items: center; gap: 7px; height: 30px; padding: 0 12px; border-radius: 999px;
    font-size: 12.5px; font-weight: 600; color: var(--osw-tx); background: var(--osw-s2) !important; border: 1px solid var(--osw-line2) !important;
}
.osw-chip-btn i { font-size: 11px; color: var(--osw-ok); }
.osw-chip-btn:hover { background: var(--osw-s3) !important; }
.osw-input {
    display: flex; align-items: flex-end; gap: 6px; padding: 6px; border-radius: 14px;
    background: var(--osw-s1); border: 1px solid var(--osw-line2); transition: border-color .15s, box-shadow .15s;
}
.osw-input:focus-within { border-color: rgba(255,255,255,.22); }
.osw-input textarea {
    flex: 1; min-width: 0; resize: none; border: 0; outline: none; background: transparent;
    font-size: 14px; line-height: 1.45; padding: 7px 4px; max-height: 120px; color: var(--osw-tx);
}

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

/* Na central da equipe o botão flutuante sai do caminho */
body.osw-on-helpdesk #orion-support-launcher, body.osw-on-helpdesk #orion-support-widget { display: none; }

/* ─── Mobile ───────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
    #orion-support-launcher { right: 16px; bottom: 16px; width: 52px; height: 52px; }
    #orion-support-launcher.active { display: none; }
    #orion-support-widget { inset: 0; width: 100%; height: 100%; height: 100dvh; border-radius: 0; border: 0; transform: translateY(24px); }
    .osw-hint { display: none; }
    .osw-bubble { max-width: 86%; }
}
@media (prefers-reduced-motion: reduce) {
    #orion-support-widget, .osw-pane.active, .osw-row { transition: none; animation: none; }
}
