/* ============================================================================
   SIJAECH — Hoja de estilos principal
   Identidad visual: navy #16233f · dorado #c9a227 · teal #1a7a5e
   Tipografías: Fraunces (display) · Outfit (cuerpo)
   ========================================================================== */

/* ----------------------------- Variables ------------------------------- */
:root {
    --navy:        #16233f;
    --navy-soft:   #1f3050;
    --gold:        #c9a227;
    --teal:        #1a7a5e;

    --bg:          #f4f5f7;
    --surface:     #ffffff;
    --border:      #e2e5ea;
    --text:        #1c2430;
    --text-muted:  #6b7280;

    --sidebar-w:   248px;
    --sidebar-w-collapsed: 64px;
    --navbar-h:    64px;
    --radius:      12px;
    --shadow:      0 1px 3px rgba(22, 35, 63, .08), 0 1px 2px rgba(22, 35, 63, .06);

    --font-display: "Fraunces", Georgia, serif;
    --font-body:    "Outfit", system-ui, -apple-system, sans-serif;
}

/* ------------------------------- Reset --------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
    font-family: var(--font-body);
    color: var(--text);
    background: var(--bg);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

/* ============================== NAVBAR ================================== */
.navbar {
    position: sticky;
    top: 0;
    z-index: 30;
    height: var(--navbar-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    background: var(--navy);
    color: #fff;
    box-shadow: var(--shadow);
}

.navbar__left { display: flex; align-items: center; gap: 16px; }

.navbar__toggle {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    width: 38px;
    height: 38px;
    padding: 9px;
    border: none;
    border-radius: 8px;
    background: transparent;
    cursor: pointer;
    transition: background .2s;
}
.navbar__toggle:hover { background: var(--navy-soft); }
.navbar__toggle span {
    display: block;
    height: 2px;
    border-radius: 2px;
    background: #fff;
}

/* Marca / logo */
.brand { display: flex; align-items: center; gap: 12px; }
.brand__mark {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--gold);
    color: var(--navy);
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 16px;
}
.brand__text { display: flex; flex-direction: column; line-height: 1.15; }
.brand__text strong {
    font-family: var(--font-display);
    font-size: 18px;
    letter-spacing: .5px;
}
.brand__text small { font-size: 11px; color: #aeb6c6; }

/* Usuario */
.user { display: flex; align-items: center; gap: 12px; }
.user__avatar {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--teal);
    color: #fff;
    font-weight: 600;
    font-size: 14px;
}
.user__info { display: flex; flex-direction: column; line-height: 1.2; text-align: right; }
.user__info strong { font-size: 13px; font-weight: 600; }
.user__info small { font-size: 11px; color: #aeb6c6; }

/* ============================== LAYOUT ================================= */
.layout { display: flex; min-height: calc(100vh - var(--navbar-h)); }

/* ============================= SIDEBAR ================================= */
.sidebar {
    flex: 0 0 var(--sidebar-w);
    width: var(--sidebar-w);
    background: var(--navy);
    color: #c8cedb;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 16px 12px;
    transition: width .22s ease, flex-basis .22s ease;
    overflow: hidden;
}

.sidebar__heading {
    padding: 14px 12px 6px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #6f7b93;
    white-space: nowrap;
}

.sidebar__item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    color: #c8cedb;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    transition: background .18s, color .18s;
}
.sidebar__item:hover { background: var(--navy-soft); color: #fff; }
.sidebar__item.is-active {
    background: var(--navy-soft);
    color: #fff;
    box-shadow: inset 3px 0 0 var(--gold);
}
.sidebar__item.is-disabled { opacity: .5; cursor: not-allowed; }

.sidebar__icon {
    flex: 0 0 24px;
    text-align: center;
    font-size: 16px;
    color: var(--gold);
}

/* --- Submenú en cascada (ej. Proyectos) --- */
.sidebar__item--parent { position: relative; }
.sidebar__chevron {
    margin-left: auto;
    font-size: 16px;
    color: #6f7b93;
    transition: transform .2s ease;
}
.sidebar__item--parent.is-open .sidebar__chevron {
    transform: rotate(90deg);
    color: var(--gold);
}
.sidebar__submenu {
    display: flex;
    flex-direction: column;
    margin: 2px 0 6px;
    padding-left: 8px;
}
.sidebar__subitem {
    padding: 8px 12px 8px 26px;
    border-radius: 8px;
    color: #aeb6c6;
    font-size: 13px;
    font-weight: 400;
    white-space: nowrap;
    transition: background .16s, color .16s;
}
.sidebar__subitem:hover { background: var(--navy-soft); color: #fff; }
/* Colapsado SIN hover: ocultar chevron y submenú (en escritorio el sidebar
   conserva is-collapsed y solo se expande al pasar el cursor, así que el
   submenú debe poder mostrarse durante el hover). */
.sidebar.is-collapsed:not(:hover) .sidebar__chevron { opacity: 0; }
.sidebar.is-collapsed:not(:hover) .sidebar__submenu { display: none !important; }

.sidebar__footer {
    padding: 12px;
    font-size: 11px;
    color: #6f7b93;
    white-space: nowrap;
}

/* --- Estado colapsado: solo iconos, las etiquetas se ocultan --- */
.sidebar.is-collapsed {
    flex-basis: var(--sidebar-w-collapsed);
    width: var(--sidebar-w-collapsed);
}
.sidebar.is-collapsed .sidebar__label,
.sidebar.is-collapsed .sidebar__heading,
.sidebar.is-collapsed .sidebar__footer .sidebar__label {
    opacity: 0;
    pointer-events: none;
}
/* Al pasar el cursor sobre el sidebar colapsado, se expande temporalmente (solo en desktop) */
@media (min-width: 769px) {
    .sidebar.is-collapsed:hover {
        flex-basis: var(--sidebar-w);
        width: var(--sidebar-w);
    }
    .sidebar.is-collapsed:hover .sidebar__label,
    .sidebar.is-collapsed:hover .sidebar__heading {
        opacity: 1;
        pointer-events: auto;
    }
}

/* ============================= CONTENIDO =============================== */
.content {
    flex: 1;
    padding: 28px 32px;
    overflow-y: auto;
}

.page-head { margin-bottom: 24px; }
.page-head__title {
    font-family: var(--font-display);
    font-size: 30px;
    font-weight: 600;
    color: var(--navy);
}
.page-head__sub { color: var(--text-muted); font-size: 14px; }

/* --- Vistas (módulos): solo se muestra la activa --- */
.view { display: none; }
.view.is-active { display: block; animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ========================= BANNER DE AVISO ============================= */
.alert-banner {
    display: flex;
    gap: 8px;
    margin-bottom: 22px;
    padding: 12px 16px;
    background: #fef8e7;
    border: 1px solid #f0d98a;
    border-left: 4px solid var(--gold);
    border-radius: 10px;
    font-size: 13px;
    color: #7a6a2a;
}

/* ===================== SECCIÓN 1 · TARJETAS KPI ======================== */
.kpi-row {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    overflow: visible;
    /* Margen vertical para que la elevación (hover) y sombras no se recorten */
    padding: 8px 2px 12px;
}
.kpi-card {
    flex: 1 1 150px;
    min-width: 140px;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent, var(--navy));
    border-radius: var(--radius);
    padding: 18px;
    box-shadow: var(--shadow);
}
.kpi-card__value {
    font-family: var(--font-display);
    font-size: 48px;
    font-weight: 700;
    line-height: 1;
    color: var(--accent, var(--navy));
}
.kpi-card__label {
    margin-top: 10px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .6px;
    text-transform: uppercase;
    color: #4b5563;
}
.kpi-card__divider {
    height: 1px;
    background: var(--border);
    margin: 14px 0 10px;
}
.kpi-card__breakdown {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 7px;
}
.kpi-card__breakdown li {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    font-size: 13px;
    color: var(--text-muted);
}
.kpi-card__breakdown li span:last-child {
    font-weight: 600;
    color: var(--text);
}

/* ====================== SECCIÓN 2 · GRÁFICAS =========================== */
.charts-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
    margin-top: 26px;
}
.chart-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}
.chart-card__title {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 600;
    color: var(--navy);
    margin-bottom: 14px;
}
.chart-card__canvas-wrap {
    position: relative;
    height: 280px;
}

