/* EDST — Design tokens & base styles */

/* ── Font ── */
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── CSS Custom Properties (dark-first) ── */
:root {
  --color-bg-page: #0f172a;
  --color-bg-sidebar: #0b1121;
  --color-bg-card: #1e293b;
  --color-bg-card-hover: #233249;
  --color-bg-secondary: #162032;
  --color-bg-elevated: #162032;
  --color-bg-input: #0f172a;
  --color-border: rgba(148, 163, 184, 0.10);
  --color-border-hover: rgba(148, 163, 184, 0.16);
  --color-text-primary: #f1f5f9;
  --color-text-secondary: #94a3b8;
  --color-text-muted: #64748b;
  --color-brand: #3b82f6;
  --color-brand-glow: rgba(59, 130, 246, 0.12);
  --color-gain: #4ade80;
  --color-loss: #f87171;
  --color-warn: #fbbf24;
  --color-green-bg: rgba(74, 222, 128, 0.1);
  --color-red-bg: rgba(248, 113, 113, 0.1);
  --color-amber-bg: rgba(251, 191, 36, 0.1);
  --chart-grid: rgba(148, 163, 184, 0.12);
  --chart-text: #94a3b8;
  --sidebar-width: 210px;

  /* Elevation tokens */
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.2);
  --shadow-card-hover: 0 2px 8px rgba(0, 0, 0, 0.4), 0 8px 32px rgba(0, 0, 0, 0.25);
  --shadow-stat: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-modal: 0 8px 40px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.06);

  /* Gradient accents */
  --gradient-brand: linear-gradient(135deg, #3b82f6, #60a5fa);
  --gradient-brand-subtle: linear-gradient(135deg, rgba(59, 130, 246, 0.15), rgba(96, 165, 250, 0.06));
  --gradient-success: linear-gradient(135deg, #4ade80, #22c55e);
  --gradient-warn: linear-gradient(135deg, #fbbf24, #f59e0b);
}

/* ── Light theme overrides ── */
.light {
  --color-bg-page: #f8fafc;
  --color-bg-sidebar: #f1f5f9;
  --color-bg-card: #ffffff;
  --color-bg-card-hover: #f8fafc;
  --color-bg-secondary: #f1f5f9;
  --color-bg-elevated: #e2e8f0;
  --color-bg-input: #ffffff;
  --color-border: #cbd5e1;
  --color-border-hover: #94a3b8;
  --color-text-primary: #0f172a;
  --color-text-secondary: #475569;
  --color-text-muted: #94a3b8;
  --color-brand: #2563eb;
  --color-brand-glow: rgba(37, 99, 235, 0.08);
  --color-gain: #16a34a;
  --color-loss: #dc2626;
  --color-warn: #d97706;
  --color-green-bg: rgba(22, 163, 74, 0.08);
  --color-red-bg: rgba(220, 38, 38, 0.08);
  --color-amber-bg: rgba(217, 119, 6, 0.08);
  --chart-grid: rgba(148, 163, 184, 0.18);
  --chart-text: #475569;

  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.05), 0 4px 12px rgba(0, 0, 0, 0.04);
  --shadow-card-hover: 0 2px 6px rgba(0, 0, 0, 0.08), 0 6px 20px rgba(0, 0, 0, 0.06);
  --shadow-stat: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-modal: 0 8px 40px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.06);
}

/* ── Global smooth transitions ── */
.nav-item,
.card-glass,
.stat-card,
.hover-lift,
.pill-filter,
button,
a {
  transition: background-color 0.25s ease, border-color 0.25s ease, color 0.25s ease, box-shadow 0.25s ease, transform 0.25s ease, opacity 0.25s ease;
}

/* ── Reusable input field ── */
.input-field {
  background: var(--color-bg-elevated);
  color: var(--color-text-primary);
  border: 1px solid var(--color-border);
  border-radius: 0.5rem;
  outline: none;
  transition: border-color 0.2s ease, background 0.2s ease;
}
.input-field:focus {
  border-color: var(--color-brand);
  background: var(--color-bg-input);
}

