/* ===========================
   SIWA · Dashboard Custom Styles
   =========================== */

/* --- Logo Brand --- */
.navbar-brand-image { 
  height: 32px;
  width: auto;
  max-width: 110px;
  object-fit: contain;
}

/* --- Header responsive --- */
.siwa-navbar-container {
  padding-left: max(1rem, env(safe-area-inset-left));
  padding-right: max(1rem, env(safe-area-inset-right));
}

.siwa-navbar .navbar-brand,
.siwa-navbar-actions {
  flex: 0 0 auto;
}

.siwa-navbar .navbar-collapse {
  min-width: 0;
}

@media (min-width: 1200px) {
  .siwa-navbar .navbar-nav > .nav-item > .nav-link {
    padding-left: 0.65rem;
    padding-right: 0.65rem;
  }
}

@media (max-width: 1199.98px) {
  .siwa-navbar .navbar-collapse {
    flex-basis: 100%;
    order: 3;
  }

  .siwa-navbar .navbar-collapse .navbar-nav {
    padding-top: 0.5rem;
    padding-bottom: 0.75rem;
  }
}

@media (max-width: 420px) {
  .siwa-navbar-container {
    padding-left: max(0.75rem, env(safe-area-inset-left));
    padding-right: max(0.75rem, env(safe-area-inset-right));
  }
}

@media (max-width: 420px) {
  .navbar-brand-image {
    height: 28px;
    max-width: 90px;
  }
}

/* --- Avatar --- */
.avatar {
  background-color: var(--tblr-primary);
  color: #fff;
  font-weight: 600;
  text-transform: uppercase;
}

/* --- Dropdown icons --- */
.dropdown-item-icon {
  width: 1.25rem;
  height: 1.25rem;
  margin-right: 0.5rem;
  opacity: 0.7;
}

.dropdown-item:hover .dropdown-item-icon {
  opacity: 1;
}

/* --- Active nav item (horizontal) --- */
.navbar-nav .nav-item.active > .nav-link {
  color: var(--tblr-primary);
  font-weight: 600;
}

.navbar-nav .nav-item.active > .nav-link .nav-link-icon {
  color: var(--tblr-primary);
}

/* --- Dropdown menu active --- */
.dropdown-menu .dropdown-item.active {
  background-color: var(--tblr-primary);
  color: #fff;
}

/* --- Card enhancements --- */
.card {
  border-radius: var(--tblr-border-radius-lg);
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

[data-bs-theme="dark"] .card {
  background-color: rgba(255, 255, 255, 0.02);
}

/* --- Chart containers --- */
#chart-facturacion,
#chart-servicios,
#chart-ingresos {
  min-height: 240px;
}

/* --- Table improvements --- */
.table-vcenter td,
.table-vcenter th {
  vertical-align: middle;
}

.table > :not(caption) > * > * {
  padding: 0.75rem 0.75rem;
}

