/* Overrides de tema.
   Centraliza adaptacoes automaticas e explicitas para `theme-escuro` sem duplicar regras nos componentes base. */

@media (prefers-color-scheme: dark) {
  body:not(.theme-claro):not(.theme-escuro) {
    --brand: #3ea77f;
    --brand-strong: #2d8e69;
    --brand-soft: #123329;
    --accent: #d3b246;
    --accent-soft: #3b3214;
    --danger: #ef6f72;
    --danger-soft: #3c1719;
    --warning: #f0b35d;
    --warning-soft: #3f2a11;
    --info: #74b5dd;
    --info-soft: #162f3f;
    --violet: #a089d3;
    --violet-soft: #2b233d;
    --surface: #0f1418;
    --surface-raised: #171f25;
    --surface-muted: #1d2730;
    --surface-line: #2a3742;
    --text: #e6edf3;
    --text-soft: #c3d0db;
    --muted: #94a8b8;
    --border: #31404d;
    --border-strong: #435466;
    --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.35);
    --shadow-md: 0 18px 48px rgba(0, 0, 0, 0.45);
  }

  body:not(.theme-claro):not(.theme-escuro) {
    background-color: var(--surface);
  }

  body:not(.theme-claro):not(.theme-escuro) {
    background-image: none;
  }

  body:not(.theme-claro):not(.theme-escuro) .app-logout {
    color: #b8c8d6;
    opacity: 0.92;
  }

  body:not(.theme-claro):not(.theme-escuro) .login-card,
  body:not(.theme-claro):not(.theme-escuro) .auth-card,
  body:not(.theme-claro):not(.theme-escuro) .card {
    background: var(--surface-raised);
  }

  body:not(.theme-claro):not(.theme-escuro) .field__control,
  body:not(.theme-claro):not(.theme-escuro) .file-input {
    background: #10171d;
    color: var(--text);
  }

  body:not(.theme-claro):not(.theme-escuro) .field__control::placeholder {
    color: #7990a3;
  }

  body:not(.theme-claro):not(.theme-escuro) .data-table tr:hover td {
    background: #1a232b;
  }
}

body.theme-escuro {
  --brand: #3ea77f;
  --brand-strong: #2d8e69;
  --brand-soft: #123329;
  --accent: #d3b246;
  --accent-soft: #3b3214;
  --danger: #ef6f72;
  --danger-soft: #3c1719;
  --warning: #f0b35d;
  --warning-soft: #3f2a11;
  --info: #74b5dd;
  --info-soft: #162f3f;
  --violet: #a089d3;
  --violet-soft: #2b233d;
  --surface: #0f1418;
  --surface-raised: #171f25;
  --surface-muted: #1d2730;
  --surface-line: #2a3742;
  --surface-zebra: #1b252e;
  --text: #e6edf3;
  --text-soft: #c3d0db;
  --muted: #94a8b8;
  --border: #31404d;
  --border-strong: #435466;
  --shadow-sm: 0 1px 4px rgba(0, 0, 0, 0.28);
  --shadow-md: 0 12px 30px rgba(0, 0, 0, 0.38);
  background-color: var(--surface);
  background-image: none;
}

body.theme-escuro .app-logout {
  color: #b8c8d6;
  opacity: 0.92;
}

body.theme-escuro .login-card,
body.theme-escuro .auth-card,
body.theme-escuro .card {
  background: var(--surface-raised);
}

body.theme-escuro .auth-card__header {
  background: var(--surface-raised);
  border-bottom-color: var(--border);
  color: var(--text);
}

body.theme-escuro .auth-card__kicker,
body.theme-escuro .auth-card__subtitle {
  color: var(--muted);
}

body.theme-escuro .login-tabs {
  background: var(--surface-muted);
  border-color: var(--border);
}

body.theme-escuro .login-tab.is-active {
  background: var(--brand);
  border-color: var(--brand);
  color: #07110d;
}

body.theme-escuro .field__control,
body.theme-escuro .file-input {
  background: #10171d;
  color: var(--text);
}

body.theme-escuro .field__control::placeholder {
  color: #7990a3;
}

body.theme-escuro .field__label {
  color: #d8e4ef;
}

body.theme-escuro .tecnico-toolbar,
body.theme-escuro .tecnico-toolbar--single-line,
body.theme-escuro .tecnico-toolbar--entidades,
body.theme-escuro .action-toolbar {
  background: #1a2530;
  border-color: #334556;
}

body.theme-escuro .tecnico-toolbar .field__label,
body.theme-escuro .action-toolbar .field__label {
  color: #c7d7e4;
}

body.theme-escuro .data-table > tbody > tr:nth-child(even) > td {
  background: var(--surface-zebra) !important;
}

body.theme-escuro .data-table > tbody > tr:hover > td {
  background: #1a232b !important;
}

body.theme-escuro .data-table th {
  background: #1d2730;
  border-bottom: 1px solid #334556;
  color: #c3d0db;
}

body.theme-escuro .btn--primary {
  background: #2f9c73;
  border-color: #2f9c73;
  color: #07110d;
}

