/* Tecnigo — Professional SaaS Color System */
:root {
  --sidebar-w: 17rem;
  --header-h: 4rem;
  --bottom-nav-h: 4.25rem;

  /* Neutrals — cool slate, high clarity */
  --bg: #F4F6FB;
  --bg-muted: #EEF1F8;
  --surface: #FFFFFF;
  --surface-elevated: #FFFFFF;
  --surface-hover: #F8FAFD;
  --border: #E2E8F0;
  --border-subtle: #EEF2F7;

  /* Text hierarchy */
  --text: #0F172A;
  --text-secondary: #475569;
  --text-muted: #64748B;
  --text-faint: #94A3B8;

  /* Brand — electric blue, confident & modern */
  --brand: #2563EB;
  --brand-hover: #1D4ED8;
  --brand-light: #EFF6FF;
  --brand-muted: #DBEAFE;
  --brand-glow: rgba(37, 99, 235, 0.22);

  /* Semantic */
  --success: #059669;
  --success-light: #ECFDF5;
  --success-muted: #D1FAE5;
  --warning: #D97706;
  --warning-light: #FFFBEB;
  --warning-muted: #FEF3C7;
  --danger: #DC2626;
  --danger-light: #FEF2F2;
  --danger-muted: #FEE2E2;
  --info: #7C3AED;
  --info-light: #F5F3FF;
  --info-muted: #EDE9FE;

  --primary: var(--brand);
  --primary-hover: var(--brand-hover);

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 16px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 12px 40px rgba(15, 23, 42, 0.08);
  --shadow-brand: 0 8px 24px var(--brand-glow);

  --overlay: rgba(15, 23, 42, 0.45);
  --nav-bg: rgba(255, 255, 255, 0.88);

  --mesh-1: rgba(37, 99, 235, 0.07);
  --mesh-2: rgba(124, 58, 237, 0.06);
  --mesh-3: rgba(5, 150, 105, 0.04);

  --sidebar-from: #0F172A;
  --sidebar-to: #1E293B;
  --sidebar-active: linear-gradient(135deg, #2563EB 0%, #1D4ED8 100%);
  --sidebar-text: rgba(248, 250, 252, 0.72);
  --sidebar-text-active: #FFFFFF;
}

html.dark {
  /* Plomo suave — neutros cálidos, baja saturación */
  --bg: #1C1C21;
  --bg-muted: #242429;
  --surface: #2C2C33;
  --surface-elevated: #32323A;
  --surface-hover: #38383F;
  --border: #43434C;
  --border-subtle: #35353D;

  /* Texto legible sin brillo agresivo */
  --text: #ECECEF;
  --text-secondary: #C2C2CA;
  --text-muted: #9E9EA8;
  --text-faint: #75757F;

  /* Acentos atenuados */
  --brand: #7A9FD4;
  --brand-hover: #94B3DE;
  --brand-light: #262830;
  --brand-muted: #333848;
  --brand-glow: rgba(122, 159, 212, 0.12);

  --success: #72B592;
  --success-light: #242B28;
  --success-muted: #2F3B35;
  --warning: #C9A04E;
  --warning-light: #2B2922;
  --warning-muted: #3D3828;
  --danger: #C97A7A;
  --danger-light: #2B2424;
  --danger-muted: #3D3030;
  --info: #A396C4;
  --info-light: #282630;
  --info-muted: #353040;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.18);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.22);
  --shadow-lg: 0 8px 28px rgba(0, 0, 0, 0.28);
  --shadow-brand: 0 4px 16px rgba(122, 159, 212, 0.12);

  --overlay: rgba(0, 0, 0, 0.55);
  --nav-bg: rgba(44, 44, 51, 0.92);

  --mesh-1: rgba(122, 159, 212, 0.05);
  --mesh-2: rgba(163, 150, 196, 0.04);
  --mesh-3: rgba(114, 181, 146, 0.03);

  --sidebar-from: #222228;
  --sidebar-to: #2A2A32;
  --sidebar-active: linear-gradient(135deg, #4A6A96 0%, #3D5A82 100%);
  --sidebar-text: rgba(236, 236, 239, 0.62);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; color-scheme: light; }
html.dark { color-scheme: dark; }

body {
  font-family: 'Hanken Grotesk', sans-serif;
  -webkit-font-smoothing: antialiased;
  background-color: var(--bg);
  color: var(--text);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideInLeft { from { opacity: 0; transform: translateX(-12px); } to { opacity: 1; transform: translateX(0); } }
@keyframes scaleIn { from { opacity: 0; transform: scale(0.97); } to { opacity: 1; transform: scale(1); } }

.animate-page { animation: fadeIn 0.35s ease-out both; }
.animate-fade-up { animation: fadeInUp 0.45s cubic-bezier(0.22, 1, 0.36, 1) both; }
.animate-scale-in { animation: scaleIn 0.4s cubic-bezier(0.22, 1, 0.36, 1) both; }
.stagger-1 { animation-delay: 0.04s; }
.stagger-2 { animation-delay: 0.08s; }
.stagger-3 { animation-delay: 0.12s; }
.stagger-4 { animation-delay: 0.16s; }

.material-symbols-outlined { font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24; user-select: none; }
.material-symbols-outlined.filled { font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24; }

.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2.25rem; height: 2.25rem; border-radius: 0.625rem;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text-muted); cursor: pointer;
  transition: all 0.2s ease;
}
.theme-toggle:hover { background: var(--brand-light); color: var(--brand); border-color: var(--brand-muted); transform: scale(1.04); }
.theme-toggle:active { transform: scale(0.96); }
.theme-toggle .material-symbols-outlined { transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1); }
html.dark .theme-toggle .material-symbols-outlined { transform: rotate(-25deg); }

