/* ============================================================
   CUVI — Sistema de Diseño
   Modo claro / oscuro via [data-theme="dark"] en <html>
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ── TOKENS: MODO CLARO ───────────────────────────────────── */
:root {
  /* Marca */
  --brand-primary:      #1a3a8f;
  --brand-primary-dark: #0f2460;
  --brand-accent:       #2563eb;
  --brand-accent-hover: #1d4ed8;

  /* Superficie */
  --bg-app:     #f0f2f7;
  --bg-surface: #ffffff;
  --bg-raised:  #f8f9fc;
  --bg-overlay: rgba(0, 0, 0, 0.45);

  /* Bordes */
  --border-color:       #e2e6f0;
  --border-color-focus: #2563eb;

  /* Texto */
  --text-primary:   #0f172a;
  --text-secondary: #475569;
  --text-muted:     #94a3b8;
  --text-inverse:   #ffffff;

  /* Sidebar */
  --sidebar-bg:       #ffffff;
  --sidebar-shadow:   0 0 24px rgba(0,0,0,0.10);
  --sidebar-item-hover-bg: #eef2ff;
  --sidebar-item-hover-color: #1a3a8f;

  /* Navbar */
  --navbar-bg:    #1a3a8f;
  --navbar-color: #ffffff;

  /* Tarjetas */
  --card-shadow: 0 2px 12px rgba(0,0,0,0.07);
  --card-shadow-hover: 0 6px 20px rgba(0,0,0,0.12);
  --card-radius: 14px;

  /* Estado */
  --color-success:       #16a34a;
  --color-success-light: #dcfce7;
  --color-danger:        #dc2626;
  --color-danger-light:  #fee2e2;
  --color-warning:       #d97706;
  --color-warning-light: #fef3c7;
  --color-today:         #dc2626;
  --color-tomorrow:      #d97706;
  --color-future:        #16a34a;

  /* Inputs */
  --input-bg:     #ffffff;
  --input-border: #cbd5e1;
  --input-focus-shadow: 0 0 0 3px rgba(37,99,235,0.15);

  /* Tablas */
  --table-header-bg:  #eef2ff;
  --table-row-hover:  #f5f7ff;
  --table-border:     #e2e8f0;

  /* Toggle */
  --toggle-bg:     #e2e8f0;
  --toggle-thumb:  #1a3a8f;

  /* Misc */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --transition: 0.2s ease;
  --font: 'Inter', 'Segoe UI', system-ui, sans-serif;
}

/* ── TOKENS: MODO OSCURO ──────────────────────────────────── */
[data-theme="dark"] {
  --brand-primary:      #3b6fd4;
  --brand-primary-dark: #2554b8;
  --brand-accent:       #60a5fa;
  --brand-accent-hover: #93c5fd;

  --bg-app:     #0d1117;
  --bg-surface: #161b22;
  --bg-raised:  #1c2230;
  --bg-overlay: rgba(0, 0, 0, 0.65);

  --border-color:       #2d3748;
  --border-color-focus: #60a5fa;

  --text-primary:   #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted:     #64748b;
  --text-inverse:   #0d1117;

  --sidebar-bg:       #161b22;
  --sidebar-shadow:   0 0 24px rgba(0,0,0,0.4);
  --sidebar-item-hover-bg: #1e2a45;
  --sidebar-item-hover-color: #60a5fa;

  --navbar-bg:    #0f1729;
  --navbar-color: #e2e8f0;

  --card-shadow: 0 2px 12px rgba(0,0,0,0.3);
  --card-shadow-hover: 0 6px 20px rgba(0,0,0,0.45);

  --color-success:       #4ade80;
  --color-success-light: #14532d;
  --color-danger:        #f87171;
  --color-danger-light:  #7f1d1d;
  --color-warning:       #fbbf24;
  --color-warning-light: #78350f;

  --input-bg:     #1c2230;
  --input-border: #2d3748;
  --input-focus-shadow: 0 0 0 3px rgba(96,165,250,0.20);

  --table-header-bg:  #1e2a45;
  --table-row-hover:  #1c2230;
  --table-border:     #2d3748;

  --toggle-bg:    #334155;
  --toggle-thumb: #60a5fa;
}

/* ── BASE ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html { font-size: 16px; }

body {
  font-family: var(--font);
  background-color: var(--bg-app);
  color: var(--text-primary);
  margin: 0;
  padding: 0;
  transition: background-color 0.3s ease, color 0.3s ease;
  -webkit-font-smoothing: antialiased;
}

/* ── SCROLLBAR PERSONALIZADA ──────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 99px;
}
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── TOGGLE DARK MODE ─────────────────────────────────────── */
.theme-toggle {
  width: 40px;
  height: 22px;
  background: var(--toggle-bg);
  border-radius: 99px;
  border: none;
  cursor: pointer;
  position: relative;
  padding: 0;
  transition: background var(--transition);
  flex-shrink: 0;
}

.theme-toggle::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--toggle-thumb);
  top: 3px;
  left: 3px;
  transition: transform var(--transition);
}

[data-theme="dark"] .theme-toggle::after {
  transform: translateX(18px);
}

.theme-toggle-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
  color: var(--text-muted);
  padding: 10px 12px;
  border-top: 1px solid var(--border-color);
  margin-top: auto;
}

.theme-toggle-wrap svg {
  width: 16px;
  height: 16px;
  fill: var(--text-muted);
  flex-shrink: 0;
}