/**
 * Dark Mode Fixes - Sistema Locadora v2
 * Correções específicas para modo escuro
 */

/* ========================================
   CORREÇÕES GLOBAIS
   ======================================== */

[data-theme="dark"] {
  color-scheme: dark;
}

/* Garantir que todo texto seja legível */
[data-theme="dark"] * {
  border-color: rgba(148,163,184,0.15);
}

/* Títulos e textos importantes */
[data-theme="dark"] h1,
[data-theme="dark"] h2,
[data-theme="dark"] h3,
[data-theme="dark"] h4,
[data-theme="dark"] h5,
[data-theme="dark"] h6,
[data-theme="dark"] .h1,
[data-theme="dark"] .h2,
[data-theme="dark"] .h3,
[data-theme="dark"] .h4,
[data-theme="dark"] .h5,
[data-theme="dark"] .h6 {
  color: #f1f5f9 !important;
}

/* Parágrafos e textos gerais */
[data-theme="dark"] p,
[data-theme="dark"] li,
[data-theme="dark"] td,
[data-theme="dark"] th,
[data-theme="dark"] label,
[data-theme="dark"] .form-label {
  color: #f1f5f9;
}

/* Texto mutado mais visível */
[data-theme="dark"] .text-muted,
[data-theme="dark"] .text-secondary {
  color: #94a3b8 !important;
}

/* ========================================
   BOOTSTRAP COMPONENTS
   ======================================== */

/* Cards */
[data-theme="dark"] .card {
  background: #111827;
  border-color: rgba(148,163,184,0.15);
  color: #f1f5f9;
}

[data-theme="dark"] .card-header {
  background: rgba(30,41,59,0.5);
  border-bottom-color: rgba(148,163,184,0.15);
  color: #f1f5f9;
}

[data-theme="dark"] .card-body,
[data-theme="dark"] .card-footer {
  color: #f1f5f9;
}

/* Tables */
[data-theme="dark"] .table {
  color: #f1f5f9;
  border-color: rgba(148,163,184,0.15);
}

[data-theme="dark"] .table thead {
  color: #f1f5f9;
}

[data-theme="dark"] .table th,
[data-theme="dark"] .table td {
  border-color: rgba(148,163,184,0.15);
  color: #f1f5f9;
}

[data-theme="dark"] .table-striped tbody tr:nth-of-type(odd) {
  background: rgba(255,255,255,0.02);
}

[data-theme="dark"] .table-bordered {
  border-color: rgba(148,163,184,0.15);
}

