/* ============================================================
   CARRERA 360 — main.css
   Fuente: Plus Jakarta Sans (UI) + JetBrains Mono (números)
   Temas: dark (por defecto) | light
   ============================================================ */

/* ── Google Fonts ─────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;600&display=swap');

/* ── Reset ────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; }
a { color: inherit; text-decoration: none; }

/* ── Variables: tema oscuro (por defecto) ─────────────────── */
:root,
:root[data-theme="dark"] {
  --bg-base:         #060d1a;
  --bg-surface:      #0b1629;
  --bg-card:         #0f1f38;
  --bg-hover:        rgba(37, 99, 235, 0.08);
  --bg-input:        #0a1525;
  --bg-overlay:      rgba(0, 0, 0, 0.7);

  --border:          rgba(255, 255, 255, 0.06);
  --border-strong:   rgba(255, 255, 255, 0.12);
  --border-focus:    rgba(37, 99, 235, 0.6);

  --text-primary:    #f0f6ff;
  --text-secondary:  #4b6a9a;
  --text-muted:      #2d4060;
  --text-inverse:    #060d1a;
  --text-link:       #93c5fd;

  --accent:          #2563eb;
  --accent-hover:    #3b82f6;
  --accent-light:    #93c5fd;
  --accent-subtle:   rgba(37, 99, 235, 0.12);

  --positive:        #22c55e;
  --positive-bg:     rgba(34, 197, 94, 0.1);
  --negative:        #f87171;
  --negative-bg:     rgba(248, 113, 113, 0.1);
  --warning:         #fbbf24;
  --warning-bg:      rgba(251, 191, 36, 0.1);
  --info:            #38bdf8;
  --info-bg:         rgba(56, 189, 248, 0.1);

  --shadow-card:     none;
  --shadow-dropdown: 0 8px 32px rgba(0, 0, 0, 0.6);
  --shadow-sidebar:  none;

  --radius-sm:  6px;
  --radius-md:  10px;
  --radius-lg:  14px;
  --radius-xl:  18px;
  --radius-pill: 999px;
}

/* ── Variables: tema claro ────────────────────────────────── */
:root[data-theme="light"] {
  --bg-base:         #f5f3ef;
  --bg-surface:      #faf9f7;
  --bg-card:         #ffffff;
  --bg-hover:        rgba(37, 99, 235, 0.06);
  --bg-input:        #ffffff;
  --bg-overlay:      rgba(0, 0, 0, 0.4);

  --border:          #e5e0d8;
  --border-strong:   #d1cbc2;
  --border-focus:    rgba(37, 99, 235, 0.4);

  --text-primary:    #1a1614;
  --text-secondary:  #78716c;
  --text-muted:      #c4bfb9;
  --text-inverse:    #ffffff;
  --text-link:       #2563eb;

  --accent:          #2563eb;
  --accent-hover:    #1d4ed8;
  --accent-light:    #bfdbfe;
  --accent-subtle:   rgba(37, 99, 235, 0.08);

  --positive:        #16a34a;
  --positive-bg:     rgba(22, 163, 74, 0.08);
  --negative:        #dc2626;
  --negative-bg:     rgba(220, 38, 38, 0.08);
  --warning:         #d97706;
  --warning-bg:      rgba(217, 119, 6, 0.08);
  --info:            #0284c7;
  --info-bg:         rgba(2, 132, 199, 0.08);

  --shadow-card:     0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-dropdown: 0 8px 32px rgba(0,0,0,.12);
  --shadow-sidebar:  2px 0 12px rgba(0,0,0,.06);
}

/* ── Base ─────────────────────────────────────────────────── */
html { font-size: 17px; }

body {
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  background: var(--bg-surface);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* ── Layout global ────────────────────────────────────────── */
.layout {
  display: flex;
  min-height: 100vh;
}

.layout-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg-surface);
}

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
  width: 200px;
  flex-shrink: 0;
  background: var(--bg-base);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  box-shadow: var(--shadow-sidebar);
  transition: width 0.2s ease, transform 0.2s ease;
  z-index: 50;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-logo-icon {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
}

.sidebar-logo-text {
  font-size: 0.875rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-nav {
  flex: 1;
  padding: 8px 0;
  overflow-y: auto;
}

.sidebar-section {
  padding: 0 8px;
}

.sidebar-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 6px 12px;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
  overflow: hidden;
  border-left: 3px solid transparent;
  margin: 1px 0;
}

.sidebar-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.sidebar-item--active {
  background: var(--accent-subtle);
  color: var(--accent-light);
  border-left-color: var(--accent);
  font-weight: 600;
}

