/*
 * Tema do WhatsappChat (claro e escuro), no visual do portal Antares.
 * As telas usam só as variáveis --wc-*; o tema escolhe os valores.
 * O tema e o menu recolhido ficam em atributos do <html>, aplicados antes de a página aparecer (App.razor).
 */

/* ── Paleta: tema claro ─────────────────────────────────────────────── */
:root {
    --wc-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

    --wc-bg: #f4f5f8;
    --wc-top: #ffffff;
    --wc-card: #ffffff;
    --wc-card-2: #eef0f4;
    --wc-input: #ffffff;
    --wc-border: #e3e6ec;
    --wc-text: #1d2230;
    --wc-muted: #5b6475;

    --wc-primary: #dc2626;
    --wc-primary-hover: #b91c1c;
    --wc-primary-soft: #fde8e8;
    --wc-primary-text: #b91c1c;
    --wc-on-primary: #ffffff;

    /* Menu lateral: azul-marinho nos dois temas */
    --wc-side: #1b2340;
    --wc-side-border: #283157;
    --wc-side-text: #c9cfe0;
    --wc-side-muted: #9aa3c0;
    --wc-side-hover: #232d52;
    --wc-side-active: #4a2238;
    --wc-side-active-text: #ffffff;
    --wc-logo: #1b2340;

    --wc-success: #15803d;
    --wc-success-soft: #e7f6ec;
    --wc-warn: #a16207;
    --wc-warn-soft: #fdf3d7;
    --wc-info: #1d4ed8;
    --wc-info-soft: #e6eeff;
    --wc-danger: #dc2626;
    --wc-danger-soft: #fdecec;

    --wc-in-bubble: #ffffff;
    --wc-out-bubble: #e2f5e5;
    --wc-out-border: #c9ebcf;
    --wc-bot-bubble: #eef1ff;
    --wc-bot-border: #d8deff;
    --wc-note: #fff8e1;
    --wc-note-border: #f2e1a6;

    --wc-chat-bg: #f2f3f6;
    --wc-hover: #f3f4f7;
    --wc-overlay: rgba(15, 18, 25, .45);
    --wc-online: #22c55e;
    /* Copiloto (IA): lilás */
    --wc-ai: #7c3aed;
    --wc-ai-soft: #f3ecff;
    --wc-ai-text: #5b2a8c;
    --wc-ai-border: #d9c2f7;

    --wc-shadow: 0 1px 3px rgba(16, 24, 40, .08);
    --wc-shadow-lg: 0 8px 28px rgba(16, 24, 40, .18);
    --wc-radius: 14px;
    --wc-radius-sm: 10px;

    color-scheme: light;
}

/* ── Paleta: tema escuro ────────────────────────────────────────────── */
:root[data-theme="dark"] {
    --wc-bg: #0f1219;
    --wc-top: #0f1219;
    --wc-card: #181c28;
    --wc-card-2: #1f2433;
    --wc-input: #12151f;
    --wc-border: #2a3042;
    --wc-text: #e6e8ef;
    --wc-muted: #9aa2b6;

    --wc-primary: #4361ee;
    --wc-primary-hover: #3651d4;
    --wc-primary-soft: #232a4d;
    --wc-primary-text: #a9b8ff;
    --wc-on-primary: #ffffff;

    --wc-side: #141824;
    --wc-side-border: #232838;
    --wc-side-text: #c3c9d9;
    --wc-side-muted: #8a93ab;
    --wc-side-hover: #1c2131;
    --wc-side-active: #232a4d;
    --wc-side-active-text: #a9b8ff;
    --wc-logo: #ffffff;

    --wc-success: #4ade80;
    --wc-success-soft: #13291f;
    --wc-warn: #fbbf24;
    --wc-warn-soft: #2e2412;
    --wc-info: #7dd3fc;
    --wc-info-soft: #122634;
    --wc-danger: #f87171;
    --wc-danger-soft: #2f1618;

    --wc-in-bubble: #1f2433;
    --wc-out-bubble: #173b2f;
    --wc-out-border: #1f4d3e;
    --wc-bot-bubble: #232a4d;
    --wc-bot-border: #2e3766;
    --wc-note: #2a2414;
    --wc-note-border: #4a3d1a;

    --wc-chat-bg: #0c0f15;
    --wc-hover: #20253a;
    --wc-overlay: rgba(0, 0, 0, .6);
    --wc-online: #4ade80;
    --wc-ai: #a78bfa;
    --wc-ai-soft: #2a2140;
    --wc-ai-text: #d4b8ff;
    --wc-ai-border: #45346a;

    --wc-shadow: 0 1px 3px rgba(0, 0, 0, .4);
    --wc-shadow-lg: 0 8px 28px rgba(0, 0, 0, .5);

    color-scheme: dark;
}

