/* ============================================================
   BANREKA — Design System & Global CSS
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&family=Space+Grotesk:wght@400;500;600;700&display=swap');

/* ============================================================
   CSS Variables — Design Tokens
   ============================================================ */
:root {
  /* Brand Colors */
  --brand-50:  #f0f4ff;
  --brand-100: #e0e9ff;
  --brand-200: #c2d3ff;
  --brand-300: #94b0ff;
  --brand-400: #6088ff;
  --brand-500: #3b63f8;
  --brand-600: #1e43ea;
  --brand-700: #1630cc;
  --brand-800: #1828a5;
  --brand-900: #1a2882;

  /* Accent */
  --accent-green:  #10b981;
  --accent-yellow: #f59e0b;
  --accent-red:    #ef4444;
  --accent-purple: #8b5cf6;
  --accent-cyan:   #06b6d4;

  /* Dark Theme */
  --bg-base:    #0a0d1a;
  --bg-surface: #111527;
  --bg-card:    #161b33;
  --bg-hover:   #1e2444;
  --bg-input:   #1a2040;

  /* Borders */
  --border-subtle:  rgba(255,255,255,0.06);
  --border-medium:  rgba(255,255,255,0.12);
  --border-strong:  rgba(255,255,255,0.2);

  /* Text */
  --text-primary:   #f1f4ff;
  --text-secondary: #8892b0;
  --text-muted:     #4a5568;
  --text-accent:    #7d8fff;

  /* Gradients */
  --grad-brand: linear-gradient(135deg, #3b63f8 0%, #8b5cf6 100%);
  --grad-green: linear-gradient(135deg, #10b981 0%, #06b6d4 100%);
  --grad-red:   linear-gradient(135deg, #ef4444 0%, #f59e0b 100%);
  --grad-gold:  linear-gradient(135deg, #f59e0b 0%, #ef4444 100%);
  --grad-surface: linear-gradient(145deg, #161b33 0%, #111527 100%);

  /* Shadows */
  --shadow-sm:  0 1px 3px rgba(0,0,0,0.4);
  --shadow-md:  0 4px 16px rgba(0,0,0,0.5);
  --shadow-lg:  0 8px 32px rgba(0,0,0,0.6);
  --shadow-xl:  0 20px 60px rgba(0,0,0,0.7);
  --shadow-brand: 0 8px 32px rgba(59,99,248,0.3);
  --shadow-green: 0 4px 16px rgba(16,185,129,0.3);

  /* Spacing */
  --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;

  /* Radius */
  --r-sm: 6px; --r-md: 10px; --r-lg: 16px; --r-xl: 20px; --r-full: 9999px;

  /* Transitions */
  --t-fast:   0.15s ease;
  --t-normal: 0.25s ease;
  --t-slow:   0.4s cubic-bezier(0.4,0,0.2,1);

  /* Sidebar */
  --sidebar-w: 260px;
  --sidebar-collapsed: 72px;
  --topbar-h: 64px;
}

/* ============================================================
   Reset & Base
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 15px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
}

/* ============================================================
   Typography
   ============================================================ */
h1,h2,h3,h4,h5,h6 { font-family: 'Space Grotesk', sans-serif; font-weight: 700; line-height: 1.2; }
h1 { font-size: 2.2rem; }
h2 { font-size: 1.6rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.05rem; }
p { color: var(--text-secondary); }
a { color: var(--brand-400); text-decoration: none; transition: color var(--t-fast); }
a:hover { color: var(--brand-300); }

/* ============================================================
   Layout Shell
   ============================================================ */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* -------- Sidebar -------- */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--grad-surface);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  z-index: 100;
  transition: width var(--t-slow);
  overflow: hidden;
}

.sidebar.collapsed { width: var(--sidebar-collapsed); }

.sidebar-logo {
  padding: var(--space-6);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  border-bottom: 1px solid var(--border-subtle);
  min-height: var(--topbar-h);
}

.sidebar-logo .logo-icon {
  width: 38px; height: 38px;
  background: var(--grad-brand);
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 800;
  font-family: 'Space Grotesk', sans-serif;
  color: #fff;
  flex-shrink: 0;
  box-shadow: var(--shadow-brand);
}

.sidebar-logo .logo-text {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text-primary);
  white-space: nowrap;
  transition: opacity var(--t-normal);
}
.sidebar-logo .logo-sub {
  font-size: 0.6rem;
  color: var(--text-muted);
  display: block;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.sidebar.collapsed .logo-text { opacity: 0; width: 0; }

/* Nav */
.sidebar-nav {
  flex: 1;
  padding: var(--space-4) 0;
  overflow-y: auto;
  overflow-x: hidden;
}
.sidebar-nav::-webkit-scrollbar { width: 3px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--border-medium); border-radius: 3px; }

.nav-section-label {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: var(--space-4) var(--space-6) var(--space-2);
  white-space: nowrap;
  transition: opacity var(--t-normal);
}
.sidebar.collapsed .nav-section-label { opacity: 0; }

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 10px var(--space-5);
  margin: 2px var(--space-3);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: all var(--t-fast);
  white-space: nowrap;
  position: relative;
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 0.875rem;
  border: 1px solid transparent;
}
.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-subtle);
}
.nav-item.active {
  background: rgba(59,99,248,0.15);
  color: var(--brand-400);
  border-color: rgba(59,99,248,0.25);
}
.nav-item.active .nav-icon { color: var(--brand-400); }

