/**
 * Design System — GestionCFE
 * Tokens, base reset, layout y componentes compartidos.
 * Cada dashboard HTML importa este archivo + sus estilos específicos.
 * 
 * Patrones: sidebar 260px, shell 1400px máx, padding 40px 48px,
 * cards border-radius 16px, accent #f59e0b (amber), dark theme.
 */

/* ─────────────────────────────────────────
   1. Google Fonts (importar en cada HTML)
   ───────────────────────────────────────── */
/* <link href="https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet" /> */

/* ─────────────────────────────────────────
   2. Design Tokens (CSS Custom Properties)
   ───────────────────────────────────────── */
:root {
  /* Colores base */
  --bg:           #0c0c0e;
  --bg-subtle:    #141418;
  --card:         #1a1a1f;
  --card-hover:   #222228;

  /* Texto */
  --text:         #e8e8ec;
  --text-dim:     #9898a0;
  --muted:        #6b6b76;

  /* Acento principal (amber) */
  --accent:       #f59e0b;
  --accent-glow:  rgba(245, 158, 11, 0.15);
  --accent-dim:   #b4730a;

  /* Estados semánticos */
  --success:      #22c55e;
  --success-bg:   rgba(34, 197, 94, 0.12);
  --error:       #ef4444;
  --error-bg:    rgba(239, 68, 68, 0.12);
  --warn:        #eab308;
  --warn-bg:     rgba(234, 179, 8, 0.12);
  --running:     #3b82f6;
  --running-bg:  rgba(59, 130, 246, 0.12);

  /* Bordes */
  --border:       rgba(255, 255, 255, 0.06);
  --border-hover: rgba(255, 255, 255, 0.12);

  /* Sidebar */
  --sidebar-bg:   #08080a;
  --sidebar-border: rgba(255, 255, 255, 0.04);

  /* Espaciado base (8px grid) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;

  /* Radios */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 999px;

  /* Sombras */
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.5);
  --shadow-card: 0 4px 20px rgba(0,0,0,0.25);
  --shadow-accent: 0 4px 12px rgba(245, 158, 11, 0.3);

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

  /* Dimensiones */
  --sidebar-width: 260px;
  --shell-max: 1400px;
}

/* ─────────────────────────────────────────
   3. Base Reset
   ───────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
  margin: 0;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

p { margin: 0; line-height: 1.65; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--bg-subtle);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

pre {
  background: var(--bg-subtle);
  color: var(--text-dim);
  padding: var(--space-5);
  border-radius: var(--radius-lg);
  overflow: auto;
  font-family: var(--font-mono);
  font-size: 13px;
  border: 1px solid var(--border);
  max-height: 60vh;
}

pre code {
  background: transparent;
  border: none;
  padding: 0;
  font-size: inherit;
}

::selection {
  background: var(--accent);
  color: #000;
}

/* ─────────────────────────────────────────
   4. Sidebar (260px fixed)
   ───────────────────────────────────────── */
.sidebar {
  position: fixed;
  left: 0; top: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  z-index: 10;
}

.sidebar-header {
  padding: var(--space-8) var(--space-6);
  border-bottom: 1px solid var(--sidebar-border);
  position: relative;
  overflow: hidden;
}

.sidebar-header::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), transparent);
}

.sidebar-logo {
  color: var(--text);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.sidebar-subtitle {
  color: var(--muted);
  font-size: 11px;
  margin-top: 6px;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.sidebar-nav {
  flex: 1;
  padding: var(--space-5) var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  overflow-y: auto;
}

.sidebar-section-title {
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: var(--space-5) var(--space-3) var(--space-2);
  font-family: var(--font-mono);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-3);
  border-radius: 10px;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid transparent;
  position: relative;
}

.nav-item:hover {
  background: rgba(255,255,255,0.03);
  color: var(--text);
  border-color: var(--border);
  text-decoration: none;
}

.nav-item.active {
  background: var(--accent-glow);
  color: var(--accent);
  border-color: rgba(245, 158, 11, 0.2);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 60%;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}

.nav-item svg {
  width: 20px; height: 20px;
  flex-shrink: 0;
  opacity: 0.7;
}

.nav-item.active svg { opacity: 1; }

/* ─────────────────────────────────────────
   5. Main Layout
   ───────────────────────────────────────── */
.main {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  background:
    radial-gradient(ellipse at 20% 0%, rgba(245, 158, 11, 0.03) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 100%, rgba(59, 130, 246, 0.02) 0%, transparent 50%),
    var(--bg);
}

.shell {
  max-width: var(--shell-max);
  margin: 0 auto;
  padding: var(--space-10) var(--space-12) 80px;
}

/* ─────────────────────────────────────────
   6. Page Header
   ───────────────────────────────────────── */
.page-header {
  margin-bottom: var(--space-8);
  animation: fadeInUp 0.5s ease-out;
}

.page-header-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-6);
  flex-wrap: wrap;
}

