/* ==============================================
   SubSlayer Design System
   ============================================== */

/* -------------------- Design Tokens -------------------- */
:root {
  /* Colors - Primary (Aggressive Red/Orange) */
  --color-primary-50: #fef2f2;
  --color-primary-100: #fee2e2;
  --color-primary-200: #fecaca;
  --color-primary-300: #fca5a5;
  --color-primary-400: #f87171;
  --color-primary-500: #ef4444;
  --color-primary-600: #dc2626;
  --color-primary-700: #b91c1c;
  --color-primary-800: #991b1b;
  --color-primary-900: #7f1d1d;

  /* Colors - Success (Money Green) */
  --color-success-50: #f0fdf4;
  --color-success-100: #dcfce7;
  --color-success-200: #bbf7d0;
  --color-success-300: #86efac;
  --color-success-400: #4ade80;
  --color-success-500: #22c55e;
  --color-success-600: #16a34a;
  --color-success-700: #15803d;
  --color-success-800: #166534;
  --color-success-900: #14532d;

  /* Colors - Warning */
  --color-warning-50: #fffbeb;
  --color-warning-100: #fef3c7;
  --color-warning-200: #fde68a;
  --color-warning-300: #fcd34d;
  --color-warning-400: #fbbf24;
  --color-warning-500: #f59e0b;
  --color-warning-600: #d97706;
  --color-warning-700: #b45309;

  /* Colors - Neutral */
  --color-neutral-50: #fafafa;
  --color-neutral-100: #f4f4f5;
  --color-neutral-200: #e4e4e7;
  --color-neutral-300: #d4d4d8;
  --color-neutral-400: #a1a1aa;
  --color-neutral-500: #71717a;
  --color-neutral-600: #52525b;
  --color-neutral-700: #3f3f46;
  --color-neutral-800: #27272a;
  --color-neutral-900: #18181b;
  --color-neutral-950: #09090b;

  /* Semantic Colors */
  --color-background: #09090b;
  --color-surface: #18181b;
  --color-surface-elevated: #27272a;
  --color-border: #3f3f46;
  --color-text-primary: #fafafa;
  --color-text-secondary: #a1a1aa;
  --color-text-muted: #71717a;

  /* Typography Scale */
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-family-mono: 'JetBrains Mono', 'Fira Code', monospace;
  
  --text-xs: 0.75rem;      /* 12px */
  --text-sm: 0.875rem;     /* 14px */
  --text-base: 1rem;       /* 16px */
  --text-lg: 1.125rem;     /* 18px */
  --text-xl: 1.25rem;      /* 20px */
  --text-2xl: 1.5rem;      /* 24px */
  --text-3xl: 1.875rem;    /* 30px */
  --text-4xl: 2.25rem;     /* 36px */
  --text-5xl: 3rem;        /* 48px */
  --text-6xl: 3.75rem;     /* 60px */

  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;

  --line-height-tight: 1.25;
  --line-height-normal: 1.5;
  --line-height-relaxed: 1.625;

  /* Spacing Scale (4px base) */
  --space-0: 0;
  --space-1: 0.25rem;   /* 4px */
  --space-2: 0.5rem;    /* 8px */
  --space-3: 0.75rem;   /* 12px */
  --space-4: 1rem;      /* 16px */
  --space-5: 1.25rem;   /* 20px */
  --space-6: 1.5rem;    /* 24px */
  --space-8: 2rem;      /* 32px */
  --space-10: 2.5rem;   /* 40px */
  --space-12: 3rem;     /* 48px */
  --space-16: 4rem;     /* 64px */
  --space-20: 5rem;     /* 80px */

  /* Border Radius */
  --radius-sm: 0.25rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-2xl: 1.5rem;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
  --shadow-glow-red: 0 0 40px -10px rgb(239 68 68 / 0.5);
  --shadow-glow-green: 0 0 40px -10px rgb(34 197 94 / 0.5);

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 200ms ease;
  --transition-slow: 300ms ease;

  /* Z-Index Scale */
  --z-base: 0;
  --z-dropdown: 100;
  --z-sticky: 200;
  --z-modal: 300;
  --z-toast: 400;
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-family);
  font-size: var(--text-base);
  line-height: var(--line-height-normal);
  color: var(--color-text-primary);
  background-color: var(--color-background);
  min-height: 100vh;
}