.login-mesh {
  background:
    radial-gradient(ellipse 80% 60% at 10% 0%, var(--mesh-1), transparent 50%),
    radial-gradient(ellipse 70% 50% at 90% 100%, var(--mesh-2), transparent 50%),
    radial-gradient(ellipse 50% 40% at 50% 50%, var(--mesh-3), transparent 60%),
    var(--bg);
  transition: background 0.4s ease;
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 1rem;
  box-shadow: var(--shadow-lg);
  animation: scaleIn 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.brand-logo {
  background: var(--sidebar-active);
  box-shadow: var(--shadow-brand);
}

.app-shell { min-height: 100dvh; background: var(--bg); transition: background 0.3s; }

.app-sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(175deg, var(--sidebar-from) 0%, var(--sidebar-to) 100%);
  color: var(--sidebar-text-active);
  border-right: 1px solid rgba(255, 255, 255, 0.04);
}

.app-sidebar .nav-link {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.625rem 1rem; margin: 0.125rem 0.75rem 0.125rem 0;
  border-radius: 0 0.625rem 0.625rem 0;
  font-size: 0.875rem; font-weight: 500;
  color: var(--sidebar-text);
  transition: all 0.2s ease;
}
.app-sidebar .nav-link:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  transform: translateX(3px);
}
.app-sidebar .nav-link.active {
  background: var(--sidebar-active);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
}

.app-main { flex: 1; min-width: 0; padding-top: var(--header-h); }
@media (min-width: 1024px) {
  .app-main { margin-left: var(--sidebar-w); padding-top: 0; }
  .app-topbar { display: none !important; }
}

.app-content {
  padding: 1rem; padding-bottom: calc(var(--bottom-nav-h) + 1.5rem);
  max-width: 72rem; margin: 0 auto;
}
@media (min-width: 640px) { .app-content { padding: 1.5rem; padding-bottom: 2rem; } }
@media (min-width: 1024px) { .app-content { padding: 2rem; } }

.mobile-drawer { transform: translateX(-100%); transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1); }
.mobile-drawer.open { transform: translateX(0); }
.drawer-overlay { opacity: 0; pointer-events: none; transition: opacity 0.3s; background: var(--overlay); }
.drawer-overlay.open { opacity: 1; pointer-events: auto; }

