/* ============================================================
   SIGI-JSMF | assets/css/app.css
   Estilos institucionales IMSS — Design tokens + layout
   ============================================================ */

/* ─── VARIABLES / DESIGN TOKENS ─────────────────────────────── */
:root {
  --imss-verde:       #00823e;
  --imss-verde-claro: #e8f5ee;
  --imss-verde-hover: #006b33;
  --imss-gris:        #f0f2f5;
  --imss-gris-medio:  #8492a6;
  --imss-azul-texto:  #1a2b4a;
  --imss-rojo:        #c0392b;
  --imss-amarillo:    #f39c12;

  --sidebar-w:        260px;
  --topbar-h:         60px;
  --border-radius:    10px;
  --shadow-card:      0 2px 12px rgba(0,0,0,.08);
  --shadow-hover:     0 6px 24px rgba(0,130,62,.18);
  --transition:       all .22s ease;

  --font-main: "Segoe UI", system-ui, -apple-system, sans-serif;
}

/* ─── RESET / BASE ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: var(--font-main);
  background: var(--imss-gris);
  color: var(--imss-azul-texto);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
}

/* ─── LOGIN PAGE ────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #003d1c 0%, #00823e 50%, #00a84f 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.login-card {
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 420px;
}

.login-logo {
  width: 80px;
  height: 80px;
  background: var(--imss-verde);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1rem;
  font-size: 2.2rem;
}

.login-title {
  color: var(--imss-verde);
  font-weight: 700;
  font-size: 1.05rem;
  text-align: center;
  letter-spacing: -.3px;
}

.login-subtitle {
  color: var(--imss-gris-medio);
  font-size: .82rem;
  text-align: center;
  margin-bottom: 1.8rem;
}

/* ─── APP SHELL ─────────────────────────────────────────────── */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ─── SIDEBAR ────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: #00250f;
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 1040;
  transition: transform .28s cubic-bezier(.4,0,.2,1);
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-header {
  padding: 1.2rem 1rem;
  background: rgba(0,0,0,.2);
  border-bottom: 1px solid rgba(255,255,255,.08);
  flex-shrink: 0;
}

.sidebar-logo-text {
  font-size: .78rem;
  font-weight: 700;
  color: #7effc0;
  letter-spacing: .5px;
  line-height: 1.3;
}

.sidebar-unit {
  font-size: .7rem;
  color: rgba(255,255,255,.55);
  margin-top: 2px;
}

.sidebar-user {
  padding: .9rem 1rem;
  background: rgba(255,255,255,.05);
  border-bottom: 1px solid rgba(255,255,255,.08);
  display: flex;
  align-items: center;
  gap: .7rem;
}

.sidebar-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--imss-verde);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .9rem;
  flex-shrink: 0;
}