.nav-icon {
  width: 20px; height: 20px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-size: 1rem;
}
.nav-label {
  transition: opacity var(--t-normal);
  flex: 1;
}
.sidebar.collapsed .nav-label { opacity: 0; width: 0; overflow: hidden; }

.nav-badge {
  background: var(--accent-red);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: var(--r-full);
  min-width: 18px;
  text-align: center;
  transition: opacity var(--t-normal);
}
.sidebar.collapsed .nav-badge { opacity: 0; }

/* Sidebar footer */
.sidebar-footer {
  padding: var(--space-4);
  border-top: 1px solid var(--border-subtle);
}
.user-card {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  border-radius: var(--r-md);
  background: var(--bg-hover);
  cursor: pointer;
  transition: background var(--t-fast);
}
.user-card:hover { background: var(--bg-input); }
.user-avatar {
  width: 36px; height: 36px;
  background: var(--grad-brand);
  border-radius: var(--r-full);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.875rem; color: #fff;
  flex-shrink: 0;
}
.user-info { transition: opacity var(--t-normal); }
.user-name { font-size: 0.8rem; font-weight: 600; color: var(--text-primary); }
.user-role { font-size: 0.65rem; color: var(--text-muted); }
.sidebar.collapsed .user-info { opacity: 0; width: 0; overflow: hidden; }

/* -------- Main Content -------- */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left var(--t-slow);
}
.main-content.sidebar-collapsed { margin-left: var(--sidebar-collapsed); }

/* Topbar */
.topbar {
  height: var(--topbar-h);
  background: rgba(17,21,39,0.8);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  padding: 0 var(--space-6);
  gap: var(--space-4);
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-toggle {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-hover);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  cursor: pointer;
  color: var(--text-secondary);
  transition: all var(--t-fast);
  font-size: 1rem;
}
.topbar-toggle:hover { background: var(--bg-input); color: var(--text-primary); }

.topbar-breadcrumb { font-size: 0.875rem; color: var(--text-secondary); flex: 1; }
.topbar-breadcrumb span { color: var(--text-primary); font-weight: 600; }

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

.topbar-btn {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-hover);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  cursor: pointer;
  color: var(--text-secondary);
  transition: all var(--t-fast);
  position: relative;
  font-size: 1rem;
}
.topbar-btn:hover { background: var(--bg-input); color: var(--text-primary); }
.topbar-btn .badge {
  position: absolute;
  top: -4px; right: -4px;
  width: 16px; height: 16px;
  background: var(--accent-red);
  border-radius: var(--r-full);
  font-size: 0.6rem;
  font-weight: 700;
  color: #fff;
  display: flex; align-items: center; justify-content: center;
}

/* Page Content */
.page-content {
  padding: var(--space-8);
  flex: 1;
  animation: fadeInUp 0.3s ease;
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: var(--space-8);
  gap: var(--space-4);
}
.page-title { font-size: 1.8rem; color: var(--text-primary); }
.page-subtitle { font-size: 0.875rem; color: var(--text-secondary); margin-top: 4px; }

