/* ===========================================
   Color System & Theme Variables
   Portfolio - Centralized Design Tokens
   =========================================== */

/* ===== Dark Theme (Default) ===== */
:root,
[data-theme="dark"] {
  /* ----- Background Colors ----- */
  --color-bg-primary: #020202;
  --color-bg-secondary: #0a0a0a;
  --color-bg-tertiary: rgba(19, 19, 19, 0.6);
  --color-bg-elevated: rgba(19, 19, 19, 0.4);
  --color-bg-overlay: rgba(2, 2, 2, 0.95);
  --color-bg-hover: rgba(255, 255, 255, 0.1);
  --color-bg-hover-subtle: rgba(255, 255, 255, 0.05);

  /* ----- Surface Colors (Cards, Modals) ----- */
  --color-surface-primary: #0a0a0a;
  --color-surface-secondary: rgba(19, 19, 19, 0.95);
  --color-surface-card: rgba(255, 255, 255, 0.03);
  --color-surface-card-hover: rgba(255, 255, 255, 0.05);

  /* ----- Text Colors ----- */
  --color-text-primary: #ffffff;
  --color-text-secondary: #979797;
  --color-text-tertiary: #8d8d8d;
  --color-text-muted: #818181;
  --color-text-disabled: #767676;
  --color-text-inverse: #020202;

  /* ----- Border Colors ----- */
  --color-border-primary: rgba(255, 255, 255, 0.1);
  --color-border-secondary: rgba(255, 255, 255, 0.15);
  --color-border-tertiary: rgba(255, 255, 255, 0.2);
  --color-border-strong: rgba(255, 255, 255, 0.3);
  --color-border-hover: rgba(255, 255, 255, 0.4);
  --color-border-focus: rgba(255, 255, 255, 0.5);
  --color-border-solid: #383838;
  --color-border-dashed: #81818149;
  --color-border-page: rgba(255, 255, 255, 0.118);

  /* ----- Accent Colors ----- */
  --color-accent-primary: #FFF6AE;
  --color-accent-hover: #ffed4e;
  --color-accent-orange: #ffa96f;

  /* ----- Interactive Colors ----- */
  --color-button-primary-bg: #ffffff;
  --color-button-primary-text: #020202;
  --color-button-primary-border: #ffffff;
  --color-button-secondary-bg: transparent;
  --color-button-secondary-text: #ffffff;
  --color-button-secondary-border: rgba(255, 255, 255, 0.3);
  --color-button-secondary-border-hover: rgba(255, 255, 255, 0.5);

  /* ----- Gradient Colors ----- */
  --gradient-heading: linear-gradient(120deg, #8d8d8d 0%, #ffffff 50%, #8d8d8d 100%);
  --gradient-glow: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, transparent 70%);

  /* ----- Shadow Colors ----- */
  --color-shadow-primary: rgba(0, 0, 0, 0.3);
  --color-shadow-glow: rgba(255, 255, 255, 0.4);
  --color-shadow-subtle: rgba(255, 255, 255, 0.02);

  /* ----- State Colors ----- */
  --color-success: #4ade80;
  --color-error: #f87171;
  --color-warning: #fbbf24;
  --color-info: #60a5fa;

  /* ----- Sparkle/Effect Colors ----- */
  --color-sparkle: rgba(255, 255, 255, 0.8);

  /* ----- Timeline/Decorative ----- */
  --color-timeline: #818181;
  --color-timeline-dashed: #81818188;

  /* ----- Light Section Colors (for inverted sections in dark mode) ----- */
  --color-light-section-bg: #ffffff;
  --color-light-section-bg-alt: #f8f8f8;
  --color-light-section-text: #020202;
  --color-light-section-text-secondary: #333333;
  --color-light-section-text-muted: #555555;
  --color-light-section-border: #5E5E5E;
  --color-light-section-border-light: #e0e0e0;
  --color-light-card-bg: #ffffff;
  --color-light-card-border: rgb(96, 96, 96);
  --color-light-tag-bg: #f8f8f8;
  --color-light-tag-text: #555555;
  --color-light-tag-border: #e0e0e0;
}

