/**
 * Modo escuro — ativado com data-bs-theme="dark" no <html>
 * Paleta alinhada ao Bootstrap 5.3 dark
 */

[data-bs-theme="dark"] body {
  background-color: var(--bs-body-bg);
  color: var(--bs-body-color);
}

/* Cards e cabeçalhos de página */
[data-bs-theme="dark"] .card {
  background-color: var(--bs-secondary-bg);
  border-color: var(--bs-border-color-translucent);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
}
[data-bs-theme="dark"] .card:hover {
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
}
[data-bs-theme="dark"] .card-header {
  background-color: rgba(0, 0, 0, 0.28) !important;
  background-image: none !important;
  border-bottom-color: var(--bs-border-color);
  color: var(--bs-emphasis-color);
}
/* .bg-light no cabeçalho força branco — neutralizar no tema escuro */
[data-bs-theme="dark"] .card-header.bg-light,
[data-bs-theme="dark"] .card .card-header.bg-light {
  background-color: rgba(0, 0, 0, 0.32) !important;
  color: var(--bs-emphasis-color) !important;
}
[data-bs-theme="dark"] .card-header h5,
[data-bs-theme="dark"] .card-header h6,
[data-bs-theme="dark"] .card-header .mb-0 {
  color: var(--bs-emphasis-color) !important;
}
[data-bs-theme="dark"] .card-header .text-muted {
  color: rgba(255, 255, 255, 0.55) !important;
}

/* Linha TOTAL e outros tr.bg-light em tabelas */
[data-bs-theme="dark"] .table tr.bg-light,
[data-bs-theme="dark"] .table-dashboard tr.bg-light {
  --bs-table-bg: rgba(255, 255, 255, 0.05);
  background-color: rgba(255, 255, 255, 0.06) !important;
  color: var(--bs-emphasis-color);
}
[data-bs-theme="dark"] .table tr.bg-light td {
  color: var(--bs-body-color);
}

[data-bs-theme="dark"] .relatorio-tbody-total-row td {
  background-color: rgba(0, 0, 0, 0.32) !important;
  border-top: 1px solid rgba(255, 255, 255, 0.1) !important;
  color: var(--bs-emphasis-color);
}

[data-bs-theme="dark"] .card-footer.bg-light {
  background-color: rgba(0, 0, 0, 0.22) !important;
  border-top-color: var(--bs-border-color);
  color: rgba(255, 255, 255, 0.65);
}

/* Formulário anexar documentos (evita faixa branca no card) */
[data-bs-theme="dark"] .documentos-upload-area {
  background-color: rgba(0, 0, 0, 0.32) !important;
  border-color: var(--bs-border-color) !important;
}
[data-bs-theme="dark"] .documentos-upload-area .form-label {
  color: rgba(255, 255, 255, 0.88);
}
[data-bs-theme="dark"] .documentos-upload-area .form-text {
  color: rgba(255, 255, 255, 0.55) !important;
}
[data-bs-theme="dark"] #documentos-exames .card-body > .mt-3 .text-muted {
  color: rgba(255, 255, 255, 0.55) !important;
}
[data-bs-theme="dark"] #documentos-exames .table .badge.bg-light.text-dark {
  background: rgba(255, 255, 255, 0.12) !important;
  color: var(--bs-body-color) !important;
  border: 1px solid var(--bs-border-color);
}

/* Relatório pacientes: linha de totais no rodapé da tabela */
[data-bs-theme="dark"] .relatorio-tfoot-totais td {
  background-color: rgba(0, 0, 0, 0.38) !important;
  border-top-color: var(--bs-border-color) !important;
  color: var(--bs-body-color);
}
[data-bs-theme="dark"] .relatorio-tfoot-totais .text-muted {
  color: rgba(255, 255, 255, 0.55) !important;
}
[data-bs-theme="dark"] .relatorio-tfoot-totais .text-primary,
[data-bs-theme="dark"] .relatorio-tfoot-totais strong.text-primary {
  color: #9ec5fe !important;
}
[data-bs-theme="dark"] .relatorio-tfoot-totais strong:not(.text-primary) {
  color: var(--bs-emphasis-color);
}
[data-bs-theme="dark"] .page-header-modern {
  background: var(--bs-secondary-bg);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
}
[data-bs-theme="dark"] .page-header-modern h1,
[data-bs-theme="dark"] .page-header-modern h2 {
  color: var(--bs-emphasis-color);
}
[data-bs-theme="dark"] .page-modern > .card:first-of-type {
  border-left-color: #5b9cf9;
}