/* -------------------- Typography -------------------- */
h1, h2, h3, h4, h5, h6 {
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-tight);
}

h1 { font-size: var(--text-4xl); }
h2 { font-size: var(--text-3xl); }
h3 { font-size: var(--text-2xl); }
h4 { font-size: var(--text-xl); }

p {
  color: var(--color-text-secondary);
}

a {
  color: var(--color-primary-400);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--color-primary-300);
}

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

.sidebar {
  width: 280px;
  background-color: var(--color-surface);
  border-right: 1px solid var(--color-border);
  padding: var(--space-6);
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
  overflow-y: auto;
}

.main-content {
  flex: 1;
  margin-left: 280px;
  padding: var(--space-8);
  max-width: 1200px;
}

/* -------------------- Logo & Branding -------------------- */
.logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-8);
}

.logo-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--color-primary-500), var(--color-primary-700));
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xl);
}

.logo-text {
  font-size: var(--text-xl);
  font-weight: var(--font-weight-bold);
  color: var(--color-text-primary);
}

/* -------------------- Navigation -------------------- */
.nav-section {
  margin-bottom: var(--space-6);
}

.nav-label {
  font-size: var(--text-xs);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-3);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  color: var(--color-text-secondary);
  transition: all var(--transition-fast);
  cursor: pointer;
  margin-bottom: var(--space-1);
}

.nav-item:hover {
  background-color: var(--color-surface-elevated);
  color: var(--color-text-primary);
}

.nav-item.active {
  background-color: var(--color-primary-500);
  background: linear-gradient(135deg, var(--color-primary-600), var(--color-primary-700));
  color: white;
}

.nav-item-icon {
  font-size: var(--text-lg);
  width: 24px;
  text-align: center;
}

.nav-item-badge {
  margin-left: auto;
  background-color: var(--color-primary-500);
  color: white;
  font-size: var(--text-xs);
  font-weight: var(--font-weight-semibold);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-full);
  min-width: 20px;
  text-align: center;
}

/* -------------------- Stats Cards -------------------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--space-6);
  margin-bottom: var(--space-8);
}

.stat-card {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  transition: all var(--transition-base);
}

.stat-card:hover {
  border-color: var(--color-primary-500);
  transform: translateY(-2px);
}

.stat-card.danger {
  border-color: var(--color-primary-700);
  background: linear-gradient(135deg, var(--color-surface), rgba(239, 68, 68, 0.1));
}

.stat-card.success {
  border-color: var(--color-success-700);
  background: linear-gradient(135deg, var(--color-surface), rgba(34, 197, 94, 0.1));
}

.stat-card.warning {
  border-color: var(--color-warning-600);
  background: linear-gradient(135deg, var(--color-surface), rgba(245, 158, 11, 0.1));
}

.stat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-2xl);
}

.stat-icon.danger {
  background-color: rgba(239, 68, 68, 0.2);
}

.stat-icon.success {
  background-color: rgba(34, 197, 94, 0.2);
}

.stat-icon.warning {
  background-color: rgba(245, 158, 11, 0.2);
}

.stat-trend {
  font-size: var(--text-sm);
  font-weight: var(--font-weight-medium);
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.stat-trend.up {
  color: var(--color-primary-400);
}

.stat-trend.down {
  color: var(--color-success-400);
}

.stat-value {
  font-size: var(--text-4xl);
  font-weight: var(--font-weight-bold);
  margin-bottom: var(--space-1);
  font-family: var(--font-family-mono);
}

.stat-value.danger {
  color: var(--color-primary-400);
}

.stat-value.success {
  color: var(--color-success-400);
}

.stat-value.warning {
  color: var(--color-warning-400);
}

.stat-label {
  color: var(--color-text-secondary);
  font-size: var(--text-sm);
}

/* -------------------- Subscription List -------------------- */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-6);
}

