:root, html, body {
  color-scheme: only light !important;
  supported-color-schemes: only light !important;
}

:root,
[data-bs-theme="light"],
[data-bs-theme="dark"] {
  --primary-color: #0d6efd;
  --primary-hover: #0b5ed7;
  --bg-main: #f4f6f9;
  --bg-card: #ffffff;
  --text-main: #212529;
  --text-muted: #6c757d;
  --border-color: #dee2e6;
  --border-subtle: rgba(0, 0, 0, 0.08);

  --bs-body-bg: #f4f6f9 !important;
  --bs-body-bg-rgb: 244, 246, 249 !important;
  --bs-body-color: #212529 !important;
  --bs-body-color-rgb: 33, 37, 41 !important;
  --bs-tertiary-bg: #f4f6f9 !important;
  --bs-secondary-bg: #e9ecef !important;
  --bs-card-bg: #ffffff !important;
  --bs-card-color: #212529 !important;
  --bs-border-color: #dee2e6 !important;
  --bs-emphasis-color: #000000 !important;
}

/* Fondo principal y estructura */
html,
body,
body.layout-fixed,
.app-wrapper,
.app-main,
.bg-body-tertiary,
.bg-body-secondary,
.bg-body {
  background-color: var(--bg-main) !important;
  color: var(--text-main) !important;
  font-family: 'Source Sans 3', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
}

/* Cabecera (Navbar) */
.app-header {
  background: #ffffff !important;
  color: var(--text-main) !important;
  border-bottom: 1px solid var(--border-color) !important;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.03) !important;
}

.app-header .nav-link {
  color: #495057 !important;
  transition: color 0.2s ease;
}

.app-header .nav-link:hover {
  color: var(--primary-color) !important;
}

/* Menú lateral (Sidebar) */
.app-sidebar {
  background: #ffffff !important;
  border-right: 1px solid var(--border-color) !important;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04) !important;
}

.sidebar-brand {
  background-color: #ffffff !important;
  border-bottom: 1px solid #f1f5f9 !important;
}

.sidebar-brand .brand-text {
  color: var(--text-main) !important;
  font-weight: 700 !important;
}

.sidebar-wrapper .nav-link {
  color: #334155 !important;
  transition: all 0.2s ease;
  border-radius: 8px;
  margin: 2px 8px;
}

.sidebar-wrapper .nav-link:hover {
  color: var(--primary-color) !important;
  background-color: #f1f5f9 !important;
}

.sidebar-wrapper .nav-item.menu-open > .nav-link,
.sidebar-wrapper .nav-link.active {
  background: #e2e8f0 !important;
  color: var(--primary-color) !important;
  font-weight: 700 !important;
}

/* Contenido Principal y Títulos */
.app-content-header h3,
.app-content-header h1,
.app-content-header h2 {
  color: var(--text-main) !important;
  font-weight: 700 !important;
  letter-spacing: -0.5px;
}

.breadcrumb-item a {
  color: var(--primary-color) !important;
  text-decoration: none;
}

.breadcrumb-item.active {
  color: var(--text-muted) !important;
}

/* Tarjetas (Cards) */
.card:not([class*="bg-"]) {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.04);
  border-radius: 12px;
}

.card:not([class*="bg-"]) > .card-header:not([class*="text-white"]):not([style*="background"]) {
  background-color: #ffffff;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-main);
}

.card-title,
.card-header h5,
.card-header h6 {
  font-weight: 700;
}

.card:not([class*="bg-"]) .card-title:not(.text-white) {
  color: var(--text-main);
}

.card-primary.card-outline {
  border-top: 3px solid var(--primary-color) !important;
}

/* Tablas */
.table {
  color: var(--text-main) !important;
  border-color: var(--border-color) !important;
  background-color: #ffffff !important;
}

.table-striped tbody tr:nth-of-type(odd) {
  background-color: rgba(0, 0, 0, 0.02) !important;
}

.table-hover tbody tr:hover {
  background-color: rgba(0, 0, 0, 0.04) !important;
}

.table-bordered th, 
.table-bordered td {
  border: 1px solid var(--border-color) !important;
}

/* Formularios e Inputs */
.form-control,
.form-select,
.modal .form-control,
.modal .form-select {
  background-color: #ffffff !important;
  border: 1px solid #ced4da !important;
  color: #212529 !important;
  border-radius: 8px !important;
}

.form-control:focus,
.form-select:focus,
.modal .form-control:focus,
.modal .form-select:focus {
  background-color: #ffffff !important;
  color: #212529 !important;
  border-color: var(--primary-color) !important;
  box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.15) !important;
}

