/* ════════════════════════════════════════════════════════════════
   main.css — AESS Sistema Jurídico Sindical CCSS
   Tipografía: Crimson Pro (jurídico/serif) + DM Sans (UI)
   Paleta: azul institucional (Navy #1F3864 + Accent #2E75B6)
   Estética: Software jurídico profesional de nivel enterprise
════════════════════════════════════════════════════════════════ */

/* ── Variables ────────────────────────────────────────────────── */
:root {
  /* Colores primarios — azul institucional (Navy + Accent) */
  --blue-950: #0a1628;
  --blue-900: #14264a;
  --blue-800: #1a3358;
  --blue-700: #1F3864;   /* Navy — color primario de marca */
  --blue-600: #2E75B6;   /* Accent — color secundario/hover de marca */
  --blue-500: #4a8fc9;
  --blue-400: #6ba8d8;
  --blue-200: #bfdbf7;
  --blue-100: #dbeafe;
  --blue-50:  #eff6ff;

  /* Antes "dorado judicial" — ahora remapeado a la escala azul para que
     todo el sistema use un solo esquema de marca (Navy + Accent), igual
     que el sistema de referencia. Se conserva el nombre de las variables
     para no tener que tocar cada regla que las usa. */
  --gold-700: #17325c;
  --gold-600: #1a3a6b;
  --gold-500: #2E75B6;
  --gold-400: #6ba8d8;
  --gold-200: #bfdbf7;
  --gold-100: #eff6ff;

  /* Semánticos */
  --success:   #16a34a;
  --success-bg:#dcfce7;
  --warning:   #d97706;
  --warning-bg:#fef3c7;
  --danger:    #dc2626;
  --danger-bg: #fee2e2;
  --info:      #0ea5e9;
  --info-bg:   #e0f2fe;

  /* Grises */
  --gray-950: #0c0f16;
  --gray-900: #111827;
  --gray-800: #1f2937;
  --gray-700: #374151;
  --gray-600: #4b5563;
  --gray-500: #6b7280;
  --gray-400: #9ca3af;
  --gray-300: #d1d5db;
  --gray-200: #e5e7eb;
  --gray-100: #f3f4f6;
  --gray-50:  #f9fafb;
  --white:    #ffffff;

  /* Superficies */
  --surface:       var(--white);
  --surface-2:     var(--gray-50);
  --surface-3:     var(--gray-100);
  --border:        var(--gray-200);
  --border-strong: var(--gray-300);

  /* Aliases de fondo (usados en dashboard) */
  --bg-card:       var(--white);
  --bg-soft:       var(--gray-50);

  /* Texto */
  --text-primary:   var(--gray-900);
  --text-secondary: var(--gray-600);
  --text-muted:     var(--gray-400);

  /* Tipografía */
  --font-display: 'Crimson Pro', Georgia, serif;
  --font-ui:      'DM Sans', system-ui, sans-serif;
  --font-mono:    'JetBrains Mono', 'Fira Code', monospace;

  /* Radios */
  --radius-sm:  4px;
  --radius:     8px;
  --radius-md:  10px;
  --radius-lg:  14px;
  --radius-xl:  18px;
  --radius-2xl: 24px;

  /* Sombras */
  --shadow-xs:  0 1px 2px rgba(0,0,0,.05);
  --shadow-sm:  0 1px 4px rgba(0,0,0,.08);
  --shadow:     0 2px 8px rgba(0,0,0,.10);
  --shadow-md:  0 4px 16px rgba(0,0,0,.12);
  --shadow-lg:  0 8px 32px rgba(0,0,0,.15);
  --shadow-xl:  0 16px 48px rgba(0,0,0,.20);

  /* Transición */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --dur: 180ms;
}

/* ── Reset ────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; -webkit-font-smoothing: antialiased; }
body { font-family: var(--font-ui); color: var(--text-primary); background: var(--gray-100); }
a { color: inherit; text-decoration: none; }
button { font-family: var(--font-ui); cursor: pointer; border: none; background: none; }
input, textarea, select { font-family: var(--font-ui); font-size: inherit; }
img { max-width: 100%; display: block; }

/* ── Scrollbar ────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }

/* ── Animaciones ──────────────────────────────────────────────── */
@keyframes fadeUp   { from { opacity:0; transform:translateY(8px)  } to { opacity:1; transform:translateY(0)  } }
@keyframes fadeIn   { from { opacity:0 }                              to { opacity:1 }                           }
@keyframes slideIn  { from { opacity:0; transform:translateX(-12px)} to { opacity:1; transform:translateX(0)   } }
@keyframes spin     { to { transform: rotate(360deg) } }
@keyframes pulse    { 0%,100%{opacity:1} 50%{opacity:.4} }
@keyframes popIn    { from { opacity:0; transform:scale(.92) } to { opacity:1; transform:scale(1) } }
@keyframes shimmer  {
  0%   { background-position: -400px 0 }
  100% { background-position:  400px 0 }
}

/* ════════════════════════════════════════════════════════════════
   COMPONENTES COMPARTIDOS
════════════════════════════════════════════════════════════════ */