/* ============================================================
   Cards
   ============================================================ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-xl);
  padding: var(--space-6);
  transition: all var(--t-normal);
}
.card:hover { border-color: var(--border-medium); }

.card-sm { padding: var(--space-4); border-radius: var(--r-lg); }

.card-glass {
  background: rgba(22,27,51,0.7);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-medium);
  border-radius: var(--r-xl);
}

/* KPI Cards */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-5);
  margin-bottom: var(--space-8);
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-xl);
  padding: var(--space-6);
  position: relative;
  overflow: hidden;
  transition: all var(--t-normal);
  cursor: default;
}
.kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--kpi-color, var(--grad-brand));
}
.kpi-card:hover {
  border-color: var(--border-medium);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.kpi-icon {
  width: 44px; height: 44px;
  border-radius: var(--r-lg);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.25rem;
  margin-bottom: var(--space-4);
  background: var(--kpi-icon-bg, rgba(59,99,248,0.15));
  color: var(--kpi-icon-color, var(--brand-400));
}

.kpi-value {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
  margin-bottom: var(--space-2);
}
.kpi-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.kpi-change {
  font-size: 0.75rem;
  font-weight: 600;
  margin-top: var(--space-2);
  display: flex;
  align-items: center;
  gap: 4px;
}
.kpi-change.up { color: var(--accent-green); }
.kpi-change.down { color: var(--accent-red); }

/* ============================================================
   Tables
   ============================================================ */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--r-xl);
  border: 1px solid var(--border-subtle);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
.table thead {
  background: rgba(255,255,255,0.03);
  border-bottom: 1px solid var(--border-subtle);
}
.table th {
  padding: var(--space-4) var(--space-5);
  text-align: left;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
}
.table td {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr {
  transition: background var(--t-fast);
}
.table tbody tr:hover { background: var(--bg-hover); }

.table-primary { color: var(--text-primary); font-weight: 500; }
.table-small { font-size: 0.75rem; color: var(--text-muted); }

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 10px var(--space-5);
  border-radius: var(--r-md);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--t-fast);
  border: 1px solid transparent;
  white-space: nowrap;
  font-family: 'Inter', sans-serif;
  text-decoration: none;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--grad-brand);
  color: #fff;
  box-shadow: var(--shadow-brand);
}
.btn-primary:hover:not(:disabled) { 
  transform: translateY(-1px); 
  box-shadow: 0 12px 40px rgba(59,99,248,0.4);
}

.btn-secondary {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-medium);
}
.btn-secondary:hover:not(:disabled) { background: var(--bg-input); }

.btn-success {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
  box-shadow: var(--shadow-green);
}
.btn-success:hover:not(:disabled) { transform: translateY(-1px); }

.btn-danger {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: #fff;
}
.btn-danger:hover:not(:disabled) { transform: translateY(-1px); }

.btn-sm {
  padding: 6px var(--space-3);
  font-size: 0.8rem;
}

.btn-icon {
  width: 36px; height: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ============================================================
   Badges & Tags
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--r-full);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.badge-blue { background: rgba(59,99,248,0.15); color: var(--brand-400); border: 1px solid rgba(59,99,248,0.25); }
.badge-green { background: rgba(16,185,129,0.15); color: var(--accent-green); border: 1px solid rgba(16,185,129,0.25); }
.badge-yellow { background: rgba(245,158,11,0.15); color: var(--accent-yellow); border: 1px solid rgba(245,158,11,0.25); }
.badge-red { background: rgba(239,68,68,0.15); color: var(--accent-red); border: 1px solid rgba(239,68,68,0.25); }
.badge-purple { background: rgba(139,92,246,0.15); color: var(--accent-purple); border: 1px solid rgba(139,92,246,0.25); }
.badge-gray { background: rgba(255,255,255,0.08); color: var(--text-secondary); border: 1px solid var(--border-subtle); }

/* Semáforo */
.semaforo {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 0.8rem;
  font-weight: 600;
}
.semaforo::before { content: '●'; font-size: 0.7rem; }
.semaforo-verde  { color: var(--accent-green); }
.semaforo-verde::before  { color: var(--accent-green); }
.semaforo-amarillo { color: var(--accent-yellow); }
.semaforo-amarillo::before { color: var(--accent-yellow); }
.semaforo-rojo   { color: var(--accent-red); }
.semaforo-rojo::before   { color: var(--accent-red); }