.form-control[readonly] {
  background-color: #e9ecef !important;
  color: #495057 !important;
}

label,
.form-label,
.modal label,
.modal .form-label {
  color: #212529 !important;
  font-weight: 700 !important;
}

/* Modales */
.modal-content,
.modal-body,
.modal-footer {
  background-color: #ffffff !important;
  color: #212529 !important;
}

.modal-content {
  border: 1px solid var(--border-subtle) !important;
  border-radius: 16px !important;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.15) !important;
}

.modal-header:not([class*="bg-"]) {
  background-color: #ffffff !important;
  color: #212529 !important;
  border-bottom: 1px solid var(--border-color) !important;
}

.modal-footer {
  border-top: 1px solid var(--border-color) !important;
}

/* Botones */
.btn-primary {
  background-color: var(--primary-color) !important;
  border-color: var(--primary-color) !important;
  color: #ffffff !important;
  border-radius: 8px !important;
  font-weight: 600;
}

.btn-primary:hover {
  background-color: var(--primary-hover) !important;
  border-color: var(--primary-hover) !important;
  box-shadow: 0 4px 12px rgba(13, 110, 253, 0.25) !important;
}

.btn-warning {
  border-radius: 8px !important;
}

.btn-secondary {
  border-radius: 8px !important;
}

/* Pie de Página (Footer) */
.app-footer {
  background: #ffffff !important;
  border-top: 1px solid var(--border-color) !important;
  color: var(--text-muted) !important;
}

/* Barra de Desplazamiento */
::-webkit-scrollbar-track {
  background: #f1f5f9;
}

::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Estilos de Contenedores de Tarjetas */
.card-body.bg-light,
.card .bg-light {
  background-color: #f8f9fa !important;
}

.card .bg-white {
  background-color: #ffffff !important;
}

.card .text-dark {
  color: #212529 !important;
}

/* ==========================================================================
   REGLAS ESTRICTAS EXCLUSIVAS PARA VERSIÓN MÓVIL (PANTALLAS <= 991.98px)
   ========================================================================== */
@media (max-width: 991.98px) {
  /* Fondo general claro de toda la pantalla y estructura */
  html, 
  body, 
  .app-wrapper, 
  .app-main, 
  .app-content, 
  .app-content-header,
  .container-fluid,
  .bg-body-tertiary, 
  .bg-body-secondary, 
  .bg-body {
    background-color: #f4f6f9 !important;
    background: #f4f6f9 !important;
    color: #212529 !important;
  }

  /* Encabezados y títulos en negro/oscuro */
  h1, h2, h3, h4, h5, h6,
  .app-content-header h3,
  .app-content-header h1,
  .card-title,
  .modal-title:not(.text-white) {
    color: #212529 !important;
  }

  /* Todas las tarjetas del dashboard y vistas con fondo blanco */
  .card:not([class*="bg-gradient-"]):not(.bg-primary):not(.bg-danger):not(.bg-warning):not(.bg-success):not(.bg-info) {
    background-color: #ffffff !important;
    background: #ffffff !important;
    color: #212529 !important;
    border: 1px solid rgba(0, 0, 0, 0.08) !important;
  }

  .card-body {
    color: #212529 !important;
  }

  /* Modales en blanco con texto negro */
  .modal-dialog,
  .modal-content,
  .modal-body,
  .modal-footer {
    background-color: #ffffff !important;
    background: #ffffff !important;
    color: #212529 !important;
  }

  /* Textos de etiquetas, párrafos, tablas y formularios */
  label,
  .form-label,
  .modal label,
  .modal .form-label,
  p:not(.text-white):not(.text-white-50),
  span:not(.badge):not(.text-white):not(.text-white-50) {
    color: #212529 !important;
  }

  /* Inputs y selects en blanco con borde claro y texto negro */
  .form-control,
  .form-select,
  .modal .form-control,
  .modal .form-select {
    background-color: #ffffff !important;
    background: #ffffff !important;
    color: #212529 !important;
    border: 1px solid #ced4da !important;
  }

  .form-control:focus,
  .form-select:focus,
  .modal .form-control:focus,
  .modal .form-select:focus {
    background-color: #ffffff !important;
    color: #212529 !important;
    border-color: #0d6efd !important;
  }

  .form-control::placeholder,
  .modal .form-control::placeholder {
    color: #6c757d !important;
  }

  /* Tablas con fondo blanco */
  .table,
  .table > :not(caption) > * > * {
    background-color: #ffffff !important;
    color: #212529 !important;
  }
}

