/* 12/11/2026: tema claro (padrao) e escuro (opcional), menu lateral e o que as telas dividem.
   As telas antigas usam var(--token, COR_ORIGINAL): no escuro os tokens abaixo nao existem e
   vale a cor original (fica igual era); no claro valem os de :root:not([data-tema="escuro"]). */

:root { color-scheme: light; }
:root[data-tema="escuro"] { color-scheme: dark; }

:root:not([data-tema="escuro"]) {
  --c-pagina: #f3f5f9;
  --c-fundo: #eef1f6;
  --c-painel: #f6f8fb;
  --c-topo: rgba(255, 255, 255, 0.92);
  --c-solido: #ffffff;
  --c-cartao: #ffffff;
  --c-veu: rgba(15, 23, 42, 0.45);
  --c-sombra: rgba(15, 23, 42, 0.14);
  --b-fraca: #e3e8ef;
  --b-forte: #cdd5e0;
  --t-forte: #0f172a;
  --t-normal: #334155;
  --t-suave: #566174;
  --t-fraco: #748094;
  --t-vermelho: #c81e1e;
  --t-verde: #047857;
  --t-amarelo: #a15c07;
  --t-azul: #1d4ed8;
  --t-roxo: #6d28d9;
  --t-laranja: #c2410c;
}