body {
    background: var(--wc-bg);
    color: var(--wc-text);
}

/* ── Casca: menu lateral + barra do topo (AppShell.razor) ───────────── */
.wcs {
    display: flex;
    height: 100dvh;
    font-family: var(--wc-font);
    font-size: 14px;
    background: var(--wc-bg);
    color: var(--wc-text);
}

.wcs-side {
    position: relative;
    flex: 0 0 248px;
    width: 248px;
    display: flex;
    flex-direction: column;
    background: var(--wc-side);
    color: var(--wc-side-text);
    border-right: 1px solid var(--wc-side-border);
    transition: flex-basis .15s ease, width .15s ease;
}

.wcs-brand {
    height: 64px;
    flex: none;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 20px;
    border-bottom: 1px solid var(--wc-side-border);
    color: #ffffff;
    text-decoration: none;
}
.wcs-brand:hover { color: #ffffff; }
.wcs-brand-name { display: flex; flex-direction: column; line-height: 1.05; white-space: nowrap; }
.wcs-brand-word { font-size: 22px; font-weight: 800; letter-spacing: -0.03em; }
.wcs-brand-product {
    font-size: 10px; font-weight: 700; letter-spacing: .18em; text-transform: uppercase;
    color: var(--wc-side-muted); margin-top: 2px;
}

.wcs-collapse {
    position: absolute;
    top: 18px; right: -14px;   /* na altura da barra do topo, cuja margem não tem conteúdo: não cobre a tela */
    width: 28px; height: 28px;
    border-radius: 50%;
    border: 2px solid var(--wc-bg);
    background: var(--wc-primary);
    color: var(--wc-on-primary);
    display: flex; align-items: center; justify-content: center;
    padding: 0;
    cursor: pointer;
    z-index: 5;
}
.wcs-collapse svg { transition: transform .15s ease; }

.wcs-nav {
    flex: 1;
    overflow-y: auto;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.wcs-group {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--wc-side-muted);
    padding: 16px 10px 6px;
    white-space: nowrap;
}
.wcs-group:first-child { padding-top: 4px; }
.wcs-sep { display: none; height: 1px; background: var(--wc-side-border); margin: 12px 8px; }

.wcs-item {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 44px;
    padding: 0 12px;
    border-radius: 10px;
    color: var(--wc-side-text);
    text-decoration: none;
    white-space: nowrap;
}
.wcs-item:hover { background: var(--wc-side-hover); color: #ffffff; }
.wcs-item.active { background: var(--wc-side-active); color: var(--wc-side-active-text); font-weight: 600; }
.wcs-item svg { flex: none; }
.wcs-label { flex: 1; overflow: hidden; text-overflow: ellipsis; }

.wcs-foot {
    padding: 14px 20px;
    border-top: 1px solid var(--wc-side-border);
    font-size: 12px;
    color: var(--wc-side-muted);
    white-space: nowrap;
}
.wcs-foot-short { display: none; }

/* Menu recolhido: só ícones. Atendimento tem a sua própria escolha (data-side-atd). */
:root[data-side="collapsed"] .wcs:not(.wcs-atd) .wcs-side,
:root[data-side-atd="collapsed"] .wcs.wcs-atd .wcs-side { flex-basis: 76px; width: 76px; }

:root[data-side="collapsed"] .wcs:not(.wcs-atd) :is(.wcs-brand-name, .wcs-label, .wcs-group, .wcs-foot-long),
:root[data-side-atd="collapsed"] .wcs.wcs-atd :is(.wcs-brand-name, .wcs-label, .wcs-group, .wcs-foot-long) { display: none; }

:root[data-side="collapsed"] .wcs:not(.wcs-atd) :is(.wcs-sep, .wcs-foot-short),
:root[data-side-atd="collapsed"] .wcs.wcs-atd :is(.wcs-sep, .wcs-foot-short) { display: block; }

:root[data-side="collapsed"] .wcs:not(.wcs-atd) :is(.wcs-brand, .wcs-item),
:root[data-side-atd="collapsed"] .wcs.wcs-atd :is(.wcs-brand, .wcs-item) { justify-content: center; padding-left: 0; padding-right: 0; }

:root[data-side="collapsed"] .wcs:not(.wcs-atd) .wcs-foot,
:root[data-side-atd="collapsed"] .wcs.wcs-atd .wcs-foot { text-align: center; padding-left: 0; padding-right: 0; }

:root[data-side="collapsed"] .wcs:not(.wcs-atd) .wcs-collapse svg,
:root[data-side-atd="collapsed"] .wcs.wcs-atd .wcs-collapse svg { transform: rotate(180deg); }

/* Área principal */
.wcs-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.wcs-top {
    min-height: 64px;
    flex: none;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 10px 24px;
    background: var(--wc-top);
    border-bottom: 1px solid var(--wc-border);
}
.wcs-title { margin: 0; font-size: 19px; font-weight: 700; flex: 1; min-width: 120px; color: var(--wc-text); }
.wcs-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* Botões e selos da barra do topo (as telas usam em TopActions) */
.wcs-pill {
    display: inline-flex; align-items: center; gap: 6px;
    min-height: 34px; padding: 0 12px;
    border-radius: 999px;
    border: 1px solid var(--wc-border);
    background: var(--wc-card);
    color: var(--wc-text);
    font: 600 13px var(--wc-font);
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
}
.wcs-pill:hover { border-color: var(--wc-muted); }
.wcs-pill:disabled { opacity: .6; cursor: default; }
.wcs-pill.ok { background: var(--wc-success-soft); color: var(--wc-success); }
.wcs-pill.warn { background: var(--wc-warn-soft); color: var(--wc-warn); }
.wcs-pill.danger { background: var(--wc-danger-soft); color: var(--wc-danger); }
.wcs-pill.info { background: var(--wc-primary-soft); color: var(--wc-primary-text); border-color: transparent; }
.wcs-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }

.wcs-theme { color: var(--wc-muted); font-weight: 500; padding-left: 6px; }
.wcs-switch {
    position: relative;
    width: 34px; height: 20px;
    border-radius: 999px;
    background: var(--wc-primary);
    flex: none;
}
.wcs-switch::after {
    content: "";
    position: absolute; top: 2px; left: 16px;
    width: 16px; height: 16px; border-radius: 50%;
    background: #ffffff;
    transition: left .15s ease;
}
:root[data-theme="dark"] .wcs-switch::after { left: 2px; }
.wcs-theme-to-light { display: none; }
:root[data-theme="dark"] .wcs-theme-to-light { display: inline; }
:root[data-theme="dark"] .wcs-theme-to-dark { display: none; }

/* Menu do usuário */
.wcs-user { position: relative; }
.wcs-user > summary { list-style: none; }
.wcs-user > summary::-webkit-details-marker { display: none; }
.wcs-user-btn {
    display: inline-flex; align-items: center; gap: 8px;
    min-height: 40px; padding: 0 10px 0 6px;
    border-radius: 10px;
    border: 1px solid var(--wc-border);
    background: var(--wc-card);
    color: var(--wc-text);
    font-size: 14px; font-weight: 500;
    cursor: pointer;
    max-width: 260px;
}
.wcs-user-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wcs-avatar {
    width: 28px; height: 28px; flex: none;
    border-radius: 50%;
    background: var(--wc-primary-soft);
    color: var(--wc-primary-text);
    font-size: 12px; font-weight: 700;
    display: inline-flex; align-items: center; justify-content: center;
}
.wcs-menu {
    position: absolute; right: 0; top: calc(100% + 6px);
    min-width: 200px;
    padding: 6px;
    border-radius: 12px;
    border: 1px solid var(--wc-border);
    background: var(--wc-card);
    box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
    display: flex; flex-direction: column;
    z-index: 50;
}
.wcs-menu a, .wcs-menu button {
    display: block; width: 100%;
    text-align: left;
    padding: 9px 12px;
    border: 0; border-radius: 8px;
    background: transparent;
    color: var(--wc-text);
    font: 14px var(--wc-font);
    text-decoration: none;
    cursor: pointer;
}
.wcs-menu a:hover, .wcs-menu button:hover { background: var(--wc-card-2); }
.wcs-menu-email { padding: 8px 12px 10px; font-size: 12px; color: var(--wc-muted); border-bottom: 1px solid var(--wc-border); margin-bottom: 4px; word-break: break-all; }

/* Conteúdo da tela: ocupa o resto da altura; a tela decide a própria rolagem */
.wcs-content {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: auto;
}
.wcs-content > * { flex: 1 1 auto; min-height: 0; }

/* Celular: o menu vira uma faixa no topo */
@media (max-width: 760px) {
    .wcs { flex-direction: column; height: auto; min-height: 100dvh; }
    .wcs-side, :root[data-side] .wcs .wcs-side { flex: none; width: auto; }
    .wcs-brand { height: 52px; }
    .wcs-collapse, .wcs-foot, .wcs-group, .wcs-sep { display: none !important; }
    .wcs-nav { flex-direction: row; overflow-x: auto; padding: 8px; gap: 4px; }
    .wcs-item { min-height: 40px; }
    .wcs-label { display: inline !important; }
    .wcs-top { padding: 10px 16px; }
    .wcs-main { min-height: 0; }
}