/* ===== Light Theme ===== */
[data-theme="light"] {
  /* ----- Background Colors ----- */
  --color-bg-primary: #ffffff;
  --color-bg-secondary: #f5f5f5;
  --color-bg-tertiary: rgba(245, 245, 245, 0.9);
  --color-bg-elevated: rgba(255, 255, 255, 0.95);
  --color-bg-overlay: rgba(255, 255, 255, 0.98);
  --color-bg-hover: rgba(0, 0, 0, 0.05);
  --color-bg-hover-subtle: rgba(0, 0, 0, 0.03);

  /* ----- Surface Colors (Cards, Modals) ----- */
  --color-surface-primary: #ffffff;
  --color-surface-secondary: #f8f8f8;
  --color-surface-card: rgba(0, 0, 0, 0.02);
  --color-surface-card-hover: rgba(0, 0, 0, 0.04);

  /* ----- Text Colors ----- */
  --color-text-primary: #1a1a1a;
  --color-text-secondary: #4a4a4a;
  --color-text-tertiary: #666666;
  --color-text-muted: #888888;
  --color-text-disabled: #aaaaaa;
  --color-text-inverse: #ffffff;

  /* ----- Border Colors ----- */
  --color-border-primary: rgba(0, 0, 0, 0.1);
  --color-border-secondary: rgba(0, 0, 0, 0.12);
  --color-border-tertiary: rgba(0, 0, 0, 0.15);
  --color-border-strong: rgba(0, 0, 0, 0.2);
  --color-border-hover: rgba(0, 0, 0, 0.25);
  --color-border-focus: rgba(0, 0, 0, 0.3);
  --color-border-solid: #d4d4d4;
  --color-border-dashed: rgba(100, 100, 100, 0.3);
  --color-border-page: rgba(0, 0, 0, 0.08);

  /* ----- Accent Colors ----- */
  --color-accent-primary: #e6a800;
  --color-accent-hover: #cc9600;
  --color-accent-orange: #e07c3f;

  /* ----- Interactive Colors ----- */
  --color-button-primary-bg: #1a1a1a;
  --color-button-primary-text: #ffffff;
  --color-button-primary-border: #1a1a1a;
  --color-button-secondary-bg: transparent;
  --color-button-secondary-text: #1a1a1a;
  --color-button-secondary-border: rgba(0, 0, 0, 0.2);
  --color-button-secondary-border-hover: rgba(0, 0, 0, 0.4);

  /* ----- Gradient Colors ----- */
  --gradient-heading: linear-gradient(120deg, #666666 0%, #1a1a1a 50%, #666666 100%);
  --gradient-glow: radial-gradient(circle, rgba(0, 0, 0, 0.05) 0%, transparent 70%);

  /* ----- Shadow Colors ----- */
  --color-shadow-primary: rgba(0, 0, 0, 0.1);
  --color-shadow-glow: rgba(0, 0, 0, 0.15);
  --color-shadow-subtle: rgba(0, 0, 0, 0.03);

  /* ----- State Colors ----- */
  --color-success: #22c55e;
  --color-error: #ef4444;
  --color-warning: #f59e0b;
  --color-info: #3b82f6;

  /* ----- Sparkle/Effect Colors ----- */
  --color-sparkle: rgba(0, 0, 0, 0.3);

  /* ----- Timeline/Decorative ----- */
  --color-timeline: #888888;
  --color-timeline-dashed: rgba(100, 100, 100, 0.5);

  /* ----- Light Section Colors (inverted in light mode - now dark sections) ----- */
  --color-light-section-bg: #f5f5f5;
  --color-light-section-bg-alt: #eeeeee;
  --color-light-section-text: #1a1a1a;
  --color-light-section-text-secondary: #333333;
  --color-light-section-text-muted: #666666;
  --color-light-section-border: #cccccc;
  --color-light-section-border-light: #e0e0e0;
  --color-light-card-bg: #ffffff;
  --color-light-card-border: #d4d4d4;
  --color-light-tag-bg: #f0f0f0;
  --color-light-tag-text: #555555;
  --color-light-tag-border: #d4d4d4;
}

/* ===== Theme Transition ===== */
/* Smooth transitions when switching themes */
html {
  transition: background-color 0.3s ease, color 0.3s ease;
}

html.theme-transitioning,
html.theme-transitioning *,
html.theme-transitioning *::before,
html.theme-transitioning *::after {
  transition:
    background-color 0.3s ease,
    border-color 0.3s ease,
    color 0.3s ease,
    fill 0.3s ease,
    stroke 0.3s ease,
    box-shadow 0.3s ease !important;
}

/* ===== Theme Toggle Switch Styles ===== */
.theme-toggle {
  position: relative;
  width: 72px;
  height: 36px;
  background: #3d3d3d;
  border-radius: 50px;
  cursor: pointer;
  border: none;
  padding: 4px;
  margin-left: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: background-color 0.3s ease;
}


/* Toggle track icons container */
.theme-toggle-icons {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px;
  pointer-events: none;
}

/* Sun icon (left side) */
.theme-toggle .sun-icon {
  width: 16px;
  height: 16px;
  color: #ffffff;
  opacity: 1;
  transition: opacity 0.3s ease;
}

/* Moon icon (right side) */
.theme-toggle .moon-icon {
  width: 16px;
  height: 16px;
  color: #6b7280;
  opacity: 0.5;
  transition: opacity 0.3s ease;
}

/* Toggle knob/circle */
.theme-toggle-knob {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 28px;
  height: 28px;
  background: #ffffff;
  border-radius: 50%;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  transform: translateX(36px);
}

.theme-toggle-knob svg {
  width: 14px;
  height: 14px;
  color: #020202;
}

/* Knob icon visibility - dark mode shows moon in knob */
.theme-toggle-knob .knob-sun {
  display: none;
}

.theme-toggle-knob .knob-moon {
  display: block;
}

/* Light mode styles */
[data-theme="light"] .theme-toggle {
  background: #e5e7eb;
}

[data-theme="light"] .theme-toggle .sun-icon {
  opacity: 1;
  color: #374151;
}

[data-theme="light"] .theme-toggle .moon-icon {
  opacity: 0.5;
  color: #9ca3af;
}

[data-theme="light"] .theme-toggle-knob {
  transform: translateX(0);
  background: #020202;
}

/* Light mode shows sun in knob */
[data-theme="light"] .theme-toggle-knob .knob-sun {
  display: block;
  color: #ffed4e;
}

[data-theme="light"] .theme-toggle-knob .knob-moon {
  display: none;
}

/* ===== Responsive Theme Toggle ===== */
@media (max-width: 768px) { 
  .theme-toggle {
    width: 64px;
    height: 32px;
    margin-left: 12px;
  }

  .theme-toggle-knob {
    width: 24px;
    height: 24px;
  }

  .theme-toggle .sun-icon,
  .theme-toggle .moon-icon {
    width: 14px;
    height: 14px;
  }

  .theme-toggle-knob svg {
    width: 12px;
    height: 12px;
  }

  [data-theme="light"] .theme-toggle-knob {
    transform: translateX(32px);
  }
}

@media (max-width: 480px) {
  .theme-toggle {
    width: 56px;
    height: 28px;
    margin-left: 8px;
  }

  .theme-toggle-knob {
    width: 20px;
    height: 20px;
  }

  .theme-toggle .sun-icon,
  .theme-toggle .moon-icon {
    width: 12px;
    height: 12px;
  }

  .theme-toggle-knob svg {
    width: 10px;
    height: 10px;
  }

  [data-theme="light"] .theme-toggle-knob {
    transform: translateX(28px);
  }
}