.section-title {
  font-size: var(--text-xl);
  font-weight: var(--font-weight-semibold);
}

.section-actions {
  display: flex;
  gap: var(--space-3);
}

.subscription-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.subscription-card {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-5);
  display: flex;
  align-items: center;
  gap: var(--space-4);
  transition: all var(--transition-base);
}

.subscription-card:hover {
  border-color: var(--color-neutral-500);
  background-color: var(--color-surface-elevated);
}

.subscription-card.urgent {
  border-color: var(--color-primary-500);
  box-shadow: var(--shadow-glow-red);
}

.subscription-card.safe {
  border-color: var(--color-success-600);
}

.subscription-logo {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-2xl);
  font-weight: var(--font-weight-bold);
  flex-shrink: 0;
}

.subscription-info {
  flex: 1;
  min-width: 0;
}

.subscription-name {
  font-weight: var(--font-weight-semibold);
  font-size: var(--text-lg);
  margin-bottom: var(--space-1);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.subscription-category {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  background-color: var(--color-surface-elevated);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-full);
}

.subscription-meta {
  display: flex;
  gap: var(--space-4);
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
}

.subscription-price {
  text-align: right;
}

.subscription-amount {
  font-size: var(--text-xl);
  font-weight: var(--font-weight-bold);
  font-family: var(--font-family-mono);
  color: var(--color-text-primary);
}

.subscription-period {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.subscription-actions {
  display: flex;
  gap: var(--space-2);
}

/* -------------------- Renewal Alert Badge -------------------- */
.renewal-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--font-weight-semibold);
}

.renewal-badge.critical {
  background-color: var(--color-primary-500);
  color: white;
  animation: pulse 2s infinite;
}

.renewal-badge.warning {
  background-color: var(--color-warning-500);
  color: var(--color-neutral-900);
}

.renewal-badge.safe {
  background-color: var(--color-success-600);
  color: white;
}

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

/* -------------------- Buttons -------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
  font-weight: var(--font-weight-medium);
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-primary {
  background: linear-gradient(135deg, var(--color-primary-500), var(--color-primary-600));
  color: white;
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--color-primary-400), var(--color-primary-500));
  transform: translateY(-1px);
}

.btn-success {
  background: linear-gradient(135deg, var(--color-success-500), var(--color-success-600));
  color: white;
}

.btn-success:hover {
  background: linear-gradient(135deg, var(--color-success-400), var(--color-success-500));
}

.btn-ghost {
  background-color: transparent;
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border);
}

.btn-ghost:hover {
  background-color: var(--color-surface-elevated);
  color: var(--color-text-primary);
  border-color: var(--color-neutral-500);
}

.btn-danger {
  background-color: transparent;
  color: var(--color-primary-400);
  border: 1px solid var(--color-primary-500);
}

.btn-danger:hover {
  background-color: var(--color-primary-500);
  color: white;
}

.btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: var(--radius-lg);
}

/* -------------------- Health Score -------------------- */
.health-score-card {
  background: linear-gradient(135deg, var(--color-surface), var(--color-surface-elevated));
  border: 1px solid var(--color-border);
  border-radius: var(--radius-2xl);
  padding: var(--space-8);
  text-align: center;
  margin-bottom: var(--space-8);
}

.health-score-circle {
  width: 160px;
  height: 160px;
  border-radius: var(--radius-full);
  margin: 0 auto var(--space-6);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.health-score-circle::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--radius-full);
  padding: 6px;
  background: conic-gradient(
    var(--color-warning-500) 0deg,
    var(--color-warning-500) calc(var(--score, 65) * 3.6deg),
    var(--color-neutral-700) calc(var(--score, 65) * 3.6deg)
  );
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
}

.health-score-value {
  font-size: var(--text-5xl);
  font-weight: var(--font-weight-bold);
  font-family: var(--font-family-mono);
  color: var(--color-warning-400);
}