/* Forms */
[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select,
[data-theme="dark"] textarea.form-control {
  background: rgba(255,255,255,0.05);
  border-color: rgba(148,163,184,0.15);
  color: #f1f5f9;
}

[data-theme="dark"] .form-control::placeholder {
  color: #64748b;
  opacity: 1;
}

[data-theme="dark"] .form-control:focus,
[data-theme="dark"] .form-select:focus {
  background: rgba(255,255,255,0.08);
  border-color: #3b82f6;
  color: #f1f5f9;
  box-shadow: 0 0 0 0.25rem rgba(59,130,246,0.25);
}

[data-theme="dark"] .form-control:disabled,
[data-theme="dark"] .form-control[readonly],
[data-theme="dark"] .form-select:disabled {
  background: rgba(255,255,255,0.02);
  color: #64748b;
}

[data-theme="dark"] .form-check-input {
  background-color: rgba(255,255,255,0.05);
  border-color: rgba(148,163,184,0.3);
}

[data-theme="dark"] .form-check-input:checked {
  background-color: #3b82f6;
  border-color: #3b82f6;
}

[data-theme="dark"] .form-check-label {
  color: #f1f5f9;
}

/* Input Groups */
[data-theme="dark"] .input-group-text {
  background: rgba(255,255,255,0.05);
  border-color: rgba(148,163,184,0.15);
  color: #94a3b8;
}

/* Buttons */
[data-theme="dark"] .btn-secondary {
  background: rgba(255,255,255,0.1);
  border-color: rgba(148,163,184,0.2);
  color: #f1f5f9;
}

[data-theme="dark"] .btn-secondary:hover {
  background: rgba(255,255,255,0.15);
  border-color: rgba(148,163,184,0.3);
  color: #f1f5f9;
}

[data-theme="dark"] .btn-light {
  background: rgba(255,255,255,0.1);
  border-color: rgba(148,163,184,0.2);
  color: #f1f5f9;
}

[data-theme="dark"] .btn-light:hover {
  background: rgba(255,255,255,0.15);
  color: #f1f5f9;
}

[data-theme="dark"] .btn-outline-secondary {
  border-color: rgba(148,163,184,0.3);
  color: #94a3b8;
}

[data-theme="dark"] .btn-outline-secondary:hover {
  background: rgba(255,255,255,0.1);
  color: #f1f5f9;
}

/* Badges */
[data-theme="dark"] .badge {
  border: 1px solid rgba(255,255,255,0.1);
}

[data-theme="dark"] .badge.bg-light {
  background: rgba(255,255,255,0.15) !important;
  color: #f1f5f9 !important;
}

[data-theme="dark"] .badge.bg-secondary {
  background: rgba(100,116,139,0.4) !important;
  color: #f1f5f9 !important;
}

/* Alerts */
[data-theme="dark"] .alert {
  border-width: 1px;
}

[data-theme="dark"] .alert-primary {
  background: rgba(59,130,246,0.2);
  color: #93c5fd;
  border-color: rgba(59,130,246,0.4);
}

[data-theme="dark"] .alert-success {
  background: rgba(34,197,94,0.2);
  color: #86efac;
  border-color: rgba(34,197,94,0.4);
}

[data-theme="dark"] .alert-warning {
  background: rgba(245,158,11,0.2);
  color: #fcd34d;
  border-color: rgba(245,158,11,0.4);
}

[data-theme="dark"] .alert-danger {
  background: rgba(239,68,68,0.2);
  color: #fca5a5;
  border-color: rgba(239,68,68,0.4);
}

[data-theme="dark"] .alert-info {
  background: rgba(59,130,246,0.2);
  color: #93c5fd;
  border-color: rgba(59,130,246,0.4);
}

/* Modals */
[data-theme="dark"] .modal-content {
  background: #111827;
  border-color: rgba(148,163,184,0.15);
}

[data-theme="dark"] .modal-header,
[data-theme="dark"] .modal-footer {
  border-color: rgba(148,163,184,0.15);
}

[data-theme="dark"] .modal-title {
  color: #f1f5f9;
}

[data-theme="dark"] .modal-body {
  color: #f1f5f9;
}

[data-theme="dark"] .btn-close {
  filter: invert(1) grayscale(100%) brightness(200%);
}

/* Dropdowns */
[data-theme="dark"] .dropdown-menu {
  background: #111827;
  border-color: rgba(148,163,184,0.15);
}

[data-theme="dark"] .dropdown-item {
  color: #f1f5f9;
}

[data-theme="dark"] .dropdown-item:hover,
[data-theme="dark"] .dropdown-item:focus {
  background: rgba(59,130,246,0.15);
  color: #3b82f6;
}

[data-theme="dark"] .dropdown-divider {
  border-color: rgba(148,163,184,0.15);
}

[data-theme="dark"] .dropdown-header {
  color: #94a3b8;
}

/* Navs and Tabs */
[data-theme="dark"] .nav-tabs {
  border-bottom-color: rgba(148,163,184,0.15);
}

[data-theme="dark"] .nav-tabs .nav-link {
  color: #94a3b8;
}

[data-theme="dark"] .nav-tabs .nav-link:hover {
  color: #f1f5f9;
  border-color: rgba(148,163,184,0.15);
}

[data-theme="dark"] .nav-tabs .nav-link.active {
  background: #111827;
  color: #3b82f6;
  border-color: rgba(148,163,184,0.15) rgba(148,163,184,0.15) #111827;
}

[data-theme="dark"] .nav-pills .nav-link {
  color: #94a3b8;
}

[data-theme="dark"] .nav-pills .nav-link:hover {
  background: rgba(255,255,255,0.05);
  color: #f1f5f9;
}

[data-theme="dark"] .nav-pills .nav-link.active {
  background: #3b82f6;
  color: #ffffff;
}

/* Pagination */
[data-theme="dark"] .pagination .page-link {
  background: rgba(255,255,255,0.05);
  border-color: rgba(148,163,184,0.15);
  color: #f1f5f9;
}

[data-theme="dark"] .pagination .page-link:hover {
  background: rgba(59,130,246,0.15);
  border-color: #3b82f6;
  color: #3b82f6;
}

[data-theme="dark"] .pagination .page-item.active .page-link {
  background: #3b82f6;
  border-color: #3b82f6;
  color: #ffffff;
}

[data-theme="dark"] .pagination .page-item.disabled .page-link {
  background: rgba(255,255,255,0.02);
  border-color: rgba(148,163,184,0.1);
  color: #64748b;
}

/* List Groups */
[data-theme="dark"] .list-group-item {
  background: rgba(255,255,255,0.05);
  border-color: rgba(148,163,184,0.15);
  color: #f1f5f9;
}

[data-theme="dark"] .list-group-item:hover {
  background: rgba(59,130,246,0.1);
}

[data-theme="dark"] .list-group-item.active {
  background: #3b82f6;
  border-color: #3b82f6;
  color: #ffffff;
}

/* Breadcrumb */
[data-theme="dark"] .breadcrumb {
  background: transparent;
}

[data-theme="dark"] .breadcrumb-item,
[data-theme="dark"] .breadcrumb-item a {
  color: #94a3b8;
}

[data-theme="dark"] .breadcrumb-item.active {
  color: #f1f5f9;
}

/* Progress */
[data-theme="dark"] .progress {
  background: rgba(255,255,255,0.05);
}

/* Spinners */
[data-theme="dark"] .spinner-border,
[data-theme="dark"] .spinner-grow {
  color: #3b82f6;
}

/* Tooltips and Popovers */
[data-theme="dark"] .tooltip-inner {
  background: #1e293b;
  color: #f1f5f9;
}

[data-theme="dark"] .popover {
  background: #111827;
  border-color: rgba(148,163,184,0.15);
}

[data-theme="dark"] .popover-header {
  background: rgba(30,41,59,0.5);
  border-bottom-color: rgba(148,163,184,0.15);
  color: #f1f5f9;
}

[data-theme="dark"] .popover-body {
  color: #f1f5f9;
}

/* ========================================
   CORREÇÕES ESPECÍFICAS DO SISTEMA
   ======================================== */

/* Stats e KPI boxes */
[data-theme="dark"] .stat-card,
[data-theme="dark"] .kpi-box,
[data-theme="dark"] .info-box {
  background: rgba(255,255,255,0.05) !important;
  border-color: rgba(148,163,184,0.15) !important;
  color: #f1f5f9 !important;
}

/* Links */
[data-theme="dark"] a:not([class*="btn"]) {
  color: #3b82f6;
}

[data-theme="dark"] a:not([class*="btn"]):hover {
  color: #60a5fa;
}

/* Text utilities */
[data-theme="dark"] .text-dark {
  color: #f1f5f9 !important;
}

[data-theme="dark"] .text-body {
  color: #f1f5f9 !important;
}

[data-theme="dark"] .text-black-50 {
  color: #94a3b8 !important;
}

/* Background utilities override */
[data-theme="dark"] .bg-white {
  background-color: #111827 !important;
}

[data-theme="dark"] .bg-light {
  background-color: rgba(255,255,255,0.05) !important;
}

/* Border utilities */
[data-theme="dark"] .border-light {
  border-color: rgba(148,163,184,0.15) !important;
}

/* HR elements */
[data-theme="dark"] hr {
  border-color: rgba(148,163,184,0.15);
  opacity: 1;
}

/* Code blocks */
[data-theme="dark"] code {
  background: rgba(255,255,255,0.08);
  color: #93c5fd;
}

/* ========================================
   COMPLEMENTOS (BS 5.3 utilities + nativos)
   ======================================== */

/* Bootstrap 5.3 subtle backgrounds */
[data-theme="dark"] .bg-body,
[data-theme="dark"] .bg-body-tertiary,
[data-theme="dark"] .bg-body-secondary {
  background-color: #111827 !important;
  color: #f1f5f9 !important;
}
[data-theme="dark"] [class*="-subtle"] {
  color: #f1f5f9;
}
[data-theme="dark"] .bg-light-subtle,
[data-theme="dark"] .bg-secondary-subtle {
  background-color: rgba(255,255,255,0.04) !important;
}

/* Offcanvas */
[data-theme="dark"] .offcanvas {
  background: #111827;
  color: #f1f5f9;
  border-color: rgba(148,163,184,0.15);
}
[data-theme="dark"] .offcanvas-header,
[data-theme="dark"] .offcanvas-footer {
  border-color: rgba(148,163,184,0.15);
}

/* Toasts */
[data-theme="dark"] .toast {
  background: #111827;
  color: #f1f5f9;
  border-color: rgba(148,163,184,0.2);
}
[data-theme="dark"] .toast-header {
  background: rgba(30,41,59,0.6);
  color: #f1f5f9;
  border-bottom-color: rgba(148,163,184,0.15);
}

/* Accordion */
[data-theme="dark"] .accordion {
  --bs-accordion-bg: #111827;
  --bs-accordion-color: #f1f5f9;
  --bs-accordion-border-color: rgba(148,163,184,0.15);
  --bs-accordion-btn-bg: #111827;
  --bs-accordion-btn-color: #f1f5f9;
  --bs-accordion-active-bg: rgba(59,130,246,0.15);
  --bs-accordion-active-color: #f1f5f9;
}
[data-theme="dark"] .accordion-button::after {
  filter: invert(1) brightness(2);
}
[data-theme="dark"] .accordion-button:not(.collapsed) {
  color: #f1f5f9;
  background: rgba(59,130,246,0.15);
  box-shadow: none;
}

/* Pickers nativos (date/time) — força tema escuro do navegador */
[data-theme="dark"] input[type="date"],
[data-theme="dark"] input[type="time"],
[data-theme="dark"] input[type="datetime-local"],
[data-theme="dark"] input[type="month"],
[data-theme="dark"] input[type="week"],
[data-theme="dark"] input[type="color"] {
  color-scheme: dark;
}

/* Cards de tabela e tile com fundos hard-coded */
[data-theme="dark"] .card.bg-white,
[data-theme="dark"] .card.bg-light {
  background: #111827 !important;
}

/* table-light explícita */
[data-theme="dark"] .table-light,
[data-theme="dark"] .table-light > th,
[data-theme="dark"] .table-light > td,
[data-theme="dark"] .table > thead.table-light th {
  background-color: rgba(30,41,59,0.7) !important;
  color: #f1f5f9 !important;
  border-color: rgba(148,163,184,0.18) !important;
}

/* Texto escuro em badge colorido — manter branco */
[data-theme="dark"] .bg-primary,
[data-theme="dark"] .bg-success,
[data-theme="dark"] .bg-danger,
[data-theme="dark"] .bg-warning,
[data-theme="dark"] .bg-info,
[data-theme="dark"] .bg-dark,
[data-theme="dark"] .bg-secondary {
  color: #fff;
}
[data-theme="dark"] .bg-warning,
[data-theme="dark"] .bg-warning * {
  color: #1a1a1a;
}

/* Btn-close em headers escuros (já estava, reforça com seletor mais amplo) */
[data-theme="dark"] .btn-close-white,
[data-theme="dark"] .modal-header .btn-close,
[data-theme="dark"] .offcanvas-header .btn-close,
[data-theme="dark"] .toast-header .btn-close,
[data-theme="dark"] .alert .btn-close {
  filter: invert(1) grayscale(100%) brightness(200%);
}

/* Inputs com autofill (Chrome) */
[data-theme="dark"] input:-webkit-autofill,
[data-theme="dark"] input:-webkit-autofill:hover,
[data-theme="dark"] input:-webkit-autofill:focus,
[data-theme="dark"] textarea:-webkit-autofill,
[data-theme="dark"] select:-webkit-autofill {
  -webkit-text-fill-color: #f1f5f9 !important;
  -webkit-box-shadow: 0 0 0 1000px #1a2332 inset !important;
  caret-color: #f1f5f9;
}

/* Card-header com bg colorido (.bg-primary etc.) — manter texto branco */
[data-theme="dark"] .card-header[class*="bg-"]:not(.bg-transparent):not(.bg-body):not(.bg-light):not(.bg-white) {
  color: #fff;
}

/* Hr em qualquer contexto */
[data-theme="dark"] hr.border,
[data-theme="dark"] hr.border-light,
[data-theme="dark"] .border-bottom,
[data-theme="dark"] .border-top {
  border-color: rgba(148,163,184,0.18) !important;
}


[data-theme="dark"] pre {
  background: rgba(255,255,255,0.05);
  border-color: rgba(148,163,184,0.15);
  color: #f1f5f9;
}

/* Blockquotes */
[data-theme="dark"] blockquote {
  border-left-color: rgba(59,130,246,0.5);
  color: #94a3b8;
}

/* Small text */
[data-theme="dark"] small,
[data-theme="dark"] .small {
  color: #94a3b8;
}

/* Display text */
[data-theme="dark"] .display-1,
[data-theme="dark"] .display-2,
[data-theme="dark"] .display-3,
[data-theme="dark"] .display-4,
[data-theme="dark"] .display-5,
[data-theme="dark"] .display-6 {
  color: #f1f5f9;
}

/* Lead text */
[data-theme="dark"] .lead {
  color: #e2e8f0;
}

/* ========================================
   ACCORDION
   ======================================== */

[data-theme="dark"] .accordion-item {
  background: rgba(255,255,255,0.05);
  border-color: rgba(148,163,184,0.15);
}

[data-theme="dark"] .accordion-button {
  background: rgba(255,255,255,0.03);
  color: #f1f5f9;
}

[data-theme="dark"] .accordion-button:not(.collapsed) {
  background: rgba(59,130,246,0.15);
  color: #3b82f6;
}

[data-theme="dark"] .accordion-button:focus {
  box-shadow: 0 0 0 0.25rem rgba(59,130,246,0.25);
}

[data-theme="dark"] .accordion-body {
  background: #111827;
  color: #f1f5f9;
}

/* ========================================
   OFFCANVAS
   ======================================== */

[data-theme="dark"] .offcanvas {
  background: #111827;
  color: #f1f5f9;
}

[data-theme="dark"] .offcanvas-header {
  border-bottom-color: rgba(148,163,184,0.15);
}

[data-theme="dark"] .offcanvas-title {
  color: #f1f5f9;
}

/* ========================================
   SELECT2 (se usado)
   ======================================== */

[data-theme="dark"] .select2-container--default .select2-selection--single {
  background: rgba(255,255,255,0.05);
  border-color: rgba(148,163,184,0.15);
}

[data-theme="dark"] .select2-container--default .select2-selection--single .select2-selection__rendered {
  color: #f1f5f9;
}

[data-theme="dark"] .select2-dropdown {
  background: #111827;
  border-color: rgba(148,163,184,0.15);
}

[data-theme="dark"] .select2-results__option {
  color: #f1f5f9;
}

[data-theme="dark"] .select2-results__option--highlighted {
  background: rgba(59,130,246,0.15);
  color: #3b82f6;
}

/* ===========================================================
   Correções de DARK MODE (KPI cards + banners claros) — brand-neutral
   Adicionado 2026-07-03. Só cores SEMÂNTICAS universais (não mexe na marca).
   Regras !important vencem os estilos inline (não-important) das páginas.
   =========================================================== */

/* --- .pay-card.* : fundo pastel claro -> escuro tintado --- */
[data-theme="dark"] .pay-card{ background: var(--panel2) !important; border:1px solid var(--border) !important; color: var(--text) !important; }
[data-theme="dark"] .pay-card .pay-card-label{ color: var(--muted) !important; }
[data-theme="dark"] .pay-card .pay-card-value{ color: var(--text) !important; }
[data-theme="dark"] .pay-card .pay-card-sub{ color: var(--muted) !important; }
[data-theme="dark"] .pay-card .pay-card-bar{ background: rgba(255,255,255,.10) !important; }

[data-theme="dark"] .pay-card.pendente,
[data-theme="dark"] .pay-card.vhc-manutencao{ background: rgba(245,158,11,.12) !important; border-color: rgba(245,158,11,.30) !important; }
[data-theme="dark"] .pay-card.pendente .pay-card-value,
[data-theme="dark"] .pay-card.vhc-manutencao .pay-card-value{ color:#fcd34d !important; }

[data-theme="dark"] .pay-card.recebido,
[data-theme="dark"] .pay-card.vhc-disponivel{ background: rgba(34,197,94,.12) !important; border-color: rgba(34,197,94,.30) !important; }
[data-theme="dark"] .pay-card.recebido .pay-card-value,
[data-theme="dark"] .pay-card.vhc-disponivel .pay-card-value{ color:#4ade80 !important; }

[data-theme="dark"] .pay-card.vencido,
[data-theme="dark"] .pay-card.vhc-excluido{ background: rgba(239,68,68,.12) !important; border-color: rgba(239,68,68,.30) !important; }
[data-theme="dark"] .pay-card.vencido .pay-card-value,
[data-theme="dark"] .pay-card.vhc-excluido .pay-card-value{ color:#f87171 !important; }

[data-theme="dark"] .pay-card.cancelado{ background: rgba(100,116,139,.15) !important; border-color: rgba(100,116,139,.35) !important; }
[data-theme="dark"] .pay-card.cancelado .pay-card-value{ color:#cbd5e1 !important; }

/* "em tabela" = visão atual -> neutro (sem impor cor de marca) */
[data-theme="dark"] .pay-card.vhc-tabela{ background: rgba(148,163,184,.10) !important; border-color: rgba(148,163,184,.28) !important; }
[data-theme="dark"] .pay-card.vhc-tabela .pay-card-value{ color: var(--text) !important; }

/* --- Banners/boxes com fundo claro inline -> escuro legível --- */
[data-theme="dark"] [style*="#e8f4fd"],
[data-theme="dark"] [style*="#f0f9ff"]{ background: var(--panel) !important; }
[data-theme="dark"] [style*="#e8f8f0"]{ background: rgba(34,197,94,.12) !important; border-color: rgba(34,197,94,.30) !important; color:#4ade80 !important; }
[data-theme="dark"] [style*="#f8f9fa"]{ background: var(--panel2) !important; color: var(--text) !important; }
[data-theme="dark"] [style*="#fff8e1"]{ background: rgba(245,158,11,.12) !important; border-color: rgba(245,158,11,.30) !important; color:#fcd34d !important; }
[data-theme="dark"] [style*="#fff7ed"]{ background: rgba(245,158,11,.08) !important; }
[data-theme="dark"] tr[style*="#fff7ed"] td{ color: var(--text) !important; }

/* --- Card TOTAL GERAL (.pay-total-card) --- */
[data-theme="dark"] .pay-total-card{ background: var(--panel2) !important; border-color: var(--border) !important; }
[data-theme="dark"] .pay-total-card .pay-total-label{ color: var(--muted) !important; }
[data-theme="dark"] .pay-total-card .pay-total-value{ color: var(--text) !important; }
[data-theme="dark"] .pay-total-card .pay-total-sub{ color: var(--muted) !important; }

/* --- Cards KPI do Locações (.rt-kpi.*) --- */
[data-theme="dark"] .rt-kpi{ background: var(--panel2) !important; border-color: var(--border) !important; color: var(--text) !important; }
[data-theme="dark"] .rt-kpi .lab{ color: var(--muted) !important; }
[data-theme="dark"] .rt-kpi .num{ color: var(--text) !important; }
[data-theme="dark"] .rt-kpi .sub{ color: var(--muted) !important; }
[data-theme="dark"] .rt-kpi .breakdown a,
[data-theme="dark"] .rt-kpi .breakdown span{ color: var(--text) !important; }
[data-theme="dark"] .rt-kpi .breakdown a:hover{ background: rgba(255,255,255,.06) !important; }
[data-theme="dark"] .rt-kpi.k-tabela{ background: rgba(148,163,184,.10) !important; border-color: rgba(148,163,184,.28) !important; }
[data-theme="dark"] .rt-kpi.k-aluguel{ background: rgba(34,197,94,.10) !important; border-color: rgba(34,197,94,.28) !important; }
[data-theme="dark"] .rt-kpi.k-venda{ background: rgba(245,158,11,.10) !important; border-color: rgba(245,158,11,.28) !important; }