/* --- Loading states --- */
.loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(var(--tblr-body-bg-rgb), 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

/* --- Badge enhancements --- */
.badge {
  font-weight: 600;
  padding: 0.35rem 0.65rem;
  color: #fff !important; /* Texto blanco en todos los badges */
}

/* Asegurar que badges con colores específicos tengan texto blanco */
.badge.bg-success,
.badge.bg-danger,
.badge.bg-warning,
.badge.bg-info,
.badge.bg-primary,
.badge.bg-secondary,
.badge.bg-dark,
.badge.bg-purple,
.badge.bg-cyan,
.badge.bg-orange,
.badge.bg-blue {
  color: #fff !important;
}

/* Badges light pueden mantener texto oscuro */
.badge.bg-success-lt,
.badge.bg-danger-lt,
.badge.bg-warning-lt,
.badge.bg-info-lt,
.badge.bg-primary-lt,
.badge.bg-secondary-lt,
.badge.bg-purple-lt,
.badge.bg-cyan-lt,
.badge.bg-orange-lt,
.badge.bg-blue-lt {
  color: inherit;
}

/* --- Iconos - Tamaño y visibilidad --- */

/* Nota: Los iconos outline se cargan desde CDN tabler-icons-outline.min.css */

/* FORZAR uso de fuente outline en TODOS los iconos tabler */
.ti,
i.ti,
span.ti,
[class^="ti-"],
[class*=" ti-"],
.ti::before,
i.ti::before,
[class^="ti-"]::before,
[class*=" ti-"]::before {
  font-family: 'tabler-icons-outline' !important;
  font-weight: 400 !important;
  font-style: normal !important;
}

/* Tamaño base de iconos */
.icon {
  width: 1rem;
  height: 1rem;
  font-size: 1rem;
  vertical-align: -0.125em;
  stroke-width: 2;
  line-height: 1;
}

/* Iconos en el header navbar - TAMAÑO REDUCIDO Y ALINEACIÓN MEJORADA */
.navbar .nav-link .icon {
  width: 1.25rem;
  height: 1.25rem;
  font-size: 1.25rem;
  vertical-align: -0.2em;
}

/* Iconos en nav-link horizontal menu */
.nav-link-icon {
  width: 1rem;
  height: 1rem;
  font-size: 1rem;
  margin-right: 0.5rem;
  opacity: 0.8;
  vertical-align: -0.125em;
  display: inline-block;
}

.nav-link-icon i {
  display: block;
  line-height: 1;
}

.nav-link:hover .nav-link-icon,
.nav-link.active .nav-link-icon {
  opacity: 1;
}

/* Iconos en dropdown items */
.dropdown-item .dropdown-item-icon {
  width: 1rem;
  height: 1rem;
  font-size: 1rem;
  vertical-align: -0.125em;
}

.dropdown-item .dropdown-item-icon i {
  display: block;
  line-height: 1;
}

/* Iconos en badges */
.badge .icon,
.badge i {
  width: 0.875rem;
  height: 0.875rem;
  font-size: 0.875rem;
  margin-right: 0.25rem;
  vertical-align: -0.1em;
}

/* Iconos en botones */
.btn .icon,
.btn i {
  width: 1rem;
  height: 1rem;
  font-size: 1rem;
  vertical-align: -0.125em;
}

/* Iconos en alertas */
.alert-icon {
  width: 1.25rem;
  height: 1.25rem;
  font-size: 1.25rem;
  margin-right: 0.75rem;
  vertical-align: -0.125em;
}

/* Iconos en tabla - tamaño adecuado */
.table .icon,
.table i {
  font-size: 1rem;
  opacity: 0.7;
  vertical-align: -0.125em;
}

.table .icon:hover,
.table i:hover {
  opacity: 1;
}

/* --- Botones de Acción en Tablas --- */
/* Hacer botones más grandes y con más espacio para tablets/móviles */
.table .btn-sm,
.table .btn-icon {
  min-width: 2.25rem;
  min-height: 2.25rem;
  padding: 0.375rem 0.5rem;
}

.table .btn-group .btn {
  margin-right: 0.25rem;
}

.table .btn-group .btn:last-child {
  margin-right: 0;
}

/* Aumentar espacio entre botones en grupo */
.btn-group > .btn:not(:last-child) {
  margin-right: 0.375rem;
}

/* Mejorar botones en tarjetas y acciones */
.card-actions .btn,
.table-actions .btn {
  min-width: 2.5rem;
  min-height: 2.5rem;
}

/* En tablets, hacer botones aún más grandes */
@media (max-width: 991px) {
  .table .btn-sm,
  .table .btn-icon {
    min-width: 2.5rem;
    min-height: 2.5rem;
    padding: 0.5rem 0.625rem;
  }

  .btn-group > .btn:not(:last-child) {
    margin-right: 0.5rem;
  }

  .card-actions .btn,
  .table-actions .btn {
    min-width: 2.75rem;
    min-height: 2.75rem;
    font-size: 1rem;
  }
}

/* En móviles, hacer botones más accesibles */
@media (max-width: 767px) {
  .table .btn-sm,
  .table .btn-icon {
    min-width: 2.75rem;
    min-height: 2.75rem;
    padding: 0.625rem 0.75rem;
  }

  .btn-group > .btn:not(:last-child) {
    margin-right: 0.625rem;
  }

  .card-actions .btn,
  .table-actions .btn {
    min-width: 3rem;
    min-height: 3rem;
    font-size: 1.125rem;
  }
}

/* --- Footer --- */
.footer {
  padding: 1.5rem 0;
  margin-top: 3rem;
  border-top: 1px solid var(--tblr-border-color);
}

/* --- Responsive --- */
@media (max-width: 767px) {
  .page-header {
    padding: 1rem 0;
  }

  .page-header .page-title {
    font-size: 1.5rem;
  }

  .card {
    margin-bottom: 1rem;
  }
}

/* --- Print --- */
@media print {
  .navbar,
  .footer,
  .page-header .btn,
  .card-actions {
    display: none !important;
  }
}

/* --- Modo Claro --- */
[data-bs-theme="light"] {
  color-scheme: light;
}

[data-bs-theme="light"] .card {
  background-color: #fff;
  border: 1px solid var(--tblr-border-color);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

[data-bs-theme="light"] .navbar {
  background-color: #fff;
  border-bottom: 1px solid var(--tblr-border-color);
}

[data-bs-theme="light"] .page {
  background-color: #f5f7fb;
}

[data-bs-theme="light"] .page-body {
  background-color: #f5f7fb;
}

[data-bs-theme="light"] .table {
  --tblr-table-striped-bg: rgba(0, 0, 0, 0.02);
}

[data-bs-theme="light"] .dropdown-menu {
  background-color: #fff;
  border: 1px solid var(--tblr-border-color);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

[data-bs-theme="light"] .avatar {
  background-color: var(--tblr-primary);
  color: #fff;
}

/* Badge texto en modo claro: los colores claros (*-lt) usan color del tema */
[data-bs-theme="light"] .badge.bg-success-lt,
[data-bs-theme="light"] .badge.bg-danger-lt,
[data-bs-theme="light"] .badge.bg-warning-lt,
[data-bs-theme="light"] .badge.bg-info-lt,
[data-bs-theme="light"] .badge.bg-primary-lt,
[data-bs-theme="light"] .badge.bg-secondary-lt,
[data-bs-theme="light"] .badge.bg-purple-lt,
[data-bs-theme="light"] .badge.bg-cyan-lt,
[data-bs-theme="light"] .badge.bg-orange-lt,
[data-bs-theme="light"] .badge.bg-blue-lt {
  color: inherit !important;
}

/* Sidebar / nav lateral en modo claro */
[data-bs-theme="light"] .navbar-nav .nav-item.active > .nav-link {
  color: var(--tblr-primary);
}

/* Footer en modo claro */
[data-bs-theme="light"] .footer {
  background-color: #fff;
  border-top: 1px solid var(--tblr-border-color);
}

/* ── Consentimientos: vista previa del modelo en el dashboard ── */
.consent-preview-doc { font-size: .95rem; line-height: 1.65; }
.consent-preview-doc h2 { font-size: 1.25rem; margin: 1.2rem 0 .5rem; }
.consent-preview-doc h3 { font-size: 1.1rem; margin: 1rem 0 .4rem; }
.consent-preview-doc h4 { font-size: 1rem; margin: .9rem 0 .35rem; }
.consent-preview-doc h2:first-child,
.consent-preview-doc h3:first-child,
.consent-preview-doc p:first-child { margin-top: 0; }
.consent-preview-doc table { width: 100%; border-collapse: collapse; margin: .5rem 0 1rem; }
.consent-preview-doc th, .consent-preview-doc td { border: 1px solid var(--tblr-border-color); padding: .4rem .6rem; }
.modelo-aceptacion-row .form-label { font-size: .75rem; margin-bottom: .2rem; }
.modelo-campo-row .form-label { font-size: .75rem; margin-bottom: .2rem; }