.health-score-label {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.health-score-title {
  font-size: var(--text-2xl);
  font-weight: var(--font-weight-bold);
  margin-bottom: var(--space-2);
}

.health-score-subtitle {
  color: var(--color-text-secondary);
  margin-bottom: var(--space-6);
}

.health-tips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  justify-content: center;
}

.health-tip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
}

/* -------------------- Savings Counter -------------------- */
.savings-banner {
  background: linear-gradient(135deg, var(--color-success-700), var(--color-success-900));
  border-radius: var(--radius-2xl);
  padding: var(--space-8);
  text-align: center;
  margin-bottom: var(--space-8);
  box-shadow: var(--shadow-glow-green);
}

.savings-label {
  font-size: var(--text-sm);
  color: var(--color-success-200);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: var(--space-2);
}

.savings-amount {
  font-size: var(--text-6xl);
  font-weight: var(--font-weight-bold);
  font-family: var(--font-family-mono);
  color: white;
  margin-bottom: var(--space-2);
}

.savings-detail {
  font-size: var(--text-lg);
  color: var(--color-success-200);
}

.savings-slayed {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  margin-top: var(--space-4);
  font-size: var(--text-lg);
  color: white;
}

/* -------------------- Empty & Loading States -------------------- */
.empty-state {
  text-align: center;
  padding: var(--space-16) var(--space-8);
  color: var(--color-text-secondary);
}

.empty-state-icon {
  font-size: var(--text-6xl);
  margin-bottom: var(--space-4);
}

.empty-state-title {
  font-size: var(--text-xl);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-primary);
  margin-bottom: var(--space-2);
}

.loading-skeleton {
  background: linear-gradient(
    90deg,
    var(--color-surface) 25%,
    var(--color-surface-elevated) 50%,
    var(--color-surface) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-lg);
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* -------------------- Modal -------------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-base);
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-2xl);
  padding: var(--space-8);
  max-width: 500px;
  width: 90%;
  transform: scale(0.95);
  transition: transform var(--transition-base);
}

.modal-overlay.active .modal {
  transform: scale(1);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-6);
}

.modal-title {
  font-size: var(--text-xl);
  font-weight: var(--font-weight-bold);
}

.modal-close {
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-size: var(--text-2xl);
  cursor: pointer;
  padding: var(--space-2);
  line-height: 1;
}

.modal-close:hover {
  color: var(--color-text-primary);
}

/* -------------------- Toast Notifications -------------------- */
.toast-container {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.toast {
  background-color: var(--color-surface-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 300px;
  box-shadow: var(--shadow-xl);
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.toast-icon {
  font-size: var(--text-xl);
}

.toast-content {
  flex: 1;
}

.toast-title {
  font-weight: var(--font-weight-semibold);
  margin-bottom: var(--space-1);
}

.toast-message {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
}

/* -------------------- Responsive -------------------- */
@media (max-width: 1024px) {
  .sidebar {
    width: 240px;
  }
  
  .main-content {
    margin-left: 240px;
  }
}

@media (max-width: 768px) {
  .app-container {
    flex-direction: column;
  }
  
  .sidebar {
    width: 100%;
    height: auto;
    position: relative;
    border-right: none;
    border-bottom: 1px solid var(--color-border);
  }
  
  .main-content {
    margin-left: 0;
    padding: var(--space-4);
  }
  
  .stats-grid {
    grid-template-columns: 1fr;
  }
  
  .subscription-card {
    flex-direction: column;
    text-align: center;
  }
  
  .subscription-price {
    text-align: center;
    margin: var(--space-3) 0;
  }
}

/* -------------------- Utility Classes -------------------- */
.text-center { text-align: center; }
.text-right { text-align: right; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--space-2); }
.gap-4 { gap: var(--space-4); }
.mt-4 { margin-top: var(--space-4); }
.mb-4 { margin-bottom: var(--space-4); }
.hidden { display: none; }