.page-title {
  margin: 0;
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, var(--text) 0%, var(--text-dim) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.page-meta {
  color: var(--muted);
  font-size: 14px;
  margin-top: var(--space-2);
  font-family: var(--font-mono);
}

.page-actions {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
  align-items: center;
}

/* ─────────────────────────────────────────
   7. Stats Bar
   ───────────────────────────────────────── */
.stats-bar {
  display: flex;
  gap: var(--space-4);
  margin-bottom: var(--space-7);
  flex-wrap: wrap;
  animation: fadeInUp 0.5s ease-out 0.1s both;
}

.stat-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
  min-width: 180px;
  flex: 1;
}

.stat-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-family: var(--font-mono);
  margin-bottom: var(--space-2);
}

.stat-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
  word-break: break-word;
}

.stat-value.success { color: var(--success); }
.stat-value.error   { color: var(--error); }
.stat-value.warn    { color: var(--warn); }
.stat-value.running { color: var(--running); }

.stat-value code {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-dim);
  background: transparent;
  border: none;
  padding: 0;
}

/* ─────────────────────────────────────────
   8. Card
   ───────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  margin-bottom: var(--space-6);
  animation: fadeInUp 0.5s ease-out 0.15s both;
}

.card-header {
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-4);
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.card-title::before {
  content: '';
  width: 8px; height: 8px;
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 12px var(--accent);
}

.card-body {
  padding: var(--space-6);
}

.card-footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border);
  background: rgba(0,0,0,0.15);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
}

/* ─────────────────────────────────────────
   9. Form Elements
   ───────────────────────────────────────── */
input, select, textarea {
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  color: var(--text);
  padding: 10px 14px;
  font-size: 13px;
  font-family: var(--font-mono);
  transition: border-color 0.2s, box-shadow 0.2s;
  width: 100%;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

textarea {
  resize: vertical;
  min-height: 100px;
}

select option {
  background: var(--bg-subtle);
}

label.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  font-size: 12px;
  color: var(--muted);
  font-family: var(--font-mono);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4);
}

.form-grid .full { grid-column: 1 / -1; }

@media (max-width: 720px) {
  .form-grid { grid-template-columns: 1fr; }
}

/* ─────────────────────────────────────────
   10. Buttons
   ───────────────────────────────────────── */
button {
  cursor: pointer;
  background: var(--accent);
  border: none;
  color: #000;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-family: var(--font-sans);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

button:hover {
  background: #fbbf24;
  transform: translateY(-1px);
  box-shadow: var(--shadow-accent);
}

button:active { transform: translateY(0); }

button.secondary {
  background: var(--card-hover);
  color: var(--text);
  border: 1px solid var(--border);
}

button.secondary:hover {
  background: var(--card-hover);
  border-color: var(--border-hover);
  transform: none;
  box-shadow: none;
}

button.danger {
  background: var(--error);
  color: #fff;
}

button.danger:hover {
  background: #dc2626;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* Ghost buttons (text-like) */
.btn-link {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: var(--radius-md);
  font-size: 12px;
  font-family: var(--font-mono);
  transition: all 0.2s;
  cursor: pointer;
}

.btn-link:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-glow);
}

.btn-link.approve { color: var(--success); }
.btn-link.approve:hover {
  color: #16a34a;
  border-color: var(--success);
  background: var(--success-bg);
}

.btn-link.reject { color: var(--error); }
.btn-link.reject:hover {
  color: #dc2626;
  border-color: var(--error);
  background: var(--error-bg);
}

/* ─────────────────────────────────────────
   11. Table
   ───────────────────────────────────────── */
table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  text-align: left;
  padding: 14px 20px;
  font-size: 13px;
}

th {
  color: var(--muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-family: var(--font-mono);
  background: rgba(0,0,0,0.2);
  border-bottom: 1px solid var(--border);
}

td {
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text);
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,0.02); }

td code {
  font-size: 11px;
  color: var(--text-dim);
  background: var(--bg-subtle);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.actions-cell {
  display: flex;
  gap: var(--space-2);
  align-items: center;
}

/* ─────────────────────────────────────────
   12. Pills / Status Badges
   ───────────────────────────────────────── */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border: 1px solid;
}

.pill::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.pill.success  { color: var(--success);  background: var(--success-bg);  border-color: rgba(34,197,94,0.2); }
.pill.error    { color: var(--error);    background: var(--error-bg);    border-color: rgba(239,68,68,0.2); }
.pill.warn    { color: var(--warn);     background: var(--warn-bg);     border-color: rgba(234,179,8,0.2); }
.pill.pending { color: var(--warn);     background: var(--warn-bg);     border-color: rgba(234,179,8,0.2); }
.pill.running { color: var(--running);   background: var(--running-bg);   border-color: rgba(59,130,246,0.2); }

/* ─────────────────────────────────────────
   13. Banners / Alerts
   ───────────────────────────────────────── */
.banner {
  padding: 14px 18px;
  border-radius: var(--radius-lg);
  font-size: 13px;
  margin-bottom: var(--space-5);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
}

.banner.error   { color: var(--error);   background: var(--error-bg);   border: 1px solid rgba(239,68,68,0.2); }
.banner.warn    { color: var(--warn);    background: var(--warn-bg);    border: 1px solid rgba(234,179,8,0.2); }
.banner.success { color: var(--success); background: var(--success-bg); border: 1px solid rgba(34,197,94,0.2); }