body.theme-escuro .btn--primary:hover {
  background: #3ea77f;
  border-color: #3ea77f;
  color: #06100c;
}

body.theme-escuro .btn--secondary {
  background: #1d2730;
  border-color: #435466;
  color: #d4e0ea;
}

body.theme-escuro .btn--secondary:hover {
  background: #24313c;
  border-color: #567086;
  color: #e6edf3;
}

body.theme-escuro .btn--danger {
  background: #b84e56;
  border-color: #b84e56;
  color: #fff;
}

body.theme-escuro .btn--danger:hover {
  background: #c85f67;
  border-color: #c85f67;
}

body.theme-escuro .app-icon-btn {
  background: #1d2730;
  border-color: #425361;
  color: #d3deea;
}

body.theme-escuro .app-icon-btn:hover {
  background: #25333f;
  border-color: #567086;
  color: #f0f5fa;
}

body.theme-escuro .app-notify__item {
  background: #19232c;
  border-color: #344452;
}

body.theme-escuro .app-notify__item.is-unread {
  background: #1b2d3a;
  border-color: #4f7692;
}

body.theme-escuro .app-notify__item--entidade {
  background: #172b24;
  border-color: #396f52;
}

body.theme-escuro .app-notify__item--entidade.is-unread {
  background: #1c3a2d;
  border-color: #58a879;
}

body.theme-escuro .app-notify__item--produtor {
  background: #302716;
  border-color: #806334;
}

body.theme-escuro .app-notify__item--produtor.is-unread {
  background: #423116;
  border-color: #c89542;
}

body.theme-escuro .entity-pill {
  background: #1a2631;
  border-color: #385063;
  color: #cfe0ee;
}

body.theme-escuro .entity-pill.is-active {
  background: #0b4a37;
  border-color: #58c99c;
  color: #ffffff;
}

body.theme-escuro .entity-pill.is-active:hover {
  background: #083b2c;
  border-color: #70d8ae;
}

body.theme-escuro .panel--accent {
  border-top-color: #48bf91;
}

body.theme-escuro .status-aprovado,
body.theme-escuro .status-validado,
body.theme-escuro .status-badge--success {
  background: #17392f;
  color: #91f0c8;
}

body.theme-escuro .status-anexado,
body.theme-escuro .status-badge--info {
  background: #173149;
  color: #9ed0ff;
}

body.theme-escuro .status-pendente,
body.theme-escuro .status-rascunho,
body.theme-escuro .status-ajuste-solicitado,
body.theme-escuro .status-badge--warning {
  background: #4a3110;
  color: #ffd08c;
}

body.theme-escuro .status-badge--danger,
body.theme-escuro .status-inativo,
body.theme-escuro .status-rejeitada {
  background: #492126;
  color: #ffb7bf;
}

body.theme-escuro .status-badge--neutral,
body.theme-escuro .status-indefinido,
body.theme-escuro .status-encerrado {
  background: #27323c;
  color: #cfdae4;
}

body.theme-escuro .stats-tabs-panel,
body.theme-escuro .stats-tab-pane .panel,
body.theme-escuro .panel--sticky-toolbar {
  background: #16212b;
  border-color: #2c3a47;
}

body.theme-escuro .tabs {
  background: #1b2833;
  border-color: #31404d;
}

body.theme-escuro .tabs__item {
  background: #243340;
  border: 1px solid #31404d;
  color: #b7c6d4;
}

body.theme-escuro .tabs__item.is-active {
  background: #0f1b25;
  border-color: #3ea77f;
  color: #7ed8ae;
  box-shadow: none;
}

body.theme-escuro .geo-map {
  background: #0f1b25;
  border-color: #344555;
}

body.theme-escuro .modal__dialog {
  background: var(--surface-raised);
}

body.theme-escuro .toast {
  background: var(--surface-raised);
}

body.theme-escuro .status-form-icon--edit {
  background: var(--surface-raised);
}

body.theme-escuro .doc-entity-accordion .accordion__item.is-editing .doc-upload-form--inline {
  background: #0f2a1f;
}

body.theme-escuro .doc-upload-row td {
  background: var(--surface-raised);
}

body.theme-escuro .resource-card__text a {
  color: #6db8f2;
}

body.theme-escuro .check-row input,
body.theme-escuro .inline-check input {
  background: #10171d;
  border-color: var(--border-strong);
}

body.theme-escuro input.field__control:-webkit-autofill,
body.theme-escuro input.field__control:-webkit-autofill:hover,
body.theme-escuro input.field__control:-webkit-autofill:focus,
body.theme-escuro textarea.field__control:-webkit-autofill,
body.theme-escuro select.field__control:-webkit-autofill {
  -webkit-text-fill-color: var(--text);
  box-shadow: 0 0 0 1000px #10171d inset;
}

body.theme-escuro .emoji-picker {
  background: var(--surface-raised);
  border-color: var(--border);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.5);
}

body.theme-escuro .emoji-picker__search {
  background: #10171d;
  border-color: var(--border);
  color: var(--text);
}

body.theme-escuro .emoji-picker__item {
  background: var(--surface-muted);
  border-color: var(--border);
}