/* Score Bar */
.score-bar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.score-track {
  flex: 1;
  height: 6px;
  background: var(--bg-hover);
  border-radius: var(--r-full);
  overflow: hidden;
}
.score-fill {
  height: 100%;
  border-radius: var(--r-full);
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}
.score-fill.alto     { background: var(--grad-green); }
.score-fill.confiable { background: linear-gradient(90deg, var(--accent-green), var(--accent-cyan)); }
.score-fill.poco     { background: var(--grad-gold); }
.score-fill.dudoso   { background: var(--grad-red); }
.score-value { font-weight: 700; font-size: 0.8rem; color: var(--text-primary); min-width: 28px; }

/* ============================================================
   Forms
   ============================================================ */
.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-5);
}
.form-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.form-label.required::after { content: ' *'; color: var(--accent-red); }

.form-control {
  background: var(--bg-input);
  border: 1px solid var(--border-medium);
  border-radius: var(--r-md);
  padding: 10px var(--space-4);
  color: var(--text-primary);
  font-size: 0.875rem;
  font-family: 'Inter', sans-serif;
  transition: all var(--t-fast);
  width: 100%;
}
.form-control:focus {
  outline: none;
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px rgba(59,99,248,0.15);
}
.form-control::placeholder { color: var(--text-muted); }
.form-control:disabled { opacity: 0.5; cursor: not-allowed; }

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238892b0' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

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

.form-error { font-size: 0.75rem; color: var(--accent-red); }
.form-hint  { font-size: 0.75rem; color: var(--text-muted); }

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-5);
}

/* ============================================================
   Modal
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(8px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-5);
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-medium);
  border-radius: var(--r-xl);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  animation: slideUp 0.3s cubic-bezier(0.4,0,0.2,1);
}
.modal-lg { max-width: 900px; }
.modal-sm { max-width: 400px; }

@keyframes slideUp {
  from { transform: translateY(30px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.modal-header {
  padding: var(--space-6);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title { font-size: 1.1rem; font-weight: 700; color: var(--text-primary); }
.modal-close {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--r-md);
  cursor: pointer;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  font-size: 1rem;
  transition: all var(--t-fast);
}
.modal-close:hover { background: var(--bg-hover); color: var(--text-primary); border-color: var(--border-subtle); }

.modal-body { padding: var(--space-6); }
.modal-footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
}

/* ============================================================
   Search & Filters
   ============================================================ */
.search-bar {
  position: relative;
  max-width: 360px;
}
.search-bar input {
  padding-left: 38px;
  background: var(--bg-input);
  border: 1px solid var(--border-medium);
  border-radius: var(--r-full);
  width: 100%;
  color: var(--text-primary);
  font-size: 0.875rem;
  height: 38px;
  transition: all var(--t-fast);
  font-family: 'Inter', sans-serif;
}
.search-bar input:focus {
  outline: none;
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px rgba(59,99,248,0.15);
}
.search-bar .search-icon {
  position: absolute;
  left: 12px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.9rem;
  pointer-events: none;
}

.filters-bar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-bottom: var(--space-6);
}

/* ============================================================
   Charts Container
   ============================================================ */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
  gap: var(--space-6);
  margin-bottom: var(--space-8);
}
.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-xl);
  padding: var(--space-6);
}
.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-6);
}
.chart-title { font-size: 0.9rem; font-weight: 600; color: var(--text-primary); }
.chart-canvas-wrapper { position: relative; height: 220px; }

/* ============================================================
   Upload Zone
   ============================================================ */
.upload-zone {
  border: 2px dashed var(--border-medium);
  border-radius: var(--r-lg);
  padding: var(--space-8);
  text-align: center;
  cursor: pointer;
  transition: all var(--t-normal);
  background: var(--bg-input);
}
.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--brand-500);
  background: rgba(59,99,248,0.05);
}
.upload-icon { font-size: 2rem; margin-bottom: var(--space-3); color: var(--text-muted); }
.upload-text { color: var(--text-secondary); font-size: 0.875rem; }
.upload-text strong { color: var(--brand-400); }

.doc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: var(--space-4);
  margin-top: var(--space-4);
}
.doc-item {
  background: var(--bg-hover);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-lg);
  padding: var(--space-4);
  text-align: center;
  cursor: pointer;
  transition: all var(--t-fast);
}
.doc-item:hover { border-color: var(--brand-500); background: var(--bg-input); }
.doc-type-icon { font-size: 2rem; margin-bottom: var(--space-2); }
.doc-name { font-size: 0.75rem; color: var(--text-secondary); word-break: break-all; }