/* Tabelas */
[data-bs-theme="dark"] .table {
  color: var(--bs-body-color);
  --bs-table-bg: transparent;
  --bs-table-striped-bg: rgba(255, 255, 255, 0.03);
  --bs-table-hover-bg: rgba(255, 255, 255, 0.06);
}
[data-bs-theme="dark"] .table thead,
[data-bs-theme="dark"] .table-dashboard thead {
  background-color: rgba(0, 0, 0, 0.25);
}
[data-bs-theme="dark"] .table thead th,
[data-bs-theme="dark"] .table-dashboard thead th {
  color: var(--bs-emphasis-color);
  border-bottom-color: var(--bs-border-color);
}
[data-bs-theme="dark"] .table tbody tr:hover,
[data-bs-theme="dark"] .table-dashboard tbody tr:hover,
[data-bs-theme="dark"] .table-hover tbody tr:hover {
  background-color: rgba(255, 255, 255, 0.06);
}

/* Formulários */
[data-bs-theme="dark"] .form-label {
  color: var(--bs-body-color);
}
[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select {
  background-color: var(--bs-body-bg);
  border-color: var(--bs-border-color);
  color: var(--bs-body-color);
}
[data-bs-theme="dark"] .form-control:focus,
[data-bs-theme="dark"] .form-select:focus {
  background-color: var(--bs-body-bg);
  border-color: #5b9cf9;
  color: var(--bs-body-color);
}
[data-bs-theme="dark"] .input-group-text {
  background-color: var(--bs-secondary-bg);
  border-color: var(--bs-border-color);
  color: var(--bs-body-color);
}

/* Títulos */
[data-bs-theme="dark"] .container h1,
[data-bs-theme="dark"] .container h2,
[data-bs-theme="dark"] .container-fluid h1,
[data-bs-theme="dark"] .container-fluid h2,
[data-bs-theme="dark"] .content-container h1,
[data-bs-theme="dark"] .content-container h2 {
  color: var(--bs-emphasis-color);
}

/* List group */
[data-bs-theme="dark"] .card .list-group-item {
  background-color: transparent;
  border-color: var(--bs-border-color);
  color: var(--bs-body-color);
}

/* Navbar */
[data-bs-theme="dark"] .navbar-modern {
  background: var(--bs-dark) !important;
  border-bottom-color: var(--bs-border-color);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
}
[data-bs-theme="dark"] .navbar-brand-modern {
  color: #7eb6ff !important;
}
[data-bs-theme="dark"] .navbar-brand-modern:hover {
  color: #a8ccff !important;
}
[data-bs-theme="dark"] .nav-link-modern {
  color: rgba(255, 255, 255, 0.75) !important;
}
[data-bs-theme="dark"] .nav-link-modern:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff !important;
}
[data-bs-theme="dark"] .nav-link-modern.active {
  background: rgba(91, 156, 249, 0.2);
  color: #7eb6ff !important;
}
[data-bs-theme="dark"] .nav-link-user {
  color: #fff !important;
}
[data-bs-theme="dark"] .navbar-toggler-modern {
  border-color: var(--bs-border-color);
}
[data-bs-theme="dark"] .navbar-toggler-icon {
  filter: invert(1) grayscale(100%);
}
[data-bs-theme="dark"] .dropdown-menu-modern {
  background-color: var(--bs-secondary-bg);
  border: 1px solid var(--bs-border-color);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}