body.theme-escuro .emoji-picker__item:hover,
body.theme-escuro .emoji-picker__item.is-active {
  background: #1c3a2e;
  border-color: var(--brand);
}

body.theme-escuro .rt-palette {
  background: var(--surface-raised);
  border-color: var(--border);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
}

body.theme-escuro .rt-emoji-grid {
  background: var(--surface-raised);
  border-color: var(--border);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
}

body.theme-escuro .rt-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

body.theme-escuro .rt-btn:active {
  background: rgba(255, 255, 255, 0.14);
}

@media (prefers-color-scheme: dark) {
  body:not(.theme-claro):not(.theme-escuro) .stats-tabs-panel,
  body:not(.theme-claro):not(.theme-escuro) .stats-tab-pane .panel,
  body:not(.theme-claro):not(.theme-escuro) .panel--sticky-toolbar {
    background: #16212b;
    border-color: #2c3a47;
  }

  body:not(.theme-claro):not(.theme-escuro) .tabs {
    background: #1b2833;
    border-color: #31404d;
  }

  body:not(.theme-claro):not(.theme-escuro) .tabs__item {
    background: #243340;
    border: 1px solid #31404d;
    color: #b7c6d4;
  }

  body:not(.theme-claro):not(.theme-escuro) .tabs__item.is-active {
    background: #0f1b25;
    border-color: #3ea77f;
    color: #7ed8ae;
    box-shadow: none;
  }

  body:not(.theme-claro):not(.theme-escuro) .geo-map {
    background: #0f1b25;
    border-color: #344555;
  }

  body:not(.theme-claro):not(.theme-escuro) .modal__dialog {
    background: var(--surface-raised);
  }

  body:not(.theme-claro):not(.theme-escuro) .toast {
    background: var(--surface-raised);
  }

  body:not(.theme-claro):not(.theme-escuro) .status-form-icon--edit {
    background: var(--surface-raised);
  }

  body:not(.theme-claro):not(.theme-escuro) .doc-entity-accordion .accordion__item.is-editing .doc-upload-form--inline {
    background: #0f2a1f;
  }

  body:not(.theme-claro):not(.theme-escuro) .doc-upload-row td {
    background: var(--surface-raised);
  }

  body:not(.theme-claro):not(.theme-escuro) .resource-card__text a {
    color: #6db8f2;
  }

  body:not(.theme-claro):not(.theme-escuro) .check-row input,
  body:not(.theme-claro):not(.theme-escuro) .inline-check input {
    background: #10171d;
    border-color: var(--border-strong);
  }

  body:not(.theme-claro):not(.theme-escuro) input.field__control:-webkit-autofill,
  body:not(.theme-claro):not(.theme-escuro) input.field__control:-webkit-autofill:hover,
  body:not(.theme-claro):not(.theme-escuro) input.field__control:-webkit-autofill:focus,
  body:not(.theme-claro):not(.theme-escuro) textarea.field__control:-webkit-autofill,
  body:not(.theme-claro):not(.theme-escuro) select.field__control:-webkit-autofill {
    -webkit-text-fill-color: var(--text);
    box-shadow: 0 0 0 1000px #10171d inset;
  }

  body:not(.theme-claro):not(.theme-escuro) .emoji-picker {
    background: var(--surface-raised);
    border-color: var(--border);
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.5);
  }

  body:not(.theme-claro):not(.theme-escuro) .emoji-picker__search {
    background: #10171d;
    border-color: var(--border);
    color: var(--text);
  }

  body:not(.theme-claro):not(.theme-escuro) .emoji-picker__item {
    background: var(--surface-muted);
    border-color: var(--border);
  }

  body:not(.theme-claro):not(.theme-escuro) .emoji-picker__item:hover,
  body:not(.theme-claro):not(.theme-escuro) .emoji-picker__item.is-active {
    background: #1c3a2e;
    border-color: var(--brand);
  }

  body:not(.theme-claro):not(.theme-escuro) .rt-palette {
    background: var(--surface-raised);
    border-color: var(--border);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
  }

  body:not(.theme-claro):not(.theme-escuro) .rt-emoji-grid {
    background: var(--surface-raised);
    border-color: var(--border);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
  }

  body:not(.theme-claro):not(.theme-escuro) .rt-btn:hover {
    background: rgba(255, 255, 255, 0.08);
  }

  body:not(.theme-claro):not(.theme-escuro) .rt-btn:active {
    background: rgba(255, 255, 255, 0.14);
  }
}

/* Dark mode overrides for accessibility & nav components */
body.theme-escuro .app-icon-btn,
body.theme-escuro .app-nav__toggle {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.8);
}

body.theme-escuro .app-a11y__option {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.7);
}

body.theme-escuro .app-a11y__option:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.2);
  color: #fff;
}

body.theme-escuro .app-a11y__option[aria-pressed="true"] {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

body.theme-escuro .app-tooltip {
  background: #f0f4f8;
  color: #1a1a1a;
}

body.theme-escuro .app-tooltip::before {
  border-bottom-color: #f0f4f8;
}