/* ============================================================
   Pagination
   ============================================================ */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-6) 0;
}
.page-btn {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--r-md);
  cursor: pointer;
  background: var(--bg-hover);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 0.875rem;
  transition: all var(--t-fast);
  font-weight: 500;
}
.page-btn:hover { background: var(--bg-input); color: var(--text-primary); }
.page-btn.active { background: var(--brand-500); color: #fff; border-color: var(--brand-500); }
.page-btn:disabled { opacity: 0.3; cursor: not-allowed; }

/* ============================================================
   Alerts & Notifications
   ============================================================ */
.alert {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-4);
  border-radius: var(--r-lg);
  margin-bottom: var(--space-5);
  border: 1px solid;
}
.alert-success { background: rgba(16,185,129,0.1); border-color: rgba(16,185,129,0.3); color: var(--accent-green); }
.alert-danger  { background: rgba(239,68,68,0.1);  border-color: rgba(239,68,68,0.3);  color: var(--accent-red); }
.alert-warning { background: rgba(245,158,11,0.1); border-color: rgba(245,158,11,0.3); color: var(--accent-yellow); }
.alert-info    { background: rgba(59,99,248,0.1);  border-color: rgba(59,99,248,0.3);  color: var(--brand-400); }

/* Toast */
.toast-container {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.toast {
  background: var(--bg-card);
  border: 1px solid var(--border-medium);
  border-radius: var(--r-lg);
  padding: var(--space-4) var(--space-5);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 280px;
  max-width: 400px;
  animation: slideInRight 0.3s ease;
}
@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}
.toast.hide { animation: slideOutRight 0.3s ease forwards; }
@keyframes slideOutRight {
  from { transform: translateX(0);    opacity: 1; }
  to   { transform: translateX(100%); opacity: 0; }
}
.toast-success .toast-icon { color: var(--accent-green); }
.toast-error   .toast-icon { color: var(--accent-red); }
.toast-msg { flex: 1; font-size: 0.875rem; color: var(--text-primary); }

/* ============================================================
   Loading States
   ============================================================ */
.spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--border-medium);
  border-top-color: var(--brand-400);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: var(--space-8) auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton {
  background: linear-gradient(90deg, var(--bg-hover) 25%, var(--bg-input) 50%, var(--bg-hover) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--r-md);
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ============================================================
   Empty State
   ============================================================ */
.empty-state {
  text-align: center;
  padding: var(--space-16) var(--space-8);
  color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 3.5rem; margin-bottom: var(--space-4); opacity: 0.4; }
.empty-state h3 { color: var(--text-secondary); margin-bottom: var(--space-2); }
.empty-state p { font-size: 0.875rem; max-width: 300px; margin: 0 auto var(--space-5); }

/* ============================================================
   Cartera / Cobranza específica
   ============================================================ */
.cobranza-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-xl);
  padding: var(--space-5);
  display: flex;
  align-items: center;
  gap: var(--space-4);
  transition: all var(--t-normal);
  cursor: pointer;
}
.cobranza-card:hover { border-color: var(--border-medium); transform: translateY(-1px); }
.cobranza-card.vencido { border-left: 3px solid var(--accent-red); }
.cobranza-card.proximo { border-left: 3px solid var(--accent-yellow); }
.cobranza-card.pagado  { border-left: 3px solid var(--accent-green); opacity: 0.7; }

.semaforo-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  animation: pulse 2s infinite;
}
.semaforo-dot.verde  { background: var(--accent-green); box-shadow: 0 0 8px var(--accent-green); }
.semaforo-dot.amarillo { background: var(--accent-yellow); box-shadow: 0 0 8px var(--accent-yellow); }
.semaforo-dot.rojo   { background: var(--accent-red); box-shadow: 0 0 8px var(--accent-red); }

@keyframes pulse {
  0%,100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 1024px) {
  :root { --sidebar-w: var(--sidebar-collapsed); }
  .sidebar-logo .logo-text,
  .sidebar .nav-label,
  .sidebar .nav-badge,
  .sidebar .nav-section-label,
  .sidebar .user-info { opacity: 0; width: 0; overflow: hidden; }
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.mobile-open { transform: translateX(0); width: var(--sidebar-w) !important; }
  .sidebar.mobile-open .logo-text,
  .sidebar.mobile-open .nav-label,
  .sidebar.mobile-open .nav-badge,
  .sidebar.mobile-open .nav-section-label,
  .sidebar.mobile-open .user-info { opacity: 1 !important; width: auto !important; }
  .main-content { margin-left: 0 !important; }
  .page-content { padding: var(--space-5); }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .charts-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; align-items: flex-start; }
  
  .mobile-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 99;
    display: none;
  }
  .mobile-overlay.active { display: block; }
}

