/* Tema escuro — Brasil Certificadora */

html[data-theme="dark"] {
  color-scheme: dark;

  --bg: #101b27;
  --surface: #1c2b3a;
  --surface-2: #223344;
  --surface-3: #293d4d;
  --line: #344858;
  --line-strong: #4a6170;
  --text: #e8eff3;
  --muted: #afc0cb;
  --navy: #f0f6f8;
  --navy-2: #d3e4eb;
  --green: #08775e;
  --green-2: #129575;
  --green-soft: #183d35;
  --danger: #ffb9b9;
  --danger-soft: #532b31;
  --warning: #f3d18a;
  --warning-soft: #493d29;
}

html[data-theme="dark"],
html[data-theme="dark"] body {
  background: var(--bg);
  color: var(--text);
}

html[data-theme="dark"] .topbar,
html[data-theme="dark"] .crm-nav,
html[data-theme="dark"] .toolbar,
html[data-theme="dark"] .management-card,
html[data-theme="dark"] .metric,
html[data-theme="dark"] .panel,
html[data-theme="dark"] .login-card {
  background: var(--surface);
  color: var(--text);
  border-color: var(--line);
}

html[data-theme="dark"] .crm-nav button {
  color: var(--muted);
}

html[data-theme="dark"] .crm-nav button:hover {
  background: var(--surface-3);
  color: var(--text);
}

html[data-theme="dark"] .crm-nav button[aria-current="page"] {
  background: var(--green);
  color: #fff;
}

html[data-theme="dark"] .column {
  background: #223443;
  border-color: var(--line);
}

html[data-theme="dark"] .column[data-status="certificado_emitido"] {
  background: #1a4039;
}

html[data-theme="dark"] .card,
html[data-theme="dark"] .renewal-stat,
html[data-theme="dark"] .hierarchy-toolbar,
html[data-theme="dark"] .kanban-navigation {
  background: var(--surface);
  color: var(--text);
  border-color: var(--line);
}

html[data-theme="dark"] .card h3,
html[data-theme="dark"] .column-title strong,
html[data-theme="dark"] .view-head h1,
html[data-theme="dark"] .page-head h1,
html[data-theme="dark"] .management-card h2,
html[data-theme="dark"] .account-copy strong,
html[data-theme="dark"] .kanban-position {
  color: var(--text);
}

html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea,
html[data-theme="dark"] .control,
html[data-theme="dark"] .input,
html[data-theme="dark"] .select,
html[data-theme="dark"] .textarea,
html[data-theme="dark"] .quick-stage {
  background: #152534;
  color: var(--text);
  border-color: var(--line-strong);
}

html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder {
  color: #a6b7c2;
}

html[data-theme="dark"] .base-table,
html[data-theme="dark"] .base-table td,
html[data-theme="dark"] .base-table th,
html[data-theme="dark"] .table-scroll {
  background: var(--surface);
  color: var(--text);
  border-color: var(--line);
}

html[data-theme="dark"] .base-table tr:hover td {
  background: var(--surface-2);
}

html[data-theme="dark"] .btn-secondary,
html[data-theme="dark"] .icon-btn,
html[data-theme="dark"] .kanban-nav-btn:disabled {
  background: var(--surface-3);
  color: var(--text);
  border-color: var(--line);
}

html[data-theme="dark"] .btn-soft,
html[data-theme="dark"] .quick-new-lead {
  background: #18483b;
  color: #baf2d8;
  border-color: #326c58;
}

/* Preserva o destaque vermelho do botão Remover. */
html[data-theme="dark"]
.base-stage-buttons .row-actions button:last-child {
  background: #532b31;
  color: #ffb9b9;
  border-color: #85434b;
}

html[data-theme="dark"]
.base-stage-buttons .row-actions button:last-child:hover {
  background: #68343c;
}

html[data-theme="dark"] .login-screen {
  background:
    radial-gradient(circle at 15% 0%, #164b40, transparent 34rem),
    var(--bg);
}

html[data-theme="dark"] .modal {
  color: var(--text);
}

html[data-theme="dark"] .tag,
html[data-theme="dark"] .status-badge {
  border-color: var(--line);
}

html[data-theme="dark"] .empty,
html[data-theme="dark"] .small-note {
  color: var(--muted);
}

/* Botão de alternância */
#themeToggle {
  width: auto;
  min-width: 40px;
  padding: 0 11px;
  gap: 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 700;
}

@media (max-width: 600px) {
  #themeToggle {
    padding: 0 9px;
  }

  #themeToggle .theme-label {
    display: none;
  }
}