/* Botones */
.ph-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: var(--radius-md);
  font-size: 12.5px; font-weight: 600; line-height: 1;
  transition: all var(--dur) var(--ease); white-space: nowrap;
}
.ph-btn--primary {
  background: var(--blue-700); color: var(--white);
  box-shadow: 0 1px 3px rgba(26,58,107,.35);
}
.ph-btn--primary:hover { background: var(--blue-800); box-shadow: 0 2px 8px rgba(26,58,107,.4); }
.ph-btn--ghost {
  background: transparent; color: var(--text-secondary);
  border: 1px solid var(--border-strong);
}
.ph-btn--ghost:hover { background: var(--gray-100); color: var(--text-primary); }
.ph-btn--danger { background: var(--danger-bg); color: var(--danger); }
.ph-btn--danger:hover { background: var(--danger); color: #fff; }
.ph-btn i { font-size: 15px; }

/* Panel header */
.panel-header {
  padding: 16px 20px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--white);
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
}
.ph-left { display: flex; align-items: center; gap: 10px; }
.ph-left h2 {
  font-family: var(--font-display); font-size: 1.3rem; font-weight: 700;
  display: flex; align-items: center; gap: 8px;
}
.ph-left h2 i { font-size: 1.2rem; color: var(--blue-700); }
.ph-count {
  font-size: 11px; font-weight: 500; color: var(--text-muted);
  background: var(--gray-100); padding: 2px 8px; border-radius: 99px;
}
.ph-actions { display: flex; align-items: center; gap: 8px; }
.ph-search {
  display: flex; align-items: center; gap: 6px;
  border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 6px 10px; background: var(--white);
}
.ph-search i { color: var(--text-muted); font-size: 14px; }
.ph-search input {
  border: none; outline: none; font-size: 12.5px;
  width: 180px; background: transparent; color: var(--text-primary);
}

/* El header de panel (título + acciones/botones) es un solo renglón sin
   wrap por defecto — con varios botones (filtros, buscador, "Nuevo...")
   esto se desborda del ancho de un celular y el botón queda invisible,
   empujado fuera de la pantalla sin ninguna forma de hacer scroll para
   alcanzarlo. Lo compartimos entre 9 paneles (Mensajes, Expedientes,
   Consultas, Afiliados, Audiencias, Admin, Casos, Documentos Modelo,
   Administradores), así que el arreglo va aquí una sola vez. */
@media (max-width: 640px) {
  .panel-header { flex-wrap: wrap; row-gap: 10px; }
  .ph-actions { flex-wrap: wrap; width: 100%; }
  .ph-search { flex: 1; min-width: 0; }
  .ph-search input { width: 100%; }
}

/* Panel body */
.panel-body {
  flex: 1; overflow-y: auto; padding: 20px;
  background: var(--surface-2);
}

/* Empty state */
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 64px 32px; text-align: center;
  color: var(--text-muted); gap: 12px;
}
.empty-state i { font-size: 3rem; opacity: .4; }
.empty-state h3 { font-size: 1rem; font-weight: 600; color: var(--text-secondary); }
.empty-state p  { font-size: .875rem; }

/* Modales */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(10,22,40,.55); backdrop-filter: blur(4px);
  z-index: 1000; display: none; align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--white); border-radius: var(--radius-xl);
  width: 560px; max-width: calc(100vw - 32px);
  box-shadow: var(--shadow-xl); animation: popIn .2s var(--ease);
  display: flex; flex-direction: column; max-height: 90vh; max-height: 90dvh;
}
.modal--lg { width: 680px; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px 16px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.modal-header h3 {
  font-family: var(--font-display); font-size: 1.15rem; font-weight: 700;
}
.modal-close {
  width: 30px; height: 30px; border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); transition: all var(--dur);
}
.modal-close:hover { background: var(--gray-100); color: var(--text-primary); }
.modal-body { padding: 20px 22px; overflow-y: auto; flex: 1; min-height: 0; }
.modal-footer {
  padding: 14px 22px 18px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 8px; flex-shrink: 0;
}

/* Formulario modal */
.mform-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px;
}
.mf-field { display: flex; flex-direction: column; gap: 5px; }
.mf-field--wide { grid-column: 1 / -1; }
.mf-field label { font-size: 11.5px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: .4px; }
.mf-field input,
.mf-field select,
.mf-field textarea {
  border: 1.5px solid var(--border); border-radius: var(--radius-md);
  padding: 8px 10px; font-size: 13px; outline: none;
  transition: border-color var(--dur); background: var(--white);
}
.mf-field input:focus,
.mf-field select:focus,
.mf-field textarea:focus { border-color: var(--blue-600); }
.mf-field textarea { resize: vertical; font-family: var(--font-ui); }

/* Toasts */
#toasts {
  position: fixed; top: 64px; right: 16px;
  z-index: 9999; display: flex; flex-direction: column;
  gap: 8px; pointer-events: none; max-width: 320px;
}
.toast {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 12px 14px;
  display: flex; gap: 10px; align-items: flex-start;
  pointer-events: all; animation: fadeUp .25s var(--ease);
  box-shadow: var(--shadow-md);
}
.toast-ico {
  width: 32px; height: 32px; border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 15px;
}
.toast-ico.ok   { background: var(--success-bg); color: var(--success); }
.toast-ico.err  { background: var(--danger-bg);  color: var(--danger);  }
.toast-ico.warn { background: var(--warning-bg); color: var(--warning); }
.toast-ico.info { background: var(--info-bg);    color: var(--info);    }
.toast-body h4  { font-size: 12px; font-weight: 700; }
.toast-body p   { font-size: 11px; color: var(--text-secondary); margin-top: 2px; }

/* Estado chips */
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 99px;
  font-size: 11px; font-weight: 600;
}
.chip--active   { background: var(--success-bg); color: var(--success); }
.chip--resuelto { background: var(--info-bg);    color: var(--info);    }
.chip--archivado{ background: var(--gray-100);   color: var(--gray-500);}
.chip--pendiente{ background: var(--warning-bg); color: var(--warning); }