.sidebar-user-name  { font-size: .82rem; font-weight: 600; color: #fff; }
.sidebar-user-role  { font-size: .7rem; color: #7effc0; }

/* Nav links */
.sidebar-nav { padding: .5rem 0; flex: 1; }

.nav-section-title {
  padding: .5rem 1rem .25rem;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: 1.2px;
  color: rgba(255,255,255,.35);
  text-transform: uppercase;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .6rem 1rem;
  color: rgba(255,255,255,.75);
  text-decoration: none;
  font-size: .83rem;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: var(--transition);
  cursor: pointer;
}

.sidebar-link:hover {
  background: rgba(255,255,255,.07);
  color: #fff;
  border-left-color: var(--imss-verde);
}

.sidebar-link.active {
  background: rgba(0,130,62,.25);
  color: #7effc0;
  border-left-color: #7effc0;
  font-weight: 700;
}

.sidebar-link .nav-icon { font-size: 1.1rem; width: 22px; text-align: center; }

.sidebar-badge {
  margin-left: auto;
  background: var(--imss-rojo);
  color: #fff;
  font-size: .65rem;
  font-weight: 700;
  padding: .15rem .45rem;
  border-radius: 10px;
  min-width: 20px;
  text-align: center;
}

/* ─── MAIN CONTENT ───────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ─── TOPBAR ─────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: #fff;
  border-bottom: 1px solid #e4e9f0;
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 1030;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

.topbar-title {
  font-size: .95rem;
  font-weight: 700;
  color: var(--imss-azul-texto);
  flex: 1;
}

.topbar-actions { display: flex; align-items: center; gap: .5rem; }

.btn-sidebar-toggle {
  display: none;
  background: none; border: none;
  font-size: 1.4rem; cursor: pointer; color: var(--imss-azul-texto);
  padding: .25rem .5rem; border-radius: 6px;
}
.btn-sidebar-toggle:hover { background: var(--imss-gris); }

/* ─── PAGE CONTAINER ─────────────────────────────────────────── */
.page-container {
  padding: 1.5rem;
  flex: 1;
}

/* ─── CARDS ──────────────────────────────────────────────────── */
.card {
  border: none;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-card);
  transition: var(--transition);
}

.card:hover { box-shadow: var(--shadow-hover); }

.card-header {
  border-radius: var(--border-radius) var(--border-radius) 0 0 !important;
  border-bottom: 1px solid rgba(0,0,0,.07);
  font-weight: 600;
  font-size: .9rem;
}

/* ─── KPI CARDS ──────────────────────────────────────────────── */
.kpi-card {
  background: #fff;
  border-radius: var(--border-radius);
  padding: 1.2rem 1.4rem;
  box-shadow: var(--shadow-card);
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: var(--transition);
  border-left: 4px solid var(--imss-verde);
}
.kpi-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); }
.kpi-icon  { font-size: 2rem; }
.kpi-value { font-size: 1.8rem; font-weight: 800; line-height: 1; color: var(--imss-azul-texto); }
.kpi-label { font-size: .75rem; color: var(--imss-gris-medio); font-weight: 500; margin-top: 2px; }