/* ---------- casca: menu lateral + barra de cima ---------- */
:root {
  --ui-lateral: #ffffff;
  --ui-borda: #e3e8ef;
  --ui-item: #334155;
  --ui-item-suave: #748094;
  --ui-hover: #f1f4f8;
  --ui-acento: #2563eb;
  --ui-acento-fundo: rgba(37, 99, 235, 0.09);
  --ui-acento-txt: #1d4ed8;
  --ui-largura: 252px;
}
body.area-admin { --ui-acento: #f97316; --ui-acento-fundo: rgba(249, 115, 22, 0.1); --ui-acento-txt: #c2410c; }
:root[data-tema="escuro"] {
  --ui-lateral: #0b1222;
  --ui-borda: rgba(148, 163, 184, 0.12);
  --ui-item: #cbd5e1;
  --ui-item-suave: #64748b;
  --ui-hover: rgba(148, 163, 184, 0.08);
  --ui-acento-fundo: rgba(96, 165, 250, 0.14);
  --ui-acento-txt: #93c5fd;
}
:root[data-tema="escuro"] body.area-admin { --ui-acento-fundo: rgba(249, 115, 22, 0.15); --ui-acento-txt: #fdba74; }

.app { display: flex; min-height: 100vh; width: 100%; }
.app-corpo { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.lateral { position: sticky; top: 0; height: 100vh; width: var(--ui-largura); flex: none; display: flex; flex-direction: column; gap: 2px; padding: 18px 12px 14px; background: var(--ui-lateral); border-right: 1px solid var(--ui-borda); overflow-y: auto; z-index: 70; }
.lateral-marca { display: flex; align-items: center; gap: 8px; padding: 2px 10px 16px; }
.lateral-marca .marca-texto { font-size: 19px; font-weight: 800; letter-spacing: -0.3px; background: linear-gradient(135deg, #3b82f6, #8b5cf6); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
body.area-admin .lateral-marca .marca-texto { background-image: linear-gradient(135deg, #f59e0b, #f97316); }
.lateral-marca .marca-tag { padding: 2px 7px; border-radius: 6px; font-size: 10px; font-weight: 700; letter-spacing: 0.5px; color: var(--ui-acento-txt); background: var(--ui-acento-fundo); }
.lateral-fechar { display: none; margin-left: auto; border: 0; background: none; color: var(--ui-item-suave); font-size: 20px; cursor: pointer; padding: 4px 6px; border-radius: 8px; }
.lateral-grupo { font-size: 11px; font-weight: 700; letter-spacing: 0.7px; text-transform: uppercase; color: var(--ui-item-suave); padding: 14px 12px 6px; }
.lateral-item { display: flex; align-items: center; gap: 11px; width: 100%; padding: 10px 12px; border: 0; border-radius: 10px; background: none; color: var(--ui-item); font: inherit; font-size: 14px; font-weight: 500; text-align: left; text-decoration: none; cursor: pointer; transition: background 0.15s, color 0.15s; min-height: 42px; }
.lateral-item:hover { background: var(--ui-hover); }
.lateral-item.ativo { background: var(--ui-acento-fundo); color: var(--ui-acento-txt); font-weight: 650; }
.lateral-item .ico { flex: none; width: 22px; text-align: center; font-size: 16px; line-height: 1; }
.lateral-item .txt { flex: 1; min-width: 0; }
.lateral-item .txt small { display: block; font-size: 11.5px; font-weight: 400; color: var(--ui-item-suave); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.lateral-item .txt b { display: block; font-weight: inherit; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lateral-item .contador { flex: none; min-width: 20px; padding: 0 6px; border-radius: 10px; background: #ef4444; color: #fff; font-size: 11px; font-weight: 700; line-height: 20px; text-align: center; }
.lateral-rodape { margin-top: auto; padding-top: 10px; border-top: 1px solid var(--ui-borda); display: flex; flex-direction: column; gap: 2px; }
.lateral-usuario { display: flex; align-items: center; gap: 10px; padding: 10px 12px 6px; min-width: 0; }
.lateral-usuario .avatar { flex: none; width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; color: #fff; background: linear-gradient(135deg, #3b82f6, #8b5cf6); }
body.area-admin .lateral-usuario .avatar { background: linear-gradient(135deg, #f59e0b, #f97316); }
.lateral-usuario .nome { font-size: 13px; font-weight: 600; color: var(--ui-item); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lateral-sair:hover { color: #ef4444; }
.lateral-veu { display: none; }

.topo { position: sticky; top: 0; z-index: 50; display: flex; align-items: center; gap: 14px; padding: 14px 32px; min-height: 66px; background: var(--c-topo, rgba(15, 23, 42, 0.8)); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-bottom: 1px solid var(--ui-borda); flex-wrap: wrap; }
.topo-titulo { flex: 1 1 220px; min-width: 0; }
.topo-titulo h1 { font-size: 19px; font-weight: 750; color: var(--t-forte, #f1f5f9); line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topo-titulo .topo-sub { font-size: 12.5px; color: var(--t-suave, #94a3b8); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topo-acoes { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.btn-menu { display: none; flex: none; width: 42px; height: 42px; border-radius: 10px; border: 1px solid var(--ui-borda); background: var(--ui-lateral); color: var(--ui-item); font-size: 20px; cursor: pointer; align-items: center; justify-content: center; }

/* sem menu (telas abertas dentro do admin) */
.app.sem-lateral .lateral, .app.sem-lateral .btn-menu, .app.sem-lateral .lateral-veu { display: none !important; }

/* conteudo ocupa a largura toda */
.conteudo { width: 100%; padding: 28px 32px 48px; }

@media (max-width: 1000px) {
  .lateral { position: fixed; left: 0; top: 0; bottom: 0; height: auto; transform: translateX(-105%); transition: transform 0.22s ease, box-shadow 0.22s; width: min(300px, 86vw); visibility: hidden; }
  .app.menu-aberto .lateral { transform: none; visibility: visible; box-shadow: 0 20px 50px rgba(15, 23, 42, 0.25); }
  .app.menu-aberto .lateral-veu { display: block; position: fixed; inset: 0; z-index: 65; background: var(--c-veu, rgba(0, 0, 0, 0.6)); }
  .lateral-fechar { display: block; }
  .btn-menu { display: inline-flex; }
  .topo { padding: 10px 16px; min-height: 60px; gap: 10px; }
  .conteudo { padding: 18px 16px 40px; }
}
@media (max-width: 600px) {
  .topo-titulo { flex-basis: 0; }
  .topo-titulo h1 { font-size: 17px; }
  .so-largo { display: none; }
}

/* ---------- olho nas senhas (tema.js poe em todo campo de senha) ---------- */
.olho-wrap { position: relative; display: block; width: 100%; }
.olho-wrap > input { width: 100%; padding-right: 46px !important; }
.olho-senha { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 36px; height: 36px; margin: 0 !important; padding: 0 !important; border: 0 !important; border-radius: 8px; background: none !important; color: var(--t-fraco, #64748b); cursor: pointer; display: flex; align-items: center; justify-content: center; }
.olho-senha:hover { color: var(--t-forte, #e2e8f0); background: rgba(148, 163, 184, 0.12) !important; }

/* ---------- toques do tema claro ---------- */
:root:not([data-tema="escuro"]) .card,
:root:not([data-tema="escuro"]) .stat-card,
:root:not([data-tema="escuro"]) .tabela-wrap,
:root:not([data-tema="escuro"]) .vg-total,
:root:not([data-tema="escuro"]) .grafico-card,
:root:not([data-tema="escuro"]) .resultado-card,
:root:not([data-tema="escuro"]) .numero,
:root:not([data-tema="escuro"]) .item,
:root:not([data-tema="escuro"]) .modal,
:root:not([data-tema="escuro"]) .escolha { box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05), 0 1px 8px rgba(15, 23, 42, 0.04); }
:root:not([data-tema="escuro"]) .modal { box-shadow: 0 24px 60px -12px rgba(15, 23, 42, 0.3); }
:root:not([data-tema="escuro"]) .card:hover { box-shadow: 0 6px 18px rgba(15, 23, 42, 0.08); }
:root:not([data-tema="escuro"]) ::selection { background: rgba(59, 130, 246, 0.2); }

/* ---------- previa do criativo (ui/previa.js), 12/11/2026 ---------- */
.previa-gatilho { position: relative; flex: none; display: block; padding: 0; margin: 0; border: 0; background: none; border-radius: 10px; cursor: pointer; line-height: 0; }
.previa-gatilho:hover > img, .previa-gatilho:hover > div { filter: brightness(0.9); }
.previa-gatilho:focus-visible { outline: 2px solid var(--ui-acento); outline-offset: 2px; }
.previa-gatilho .previa-play { position: absolute; right: 4px; bottom: 4px; width: 22px; height: 22px; border-radius: 50%; background: rgba(15, 23, 42, 0.78); color: #fff; font-size: 9px; line-height: 22px; text-align: center; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35); pointer-events: none; }
.ver-anuncio { display: inline-flex; align-items: center; gap: 5px; margin-top: 6px; padding: 5px 10px; border-radius: 999px; border: 1px solid var(--b-forte, rgba(148, 163, 184, 0.25)); background: none; color: var(--t-azul, #93c5fd); font: inherit; font-size: 12px; font-weight: 650; cursor: pointer; }
.ver-anuncio:hover { background: rgba(59, 130, 246, 0.1); }
html.previa-aberta { overflow: hidden; }
.previa-veu { position: fixed; inset: 0; z-index: 300; display: flex; align-items: center; justify-content: center; padding: 20px; background: var(--c-veu, rgba(2, 6, 23, 0.72)); }
.previa { width: min(460px, 100%); max-height: calc(100vh - 40px); overflow-y: auto; display: flex; flex-direction: column; gap: 12px; padding: 18px 18px 14px; border-radius: 20px; background: var(--c-solido, #0f172a); color: var(--t-forte, #e2e8f0); border: 1px solid var(--b-fraca, rgba(148, 163, 184, 0.16)); box-shadow: 0 30px 70px -20px rgba(2, 6, 23, 0.55); }
.previa:focus { outline: none; }
.previa-topo { display: flex; align-items: flex-start; gap: 12px; }
.previa-rot { font-size: 11px; font-weight: 800; letter-spacing: 0.7px; text-transform: uppercase; color: var(--ui-acento-txt); }
.previa-topo h3 { margin-top: 3px; font-size: 16px; font-weight: 700; line-height: 1.3; color: var(--t-forte, #f1f5f9); overflow-wrap: anywhere; }
.previa-fechar { flex: none; margin-left: auto; width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--b-fraca, rgba(148, 163, 184, 0.18)); background: none; color: var(--t-suave, #94a3b8); font-size: 15px; cursor: pointer; }
.previa-fechar:hover { color: var(--t-forte, #f1f5f9); background: rgba(148, 163, 184, 0.12); }
.previa-abas { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; padding: 4px; border-radius: 12px; background: var(--c-painel, rgba(15, 23, 42, 0.6)); border: 1px solid var(--b-forte, rgba(148, 163, 184, 0.16)); }
.previa-abas button { min-width: 0; padding: 9px 4px; border: 0; border-radius: 9px; background: transparent; color: var(--t-suave, #94a3b8); font: inherit; font-size: 13px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.previa-abas button:hover { color: var(--t-forte, #f1f5f9); }
.previa-abas button.ativa { background: var(--ui-acento-fundo); color: var(--ui-acento-txt); }
.previa-abas button.recusado:not(.ativa) { opacity: 0.55; text-decoration: line-through; }
.previa-palco { position: relative; display: flex; align-items: flex-start; justify-content: center; min-height: 340px; padding: 12px; border-radius: 14px; background: rgba(148, 163, 184, 0.1); }
.previa-moldura { position: relative; overflow: hidden; border-radius: 12px; background: #fff; box-shadow: 0 8px 24px rgba(15, 23, 42, 0.2); }
.previa-moldura iframe { display: block; border: 0; transform-origin: 0 0; }
.previa-estado { position: absolute; inset: 0; z-index: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 24px; text-align: center; font-size: 14px; line-height: 1.5; color: var(--t-suave, #94a3b8); }
.previa-estado.previa-carregando { background: var(--c-solido, #0f172a); border-radius: 14px; }
.previa-estado .emoji { font-size: 34px; line-height: 1; }
.previa-estado small { font-size: 12px; color: var(--t-fraco, #64748b); max-width: 320px; }
.previa-girando { width: 28px; height: 28px; border-radius: 50%; border: 3px solid rgba(148, 163, 184, 0.25); border-top-color: var(--ui-acento); animation: previa-gira 0.8s linear infinite; }
@keyframes previa-gira { to { transform: rotate(360deg); } }
.previa-tentar { margin-top: 4px; padding: 8px 14px; border-radius: 10px; border: 1px solid var(--b-forte, rgba(148, 163, 184, 0.25)); background: var(--c-cartao, rgba(30, 41, 59, 0.6)); color: var(--t-forte, #e2e8f0); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.previa-rodape { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; font-size: 12px; color: var(--t-fraco, #64748b); }
.previa-rodape a { color: var(--t-azul, #93c5fd); font-weight: 600; text-decoration: none; }
.previa-rodape a[hidden] { display: none; }
@media (max-width: 640px) {
  .previa-veu { align-items: flex-end; padding: 0; }
  .previa { width: 100%; max-height: 94vh; border-radius: 20px 20px 0 0; padding: 14px 14px calc(12px + env(safe-area-inset-bottom)); border-bottom: 0; }
  .previa-abas button { font-size: 12px; padding: 9px 2px; }
  .previa-palco { min-height: 300px; padding: 10px; }
}
@media (prefers-reduced-motion: reduce) { .previa-girando { animation-duration: 2.4s; } }
