/* ==========================================================================
   SISTEMA DE DISEÑO INSTITUCIONAL - GNESIS / EXODO
   Colores extraídos directamente del logotipo oficial
   ========================================================================== */

:root {
  /* --- PALETA PRINCIPAL (Azul Gnesis) --- */
  --brand-primary: #016599;             /* Azul corporativo principal del logo */
  --brand-primary-hover: #01527c;       /* Azul más oscuro para estados hover */
  --brand-primary-active: #013f60;      /* Azul profundo para selección activa */
  --brand-primary-dark: #003653;        /* Azul marino oscuro para contrastes y textos */
  --brand-primary-light: #e8f3f9;       /* Azul tenue para fondos de tarjetas y hover */
  --brand-primary-subtle: #f0f7fb;      /* Azul casi blanco para fondos secundarios */
  --brand-primary-rgb: 1, 101, 153;     /* Formato RGB para opacidades y sombras */

  /* --- PALETA SECUNDARIA Y DECORATIVA --- */
  --brand-accent: #0284c7;              /* Azul tecnológico brillante (detalle USB/chip) */
  --brand-slate: #667781;               /* Gris sombra del circuito interno */
  --brand-slate-light: #94a3b8;         /* Gris medio para bordes neutros y textos suaves */
  --brand-gray-border: #dbe4ea;         /* Gris sutil para bordes de tablas y tarjetas */

  /* --- SUPERFICIES Y FONDOS --- */
  --bg-app: #f4f6f8;                    /* Fondo global de la aplicación (gris limpio del logo) */
  --bg-card: #ffffff;                   /* Fondo de tarjetas y contenedores de formularios */
  --bg-card-header: #f8fafc;            /* Fondo base de cabeceras */
  --bg-topbar: #ffffff;                 /* Fondo de barra superior */

  /* --- TIPOGRAFÍA Y TEXTOS --- */
  --text-primary: #0f172a;              /* Texto principal de alto contraste */
  --text-secondary: #475569;            /* Texto secundario y etiquetas de formulario */
  --text-muted: #64748b;                /* Texto atenuado para notas y descripciones */
  --text-light: #ffffff;                /* Texto blanco */

  /* --- ESTADOS SEMÁNTICOS --- */
  --brand-success: #059669;             /* Verde esmeralda para guardar/éxito */
  --brand-success-hover: #047857;
  --brand-danger: #dc2626;              /* Rojo para errores y eliminación */
  --brand-danger-hover: #b91c1c;
  --brand-warning: #d97706;             /* Ámbar para alertas */
  --brand-info: #0284c7;                /* Azul cian para notificaciones */

  /* --- SOMBRAS Y PROFUNDIDAD --- */
  --shadow-sm: 0 1px 3px rgba(1, 101, 153, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(1, 101, 153, 0.10), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(1, 101, 153, 0.12), 0 4px 6px -4px rgba(0, 0, 0, 0.05);

  /* --- RADIOS DE BORDE --- */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;

  /* --- COMPATIBILIDAD CON VARIABLES PREVIAS --- */
  --brand-blue: var(--brand-primary);
  --brand-dark: var(--brand-primary-hover);
  --brand-gray: var(--brand-slate);
  --bg: var(--bg-app);
}

/* ==========================================================================
   CONFIGURACIÓN BASE Y TIPOGRAFÍA
   ========================================================================== */
html {
  font-size: 14px;
  position: relative;
  min-height: 100%;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

body {
  background-color: var(--bg-app);
  color: var(--text-primary);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  margin-bottom: 60px;
}

h1, .page-title {
  color: var(--brand-primary-dark);
  font-weight: 700;
  letter-spacing: -0.3px;
  margin-bottom: 1.25rem;
}

a {
  color: var(--brand-primary);
  text-decoration: none;
  transition: color 0.15s ease;
}

a:hover {
  color: var(--brand-primary-hover);
  text-decoration: underline;
}

/* ==========================================================================
   ESTRUCTURA DE APLICACIÓN: SHELL, SIDEBAR Y TOPBAR
   ========================================================================== */
.app-shell {
  min-height: calc(100vh - 60px);
}

.content {
  background: var(--bg-app);
  width: 100%;
  margin-left: 0;
  transition: margin-left 0.25s ease;
}

@media (min-width: 992px) {
  .content-shift {
    margin-left: 240px;
  }
}

/* Topbar */
.topbar {
  background: var(--bg-topbar);
  border-bottom: 2px solid var(--brand-primary-light);
  box-shadow: 0 2px 6px rgba(1, 101, 153, 0.04);
}

.topbar .page-info {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.topbar .page-info strong {
  color: var(--brand-primary);
}

.topbar .user-info {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.topbar .user-info strong {
  color: var(--brand-primary-dark);
}

/* Menú lateral (Sidebar y Offcanvas) */
.sidebar,
.offcanvas.offcanvas-start,
.offcanvas-sidebar {
  width: 240px;
  background: linear-gradient(180deg, var(--brand-primary) 0%, var(--brand-primary-dark) 100%);
  color: #ffffff;
  box-shadow: 4px 0 15px rgba(1, 101, 153, 0.15);
}

.offcanvas.offcanvas-start .offcanvas-header {
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.05);
}

.offcanvas-sidebar .offcanvas-title {
  color: #ffffff;
  font-weight: 600;
  font-size: 1.1rem;
}

.offcanvas-sidebar .btn-close {
  filter: invert(1) grayscale(100%) brightness(200%);
}

.sidebar .nav-link,
.offcanvas-sidebar .nav-link {
  color: rgba(255, 255, 255, 0.88);
  font-weight: 500;
  padding: 0.65rem 1rem 0.65rem 48px;
  margin: 2px 8px;
  border-radius: var(--radius-sm);
  border-left: 4px solid transparent;
  transition: all 0.2s ease;
  position: relative;
}

.sidebar .nav-link:hover,
.sidebar .nav-link:focus,
.offcanvas-sidebar .nav-link:hover,
.offcanvas-sidebar .nav-link:focus {
  background-color: rgba(255, 255, 255, 0.15);
  color: #ffffff;
  text-decoration: none;
  border-left-color: var(--brand-accent);
  transform: translateX(3px);
}

.sidebar .nav-link.active,
.offcanvas-sidebar .nav-link.active {
  background-color: rgba(255, 255, 255, 0.22);
  color: #ffffff;
  font-weight: 600;
  border-left-color: #ffffff;
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.08);
}

/* Iconos del menú lateral */
.sidebar .nav-link::before,
.offcanvas-sidebar .nav-link::before {
  content: "";
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  background-size: 20px 20px !important;
  background-repeat: no-repeat;
  background-position: center;
  opacity: 0.95;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.sidebar .nav-link:hover::before,
.offcanvas-sidebar .nav-link:hover::before {
  transform: translateY(-50%) scale(1.1);
  opacity: 1;
}

/* Iconos vectoriales del menú */
.sidebar .nav-link.icon-dashboard::before,
.offcanvas-sidebar .nav-link.icon-dashboard::before {
  background-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22%23fff%22%3E%3Cpath%20d%3D%22M3%203h8v8H3V3zm10%200h8v8h-8V3zM3%2013h8v8H3v-8zm10%200h8v8h-8v-8z%22%2F%3E%3C%2Fsvg%3E");
}

.sidebar .nav-link.icon-reports::before,
.offcanvas-sidebar .nav-link.icon-reports::before {
  background-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22%23fff%22%3E%3Crect%20x%3D%223%22%20y%3D%2210%22%20width%3D%224%22%20height%3D%2211%22%2F%3E%3Crect%20x%3D%229%22%20y%3D%226%22%20width%3D%224%22%20height%3D%2215%22%2F%3E%3Crect%20x%3D%2215%22%20y%3D%222%22%20width%3D%224%22%20height%3D%2219%22%2F%3E%3C%2Fsvg%3E");
}

.sidebar .nav-link.icon-add::before,
.offcanvas-sidebar .nav-link.icon-add::before {
  background-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D'http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg'%20viewBox%3D'0%200%2024%2024'%20fill%3D'%23fff'%3E%3Cpath%20d%3D'M19%2011H13V5h-2v6H5v2h6v6h2v-6h6z'%2F%3E%3C%2Fsvg%3E");
}

.sidebar .nav-link.icon-settings::before,
.offcanvas-sidebar .nav-link.icon-settings::before {
  background-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22%23fff%22%3E%3Cpath%20d%3D%22M19.14%2012.94c.04-.31.06-.63.06-.94s-.02-.63-.06-.94l2.03-1.58c.18-.14.23-.4.12-.6l-1.92-3.32c-.11-.2-.35-.28-.56-.2l-2.39.96a7.027%207.027%200%200%200-1.62-.94l-.36-2.54A.487.487%200%200%200%2014%202h-4c-.24%200-.44.17-.48.41l-.36%202.54c-.58.24-1.12.56-1.62.94l-2.39-.96a.5.5%200%200%200-.56.2L2.71%209.88c-.11.2-.06.46.12.6L4.86%2012.06c-.04.31-.06.63-.06.94s.02.63.06.94L2.83%2015.52c-.18.14-.23.4-.12.6l1.92%203.32c.11.2.35.28.56.2l2.39-.96c.5.38%201.04.7%201.62.94l.36%202.54c.04.24.24.41.48.41h4c.24%200%20.44-.17.48-.41l.36-2.54c.58-.24%201.12-.56%201.62-.94l2.39.96c.21.08.45%200%20.56-.2l1.92-3.32c.11-.2.06-.46-.12-.6l-2.03-1.58zM12%2016c-2.21%200-4-1.79-4-4s1.79-4%204-4%204%201.79%204%204-1.79%204-4%204z%22%2F%3E%3C%2Fsvg%3E");
}

.sidebar .nav-link.icon-users::before,
.offcanvas-sidebar .nav-link.icon-users::before {
  background-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22%23fff%22%3E%3Cpath%20d%3D%22M12%2012c2.7%200%205-2.3%205-5s-2.3-5-5-5-5%202.3-5%205%202.3%205%205%205zm0%202c-3.3%200-10%201.7-10%205v3h20v-3c0-3.3-6.7-5-10-5z%22%2F%3E%3C%2Fsvg%3E");
}

.sidebar .nav-link.icon-logout::before,
.offcanvas-sidebar .nav-link.icon-logout::before {
  background-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22%23fff%22%3E%3Cpath%20d%3D%22M16%2017l5-5-5-5v3H9v4h7v3zM5%2019h8v2H5c-1.1%200-2-.9-2-2V5c0-1.1.9-2%202-2h8v2H5v14z%22%2F%3E%3C%2Fsvg%3E");
}

/* Botón cerrar sesión al fondo del sidebar */
.offcanvas-sidebar .nav-link.logout {
  margin-top: auto;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.08);
}

.offcanvas-sidebar .nav-link.logout:hover {
  background: rgba(220, 38, 38, 0.25);
  border-left-color: var(--brand-danger);
}

/* ==========================================================================
   COMPONENTES: TARJETAS Y FORMULARIOS (Reutilizables en todas las páginas)
   ========================================================================== */
.card {
  background-color: var(--bg-card);
  border: 1px solid var(--brand-gray-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
  overflow: hidden;
}

.card:hover {
  box-shadow: var(--shadow-md);
  border-color: #cbd5e1;
}

.card-header {
  background: linear-gradient(90deg, var(--brand-primary-light) 0%, #ffffff 100%);
  border-bottom: 1px solid var(--brand-gray-border);
  border-left: 4px solid var(--brand-primary);
  color: var(--brand-primary-dark);
  font-weight: 600;
  font-size: 1rem;
  padding: 0.75rem 1.25rem;
  letter-spacing: 0.1px;
}

.card-body {
  padding: 1.25rem;
}

/* Etiquetas e inputs de formularios */
label, .form-label {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 0.35rem;
}

.form-control, .form-select {
  border: 1px solid var(--brand-gray-border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.925rem;
  padding: 0.5rem 0.75rem;
  background-color: #ffffff;
  transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.form-control:focus, .form-select:focus {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 0.2rem rgba(var(--brand-primary-rgb), 0.2);
  outline: none;
}

/* Campos de totales calculados (readonly) */
.form-control[readonly] {
  background-color: var(--brand-primary-light);
  border-color: #c9dff0;
  font-weight: 600;
  color: var(--brand-primary-dark);
}

.input-group-text {
  background-color: var(--brand-primary-light);
  border-color: var(--brand-gray-border);
  color: var(--brand-primary-dark);
  font-weight: 500;
}

/* ==========================================================================
   BOTONES INSTITUCIONALES
   ========================================================================== */
.btn {
  border-radius: var(--radius-sm);
  font-weight: 500;
  padding: 0.5rem 1.15rem;
  transition: all 0.2s ease;
}

.btn:focus, .btn:active:focus {
  box-shadow: 0 0 0 0.1rem #ffffff, 0 0 0 0.25rem var(--brand-primary);
}

/* Botón Primario (Azul Gnesis) */
.btn-primary, .btn-brand {
  background-color: var(--brand-primary) !important;
  border-color: var(--brand-primary) !important;
  color: #ffffff !important;
}

.btn-primary:hover, .btn-primary:focus, .btn-brand:hover, .btn-brand:focus {
  background-color: var(--brand-primary-hover) !important;
  border-color: var(--brand-primary-hover) !important;
  color: #ffffff !important;
  box-shadow: 0 4px 10px rgba(var(--brand-primary-rgb), 0.25);
  transform: translateY(-1px);
}

/* Botón Delineado (Outline Gnesis) */
.btn-outline-primary, .btn-outline-brand {
  color: var(--brand-primary) !important;
  border-color: var(--brand-primary) !important;
  background-color: transparent !important;
}

.btn-outline-primary:hover, .btn-outline-primary:focus, .btn-outline-brand:hover, .btn-outline-brand:focus {
  background-color: var(--brand-primary) !important;
  border-color: var(--brand-primary) !important;
  color: #ffffff !important;
  box-shadow: 0 4px 10px rgba(var(--brand-primary-rgb), 0.2);
}

/* Botón Éxito / Guardar */
.btn-success {
  background-color: var(--brand-success) !important;
  border-color: var(--brand-success) !important;
  color: #ffffff !important;
}

.btn-success:hover, .btn-success:focus {
  background-color: var(--brand-success-hover) !important;
  border-color: var(--brand-success-hover) !important;
  color: #ffffff !important;
  box-shadow: 0 4px 10px rgba(5, 150, 105, 0.25);
  transform: translateY(-1px);
}

/* Botón Secundario (Gris Circuito) */
.btn-secondary {
  background-color: var(--brand-slate) !important;
  border-color: var(--brand-slate) !important;
  color: #ffffff !important;
}

.btn-secondary:hover, .btn-secondary:focus {
  background-color: #526068 !important;
  border-color: #526068 !important;
  color: #ffffff !important;
}

/* ==========================================================================
   MODALES Y DIÁLOGOS
   ========================================================================== */
.modal-content {
  border-radius: var(--radius-lg);
  border: 1px solid var(--brand-gray-border);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.modal-header {
  background: linear-gradient(90deg, var(--brand-primary-light) 0%, #ffffff 100%);
  border-bottom: 1px solid var(--brand-gray-border);
  border-left: 5px solid var(--brand-primary);
  padding: 1rem 1.25rem;
}

.modal-header .modal-title {
  color: var(--brand-primary-dark);
  font-weight: 600;
}

.modal-footer {
  border-top: 1px solid var(--brand-gray-border);
  background-color: #fafbfc;
  padding: 0.75rem 1.25rem;
}

/* ==========================================================================
   LOGIN Y PANTALLA DE ACCESO
   ========================================================================== */
.login-page {
  min-height: calc(100vh - 60px);
  padding: 2rem;
  background: linear-gradient(135deg, var(--bg-app) 0%, #e6f0f7 100%);
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: #ffffff;
  border-radius: var(--radius-lg);
  padding: 2rem;
  border-top: 5px solid var(--brand-primary);
  box-shadow: var(--shadow-lg);
  border-left: 1px solid var(--brand-gray-border);
  border-right: 1px solid var(--brand-gray-border);
  border-bottom: 1px solid var(--brand-gray-border);
}

/* ==========================================================================
   UTILIDADES REUTILIZABLES PARA FUTURAS PÁGINAS Y FORMULARIOS
   ========================================================================== */
.text-brand { color: var(--brand-primary) !important; }
.text-brand-dark { color: var(--brand-primary-dark) !important; }
.bg-brand { background-color: var(--brand-primary) !important; color: #fff !important; }
.bg-brand-light { background-color: var(--brand-primary-light) !important; }
.border-brand { border-color: var(--brand-primary) !important; }

.badge-brand {
  background-color: var(--brand-primary-light);
  color: var(--brand-primary-dark);
  font-weight: 600;
  border: 1px solid rgba(var(--brand-primary-rgb), 0.15);
  border-radius: var(--radius-sm);
  padding: 0.35em 0.65em;
}

.footer {
  background-color: #ffffff;
  border-top: 1px solid var(--brand-gray-border);
  color: var(--text-muted);
}

/* ==========================================================================
   RESPONSIVIDAD Y AJUSTES MÓVILES
   ========================================================================== */
@media (max-width: 991.98px) {
  .app-shell { padding: 0; }
  .content { padding-left: 1rem; padding-right: 1rem; }
  .offcanvas.offcanvas-start.sidebar {
    width: 100% !important;
    max-width: 320px !important;
  }
}
}