.banner-actions { display: flex; gap: var(--space-2); flex-shrink: 0; }
.banner button { padding: 4px 10px; font-size: 12px; }

/* ─────────────────────────────────────────
   14. Login / Auth Screen
   ───────────────────────────────────────── */
.login {
  max-width: 400px;
  margin: 120px auto;
  padding: var(--space-10);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.03),
    0 20px 50px rgba(0,0,0,0.5);
  animation: fadeInUp 0.4s ease-out;
}

.login h2 { font-size: 24px; font-weight: 700; margin: 0 0 var(--space-2); }
.login .muted { color: var(--muted); font-size: 14px; }
.login input { width: 100%; margin: var(--space-4) 0; }
.login button { width: 100%; margin-top: var(--space-2); padding: 14px; font-size: 14px; }

/* ─────────────────────────────────────────
   15. Tab Navigation
   ───────────────────────────────────────── */
.tab-nav {
  position: sticky; top: 0; z-index: 5;
  display: flex; gap: var(--space-8); align-items: center;
  padding: var(--space-3) 0 0;
  margin: 0 0 var(--space-6);
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(8,8,10,0.96) 70%, rgba(8,8,10,0.6) 100%);
  backdrop-filter: blur(8px);
  animation: fadeInUp 0.5s ease-out 0.12s both;
}

.tab-btn {
  background: transparent; border: none; color: var(--text-dim);
  padding: var(--space-3) 0 var(--space-4);
  margin: 0; cursor: pointer;
  font-family: var(--font-sans); font-size: 14px; font-weight: 600;
  letter-spacing: -0.005em;
  border-bottom: 2px solid transparent;
  transition: color 0.18s ease, border-color 0.18s ease;
  border-radius: 0;
}

.tab-btn:hover { color: var(--text); background: transparent; transform: none; box-shadow: none; }
.tab-btn[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.tab-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 4px; }

.tab-help {
  color: var(--muted); font-size: 12px; cursor: help;
  border: 1px solid var(--border); padding: 1px 7px; border-radius: var(--radius-full);
  font-family: var(--font-mono); margin-left: auto;
}

.tab-help:hover { color: var(--accent); border-color: var(--accent); }
.tab-panel { animation: fadeInUp 0.35s ease-out both; }

.tab-notice {
  color: var(--text-dim); font-size: 12px;
  background: var(--bg-subtle); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 10px 14px; margin: 0 0 var(--space-5);
  font-family: var(--font-mono);
}

/* ─────────────────────────────────────────
   16. Toolbar
   ───────────────────────────────────────── */
.toolbar {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-6);
  padding-bottom: var(--space-5);
  border-bottom: 1px solid var(--border);
}

.toolbar-left {
  color: var(--muted);
  font-size: 13px;
  font-family: var(--font-mono);
  min-width: 0;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.toolbar-left strong { color: var(--text); }
.toolbar-left code { font-size: 12px; }

.toolbar-actions { display: flex; gap: var(--space-3); flex-wrap: wrap; }

/* ─────────────────────────────────────────
   17. Empty / Loading States
   ───────────────────────────────────────── */
.empty {
  padding: var(--space-10) var(--space-6);
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  padding: var(--space-10);
  color: var(--muted);
  font-size: 13px;
}

.loading::before {
  content: '';
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ─────────────────────────────────────────
   18. Pagination
   ───────────────────────────────────────── */
.pager {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  padding: var(--space-3) var(--space-5);
}

.pager .spacer { flex: 1; }

/* ─────────────────────────────────────────
   19. Utilities
   ───────────────────────────────────────── */
.muted { color: var(--muted); font-size: 14px; }
.text-success { color: var(--success); }
.text-error   { color: var(--error); }
.text-warn    { color: var(--warn); }
.text-dim     { color: var(--text-dim); }

.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.w-full { width: 100%; }
.truncate {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ─────────────────────────────────────────
   20. Animations
   ───────────────────────────────────────── */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
@keyframes scaleIn { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }
@keyframes spin { to { transform: rotate(360deg); } }

/* ─────────────────────────────────────────
   21. Scrollbar
   ───────────────────────────────────────── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border-hover); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ─────────────────────────────────────────
   22. Responsive
   ───────────────────────────────────────── */
@media (max-width: 1200px) {
  .shell { padding: var(--space-8) var(--space-6) 60px; }
}

@media (max-width: 900px) {
  .sidebar { width: 200px; }
  .main { margin-left: 200px; }
  .shell { padding: var(--space-6) var(--space-4) 48px; }
  .page-title { font-size: 24px; }
  .stats-bar { gap: var(--space-3); }
  .stat-item { min-width: 140px; }
}

@media (max-width: 640px) {
  .sidebar { display: none; }
  .main { margin-left: 0; }
  .shell { padding: var(--space-4) var(--space-3) 40px; }
  .card-body { padding: var(--space-4); }
  .card-header { padding: var(--space-4); }
  .toolbar { flex-direction: column; align-items: flex-start; }
  .toolbar-left, .toolbar-actions { width: 100%; }
}