/* ── Reusable buttons ── */
.btn-primary {
  background: var(--color-brand);
  color: #fff;
  border: none;
  cursor: pointer;
}
.btn-secondary {
  background: transparent;
  border: 1px solid var(--color-border);
  color: var(--color-text-secondary);
  cursor: pointer;
}
.btn-danger {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--color-red-bg);
  border: 1px solid var(--color-loss);
  color: var(--color-loss);
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 500;
  transition: all 0.15s ease;
}
.btn-danger:hover {
  background: var(--color-loss);
  color: #fff;
}

/* ── Table row hover (replaces inline onmouseover/onmouseout) ── */
.row-hover tbody tr {
  transition: background 0.1s;
}
.row-hover tbody tr:hover {
  background: var(--color-bg-elevated);
}

/* ── Modal / overlay fade-in ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
  animation: fadeIn 0.2s ease-out;
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ── Page content fade-in ── */
.page-content {
  animation: fadeUp 0.35s ease-out forwards;
}

/* ── Scrollbar (thin Apple-style) ── */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.2);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(148, 163, 184, 0.35);
}

/* ── Border utilities ── */
.border-b-05 { border-bottom-width: 0.5px; }
.border-t-05 { border-top-width: 0.5px; }

/* ── Typography scale ── */
.heading-xl {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.heading-lg {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.3;
}
.heading-md {
  font-size: 18px;
  font-weight: 600;
  line-height: 1.4;
}
.heading-sm {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.4;
}
.body-text {
  font-size: 13px;
  font-weight: 400;
  line-height: 1.6;
}
.caption {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
  line-height: 1.4;
}

/* ── Badge pills ── */
.badge-pill {
  font-size: 11px;
  font-weight: 500;
  padding: 1px 8px;
  border-radius: 12px;
  line-height: 1.6;
}

/* ── Card (enhanced frosted glass) ── */
.card-glass {
  background: var(--color-bg-card);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 14px;
  box-shadow: var(--shadow-card);
}

/* ── Modal (stronger glassmorphism, larger radius) ── */
.modal-glass {
  background: color-mix(in srgb, var(--color-bg-card) 85%, transparent);
  backdrop-filter: blur(24px) saturate(140%);
  -webkit-backdrop-filter: blur(24px) saturate(140%);
  border: 1px solid var(--color-border);
  border-radius: 20px;
  box-shadow: var(--shadow-modal);
}

/* ── Hover lift (refined spring, subtle pop) ── */
.hover-lift {
  transition: transform 0.35s cubic-bezier(0.25, 1.2, 0.5, 1), box-shadow 0.35s cubic-bezier(0.25, 1.2, 0.5, 1), border-color 0.35s cubic-bezier(0.25, 1.2, 0.5, 1);
}
.hover-lift:hover {
  transform: translateY(-4px) scale(1.01);
  border-color: var(--color-border-hover);
  box-shadow: var(--shadow-card-hover);
}

/* ── Nav item ── */
.nav-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 7px 10px;
  font-size: 13px;
  font-weight: 400;
  border-radius: 8px;
  color: var(--color-text-secondary);
  text-decoration: none;
  transition: all 0.2s ease;
  margin-bottom: 1px;
}
.nav-item:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--color-text-primary);
}
.nav-item.active {
  background: var(--color-brand-glow);
  color: var(--color-brand);
  font-weight: 600;
}

/* ── Stat card ── */
.stat-card {
  background: var(--color-bg-card);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 14px;
  padding: 16px 20px;
  box-shadow: var(--shadow-stat);
}
.stat-card:hover {
  border-color: var(--color-border-hover);
  box-shadow: var(--shadow-card-hover);
}

/* ── Top bar ── */
.top-bar {
  border-bottom: 1px solid var(--color-border);
}

/* ── Button press states ── */
button:active,
.pill-filter:active,
.nav-item:active {
  transform: scale(0.97);
}

/* ── Animated pulse for loading (legacy) ── */
@keyframes pulse-subtle {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}
.loading-pulse {
  animation: pulse-subtle 1.5s ease-in-out infinite;
}

