/**
 * Tema escuro global — overlay SaaS (Linear / Vercel).
 * Depende de html[data-theme="dark"] e dos tokens em style.css.
 */

html[data-theme="dark"] {
  color-scheme: dark;
}

/* ——— Superfícies Bootstrap / app ——— */
html[data-theme="dark"] .card,
html[data-theme="dark"] .modal-content,
html[data-theme="dark"] .offcanvas,
html[data-theme="dark"] .dropdown-menu,
html[data-theme="dark"] .list-group-item,
html[data-theme="dark"] .accordion-item,
html[data-theme="dark"] .popover,
html[data-theme="dark"] .toast,
html[data-theme="dark"] .navbar,
html[data-theme="dark"] .page-item .page-link {
  background-color: var(--bg-card, #111827);
  color: var(--text-primary, #f1f5f9);
  border-color: var(--border-color, rgba(148, 163, 184, 0.18));
}

html[data-theme="dark"] .card-header,
html[data-theme="dark"] .card-footer,
html[data-theme="dark"] .modal-header,
html[data-theme="dark"] .modal-footer,
html[data-theme="dark"] .offcanvas-header,
html[data-theme="dark"] .accordion-header,
html[data-theme="dark"] .accordion-button {
  background-color: #0f172a;
  color: var(--text-primary, #f1f5f9);
  border-color: var(--border-color, rgba(148, 163, 184, 0.16));
}

html[data-theme="dark"] .accordion-button:not(.collapsed) {
  background-color: rgba(45, 212, 191, 0.1);
  color: #5eead4;
  box-shadow: none;
}

html[data-theme="dark"] .accordion-button::after {
  filter: invert(1) grayscale(1);
}

html[data-theme="dark"] .modal-body,
html[data-theme="dark"] .offcanvas-body {
  background-color: var(--bg-card, #111827);
  color: var(--text-primary, #f1f5f9);
}

html[data-theme="dark"] .table {
  --bs-table-bg: transparent;
  --bs-table-color: #e2e8f0;
  --bs-table-border-color: rgba(148, 163, 184, 0.12);
  --bs-table-striped-bg: rgba(148, 163, 184, 0.05);
  --bs-table-hover-bg: rgba(45, 212, 191, 0.06);
  --bs-table-hover-color: #f8fafc;
  color: #e2e8f0;
  border-color: rgba(148, 163, 184, 0.12);
}

html[data-theme="dark"] .table thead th,
html[data-theme="dark"] .table-light,
html[data-theme="dark"] .table-light > th,
html[data-theme="dark"] .table-light > td {
  background-color: #0f172a !important;
  color: #94a3b8 !important;
  border-color: rgba(148, 163, 184, 0.16) !important;
}

html[data-theme="dark"] .table td,
html[data-theme="dark"] .table th {
  border-color: rgba(148, 163, 184, 0.12);
}

html[data-theme="dark"] .bg-white,
html[data-theme="dark"] .bg-light,
html[data-theme="dark"] .bg-body,
html[data-theme="dark"] .bg-body-tertiary {
  background-color: var(--bg-card, #111827) !important;
  color: var(--text-primary, #f1f5f9) !important;
}

html[data-theme="dark"] .text-dark,
html[data-theme="dark"] .text-black,
html[data-theme="dark"] .text-body {
  color: #f1f5f9 !important;
}

html[data-theme="dark"] .text-muted,
html[data-theme="dark"] .text-secondary,
html[data-theme="dark"] .form-text {
  color: #94a3b8 !important;
}

html[data-theme="dark"] .border,
html[data-theme="dark"] .border-top,
html[data-theme="dark"] .border-bottom,
html[data-theme="dark"] .border-start,
html[data-theme="dark"] .border-end {
  border-color: rgba(148, 163, 184, 0.18) !important;
}

html[data-theme="dark"] hr {
  border-color: rgba(148, 163, 184, 0.16);
  opacity: 1;
}

html[data-theme="dark"] .form-control,
html[data-theme="dark"] .form-select,
html[data-theme="dark"] .form-control-modern,
html[data-theme="dark"] .input-group-text,
html[data-theme="dark"] textarea.form-control {
  background-color: #0b1220;
  border-color: rgba(148, 163, 184, 0.22);
  color: #f1f5f9;
}

html[data-theme="dark"] .form-control:focus,
html[data-theme="dark"] .form-select:focus,
html[data-theme="dark"] .form-control-modern:focus {
  background-color: #0f172a;
  border-color: var(--med27-accent-400);
  color: #f8fafc;
  box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.22);
}

html[data-theme="dark"] .form-control::placeholder,
html[data-theme="dark"] .form-control-modern::placeholder {
  color: #64748b;
}

html[data-theme="dark"] .form-control:disabled,
html[data-theme="dark"] .form-select:disabled {
  background-color: #1e293b;
  color: #94a3b8;
}

html[data-theme="dark"] .form-check-input {
  background-color: #0b1220;
  border-color: rgba(148, 163, 184, 0.35);
}

html[data-theme="dark"] .nav-tabs {
  border-color: rgba(148, 163, 184, 0.16);
}

html[data-theme="dark"] .nav-tabs .nav-link {
  color: #cbd5e1;
}

html[data-theme="dark"] .nav-tabs .nav-link.active {
  background-color: #111827;
  border-color: rgba(148, 163, 184, 0.18);
  color: #f8fafc;
}

html[data-theme="dark"] .nav-pills .nav-link {
  color: #cbd5e1;
}

html[data-theme="dark"] .nav-pills .nav-link.active {
  background-color: #0d9488;
}

html[data-theme="dark"] .breadcrumb {
  background: transparent;
}

html[data-theme="dark"] .breadcrumb-item a {
  color: #94a3b8;
}

html[data-theme="dark"] .breadcrumb-item.active {
  color: #e2e8f0;
}

html[data-theme="dark"] .pagination .page-link {
  background-color: #111827;
  border-color: rgba(148, 163, 184, 0.18);
  color: #e2e8f0;
}

html[data-theme="dark"] .pagination .page-item.active .page-link {
  background-color: var(--med27-primary);
  border-color: var(--med27-primary);
}

html[data-theme="dark"] .pagination .page-item.disabled .page-link {
  background-color: #0f172a;
  color: #64748b;
}

html[data-theme="dark"] .dropdown-item {
  color: #e2e8f0;
}

html[data-theme="dark"] .dropdown-item:hover,
html[data-theme="dark"] .dropdown-item:focus,
html[data-theme="dark"] .dropdown-item.active {
  background-color: rgba(45, 212, 191, 0.12);
  color: #f8fafc;
}

html[data-theme="dark"] .dropdown-divider {
  border-color: rgba(148, 163, 184, 0.16);
}

html[data-theme="dark"] .btn-close {
  filter: invert(1) grayscale(1);
  opacity: 0.7;
}

html[data-theme="dark"] .btn-light,
html[data-theme="dark"] .btn-outline-secondary,
html[data-theme="dark"] .btn-outline-dark {
  background-color: #0b1220;
  border-color: rgba(148, 163, 184, 0.22);
  color: #e2e8f0;
}

html[data-theme="dark"] .btn-light:hover,
html[data-theme="dark"] .btn-outline-secondary:hover,
html[data-theme="dark"] .btn-outline-dark:hover {
  background-color: #1e293b;
  color: #f8fafc;
  border-color: rgba(148, 163, 184, 0.35);
}

html[data-theme="dark"] .btn-outline-primary {
  color: #a5b4fc;
  border-color: rgba(129, 140, 248, 0.45);
}

html[data-theme="dark"] .alert {
  border-color: transparent;
}

html[data-theme="dark"] .alert-info {
  background: rgba(6, 182, 212, 0.14);
  color: #a5f3fc;
}

html[data-theme="dark"] .alert-success {
  background: rgba(16, 185, 129, 0.14);
  color: #6ee7b7;
}

html[data-theme="dark"] .alert-warning {
  background: rgba(245, 158, 11, 0.14);
  color: #fcd34d;
}

html[data-theme="dark"] .alert-danger {
  background: rgba(239, 68, 68, 0.14);
  color: #fca5a5;
}

html[data-theme="dark"] .alert-secondary,
html[data-theme="dark"] .alert-light {
  background: rgba(148, 163, 184, 0.12);
  color: #e2e8f0;
}

html[data-theme="dark"] .progress {
  background-color: #1e293b;
}

html[data-theme="dark"] .list-group-item-action:hover {
  background-color: rgba(148, 163, 184, 0.08);
}

html[data-theme="dark"] .shadow,
html[data-theme="dark"] .shadow-sm,
html[data-theme="dark"] .shadow-lg {
  box-shadow: 0 8px 24px -12px rgba(0, 0, 0, 0.55) !important;
}

/* Datepicker / libs comuns */
html[data-theme="dark"] .flatpickr-calendar {
  background: #111827;
  border-color: rgba(148, 163, 184, 0.18);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
}

html[data-theme="dark"] .flatpickr-day {
  color: #e2e8f0;
}

html[data-theme="dark"] .flatpickr-day:hover {
  background: #1e293b;
}

html[data-theme="dark"] .select2-container--bootstrap-5 .select2-dropdown,
html[data-theme="dark"] .select2-container--bootstrap-5 .select2-selection {
  background: #111827;
  border-color: rgba(148, 163, 184, 0.22);
  color: #e2e8f0;
}

/* Workspaces SaaS */
html[data-theme="dark"] .ag-ws,
html[data-theme="dark"] .pac-ws,
html[data-theme="dark"] .fin-ws,
html[data-theme="dark"] .con-ws,
html[data-theme="dark"] .rel-ws {
  color: #e2e8f0;
}

html[data-theme="dark"] .suporte-page .suporte-kpi,
html[data-theme="dark"] .suporte-page .suporte-detalhe-card {
  background: #111827;
  border-color: rgba(148, 163, 184, 0.16);
  color: #e2e8f0;
}

html[data-theme="dark"] .suporte-page .suporte-fila-row:hover {
  background-color: rgba(148, 163, 184, 0.08);
}

html[data-theme="dark"] .suporte-page .suporte-kpi .kpi-label {
  color: #94a3b8;
}

html[data-theme="dark"] .suporte-page .suporte-timeline {
  border-left-color: rgba(148, 163, 184, 0.18);
}

html[data-theme="dark"] .dashboard-welcome,
html[data-theme="dark"] .kpi-card {
  background: var(--bg-card, #111827);
  border-color: var(--border-color, rgba(148, 163, 184, 0.18));
}

html[data-theme="dark"] .content,
html[data-theme="dark"] .content-body {
  color: var(--text-primary, #e2e8f0);
}

html[data-theme="dark"] .sticky-col {
  background-color: var(--bg-card, #111827);
}
