/**
 * SPVSMA — Santa María shell theme (sidebar + contenido + utilidades opcionales).
 * Alcance: body.spvsma-sm-theme cuando hay sesión iniciada (.wrapper).
 * No aplicar estilos globales a table/DataTables; usar solo .sm-* para tablas demo.
 */

body.spvsma-sm-theme {
  /*
   * AdminLTE asume cabecera ~50px (.main-sidebar padding-top). El cabezote SM usa navbar más alta.
   * Una sola variable evita la franja clara entre header y lateral, y corrige scroll del menú/buscar.
   */
  /*
   * --sm-header-height = alto TOTAL cabecorte (sidebar padding-top).
   * --sm-nav-row-min fila cuando cabezote compacto (~ responsive).
   */
  --sm-header-height: 76px;
  --sm-navy: #14252d;
  --sm-navy-2: #1d333d;
  --sm-gold: #f5a623;
  --sm-blue: #2f80ed;
  --sm-green: #12b76a;
  --sm-red: #ef4444;
  --sm-bg: #eef2f6;
  --sm-card: #ffffff;
  --sm-text: #1f2937;
  --sm-muted: #6b7280;
  --sm-line: #e5e7eb;
  font-family: "Segoe UI", Arial, sans-serif;
  color: var(--sm-text);
  background: var(--sm-bg) !important;
}

@media (max-width: 991px) {
  /* Alto de fila: da margen para el ícono “mini” bien legible junto al hamburger */
  body.spvsma-sm-theme {
    --sm-nav-row-min: 56px;
    --sm-header-height: var(--sm-nav-row-min);
  }
}

body.spvsma-sm-theme .main-sidebar {
  padding-top: var(--sm-header-height) !important;
}

body.spvsma-sm-theme.fixed .content-wrapper,
body.spvsma-sm-theme.fixed .right-side {
  padding-top: var(--sm-header-height) !important;
}

/*
 * Sin layout .fixed, el área principal debe arrancar pegada al header (sin banda gris).
 * Anula padding-top de helpers (p. ej. pwa-standalone.css ≤1024px) y similares.
 */
body.spvsma-sm-theme:not(.fixed) .content-wrapper,
body.spvsma-sm-theme:not(.fixed) .right-side {
  padding-top: 0 !important;
}

/*
 * skin-black aplica #222d32 al .wrapper completo (misma capa que envuelve sidebar + contenido).
 * Si content-wrapper es transparente, se ve ese fondo oscuro — parece “cabezote negro” y área principal negra.
 */
body.spvsma-sm-theme.skin-black .wrapper {
  background-color: var(--sm-bg) !important;
}

/* Contenido principal */
body.spvsma-sm-theme .content-wrapper,
body.spvsma-sm-theme .right-side {
  background-color: var(--sm-bg) !important;
}

/*
 * Franja gris/título duplicado (AdminLTE .content-header: H1 + breadcrumbs).
 * El cabezote SM ya muestra el nombre del módulo junto a los iconos → no repetir abajo.
 */
body.spvsma-sm-theme .content-wrapper > .content-header {
  display: none !important;
}

body.spvsma-sm-theme .content-wrapper > .content {
  /*
   * AdminLTE .content trae padding: 15px → se ve como franja gris (fondo del content-wrapper).
   * Dejar el primer .box pegado arriba; el aire lo dan .box-header / .box-body.
   */
  padding-top: 0 !important;
}

/* Primer panel al ras del bloque content (sigue el redondeo del box) */
body.spvsma-sm-theme .content-wrapper > .content > .box:first-child {
  margin-top: 0;
}