/* ===== Tarjetas de seguimiento del Panel (En Revisión / Circulados) ===== */
.dash-count {
    display: inline-block;
    min-width: 22px;
    padding: 1px 8px;
    margin-left: 6px;
    border-radius: 999px;
    background: var(--gold);
    color: var(--navy);
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 700;
    vertical-align: middle;
}
.dash-list { display: flex; flex-direction: column; gap: 10px; max-height: 300px; overflow-y: auto; }
.dash-empty { color: var(--text-muted); text-align: center; padding: 28px 0; font-size: 14px; }
.dash-card {
    border: 1px solid var(--border);
    border-left: 3px solid var(--gold);
    border-radius: 10px;
    padding: 11px 13px;
    background: #fafbfd;
}
.dash-card__exp { font-weight: 700; color: var(--navy); font-size: 14px; }
.dash-card__meta { font-size: 12px; color: var(--text-muted); margin: 3px 0 9px; }
.dash-card__drive {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 8px;
    background: var(--teal);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    transition: background .18s, transform .12s;
}
.dash-card__drive:hover { background: #15694f; transform: translateY(-1px); }
.dash-card__nodrive { font-size: 12px; color: #9aa3b2; font-style: italic; }

/* ===== Visor de Carpeta Digital (Drive embebido) ===== */
.drive-modal {
    position: fixed; inset: 0; z-index: 60;
    background: rgba(15, 26, 48, .55);
    display: flex; flex-direction: column;
}
.drive-modal__bar {
    height: 52px; flex: 0 0 52px;
    background: var(--navy); color: #fff;
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 18px; border-bottom: 2px solid var(--gold);
}
.drive-modal__title { font-weight: 600; font-size: 15px; }
.drive-modal__actions { display: flex; align-items: center; gap: 12px; }
.drive-modal__ext {
    font-size: 13px; color: var(--gold); border: 1px solid rgba(201,162,39,.5);
    padding: 5px 12px; border-radius: 8px; transition: all .18s;
}
.drive-modal__ext:hover { background: rgba(201,162,39,.12); color: var(--gold-l, #e3c766); }
.drive-modal__x {
    background: none; border: none; color: #fff; font-size: 20px; cursor: pointer;
    width: 34px; height: 34px; border-radius: 8px; transition: background .18s;
}
.drive-modal__x:hover { background: var(--navy-soft); }
.drive-modal__frame { flex: 1; width: 100%; border: none; background: #fff; }

/* ====================== SECCIÓN 3 · MÓDULOS ============================ */
.section-title {
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 600;
    color: var(--navy);
    margin: 30px 0 14px;
}
.modules-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 18px;
}
.module-card {
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}
.module-card__icon {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: rgba(22, 35, 63, .06);
    color: var(--navy);
    margin-bottom: 14px;
}
.module-card__icon svg { width: 22px; height: 22px; }
.module-card__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}
.module-card__title { font-size: 16px; font-weight: 600; color: var(--navy); }
.module-card__desc {
    flex: 1;
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.badge {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .5px;
    text-transform: uppercase;
    padding: 3px 9px;
    border-radius: 999px;
    white-space: nowrap;
}
.badge--active { background: rgba(26, 122, 94, .12); color: var(--teal); }
.badge--dev    { background: rgba(201, 162, 39, .16); color: #9a7d18; }

.btn {
    display: inline-block;
    text-align: center;
    padding: 9px 14px;
    border-radius: 9px;
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 600;
    border: none;
    cursor: pointer;
}
.btn--primary { background: var(--navy); color: #fff; transition: background .18s; }
.btn--primary:hover { background: var(--navy-soft); }
.btn--disabled { background: #eef0f3; color: #9aa3b2; cursor: not-allowed; }

/* --------------------------- Placeholder ------------------------------- */
.placeholder {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 48px 32px;
    text-align: center;
    box-shadow: var(--shadow);
}
.placeholder h2 {
    font-family: var(--font-display);
    font-size: 22px;
    color: var(--navy);
    margin-bottom: 8px;
}
.placeholder p { color: var(--text-muted); }

/* ============================ RESPONSIVE ============================== */
@media (max-width: 980px) {
    .charts-row { grid-template-columns: 1fr; }
    .modules-grid { grid-template-columns: repeat(2, 1fr); }
    .user__info { display: none; }
}

@media (max-width: 640px) {
    .content { padding: 20px 16px; }
    .modules-grid { grid-template-columns: 1fr; }
    .brand__text small { display: none; }
    /* En móvil el sidebar arranca colapsado a solo iconos */
    .sidebar { flex-basis: var(--sidebar-w-collapsed); width: var(--sidebar-w-collapsed); }
    .sidebar .sidebar__label, .sidebar .sidebar__heading { opacity: 0; }
}
/* ── Logout sidebar — override ────────────────────────────── */
#sidebar .sidebar__footer {
  padding: 0.9rem 0.75rem 1.1rem;
  border-top: 1px solid rgba(201,162,39,0.18) !important;
  background: transparent !important;
}
#sidebar .sidebar__logout-btn {
  width: 100%;
  display: flex !important;
  align-items: center;
  gap: 0.55rem;
  background: none !important;
  border: 1px solid rgba(201,162,39,0.35) !important;
  border-radius: 8px;
  color: #c9a227 !important;
  font-family: 'Outfit', sans-serif;
  font-size: 0.8rem;
  font-weight: 500;
  padding: 0.6rem 0.85rem;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-bottom: 0;
}
#sidebar .sidebar__logout-btn:hover {
  background: rgba(201,162,39,0.1) !important;
  border-color: #c9a227 !important;
  color: #e3c766 !important;
}
/* El ícono ⏻ nunca debe encogerse ni recortarse */
#sidebar .sidebar__logout-btn > span:first-child {
  flex: 0 0 auto;
  font-size: 1rem;
  line-height: 1;
}
/* Colapsado: solo el ícono centrado, sin texto (display:none = sin recortes) */
.sidebar.is-collapsed .sidebar__logout-btn {
  justify-content: center;
  padding-left: 0;
  padding-right: 0;
}
.sidebar.is-collapsed .logout-texto,
.sidebar.is-collapsed .sidebar__version {
  display: none;
}
/* Al expandir por hover (escritorio) reaparece el texto */
@media (min-width: 769px) {
  .sidebar.is-collapsed:hover .sidebar__logout-btn {
    justify-content: flex-start;
    padding-left: 0.85rem;
    padding-right: 0.85rem;
  }
  .sidebar.is-collapsed:hover .logout-texto { display: inline !important; }
  .sidebar.is-collapsed:hover .sidebar__version { display: block !important; }
}
#sidebar .sidebar__version {
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.28) !important;
  text-align: center;
  margin-top: 0.7rem;
  display: block;
}
/* ── Visor módulos OVERRIDE ──────────────────────────────── */
#visorModulos {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  z-index: 9999 !important;
  background: #f3f6fb !important;
  flex-direction: column !important;
  overflow: hidden !important;
}
#visorModulos .visor-modulos__barra {
  display: flex !important;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  height: 48px;
  min-height: 48px;
  flex-shrink: 0 !important;
  background: #0f1a30 !important;
  border-bottom: 2px solid #c9a227;
}
#visorFrame {
  width: 100% !important;
  height: calc(100vh - 48px) !important;
  flex: 1 1 auto !important;
  min-height: 0 !important;
  border: none !important;
  display: block !important;
  overflow: auto;
}
.visor-modulos__marca {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.visor-modulos__sistema {
  font-family: 'Fraunces', serif;
  font-size: 0.95rem;
  font-weight: 700;
  color: #e3c766;
  letter-spacing: 0.05em;
}
.visor-modulos__sep {
  color: rgba(201,162,39,0.4);
  font-size: 0.9rem;
}
.visor-modulos__titulo {
  font-family: 'Outfit', sans-serif;
  font-size: 0.85rem;
  color: rgba(255,255,255,0.75);
  font-weight: 400;
}
.visor-modulos__cerrar {
  background: none;
  border: 1px solid rgba(201,162,39,0.4);
  color: #c9a227;
  padding: 0.3rem 0.85rem;
  border-radius: 5px;
  font-family: 'Outfit', sans-serif;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
}
.visor-modulos__cerrar:hover {
  background: rgba(201,162,39,0.12);
  border-color: #c9a227;
  color: #e3c766;
}

/* ============================================================================
   PULIDO · MICRO-INTERACCIONES (universal — aplica a todos los módulos)
   Elevación al pasar el cursor, entrada escalonada de tarjetas y transiciones
   suaves. Todo se desactiva si el usuario prefiere menos movimiento.
   ========================================================================== */

/* --- Elevación suave al pasar el cursor (hover lift) --- */
.kpi-card,
.module-card,
.chart-card {
  transition: transform .2s ease, box-shadow .2s ease;
  will-change: transform;
}
.kpi-card:hover,
.module-card:hover,
.chart-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 10px 28px rgba(22, 35, 63, .14);
}