[data-bs-theme="dark"] .dropdown-menu-modern .dropdown-item {
  color: var(--bs-body-color);
}
[data-bs-theme="dark"] .dropdown-menu-modern .dropdown-item:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--bs-body-color);
}
[data-bs-theme="dark"] .dropdown-menu-modern .dropdown-item.text-danger:hover {
  background: rgba(220, 53, 69, 0.15);
}
[data-bs-theme="dark"] .admin-bell-badge {
  border-color: var(--bs-dark) !important;
}

/* Botão tema na navbar */
[data-bs-theme="dark"] .theme-toggle-btn {
  color: rgba(255, 255, 255, 0.85) !important;
}
[data-bs-theme="dark"] .theme-toggle-btn:hover {
  color: #ffc107 !important;
  background: rgba(255, 255, 255, 0.06) !important;
}

/* Footer */
[data-bs-theme="dark"] footer,
[data-bs-theme="dark"] footer.bg-light {
  background-color: var(--bs-dark) !important;
  border-top-color: var(--bs-border-color) !important;
  color: rgba(255, 255, 255, 0.65);
}
[data-bs-theme="dark"] footer .footer-inner .d-flex a {
  color: rgba(255, 255, 255, 0.75);
}

/* Alerts claros (ex.: portal/login usa alert-light) */
[data-bs-theme="dark"] .alert.alert-light,
[data-bs-theme="dark"] .alert-light {
  background-color: rgba(255, 255, 255, 0.06) !important;
  border: 1px solid var(--bs-border-color) !important;
  color: rgba(255, 255, 255, 0.75) !important;
}
[data-bs-theme="dark"] .alert.alert-light .text-muted,
[data-bs-theme="dark"] .alert-light .text-muted {
  color: rgba(255, 255, 255, 0.6) !important;
}

/* Dashboard cards */
[data-bs-theme="dark"] .card-dashboard {
  background: var(--bs-secondary-bg);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
}
[data-bs-theme="dark"] .card-dashboard-link:hover .card-dashboard {
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
}
[data-bs-theme="dark"] .dashboard-title {
  color: rgba(255, 255, 255, 0.65);
}
[data-bs-theme="dark"] .dashboard-number {
  color: var(--bs-emphasis-color);
}
[data-bs-theme="dark"] .dashboard-donut-center {
  color: var(--bs-emphasis-color);
}

[data-bs-theme="dark"] .dashboard-icon-concluidos {
  color: #5ce1ff !important;
  text-shadow: 0 0 12px rgba(92, 225, 255, 0.35);
}
[data-bs-theme="dark"] .dashboard-card-sub-placeholder.text-warning {
  color: rgba(255, 193, 7, 0.2) !important;
}

/* Badges suaves — mantém legibilidade no escuro */
[data-bs-theme="dark"] .badge-status-modern.badge-warning,
[data-bs-theme="dark"] .badge-status-warning {
  background: rgba(255, 193, 7, 0.22);
  color: #ffd666;
  border-color: rgba(255, 193, 7, 0.35);
}
[data-bs-theme="dark"] .badge-status-modern.badge-primary,
[data-bs-theme="dark"] .badge-status-primary {
  background: rgba(13, 110, 253, 0.25);
  color: #9ec5fe;
  border-color: rgba(13, 110, 253, 0.4);
}
[data-bs-theme="dark"] .badge-status-modern.badge-success,
[data-bs-theme="dark"] .badge-status-success {
  background: rgba(25, 135, 84, 0.25);
  color: #75d59a;
  border-color: rgba(25, 135, 84, 0.35);
}
[data-bs-theme="dark"] .badge-status-modern.badge-danger,
[data-bs-theme="dark"] .badge-status-danger {
  background: rgba(220, 53, 69, 0.22);
  color: #f1aeb5;
  border-color: rgba(220, 53, 69, 0.35);
}
[data-bs-theme="dark"] .badge-status-modern.badge-info {
  background: rgba(13, 202, 240, 0.18);
  color: #9eeaf9;
  border-color: rgba(13, 202, 240, 0.35);
}
[data-bs-theme="dark"] .badge-status-modern.badge-secondary {
  background: rgba(108, 117, 125, 0.3);
  color: #ced4da;
  border-color: rgba(108, 117, 125, 0.4);
}