.app-topbar {
  background: var(--nav-bg); backdrop-filter: blur(16px) saturate(180%);
  border-bottom: 1px solid var(--border);
}

.bottom-nav {
  height: var(--bottom-nav-h); padding-bottom: env(safe-area-inset-bottom, 0);
  background: var(--nav-bg); backdrop-filter: blur(16px) saturate(180%);
  border-top: 1px solid var(--border);
  box-shadow: 0 -8px 32px rgba(15, 23, 42, 0.04);
}
.bottom-nav a, .bottom-nav button {
  flex: 1; min-width: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 0.125rem;
  padding: 0.375rem 0.25rem; font-size: 0.625rem; font-weight: 600;
  color: var(--text-faint); transition: all 0.2s ease;
  background: none; border: none; cursor: pointer;
}
.bottom-nav a:active, .bottom-nav button:active { transform: scale(0.9); }
.bottom-nav a.active { color: var(--brand); }
.bottom-nav a.active .material-symbols-outlined {
  font-variation-settings: 'FILL' 1, 'wght' 500, 'GRAD' 0, 'opsz' 24;
}

.page-header { margin-bottom: 1.5rem; }
.page-title { font-size: 1.375rem; font-weight: 700; color: var(--text); line-height: 1.25; letter-spacing: -0.02em; }
@media (min-width: 1024px) { .page-title { font-size: 1.625rem; } }
.page-subtitle { font-size: 0.875rem; color: var(--text-muted); margin-top: 0.375rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.875rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.25s, border-color 0.25s, transform 0.25s;
}
.card:hover { box-shadow: var(--shadow-md); border-color: var(--border-subtle); }
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-subtle);
}
.card-body { padding: 1.25rem; }
.card.card-body, .card-body-only { padding: 1.25rem; }

/* Stat cards — tinted surfaces per metric */
.stat-card {
  border-radius: 0.875rem;
  padding: 1.125rem 1.25rem;
  min-height: 7.25rem;
  display: flex; flex-direction: column; justify-content: space-between;
  border: 1px solid transparent;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  animation: fadeInUp 0.45s cubic-bezier(0.22, 1, 0.36, 1) both;
  position: relative; overflow: hidden;
}
.stat-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  border-radius: 0.875rem 0.875rem 0 0; opacity: 0.85;
}
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }

.stat-card.tone-brand { background: var(--brand-light); border-color: var(--brand-muted); }
.stat-card.tone-brand::before { background: var(--brand); }
.stat-card.tone-brand .stat-value { color: var(--brand-hover); }
.stat-card.tone-brand .stat-icon { background: var(--brand-muted); color: var(--brand); }

.stat-card.tone-success { background: var(--success-light); border-color: var(--success-muted); }
.stat-card.tone-success::before { background: var(--success); }
.stat-card.tone-success .stat-value { color: var(--success); }
.stat-card.tone-success .stat-icon { background: var(--success-muted); color: var(--success); }

.stat-card.tone-danger { background: var(--danger-light); border-color: var(--danger-muted); }
.stat-card.tone-danger::before { background: var(--danger); }
.stat-card.tone-danger .stat-value { color: var(--danger); }
.stat-card.tone-danger .stat-icon { background: var(--danger-muted); color: var(--danger); }