/* ─── TABLAS ─────────────────────────────────────────────────── */
.table-sigi thead th {
  background: var(--imss-verde);
  color: #fff;
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .4px;
  border: none;
  white-space: nowrap;
}
.table-sigi tbody tr { transition: background .15s; }
.table-sigi tbody tr:hover { background: var(--imss-verde-claro); }
.table-sigi td { font-size: .82rem; vertical-align: middle; border-color: #eef0f4; }

/* ─── FORMULARIOS ────────────────────────────────────────────── */
.form-label  { font-size: .82rem; font-weight: 600; color: var(--imss-azul-texto); margin-bottom: .3rem; }
.form-control, .form-select {
  border-radius: 8px;
  border: 1.5px solid #d8dde6;
  font-size: .85rem;
  transition: border-color .18s, box-shadow .18s;
}
.form-control:focus, .form-select:focus {
  border-color: var(--imss-verde);
  box-shadow: 0 0 0 3px rgba(0,130,62,.12);
}
.form-required::after { content: " *"; color: var(--imss-rojo); }

/* ─── BOTONES ────────────────────────────────────────────────── */
.btn-imss {
  background: var(--imss-verde);
  color: #fff; border: none;
  border-radius: 8px; font-weight: 600;
  transition: var(--transition);
}
.btn-imss:hover { background: var(--imss-verde-hover); color: #fff; transform: translateY(-1px); }

.btn { border-radius: 8px; font-weight: 500; font-size: .83rem; }
.btn-sm { font-size: .76rem; }

/* ─── SIGNATURE PAD ──────────────────────────────────────────── */
.signature-wrapper {
  border: 2px dashed #cdd3db;
  border-radius: 10px;
  background: #fafbfc;
  position: relative;
  overflow: hidden;
}
.signature-wrapper canvas {
  display: block;
  touch-action: none;
  cursor: crosshair;
}
.signature-placeholder {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: #bcc2ca; font-size: .85rem; pointer-events: none;
  font-style: italic;
}

/* ─── EVIDENCIAS GRID ────────────────────────────────────────── */
.evidencia-thumb {
  width: 100%; aspect-ratio: 4/3;
  object-fit: cover;
  border-radius: 8px;
  cursor: pointer;
  transition: transform .18s;
}
.evidencia-thumb:hover { transform: scale(1.03); }
.evidencia-card {
  border: 1px solid #e8ecf2;
  border-radius: 10px; overflow: hidden;
  transition: var(--transition);
}
.evidencia-card:hover { box-shadow: var(--shadow-hover); }

/* ─── HISTORIAL / TIMELINE ───────────────────────────────────── */
.timeline { position: relative; padding-left: 2rem; }
.timeline::before {
  content: ""; position: absolute;
  left: .65rem; top: 0; bottom: 0;
  width: 2px; background: #d8dde6;
}
.timeline-item { position: relative; margin-bottom: 1.2rem; }
.timeline-dot {
  position: absolute; left: -1.7rem; top: .15rem;
  width: 12px; height: 12px;
  border-radius: 50%; border: 2px solid var(--imss-verde);
  background: #fff;
}
.timeline-dot.cerrado { background: var(--imss-verde); }
.timeline-dot.escalado { border-color: var(--imss-rojo); }
.timeline-time { font-size: .7rem; color: var(--imss-gris-medio); }
.timeline-desc { font-size: .82rem; color: var(--imss-azul-texto); font-weight: 500; }

/* ─── MODAL OVERRIDE ─────────────────────────────────────────── */
.modal-content  { border: none; border-radius: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal-header   { border-radius: 14px 14px 0 0; }

/* ─── BADGES CUSTOM ──────────────────────────────────────────── */
.badge { font-size: .72rem; padding: .3em .65em; border-radius: 6px; }

/* ─── SEARCH BAR ─────────────────────────────────────────────── */
.search-bar {
  position: relative;
}
.search-bar .form-control {
  padding-left: 2.5rem;
}
.search-bar .search-icon {
  position: absolute; left: .75rem; top: 50%;
  transform: translateY(-50%);
  color: var(--imss-gris-medio);
  pointer-events: none;
}

/* ─── EMPTY STATE ────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--imss-gris-medio);
}
.empty-state .empty-icon { font-size: 3.5rem; margin-bottom: 1rem; opacity: .6; }
.empty-state p { font-size: .9rem; }

/* ─── INTERVENCIÓN ALERT ─────────────────────────────────────── */
.intervencion-required {
  background: #fff3cd;
  border: 1.5px solid #ffc107;
  border-radius: 10px;
  padding: .8rem 1rem;
  font-size: .82rem;
  display: flex; align-items: center; gap: .5rem;
}

/* ─── CHIP TIPO GESTIÓN ──────────────────────────────────────── */
.chip {
  display: inline-block;
  background: var(--imss-verde-claro);
  color: var(--imss-verde);
  border: 1px solid rgba(0,130,62,.2);
  border-radius: 20px;
  padding: .15rem .65rem;
  font-size: .72rem;
  font-weight: 600;
}

/* ─── PAGE VIEWS ─────────────────────────────────────────────── */
.page-view { display: none; }
.page-view.active { display: block; }

/* ─── RESPONSIVE — MOBILE ────────────────────────────────────── */
@media (max-width: 991.98px) {
  .sidebar {
    transform: translateX(-100%);
    box-shadow: 4px 0 24px rgba(0,0,0,.25);
  }
  .sidebar.open { transform: translateX(0); }

  .main-content { margin-left: 0; }

  .btn-sidebar-toggle { display: block; }

  .page-container { padding: 1rem .75rem; }

  .kpi-card { padding: 1rem; }
  .kpi-value { font-size: 1.5rem; }

  .topbar-title { font-size: .85rem; }

  /* Tabla responsive */
  .table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table-sigi td, .table-sigi th { white-space: nowrap; font-size: .75rem; }
}

@media (max-width: 575.98px) {
  .login-card { padding: 1.8rem 1.2rem; }
  .page-container { padding: .75rem .5rem; }
}

/* ─── OVERLAY SIDEBAR (MOBILE) ───────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 1039;
}
.sidebar-overlay.active { display: block; }

/* ─── SCROLLBAR CUSTOM ───────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c8cfd8; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #a0a9b5; }

/* ─── PRINT STYLES ───────────────────────────────────────────── */
@media print {
  .sidebar, .topbar, .btn, .no-print { display: none !important; }
  .main-content { margin-left: 0 !important; }
  .card { box-shadow: none !important; }
}