.sidebar-icon {
  font-size: 1rem;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-label {
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-footer {
  padding: 8px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* ── Topbar ───────────────────────────────────────────────── */
.topbar {
  height: 52px;
  background: var(--bg-base);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 40;
  flex-shrink: 0;
}

.topbar-hamburger {
  display: none;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  font-size: 1.1rem;
  line-height: 1;
}

.topbar-hamburger:hover { color: var(--text-primary); background: var(--bg-hover); }

.topbar-spacer { flex: 1; }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-divider {
  width: 1px;
  height: 20px;
  background: var(--border-strong);
}

.btn-theme {
  background: none;
  border: 1px solid var(--border-strong);
  color: var(--text-secondary);
  cursor: pointer;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  line-height: 1;
}

.btn-theme:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--accent);
}

/* ── Área de contenido ────────────────────────────────────── */
.content {
  flex: 1;
  padding: 24px;
}

.content-narrow  { max-width: 800px; margin: 0 auto; }
.content-medium  { max-width: 960px; margin: 0 auto; }
.content-wide    { max-width: 1200px; margin: 0 auto; }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 1023px) {
  .sidebar {
    width: 52px;
  }
  .sidebar-label,
  .sidebar-logo-text {
    display: none;
  }
  .sidebar-item {
    justify-content: center;
    border-left-width: 0;
    border-bottom: 2px solid transparent;
    padding: 10px 0;
  }
  .sidebar-item--active {
    border-bottom-color: var(--accent);
  }
  .sidebar-logo {
    justify-content: center;
  }
  .topbar-hamburger {
    display: none;
  }
}

@media (max-width: 767px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    width: 200px;
    transform: translateX(-100%);
    z-index: 100;
  }
  .sidebar.sidebar--open {
    transform: translateX(0);
  }
  .sidebar-label,
  .sidebar-logo-text {
    display: block;
  }
  .sidebar-item {
    justify-content: flex-start;
    border-left-width: 3px;
    border-bottom-width: 0;
    padding: 8px 10px;
  }
  .topbar-hamburger {
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .content {
    padding: 12px;
  }
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--bg-overlay);
    z-index: 99;
  }
  .sidebar-overlay.sidebar-overlay--visible {
    display: block;
  }
}

@media (max-width: 480px) {
  .content { padding: 8px; }
}

/* ── Auth / layout centrado ───────────────────────────────── */
.layout-auth {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-surface);
  padding: 16px;
}

.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 36px 32px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-dropdown);
}

.auth-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 28px;
}

.auth-logo-text {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text-primary);
}