.stat-card.tone-warning { background: var(--warning-light); border-color: var(--warning-muted); }
.stat-card.tone-warning::before { background: var(--warning); }
.stat-card.tone-warning .stat-value { color: #B45309; }
.stat-card.tone-warning .stat-icon { background: var(--warning-muted); color: var(--warning); }

.stat-card.tone-info { background: var(--info-light); border-color: var(--info-muted); }
.stat-card.tone-info::before { background: var(--info); }
.stat-card.tone-info .stat-value { color: #6D28D9; }
.stat-card.tone-info .stat-icon { background: var(--info-muted); color: var(--info); }

.stat-label {
  font-size: 0.6875rem; font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text-muted);
}
.stat-value {
  font-size: 1.5rem; font-weight: 800;
  color: var(--text); font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em; line-height: 1.1;
}
@media (min-width: 640px) { .stat-value { font-size: 1.625rem; } }

.stat-icon {
  width: 2rem; height: 2rem; border-radius: 0.5rem;
  display: flex; align-items: center; justify-content: center;
}
.stat-icon .material-symbols-outlined { font-size: 1.125rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  padding: 0.625rem 1.25rem; font-size: 0.875rem; font-weight: 600;
  border-radius: 0.625rem; transition: all 0.2s ease;
  cursor: pointer; border: none;
}
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: var(--sidebar-active);
  color: #fff;
  box-shadow: 0 2px 8px var(--brand-glow);
}
.btn-primary:hover {
  box-shadow: var(--shadow-brand);
  transform: translateY(-1px);
}
.btn-secondary {
  background: var(--surface); color: var(--brand);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--brand-light); border-color: var(--brand-muted); }