/* Correção de contraste e fundo preto — tema escuro */

/* Fundo externo, fora dos painéis */
html[data-theme="dark"],
html[data-theme="dark"] body,
html[data-theme="dark"] .app,
html[data-theme="dark"] main {
  background-color: #101113;
  color: #f0f3f5;
}

/* Superfícies principais */
html[data-theme="dark"] {
  --bg: #101113;
  --surface: #1b2025;
  --surface-2: #242b31;
  --surface-3: #2b343b;
  --line: #3b474f;
  --line-strong: #52616b;
  --text: #f0f3f5;
  --muted: #b7c3cb;
  --navy: #f4f6f8;
}

/* Painéis e áreas que ainda permaneciam brancas */
html[data-theme="dark"] .renewal-panel,
html[data-theme="dark"] .portfolio-panel,
html[data-theme="dark"] .management-card,
html[data-theme="dark"] .hierarchy-toolbar,
html[data-theme="dark"] .toolbar,
html[data-theme="dark"] .card,
html[data-theme="dark"] .panel {
  background: #1b2025;
  color: #f0f3f5;
  border-color: #3b474f;
}

/* Títulos e descrições */
html[data-theme="dark"] h1,
html[data-theme="dark"] h2,
html[data-theme="dark"] h3,
html[data-theme="dark"] .page-head h1,
html[data-theme="dark"] .view-head h1,
html[data-theme="dark"] .renewal-panel strong,
html[data-theme="dark"] .portfolio-panel strong {
  color: #f4f6f8;
}

html[data-theme="dark"] p,
html[data-theme="dark"] .small-note,
html[data-theme="dark"] .empty {
  color: #b7c3cb;
}

/* Indicadores da carteira */
html[data-theme="dark"] .renewal-stat {
  background: #272e35;
  color: #e2e8ec;
  border-color: #3b474f;
}

html[data-theme="dark"] .renewal-stat strong {
  color: #ffffff;
}

/* Campos e filtros */
html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea {
  background: #242b31;
  color: #f0f3f5;
  border-color: #52616b;
}

html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder {
  color: #b7c3cb;
}

/* Tabelas */
html[data-theme="dark"] .table-scroll,
html[data-theme="dark"] .base-table,
html[data-theme="dark"] .base-table th,
html[data-theme="dark"] .base-table td {
  background: #1b2025;
  color: #f0f3f5;
  border-color: #3b474f;
}

html[data-theme="dark"] .base-table tr:hover td {
  background: #272e35;
}

/* Mantém a identidade verde da marca */
html[data-theme="dark"] .eyebrow {
  color: #7dd3b0;
}


/* Legibilidade dos textos na área branca de renovação */
html[data-theme="dark"] .renewal-panel h1,
html[data-theme="dark"] .renewal-panel h2,
html[data-theme="dark"] .renewal-panel h3,
html[data-theme="dark"] .renewal-panel label,
html[data-theme="dark"] .renewal-panel p,
html[data-theme="dark"] .renewal-panel .small-note {
  color: #253443;
}

/* Contraste dos textos sobre o painel branco da carteira */
html[data-theme="dark"] #view-carteira > .section h2 {
  color: #172b3a !important;
}

html[data-theme="dark"] #view-carteira > .section .field {
  color: #34495a;
}

html[data-theme="dark"] #view-carteira > .section > .small-note {
  color: #405568;
}

html[data-theme="dark"] #view-carteira > .section > .eyebrow,
html[data-theme="dark"] #view-carteira > .section .section-head .eyebrow {
  color: #08775f;
}

/* Fundo suave da carteira no tema escuro */
html[data-theme="dark"] #view-carteira > .section {
  background: #edf1f2;
}

/* Mantém o aviso levemente mais claro */
html[data-theme="dark"] #view-carteira > .section > .small-note {
  background: #f4f8f8;
}

/* Kanban harmonizado — somente tema escuro */

/* Colunas em grafite, substituindo o azul intenso */
html[data-theme="dark"] .board .column {
  background: #252c30;
  border: 1px solid #3b464b;
}

/* Cartões com contraste equilibrado */
html[data-theme="dark"] .board .card {
  background: #30383c;
  border: 1px solid #455258;
  color: #e9f0ee;
}

/* Títulos e informações dos clientes */
html[data-theme="dark"] .board .column-title strong,
html[data-theme="dark"] .board .card h3 {
  color: #f4f7f6;
}

html[data-theme="dark"] .board .meta-row {
  color: #c5d2d0;
}

/* Informações de validade: sem caixas brancas */
html[data-theme="dark"] .board .card .small-note {
  background: #394348;
  color: #d5e2df;
  border-radius: 9px;
}

