/* ============================================================
   SISTEMA DELEGADOS FEDEF — Estilos globales
   ============================================================ */

:root {
  --primary:       #1a3a5c;
  --primary-dark:  #122840;
  --primary-light: #2c5282;
  --accent:        #2f80ed;
  --success:       #16a34a;
  --warning:       #d97706;
  --danger:        #dc2626;
  --gray-50:       #f9fafb;
  --gray-100:      #f3f4f6;
  --gray-200:      #e5e7eb;
  --gray-300:      #d1d5db;
  --gray-400:      #9ca3af;
  --gray-500:      #6b7280;
  --gray-600:      #4b5563;
  --gray-700:      #374151;
  --gray-800:      #1f2937;
  --border-color:  #dde3ea;
  --radius:        6px;
  --radius-lg:     10px;
  --shadow-sm:     0 1px 3px rgba(0,0,0,.08);
  --shadow:        0 4px 16px rgba(0,0,0,.10);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: .9rem; color: var(--gray-800);
  background: #eef2f7; min-height: 100vh;
  display: flex; flex-direction: column;
}

/* ── Layout ─────────────────────────────────────────────── */
.header {
  background: var(--primary); color: white;
  padding: .75rem 0; box-shadow: var(--shadow);
  position: sticky; top: 0; z-index: 100;
}
.header .container { display: flex; align-items: center; justify-content: space-between; }
.logo { display: flex; align-items: center; gap: .6rem; font-weight: 700; font-size: 1rem; }
.logo-img { height: 34px; width: auto; }
.nav { display: flex; align-items: center; gap: .5rem; }
.nav-link {
  color: rgba(255,255,255,.85); text-decoration: none;
  padding: .35rem .8rem; border-radius: var(--radius);
  font-size: .85rem; transition: background .15s;
}
.nav-link:hover, .nav-link.active { background: rgba(255,255,255,.15); color: white; }

.container { max-width: 1100px; margin: 0 auto; padding: 0 1rem; }
.main  { flex: 1; padding: 1.5rem 0 2.5rem; }
.footer {
  background: var(--primary); color: rgba(255,255,255,.7);
  text-align: center; padding: .75rem;
  font-size: .78rem;
}

/* ── Cards ──────────────────────────────────────────────── */
.card {
  background: white; border: 1px solid var(--border-color);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card-body { padding: 1.25rem; }
.card-header {
  padding: .9rem 1.25rem;
  background: var(--gray-50);
  border-bottom: 1px solid var(--border-color);
  font-weight: 600; font-size: .95rem;
}

/* ── Botones ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .5rem 1.1rem; border-radius: var(--radius);
  font-size: .875rem; font-weight: 600; cursor: pointer;
  border: none; text-decoration: none; transition: all .15s;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary   { background: var(--primary); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-success   { background: var(--success); color: white; }
.btn-success:hover:not(:disabled) { background: #15803d; }
.btn-danger    { background: var(--danger);  color: white; }
.btn-danger:hover:not(:disabled)  { background: #b91c1c; }
.btn-outline   { background: transparent; border: 1.5px solid var(--primary); color: var(--primary); }
.btn-outline:hover:not(:disabled) { background: var(--primary); color: white; }
.btn-ghost     { background: transparent; color: var(--gray-600); }
.btn-ghost:hover:not(:disabled)   { background: var(--gray-100); }
.btn-sm        { padding: .3rem .75rem; font-size: .8rem; }
.btn-lg        { padding: .7rem 1.5rem; font-size: .95rem; }

/* ── Forms ───────────────────────────────────────────────── */
.form-group  { margin-bottom: .9rem; }
.form-group label {
  display: block; margin-bottom: .3rem;
  font-size: .82rem; font-weight: 600; color: var(--gray-700);
}
.form-control {
  width: 100%; padding: .45rem .75rem;
  border: 1.5px solid var(--gray-300); border-radius: var(--radius);
  font-size: .875rem; color: var(--gray-800); background: white;
  transition: border-color .15s, box-shadow .15s;
}
.form-control:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47,128,237,.12);
}
.form-control:read-only { background: #f0f4f8; cursor: not-allowed; }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 90px; }

/* ── Alerts ──────────────────────────────────────────────── */
.alert {
  padding: .75rem 1rem; border-radius: var(--radius);
  border: 1px solid; margin-bottom: 1rem; font-size: .875rem;
}
.alert-success { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.alert-warning { background: #fffbeb; border-color: #fcd34d; color: #92400e; }
.alert-danger  { background: #fef2f2; border-color: #fca5a5; color: #991b1b; }
.alert-info    { background: #eff6ff; border-color: #93c5fd; color: #1e40af; }

/* ── Badges ──────────────────────────────────────────────── */
.badge {
  display: inline-block; padding: .2rem .6rem;
  border-radius: 20px; font-size: .72rem; font-weight: 600;
}
.badge-draft    { background: #f3f4f6; color: #374151; }
.badge-ready    { background: #eff6ff; color: #1d4ed8; }
.badge-pending  { background: #fffbeb; color: #92400e; }
.badge-signed   { background: #ecfdf5; color: #065f46; }
.badge-revoked  { background: #fef2f2; color: #991b1b; }

/* ── Table ───────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
table.table th {
  background: var(--gray-50); padding: .6rem .9rem;
  text-align: left; font-size: .78rem; font-weight: 700;
  color: var(--gray-600); text-transform: uppercase; letter-spacing: .04em;
  border-bottom: 2px solid var(--border-color);
}
table.table td {
  padding: .65rem .9rem; border-bottom: 1px solid var(--gray-100);
  font-size: .875rem; vertical-align: middle;
}
table.table tbody tr:hover td { background: var(--gray-50); }

/* ── Loading overlay ─────────────────────────────────────── */
.loading-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  z-index: 9999; gap: 1rem;
}
.spinner {
  width: 44px; height: 44px;
  border: 4px solid rgba(255,255,255,.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-overlay p { color: white; font-weight: 600; font-size: 1rem; }

/* ── Modal ───────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 5000; padding: 1rem;
}
.modal-box {
  background: white; border-radius: var(--radius-lg);
  box-shadow: var(--shadow); width: 100%; max-width: 440px;
  overflow: hidden; animation: popIn .2s ease;
}
@keyframes popIn { from { transform: scale(.92); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-header {
  padding: 1rem 1.25rem; font-weight: 700; font-size: 1rem;
  border-bottom: 1px solid var(--border-color);
}
.modal-body    { padding: 1.25rem; font-size: .9rem; color: var(--gray-700); }
.modal-footer  {
  padding: .9rem 1.25rem; display: flex; justify-content: flex-end; gap: .6rem;
  border-top: 1px solid var(--border-color); background: var(--gray-50);
}

/* ── Welcome section ─────────────────────────────────────── */
.welcome-section { margin-bottom: 1.25rem; }
.welcome-section h2 { font-size: 1.3rem; font-weight: 700; color: var(--primary); }
.welcome-section .subtitle { color: var(--gray-500); margin-top: .25rem; font-size: .875rem; }

/* ── Canvas firma ────────────────────────────────────────── */
.signature-container {
  border: 2px dashed var(--gray-300); border-radius: var(--radius);
  background: #fafafa; cursor: crosshair; touch-action: none;
  display: block; width: 100%;
}
.signature-container.has-sig { border-color: var(--success); border-style: solid; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 640px) {
  .logo span { display: none; }
  .btn-lg    { padding: .6rem 1rem; font-size: .875rem; }
}