@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .table-wrapper { font-size: 0.8rem; }
}

/* ============================================================
   Utilities
   ============================================================ */
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-5 { gap: var(--space-5); }
.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); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-sm { font-size: 0.8rem; }
.text-xs { font-size: 0.7rem; }
.font-bold { font-weight: 700; }
.text-muted { color: var(--text-muted); }
.text-primary { color: var(--text-primary); }
.text-success { color: var(--accent-green); }
.text-danger { color: var(--accent-red); }
.text-warning { color: var(--accent-yellow); }
.w-full { width: 100%; }
.hidden { display: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Currency display */
.currency {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
}
.currency-large {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 1.4rem;
  color: var(--text-primary);
}

/* ============================================================
   Login Page (special)
   ============================================================ */
.login-page {
  min-height: 100vh;
  background: var(--bg-base);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-5);
  position: relative;
  overflow: hidden;
}
.login-page::before {
  content: '';
  position: absolute;
  width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(59,99,248,0.2) 0%, transparent 70%);
  top: -200px; left: -200px;
  pointer-events: none;
}
.login-page::after {
  content: '';
  position: absolute;
  width: 500px; height: 500px;
  background: radial-gradient(circle, rgba(139,92,246,0.15) 0%, transparent 70%);
  bottom: -150px; right: -150px;
  pointer-events: none;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border-medium);
  border-radius: var(--r-xl);
  padding: var(--space-10);
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow-xl);
  position: relative;
  z-index: 1;
  animation: slideUp 0.5s cubic-bezier(0.4,0,0.2,1);
}

.login-logo {
  text-align: center;
  margin-bottom: var(--space-8);
}
.login-logo .logo-mark {
  width: 64px; height: 64px;
  background: var(--grad-brand);
  border-radius: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 800;
  font-size: 1.6rem;
  color: #fff;
  box-shadow: var(--shadow-brand);
  margin-bottom: var(--space-4);
}
.login-logo h1 {
  font-size: 1.8rem;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}
.login-logo p {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.login-form { display: flex; flex-direction: column; gap: var(--space-5); }

.login-input-wrapper {
  position: relative;
}
.login-input-wrapper .input-icon {
  position: absolute;
  left: 14px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.9rem;
  pointer-events: none;
}
.login-input-wrapper input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-medium);
  border-radius: var(--r-md);
  padding: 13px 14px 13px 40px;
  color: var(--text-primary);
  font-size: 0.925rem;
  font-family: 'Inter', sans-serif;
  transition: all var(--t-fast);
}
.login-input-wrapper input:focus {
  outline: none;
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px rgba(59,99,248,0.15);
}
.login-input-wrapper input::placeholder { color: var(--text-muted); }

.btn-login {
  background: var(--grad-brand);
  color: #fff;
  border: none;
  border-radius: var(--r-md);
  padding: 14px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--t-fast);
  box-shadow: var(--shadow-brand);
  font-family: 'Inter', sans-serif;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
}
.btn-login:hover { transform: translateY(-2px); box-shadow: 0 12px 40px rgba(59,99,248,0.5); }
.btn-login:active { transform: translateY(0); }
.btn-login:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.login-footer {
  text-align: center;
  margin-top: var(--space-8);
  padding-top: var(--space-6);
  border-top: 1px solid var(--border-subtle);
  font-size: 0.75rem;
  color: var(--text-muted);
}
/* =========================================================
   MEDIA QUERIES (PRINT)
========================================================= */
@media print {
  body * {
    visibility: hidden;
  }
  #printArea, #printArea * {
    visibility: visible;
  }
  #printArea {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
  }
  .print-only {
    display: block !important;
  }
  .no-print {
    display: none !important;
  }
  .modal {
    box-shadow: none;
    border: none;
    position: absolute;
    left: 0;
    top: 0;
    margin: 0;
    padding: 0;
    width: 100%;
    transform: none;
  }
  .modal-overlay {
    background: white;
  }
}