/* Etiquetas de produto e etapa */
html[data-theme="dark"] .board .product-pill {
  background: #234b40;
  color: #a9e8d0;
}

html[data-theme="dark"] .board .status-badge {
  background: #394b47;
  color: #d2f1e5;
  border-color: #506760;
}

/* Links e rótulo do seletor */
html[data-theme="dark"] .board .link-btn,
html[data-theme="dark"] .board .kanban-move-label {
  color: #9fdbc7;
}

/* Seletor de movimentação */
html[data-theme="dark"] .board .kanban-move-select {
  background: #252c30;
  color: #f4f7f6;
  border-color: #52615f;
}

/* Contadores */
html[data-theme="dark"] .board .column-count {
  background: #394448;
  color: #f4f7f6;
  border: 1px solid #52615f;
}

/* Coluna vazia */
html[data-theme="dark"] .board .empty {
  background: #30383c;
  color: #b9c9c8;
  border-color: #52615f;
}

/* Destaque ao arrastar um cartão */
html[data-theme="dark"] .board .column.drag-over {
  background: #29453c;
  outline-color: #71bda0;
}

/* Preserva uma distinção discreta para certificados emitidos */
html[data-theme="dark"]
.board .column[data-status="certificado_emitido"] {
  background: #253b35;
}


/* BOTAO_TEMA_3D_CRM
   Visual isolado do restante do CRM. */

#themeToggle.theme-3d {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 78px;
  height: 43px;
  min-width: 78px;
  min-height: 43px;
  padding: 4px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 999px;
  background:
    linear-gradient(145deg, #272c36, #080b12 65%);
  box-shadow:
    inset 2px 3px 7px rgba(0,0,0,.85),
    inset -1px -1px 3px rgba(255,255,255,.15),
    0 3px 8px rgba(0,0,0,.22);
  cursor: pointer;
  isolation: isolate;
  transition:
    box-shadow .35s ease,
    background .35s ease;
}

#themeToggle.theme-3d::before {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: inherit;
  border: 1px solid rgba(255,255,255,.08);
  background:
    radial-gradient(
      ellipse at 25% 50%,
      rgba(44,198,254,.13),
      transparent 55%
    );
  pointer-events: none;
}

#themeToggle.theme-3d .theme-icon {
  position: absolute;
  top: 5px;
  left: 5px;
  display: grid;
  place-items: center;
  width: 31px;
  height: 31px;
  border-radius: 50%;
  color: #aaf5ff;
  background:
    radial-gradient(
      circle at 35% 25%,
      #454c59,
      #191d27 55%,
      #080b11
    );
  box-shadow:
    inset 1px 2px 3px rgba(255,255,255,.22),
    inset -2px -3px 5px rgba(0,0,0,.8),
    0 2px 6px rgba(0,0,0,.65),
    0 0 9px rgba(44,198,254,.3);
  transform: translateX(0);
  transition:
    transform .45s cubic-bezier(.2,.8,.2,1),
    color .35s ease,
    box-shadow .35s ease,
    background .35s ease;
  z-index: 1;
}

#themeToggle.theme-3d .theme-icon svg {
  display: block;
  width: 19px;
  height: 19px;
  filter:
    drop-shadow(0 0 3px rgba(44,198,254,.85));
}

#themeToggle.theme-3d .theme-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

#themeToggle.theme-3d[aria-pressed="true"] {
  background:
    linear-gradient(145deg, #141923, #05070d 70%);
}

#themeToggle.theme-3d[aria-pressed="true"] .theme-icon {
  transform: translateX(35px);
  color: #ffda79;
  background:
    radial-gradient(
      circle at 35% 25%,
      #56515a,
      #26212b 55%,
      #0d0c12
    );
  box-shadow:
    inset 1px 2px 3px rgba(255,255,255,.2),
    inset -2px -3px 5px rgba(0,0,0,.8),
    0 2px 6px rgba(0,0,0,.65),
    0 0 10px rgba(255,190,80,.35);
}

#themeToggle.theme-3d[aria-pressed="true"]
.theme-icon svg {
  filter:
    drop-shadow(0 0 3px rgba(255,190,80,.75));
}

#themeToggle.theme-3d:focus-visible {
  outline: 3px solid #2cc6fe;
  outline-offset: 3px;
}

#themeToggle.theme-3d:active .theme-icon {
  scale: .94;
}

@media (prefers-reduced-motion: reduce) {
  #themeToggle.theme-3d,
  #themeToggle.theme-3d .theme-icon {
    transition: none;
  }
}