.btn-whatsapp { background: linear-gradient(135deg, #25D366, #128C7E); color: #fff; }
.btn-whatsapp:hover { box-shadow: 0 6px 20px rgba(37, 211, 102, 0.35); transform: translateY(-1px); }
.btn-full { width: 100%; }

.form-label { display: block; font-size: 0.75rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 0.375rem; letter-spacing: 0.01em; }
.form-input, .form-select, .form-textarea {
  width: 100%; padding: 0.6875rem 0.875rem; font-size: 0.875rem;
  border: 1px solid var(--border); border-radius: 0.625rem;
  background: var(--surface); color: var(--text);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.form-input::placeholder, .form-textarea::placeholder { color: var(--text-faint); }
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-glow);
}
.form-input-icon { position: relative; }
.form-input-icon .material-symbols-outlined {
  position: absolute; left: 0.75rem; top: 50%; transform: translateY(-50%);
  color: var(--text-faint); font-size: 1.25rem;
}
.form-input-icon .form-input { padding-left: 2.5rem; }

.chip {
  display: inline-flex; padding: 0.2rem 0.625rem; font-size: 0.6875rem;
  font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; border-radius: 9999px;
}
.chip-pendiente { background: var(--warning-light); color: #B45309; border: 1px solid var(--warning-muted); }
.chip-proceso { background: var(--brand-light); color: var(--brand-hover); border: 1px solid var(--brand-muted); }
.chip-completado, .chip-pagado { background: var(--success-light); color: var(--success); border: 1px solid var(--success-muted); }
.chip-default { background: var(--bg-muted); color: var(--text-muted); border: 1px solid var(--border); }
html.dark .chip-pendiente { color: var(--warning); }
html.dark .chip-proceso { color: var(--brand); }
html.dark .chip-completado, html.dark .chip-pagado { color: var(--success); }

.list-item {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.875rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: 0.625rem;
  transition: all 0.2s ease;
  animation: fadeInUp 0.4s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.list-item:hover {
  background: var(--surface-hover);
  border-color: var(--border);
  transform: translateX(2px);
  box-shadow: var(--shadow-sm);
}

.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--text-faint); }
.empty-state .material-symbols-outlined { font-size: 2.5rem; opacity: 0.35; margin-bottom: 0.5rem; display: block; }

.alert-error { padding: 0.75rem 1rem; background: var(--danger-light); border: 1px solid var(--danger-muted); border-radius: 0.625rem; color: var(--danger); font-size: 0.875rem; animation: fadeInUp 0.3s ease both; }
.alert-success { padding: 0.75rem 1rem; background: var(--success-light); border: 1px solid var(--success-muted); border-radius: 0.625rem; color: var(--success); font-size: 0.875rem; animation: fadeInUp 0.3s ease both; }

.link-action { font-size: 0.8125rem; font-weight: 600; color: var(--brand); transition: opacity 0.15s; }
.link-action:hover { opacity: 0.8; text-decoration: underline; }

.progress-bar { height: 0.375rem; background: var(--bg-muted); border-radius: 9999px; overflow: hidden; }
.progress-bar-fill { height: 100%; border-radius: 9999px; transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1); }
.progress-bar-fill.fill-success { background: linear-gradient(90deg, var(--success), #34D399); }
.progress-bar-fill.fill-danger { background: linear-gradient(90deg, var(--danger), #F87171); }
.progress-bar-fill.fill-brand { background: linear-gradient(90deg, var(--brand), #60A5FA); }

.grid-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.875rem; }
@media (min-width: 768px) { .grid-stats { grid-template-columns: repeat(4, 1fr); gap: 1rem; } }
.grid-2 { display: grid; gap: 1rem; }
@media (min-width: 768px) { .grid-2 { grid-template-columns: repeat(2, 1fr); } }
.form-grid { display: grid; gap: 1rem; }
@media (min-width: 640px) { .form-grid { grid-template-columns: repeat(2, 1fr); } }
.form-grid .span-2 { grid-column: 1 / -1; }

.desktop-page-bar {
  display: none; padding: 1.125rem 2rem;
  background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 30;
  animation: slideInLeft 0.35s ease both;
  backdrop-filter: blur(12px);
}
@media (min-width: 1024px) { .desktop-page-bar { display: block; } }

.space-y-section > * + * { margin-top: 1.5rem; }

.period-toggle {
  display: flex; background: var(--bg-muted);
  border: 1px solid var(--border); border-radius: 0.625rem; padding: 0.25rem;
}
.period-toggle a {
  padding: 0.5rem 1rem; border-radius: 0.5rem;
  font-size: 0.8125rem; font-weight: 600;
  color: var(--text-muted); transition: all 0.2s ease;
}
.period-toggle a.active {
  background: var(--surface);
  color: var(--brand);
  box-shadow: var(--shadow-sm);
}

.hide-scrollbar::-webkit-scrollbar { display: none; }
.hide-scrollbar { scrollbar-width: none; }
.auth-theme-btn { position: fixed; top: 1rem; right: 1rem; z-index: 50; }

/* Tailwind semantic overrides */
.text-primary { color: var(--brand) !important; }
.text-secondary { color: var(--success) !important; }
.text-error { color: var(--danger) !important; }
.text-tertiary-container { color: var(--info) !important; }
.text-on-surface { color: var(--text) !important; }
.text-on-surface-variant { color: var(--text-muted) !important; }
.bg-background { background-color: var(--bg) !important; }
.bg-primary-container { background: var(--sidebar-active) !important; }
.bg-surface-container-low { background-color: var(--bg-muted) !important; }
.border-outline-variant { border-color: var(--border) !important; }

.text-brand { color: var(--brand); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-info { color: var(--info); }

/* Dark mode — suavizado extra */
html.dark .stat-card::before { opacity: 0.55; }
html.dark .stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
html.dark .stat-card.tone-brand .stat-value { color: #94B3DE; }
html.dark .stat-card.tone-success .stat-value { color: #8EC9AA; }
html.dark .stat-card.tone-danger .stat-value { color: #D99A9A; }
html.dark .stat-card.tone-warning .stat-value { color: #D4B06A; }
html.dark .stat-card.tone-info .stat-value { color: #B8AED4; }
html.dark .app-sidebar .nav-link.active { box-shadow: 0 2px 10px rgba(74, 106, 150, 0.25); }
html.dark .btn-primary { box-shadow: 0 2px 8px rgba(122, 159, 212, 0.15); }
html.dark .btn-primary:hover { box-shadow: 0 4px 14px rgba(122, 159, 212, 0.2); }
html.dark .list-item { background: var(--surface); border-color: var(--border-subtle); }
html.dark .chip-pendiente { color: #D4B06A; }
html.dark .chip-proceso { color: #94B3DE; }
html.dark .chip-completado, html.dark .chip-pagado { color: #8EC9AA; }
html.dark .period-toggle a.active { background: var(--surface-hover); color: var(--brand); }
html.dark .form-input:focus, html.dark .form-select:focus, html.dark .form-textarea:focus {
  box-shadow: 0 0 0 3px rgba(122, 159, 212, 0.15);
}