/* ── Skeleton loading shimmer ── */
@keyframes shimmer {
  0% { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}
.skeleton {
  display: inline-block;
  border-radius: 6px;
  background: linear-gradient(
    90deg,
    var(--color-bg-card) 0%,
    var(--color-bg-card-hover) 40%,
    var(--color-bg-card) 80%
  );
  background-size: 800px 100%;
  animation: shimmer 1.8s ease-in-out infinite;
}
.skeleton-text {
  height: 13px;
  width: 100%;
  margin-bottom: 8px;
}
.skeleton-text:last-child { width: 60%; }
.skeleton-heading {
  height: 22px;
  width: 40%;
  margin-bottom: 12px;
}
.skeleton-stat {
  height: 28px;
  width: 50%;
  margin-top: 4px;
}
.skeleton-row {
  height: 48px;
  border-radius: 8px;
  margin-bottom: 6px;
}
.skeleton-circle {
  border-radius: 50%;
  width: 32px;
  height: 32px;
}

/* ── Entrance animations ── */
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.animate-fade-up {
  animation: fadeUp 0.4s ease-out forwards;
}
.animate-fade-up-d1 { animation-delay: 0.05s; opacity: 0; }
.animate-fade-up-d2 { animation-delay: 0.1s; opacity: 0; }
.animate-fade-up-d3 { animation-delay: 0.15s; opacity: 0; }
.animate-fade-up-d4 { animation-delay: 0.2s; opacity: 0; }
.animate-fade-up-d5 { animation-delay: 0.25s; opacity: 0; }

/* ── Empty state illustrations ── */
.empty-state-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  border-radius: 16px;
  background: var(--gradient-brand-subtle);
  color: var(--color-brand);
  font-size: 28px;
  margin-bottom: 12px;
}

/* ── Theme toggle switch ── */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 3px;
  border-radius: 99px;
  border: 1px solid var(--color-border);
  background: var(--color-bg-elevated);
  cursor: pointer;
  position: relative;
  transition: background 0.3s ease, border-color 0.3s ease;
}
.theme-toggle:hover {
  border-color: var(--color-border-hover);
}
.theme-toggle:active {
  transform: scale(0.97);
}
.theme-toggle-track {
  position: absolute;
  inset: 3px;
  pointer-events: none;
}
.theme-toggle-thumb {
  position: absolute;
  top: 0;
  left: 0;
  width: 50%;
  height: 100%;
  background: var(--color-brand);
  border-radius: 99px;
  transition: transform 0.4s cubic-bezier(0.25, 1.2, 0.5, 1);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}
.theme-toggle.light .theme-toggle-thumb {
  transform: translateX(100%);
  background: #2563eb;
}
.theme-toggle i {
  position: relative;
  z-index: 1;
  padding: 5px 7px;
  border-radius: 99px;
  transition: color 0.3s ease;
}
.theme-toggle .ti-sun {
  color: var(--color-text-muted);
}
.theme-toggle .ti-moon {
  color: var(--color-text-primary);
}
.theme-toggle.light .ti-sun {
  color: #fff;
}
.theme-toggle.light .ti-moon {
  color: var(--color-text-muted);
}

/* ── Responsive sidebar ── */
@media (max-width: 768px) {
  body > .grid {
    grid-template-columns: 1fr !important;
  }
  body > .grid > aside {
    position: fixed;
    inset: 0;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    width: var(--sidebar-width);
  }
  body > .grid > aside.open {
    transform: translateX(0);
  }
  .sidebar-overlay {
    position: fixed;
    inset: 0;
    z-index: 99;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
  }
  .sidebar-overlay.open {
    opacity: 1;
    pointer-events: auto;
  }
  .hamburger-btn {
    display: inline-flex !important;
  }
  .stat-card {
    padding: 10px 12px;
  }
  .card-glass {
    border-radius: 14px;
  }
}

.hamburger-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--color-border);
  background: var(--color-bg-card);
  color: var(--color-text-secondary);
  cursor: pointer;
  flex-shrink: 0;
  margin-right: 8px;
}
.hamburger-btn:hover {
  color: var(--color-text-primary);
  border-color: var(--color-border-hover);
}