/* Sidebar: navy + sombra */
body.spvsma-sm-theme .main-sidebar,
body.spvsma-sm-theme .left-side {
  background: linear-gradient(180deg, var(--sm-navy), #0f1d23) !important;
  box-shadow: 6px 0 20px rgba(0, 0, 0, 0.12);
}

body.spvsma-sm-theme .sidebar-menu > li.header {
  background: rgba(255, 255, 255, 0.04) !important;
  padding: 12px 18px !important;
  border-left: none !important;
}

body.spvsma-sm-theme .sidebar-menu > li.header span,
body.spvsma-sm-theme .sidebar-menu > li.header span i {
  font-size: 15px !important;
  font-weight: 800 !important;
  color: var(--sm-gold) !important;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

/* Encabezados de sección manuales en HTML */
body.spvsma-sm-theme .sidebar-menu > li.header span[style] {
  color: var(--sm-gold) !important;
}

body.spvsma-sm-theme .sidebar a {
  color: #d8e3e8 !important;
}

body.spvsma-sm-theme .sidebar-menu > li > a {
  border-left: 4px solid transparent;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}

body.spvsma-sm-theme .sidebar-menu > li:hover > a,
body.spvsma-sm-theme .sidebar-menu > li.active > a {
  background: rgba(255, 255, 255, 0.07) !important;
  border-left-color: var(--sm-gold) !important;
  color: #fff !important;
}

body.spvsma-sm-theme .sidebar-menu > li > a > .fa,
body.spvsma-sm-theme .sidebar-menu > li > a > .glyphicon {
  width: 22px;
  color: #9ed0ff !important;
}

body.spvsma-sm-theme .treeview-menu > li > a {
  color: #c5d5dc !important;
}

body.spvsma-sm-theme .treeview-menu > li:hover > a,
body.spvsma-sm-theme .treeview-menu > li.active > a {
  color: #fff !important;
}

/* Buscador lateral */
body.spvsma-sm-theme .sidebar-form {
  margin: 14px !important;
  padding: 0 !important;
  border-radius: 12px !important;
  background: #263b45 !important;
  border: none !important;
}

body.spvsma-sm-theme .sidebar-form .input-group {
  display: flex;
  align-items: center;
}

body.spvsma-sm-theme .sidebar-form .form-control {
  background: transparent !important;
  border: none !important;
  color: #fff !important;
  font-size: 13px !important;
}

body.spvsma-sm-theme .sidebar-form .form-control::placeholder {
  color: #b8c4ca !important;
}

body.spvsma-sm-theme .sidebar-form .input-group-btn .btn {
  background: transparent !important;
  border: none !important;
  color: #b8c4ca !important;
}

body.spvsma-sm-theme .sidebar-form .input-group-btn .btn:hover {
  color: #fff !important;
}

/* Scroll del menú: evita banda clara tipo “rail” por defecto del navegador */
body.spvsma-sm-theme .main-sidebar .sidebar {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.28) rgba(0, 0, 0, 0.12);
}

body.spvsma-sm-theme .main-sidebar .sidebar::-webkit-scrollbar {
  width: 8px;
}

body.spvsma-sm-theme .main-sidebar .sidebar::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.12);
}

body.spvsma-sm-theme .main-sidebar .sidebar::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.28);
  border-radius: 4px;
}

/* Cajas AdminLTE dentro del contenido */
body.spvsma-sm-theme .box {
  border-radius: 16px;
  border-color: var(--sm-line);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.05);
}

body.spvsma-sm-theme .box-header {
  border-radius: 16px 16px 0 0;
}

/* ---------- Utilidades opt-in (paneles KPI / tarjetas) — no afectan DataTables ---------- */
.sm-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 18px;
}

.sm-kpi-card {
  background: var(--sm-card, #fff);
  border-radius: 20px;
  padding: 18px;
  border: 1px solid var(--sm-line, #e5e7eb);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.05);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sm-kpi-card span {
  color: var(--sm-muted, #6b7280);
  font-size: 13px;
}

.sm-kpi-card strong {
  display: block;
  font-size: 24px;
  margin-top: 5px;
  color: var(--sm-text, #1f2937);
}

.sm-kpi-icon {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}

.sm-bg-blue {
  background: #eef6ff;
  color: #2f80ed;
}
.sm-bg-green {
  background: #ecfdf3;
  color: #12b76a;
}
.sm-bg-gold {
  background: #fff7e6;
  color: #f5a623;
}
.sm-bg-red {
  background: #fff1f2;
  color: #ef4444;
}

.sm-panel {
  background: #fff;
  border: 1px solid var(--sm-line, #e5e7eb);
  border-radius: 22px;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.06);
  overflow: hidden;
}

.sm-panel-head {
  padding: 18px 20px;
  border-bottom: 1px solid var(--sm-line, #e5e7eb);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.sm-panel-head h2 {
  margin: 0;
  font-size: 19px;
  font-weight: 800;
}

.sm-panel-head p {
  margin: 4px 0 0;
  color: var(--sm-muted, #6b7280);
  font-size: 13px;
}

.sm-panel-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.sm-btn {
  border: 0;
  padding: 10px 14px;
  border-radius: 12px;
  font-weight: 700;
  cursor: pointer;
}

.sm-btn-blue {
  background: #2f80ed;
  color: #fff;
}
.sm-btn-green {
  background: #12b76a;
  color: #fff;
}
.sm-btn-light {
  background: #f3f4f6;
  color: #374151;
}

.sm-page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 18px;
  flex-wrap: wrap;
  gap: 12px;
}

.sm-page-head h1 {
  margin: 0;
  font-size: 26px;
  font-weight: 800;
}

.sm-page-head p {
  margin: 6px 0 0;
  color: var(--sm-muted, #6b7280);
}

.sm-breadcrumb {
  color: var(--sm-muted, #6b7280);
  font-size: 13px;
}

/* Tabla solo si usas clase .sm-table explícitamente */
.sm-table-wrap {
  overflow: auto;
}

.sm-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.sm-table th {
  background: #f8fafc;
  padding: 14px;
  text-align: left;
  color: #374151;
  border-bottom: 1px solid var(--sm-line, #e5e7eb);
  white-space: nowrap;
}

.sm-table td {
  padding: 14px;
  border-bottom: 1px solid #f0f2f5;
  vertical-align: middle;
}

.sm-table tr:hover {
  background: #fbfdff;
}

@media (max-width: 1200px) {
  .sm-kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 900px) {
  .sm-kpi-grid {
    grid-template-columns: 1fr;
  }
  .sm-page-head {
    display: block;
  }
}