/* --- Botones: realce táctil --- */
.btn {
  transition: background .18s ease, transform .12s ease, box-shadow .18s ease;
}
.btn--primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(22, 35, 63, .28);
}
.btn:active { transform: translateY(0); }

/* --- Entrada escalonada de tarjetas (solo si hay movimiento permitido) --- */
@media (prefers-reduced-motion: no-preference) {
  .kpi-card,
  .module-card {
    animation: sijaechCardIn .5s cubic-bezier(.22, .61, .36, 1) both;
  }

  /* Escalonado de las tarjetas KPI */
  .kpi-row .kpi-card:nth-child(1) { animation-delay: .04s; }
  .kpi-row .kpi-card:nth-child(2) { animation-delay: .10s; }
  .kpi-row .kpi-card:nth-child(3) { animation-delay: .16s; }
  .kpi-row .kpi-card:nth-child(4) { animation-delay: .22s; }
  .kpi-row .kpi-card:nth-child(5) { animation-delay: .28s; }
  .kpi-row .kpi-card:nth-child(6) { animation-delay: .34s; }

  /* Escalonado de las tarjetas de módulo */
  .modules-grid .module-card:nth-child(1) { animation-delay: .06s; }
  .modules-grid .module-card:nth-child(2) { animation-delay: .12s; }
  .modules-grid .module-card:nth-child(3) { animation-delay: .18s; }
  .modules-grid .module-card:nth-child(4) { animation-delay: .24s; }
}

@keyframes sijaechCardIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: none; }
}

/* --- El conteo de KPI usa tabular-nums para que no "salte" el ancho --- */
.kpi-card__value {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

/* --- Seguridad: anular toda animación si el usuario lo pide --- */
@media (prefers-reduced-motion: reduce) {
  .kpi-card,
  .module-card,
  .chart-card,
  .btn {
    animation: none !important;
    transition: none !important;
  }
}