/* ── Tipografía ───────────────────────────────────────────── */
.page-title {
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.page-subtitle {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

.section-label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
}

.num {
  font-family: 'JetBrains Mono', monospace;
}

/* ── Cards ────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-card);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.card--accent   { border-left: 3px solid var(--accent); }
.card--positive { border-left: 3px solid var(--positive); }
.card--negative { border-left: 3px solid var(--negative); }
.card--warning  { border-left: 3px solid var(--warning); }

/* ── Botones ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s, opacity 0.15s;
  border: 1px solid transparent;
  white-space: nowrap;
  line-height: 1.4;
  text-decoration: none;
}

.btn:disabled, .btn--loading { opacity: 0.65; cursor: not-allowed; pointer-events: none; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-secondary {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border-strong);
}
.btn-secondary:hover { background: var(--bg-hover); color: var(--text-primary); }

.btn-danger {
  background: transparent;
  color: var(--negative);
  border-color: var(--negative);
}
.btn-danger:hover { background: var(--negative-bg); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
  padding-left: 8px; padding-right: 8px;
}
.btn-ghost:hover { color: var(--text-primary); background: var(--bg-hover); }

.btn--sm { padding: 5px 12px; font-size: 0.8125rem; }
.btn--lg { padding: 11px 22px; font-size: 1rem; }

.btn--loading::before {
  content: '';
  width: 14px; height: 14px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  flex-shrink: 0;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Formularios ──────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 5px; }

.form-label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
}

.form-input {
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 9px 12px;
  color: var(--text-primary);
  font-size: 0.9rem;
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
}

.form-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--border-focus);
}

.form-input::placeholder { color: var(--text-muted); }

select.form-input { cursor: pointer; }

textarea.form-input { resize: vertical; min-height: 90px; }

.form-hint {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.form-error {
  font-size: 0.8rem;
  color: var(--negative);
}

.form-row {
  display: grid;
  gap: 16px;
}

.form-row--2 { grid-template-columns: 1fr 1fr; }
.form-row--3 { grid-template-columns: 1fr 1fr 1fr; }

@media (max-width: 600px) {
  .form-row--2, .form-row--3 { grid-template-columns: 1fr; }
}

.form-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  padding-top: 8px;
}

/* ── Tablas ───────────────────────────────────────────────── */
.table-container {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.table th {
  background: var(--bg-base);
  color: var(--text-secondary);
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table th.num { text-align: right; }

.table td {
  padding: 11px 14px;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.table tbody tr:last-child td { border-bottom: none; }

.table tbody tr:hover { background: var(--bg-hover); cursor: default; }
.table tbody tr.clickable:hover { cursor: pointer; }

.table td.num {
  font-family: 'JetBrains Mono', monospace;
  text-align: right;
  font-size: 0.875rem;
}

.table .positive { color: var(--positive); }
.table .negative { color: var(--negative); }
.table .muted    { color: var(--text-secondary); }

/* ── Badges ───────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: var(--radius-pill);
  font-size: 0.7rem;
  font-weight: 600;
  line-height: 1.6;
  white-space: nowrap;
}

.badge--blue   { background: var(--accent-subtle); color: var(--accent-light); }
.badge--green  { background: var(--positive-bg);   color: var(--positive); }
.badge--red    { background: var(--negative-bg);   color: var(--negative); }
.badge--yellow { background: var(--warning-bg);    color: var(--warning); }
.badge--gray   { background: var(--bg-hover);      color: var(--text-secondary); }

/* ── Alertas ──────────────────────────────────────────────── */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  border-left: 3px solid;
  font-size: 0.875rem;
  line-height: 1.4;
}

.alert a { text-decoration: underline; }

.alert--info    { background: var(--info-bg);     border-color: var(--info);     color: var(--info); }
.alert--success { background: var(--positive-bg); border-color: var(--positive); color: var(--positive); }
.alert--warning { background: var(--warning-bg);  border-color: var(--warning);  color: var(--warning); }
.alert--error   { background: var(--negative-bg); border-color: var(--negative); color: var(--negative); }

.alert__body { flex: 1; color: var(--text-primary); }
.alert__body strong { font-weight: 600; }

.alert--dismissible .alert__close {
  background: none; border: none; cursor: pointer;
  color: var(--text-secondary); font-size: 1rem; line-height: 1;
  padding: 0; flex-shrink: 0;
}
.alert--dismissible .alert__close:hover { color: var(--text-primary); }

/* ── Empty states ─────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 48px 24px;
  gap: 12px;
}

.empty-state__icon {
  font-size: 2.5rem;
  opacity: 0.35;
  line-height: 1;
}

.empty-state__title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.empty-state__desc {
  font-size: 0.875rem;
  color: var(--text-secondary);
  max-width: 320px;
  line-height: 1.5;
}

/* ── Breadcrumb ───────────────────────────────────────────── */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.breadcrumb a:hover { color: var(--text-primary); }

.breadcrumb__sep {
  color: var(--text-muted);
  font-size: 0.75rem;
}

/* ── Página header ────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.page-header__actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

/* ── Utilidades ───────────────────────────────────────────── */
.text-positive { color: var(--positive); }
.text-negative { color: var(--negative); }
.text-warning  { color: var(--warning); }
.text-muted    { color: var(--text-secondary); }
.text-right    { text-align: right; }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 6px; }
.mt-2 { margin-top: 12px; }
.mt-3 { margin-top: 18px; }
.mt-4 { margin-top: 24px; }
.mt-6 { margin-top: 36px; }
.mb-1 { margin-bottom: 6px; }
.mb-2 { margin-bottom: 12px; }
.mb-3 { margin-bottom: 18px; }
.mb-4 { margin-bottom: 24px; }
.mb-6 { margin-bottom: 36px; }

.flex          { display: flex; }
.flex-wrap     { flex-wrap: wrap; }
.items-center  { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 6px; }
.gap-2 { gap: 12px; }
.gap-3 { gap: 18px; }
.gap-4 { gap: 24px; }

.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

@media (max-width: 900px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
}

.w-full { width: 100%; }
.hidden { display: none; }

dl.dl-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 20px;
  font-size: 0.875rem;
}
dl.dl-grid dt { color: var(--text-secondary); white-space: nowrap; }
dl.dl-grid dd { color: var(--text-primary); font-weight: 500; }

/* ── Metric (número grande con label) ─────────────────────── */
.metric { display: flex; flex-direction: column; gap: 3px; }
.metric__label { font-size: 0.6875rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-secondary); }
.metric__value { font-family: 'JetBrains Mono', monospace; font-size: 1.6rem; font-weight: 700; color: var(--text-primary); letter-spacing: -0.03em; line-height: 1.1; }
.metric__value--lg { font-size: 2rem; }
.metric__sub { font-size: 0.8rem; color: var(--text-secondary); margin-top: 1px; }
.metric__positive { color: var(--positive); }
.metric__negative { color: var(--negative); }

/* ── Filter bar ───────────────────────────────────────────── */
.filter-bar {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: flex-end;
  margin-bottom: 20px;
}

/* ── Code / pre ───────────────────────────────────────────── */
code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8125rem;
  background: var(--accent-subtle);
  color: var(--accent-light);
  padding: 1px 5px;
  border-radius: 4px;
}