[data-bs-theme="dark"] .badge-metric-total {
  background: rgba(108, 117, 125, 0.35);
  color: #e9ecef;
  border-color: rgba(108, 117, 125, 0.5);
}
[data-bs-theme="dark"] .badge-metric-pendente {
  background: rgba(255, 193, 7, 0.2);
  color: #ffe083;
  border-color: rgba(255, 193, 7, 0.35);
}
[data-bs-theme="dark"] .badge-metric-aceito {
  background: rgba(25, 135, 84, 0.22);
  color: #86e4a8;
  border-color: rgba(25, 135, 84, 0.35);
}
[data-bs-theme="dark"] .badge-metric-cancelado {
  background: rgba(220, 53, 69, 0.2);
  color: #f5b0b8;
  border-color: rgba(220, 53, 69, 0.35);
}
[data-bs-theme="dark"] .badge-metric-muted {
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.45);
  border-color: var(--bs-border-color);
}

/* Ícone de tema no portal (sem aparência de botão) */
[data-bs-theme="dark"] .theme-toggle-icon {
  color: rgba(255, 255, 255, 0.75) !important;
}
[data-bs-theme="dark"] .theme-toggle-icon:hover {
  color: #ffc107 !important;
  opacity: 0.9;
}
[data-bs-theme="dark"] .theme-toggle-icon:focus,
[data-bs-theme="dark"] .theme-toggle-icon:focus-visible {
  outline: none;
  box-shadow: none;
}

/* Portal: bell icon legível no escuro */
[data-bs-theme="dark"] .portal-bell-link i.text-muted {
  color: rgba(255, 255, 255, 0.75) !important;
}

/* Portal notificações: bg-light em itens não lidos */
[data-bs-theme="dark"] .list-group-item.bg-light {
  background-color: rgba(255, 255, 255, 0.06) !important;
  color: var(--bs-body-color);
}

/* Detalhes / breadcrumb */
[data-bs-theme="dark"] .detail-row {
  border-bottom-color: var(--bs-border-color);
}
[data-bs-theme="dark"] .text-muted {
  color: rgba(255, 255, 255, 0.5) !important;
}

/* Card gráfico dashboard */
[data-bs-theme="dark"] .card-dashboard-chart {
  background: var(--bs-secondary-bg);
}

[data-bs-theme="dark"] .dashboard-card-footer {
  border-top-color: var(--bs-border-color) !important;
  background: transparent !important;
}

/* Pontos da legenda do donut — tons mais suaves no escuro */
[data-bs-theme="dark"] .status-dot-warning { background: #b89d4a; }
[data-bs-theme="dark"] .status-dot-primary { background: #6b87c4; }
[data-bs-theme="dark"] .status-dot-success { background: #4d9d78; }
[data-bs-theme="dark"] .status-dot-danger { background: #a86d78; }

/* Botões “olho” / outline na tabela do dashboard — menos saturados */
[data-bs-theme="dark"] .dashboard-page .btn-outline-primary {
  color: #8eb8ff;
  border-color: rgba(110, 168, 254, 0.45);
}
[data-bs-theme="dark"] .dashboard-page .btn-outline-primary:hover {
  background: rgba(110, 168, 254, 0.12);
  color: #cfe2ff;
  border-color: rgba(110, 168, 254, 0.6);
}

/* Breadcrumb (telas antigas) */
[data-bs-theme="dark"] .breadcrumb-item a {
  color: #7eb6ff;
}
[data-bs-theme="dark"] .breadcrumb-item.active {
  color: rgba(255, 255, 255, 0.55);
}

/* Login (auth) */
[data-bs-theme="dark"] body.auth-login-body {
  background-color: var(--bs-body-bg) !important;
}
[data-bs-theme="dark"] .login-card-theme {
  background: var(--bs-secondary-bg);
  border-color: var(--bs-border-color);
}
