/**
 * HAIVEN DESIGN SYSTEM v2.0
 * Unified design tokens and components - SINGLE SOURCE OF TRUTH
 *
 * USAGE RULES:
 * 1. ALL components must use these tokens (no hardcoded values)
 * 2. Use semantic aliases (--color-primary) in component code
 * 3. Raw tokens (--haiven-cyan) only for token definitions
 * 4. Extension and frontend share this exact system
 * 5. Never duplicate these definitions elsewhere
 *
 * Last updated: 2025-11-06
 */

/* ========================================
   RESET & BASE
   ======================================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* ========================================
   SECTION 1: RAW COLOR TOKENS
   Base brand colors - DO NOT use directly in components
   ======================================== */
:root {
  /* Primary Brand - Haiven Cyan (Official brand color) */
  --haiven-cyan: #1fb6ff;
  --haiven-cyan-light: #5eccff;
  --haiven-cyan-dark: #0a8ac9;
  --haiven-cyan-alpha-10: rgba(31, 182, 255, 0.1);
  --haiven-cyan-alpha-20: rgba(31, 182, 255, 0.2);
  --haiven-cyan-alpha-30: rgba(31, 182, 255, 0.3);

  /* Secondary Brand - Teal */
  --haiven-teal: #14b8a6;
  --haiven-teal-light: #2dd4bf;
  --haiven-teal-dark: #0d9488;

  /* Base Colors */
  --black: #000000;
  --deep-black: #030712;
  --white: #ffffff;

  /* Grayscale */
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;

  /* Status Colors (Raw) */
  --success: #10b981;
  --success-light: #22c55e;
  --success-dark: #059669;

  --warning: #f59e0b;
  --warning-light: #fbbf24;
  --warning-dark: #d97706;

  --error: #ef4444;
  --error-light: #f87171;
  --error-dark: #dc2626;

  /* ========================================
       SECTION 2: SEMANTIC ALIASES
       USE THESE in component code, not raw tokens above
       ======================================== */

  /* Semantic Color Aliases */
  --color-primary: var(--haiven-cyan);
  --color-primary-light: var(--haiven-cyan-light);
  --color-primary-dark: var(--haiven-cyan-dark);
  --color-primary-alpha-10: var(--haiven-cyan-alpha-10);
  --color-primary-alpha-20: var(--haiven-cyan-alpha-20);
  --color-primary-alpha-30: var(--haiven-cyan-alpha-30);

  --color-secondary: var(--haiven-teal);
  --color-secondary-light: var(--haiven-teal-light);
  --color-secondary-dark: var(--haiven-teal-dark);

  --color-info: var(--haiven-cyan);
  --color-success: var(--success);
  --color-warning: var(--warning);
  --color-error: var(--error);

  /* ========================================
       SECTION 3: BACKGROUND SYSTEM (3 Levels)
       Standardized dark background hierarchy
       ======================================== */

  /* Background Levels - Apple Dark Mode (Premium Consumer Feel) */
  --bg-base: #000000; /* Level 1: True black for OLED - Apple style */
  --bg-surface: #1c1c1e; /* Level 2: Warm dark gray - Apple iOS/macOS */
  --bg-elevated: #2c2c2e; /* Level 3: Elevated warm gray - clearly visible */

  /* Background Alpha Variants (for glass effects) */
  --bg-glass-light: rgba(255, 255, 255, 0.05);
  --bg-glass-medium: rgba(255, 255, 255, 0.08);
  --bg-glass-heavy: rgba(255, 255, 255, 0.12);

  /* Border Colors - Warm and subtle like Apple */
  --border-subtle: rgba(255, 255, 255, 0.1);
  --border-default: rgba(255, 255, 255, 0.15);
  --border-strong: rgba(255, 255, 255, 0.25);
  --border-primary: var(--haiven-cyan);

  /* Text Colors - High contrast white text for dark backgrounds */
  --text-primary: rgba(255, 255, 255, 0.95);
  --text-secondary: rgba(255, 255, 255, 0.75);
  --text-tertiary: rgba(255, 255, 255, 0.55);
  --text-disabled: rgba(255, 255, 255, 0.35);

  /* Spacing Scale (8px base unit) */
  --space-0: 0;
  --space-1: 8px;
  --space-2: 16px;
  --space-3: 24px;
  --space-4: 32px;
  --space-5: 40px;
  --space-6: 48px;
  --space-7: 56px;
  --space-8: 64px;
  --space-10: 80px;
  --space-12: 96px;
  --space-16: 128px;

  /* Typography Scale */
  --text-xs: 12px;
  --text-sm: 14px;
  --text-base: 16px;
  --text-lg: 18px;
  --text-xl: 20px;
  --text-2xl: 24px;
  --text-3xl: 32px;
  --text-4xl: 48px;
  --text-5xl: 64px;
  --text-6xl: 84px;

  /* Font Weights */
  --font-normal: 400;
  --font-medium: 500;
  --font-semibold: 600;
  --font-bold: 700;
  --font-extrabold: 800;
  --font-black: 900;

  /* Border Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-2xl: 24px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.1);
  --shadow-2xl: 0 30px 80px rgba(0, 0, 0, 0.5);
  --shadow-glow-cyan: 0 0 20px rgba(31, 182, 255, 0.5);
  --shadow-glow-cyan-lg: 0 0 40px rgba(31, 182, 255, 0.8);

  /* ========================================
       SECTION 4: ANIMATION & TIMING SYSTEM
       ======================================== */

  /* Timing Tokens (use these for transitions/animations) */
  --timing-instant: 100ms;
  --timing-fast: 150ms;
  --timing-base: 250ms;
  --timing-slow: 400ms;
  --timing-slower: 600ms;

  /* Easing Functions */
  --ease-standard: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-decelerate: cubic-bezier(0, 0, 0.2, 1);
  --ease-accelerate: cubic-bezier(0.4, 0, 1, 1);
  --ease-bounce: cubic-bezier(0.68, -0.55, 0.265, 1.55);

  /* Composed Transitions (semantic) */
  --transition-fast: var(--timing-fast) var(--ease-standard);
  --transition-base: var(--timing-base) var(--ease-standard);
  --transition-slow: var(--timing-slow) var(--ease-standard);

  /* Z-index Scale */
  --z-base: 1;
  --z-dropdown: 100;
  --z-sticky: 200;
  --z-modal: 300;
  --z-popover: 400;
  --z-toast: 500;
  --z-nav: 1000;
}

/* ========================================
   BODY & BASE STYLES
   ======================================== */
body {
  font-family:
    'Inter',
    -apple-system,
    BlinkMacSystemFont,
    'Segoe UI',
    Roboto,
    'Helvetica Neue',
    sans-serif;
  background: linear-gradient(135deg, #1fb6ff 0%, #4ecdc4 100%);
  color: rgba(255, 255, 255, 0.92);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  line-height: 1.6;
}

/* ========================================
   TYPOGRAPHY
   ======================================== */
h1,
h2,
h3,
h4,
h5,
h6 {
  font-weight: var(--font-extrabold);
  line-height: 1.2;
  letter-spacing: -0.02em;
}

h1 {
  font-size: clamp(48px, 6vw, 84px);
  font-weight: var(--font-black);
  letter-spacing: -0.04em;
  line-height: 1.1;
}

h2 {
  font-size: clamp(32px, 4vw, 56px);
}

h3 {
  font-size: clamp(24px, 3vw, 36px);
}

h4 {
  font-size: var(--text-2xl);
}

h5 {
  font-size: var(--text-xl);
}

h6 {
  font-size: var(--text-lg);
}

p {
  line-height: 1.6;
}

.text-gradient {
  background: linear-gradient(135deg, var(--haiven-cyan), var(--haiven-teal));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.text-white-gradient {
  background: linear-gradient(135deg, var(--white) 0%, rgba(255, 255, 255, 0.8) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ========================================
   LAYOUT COMPONENTS
   ======================================== */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--space-4);
}

.container-wide {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 var(--space-4);
}

.container-narrow {
  max-width: 800px;
  margin: 0 auto;
  padding: 0 var(--space-4);
}

section {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 120px 40px 80px;
  position: relative;
}

/* ========================================
   NAVIGATION
   ======================================== */
nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: var(--z-nav);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  background: rgba(0, 0, 0, 0.7);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.nav-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px 40px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  font-size: 24px;
  font-weight: var(--font-extrabold);
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--haiven-cyan), var(--haiven-teal));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: logoPulse 3s ease-in-out infinite;
  text-decoration: none;
}

.logo-img {
  height: 50px;
  width: auto;
}

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

.nav-links {
  display: flex;
  gap: var(--space-4);
  align-items: center;
}

.nav-link {
  color: var(--gray-300);
  text-decoration: none;
  font-size: var(--text-base);
  font-weight: var(--font-medium);
  transition: color var(--transition-fast);
}

.nav-link:hover {
  color: var(--white);
}

/* ========================================
   BUTTONS
   ======================================== */
.btn {
  padding: 14px 32px;
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  font-weight: var(--font-semibold);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  transition: all var(--transition-base);
  cursor: pointer;
  border: none;
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, var(--haiven-cyan), var(--haiven-teal));
  color: var(--white);
  box-shadow: var(--shadow-glow-cyan);
}

.btn-primary:hover {
  box-shadow: var(--shadow-glow-cyan-lg);
  transform: translateY(-2px);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  color: var(--white);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-danger {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: var(--white);
  box-shadow: 0 0 20px rgba(239, 68, 68, 0.5);
}

.btn-danger:hover {
  box-shadow: 0 0 40px rgba(239, 68, 68, 0.8);
  transform: translateY(-2px);
}

.btn-sm {
  padding: 10px 20px;
  font-size: var(--text-sm);
}

.btn-lg {
  padding: 18px 48px;
  font-size: var(--text-lg);
}

.btn-full {
  width: 100%;
}

/* ========================================
   CARDS & PANELS
   ======================================== */
.glass-card {
  background: rgba(255, 255, 255, 0.05) !important; /* Transparent glass effect */
  backdrop-filter: blur(30px) saturate(180%);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.18) !important;
  border-radius: 16px;
  padding: 20px;
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.37),
    inset 0 1px 0 rgba(255, 255, 255, 0.1) !important;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  color: rgba(255, 255, 255, 0.95) !important; /* Bright white for readability */
  line-height: 1.6;
}

.glass-card:hover {
  background: rgba(255, 255, 255, 0.08) !important;
  border-color: rgba(31, 182, 255, 0.6) !important;
  box-shadow:
    0 12px 40px rgba(0, 0, 0, 0.45),
    0 0 0 1px rgba(31, 182, 255, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.15) !important;
  transform: translateY(-2px) scale(1.01);
}

.card {
  background: rgba(255, 255, 255, 0.05) !important; /* Transparent glass effect */
  backdrop-filter: blur(30px) saturate(180%);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.18) !important;
  border-radius: 16px;
  padding: 20px;
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.37),
    inset 0 1px 0 rgba(255, 255, 255, 0.1) !important;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  color: rgba(255, 255, 255, 0.95) !important; /* Bright white for readability */
  line-height: 1.6;
}

.card-hover {
  cursor: pointer;
}

.card-hover:hover {
  transform: translateY(-4px);
  border-color: var(--haiven-cyan);
  box-shadow: 0 0 40px rgba(31, 182, 255, 0.3);
}

.card-glow {
  border-color: var(--haiven-cyan);
  box-shadow: 0 0 40px rgba(31, 182, 255, 0.3);
  animation: cardGlow 2s ease-in-out infinite;
}

@keyframes cardGlow {
  0%,
  100% {
    box-shadow: 0 0 40px rgba(31, 182, 255, 0.3);
  }
  50% {
    box-shadow: 0 0 60px rgba(31, 182, 255, 0.5);
  }
}

/* ========================================
   BADGES
   ======================================== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge-primary {
  background: linear-gradient(135deg, var(--haiven-cyan), var(--haiven-teal));
  color: var(--white);
}

.badge-secondary {
  background: rgba(255, 255, 255, 0.1);
  color: var(--gray-300);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.badge-success {
  background: rgba(16, 185, 129, 0.2);
  color: var(--success);
  border: 1px solid var(--success);
}

.badge-warning {
  background: rgba(245, 158, 11, 0.2);
  color: var(--warning);
  border: 1px solid var(--warning);
}

.badge-error {
  background: rgba(239, 68, 68, 0.2);
  color: var(--error);
  border: 1px solid var(--error);
}

/* ========================================
   FORMS
   ======================================== */
.form-group {
  margin-bottom: var(--space-3);
}

.form-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--gray-300);
  margin-bottom: var(--space-1);
}

.form-input,
.form-textarea,
.form-select {
  width: 100%;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  color: var(--white);
  font-size: var(--text-base);
  font-family: inherit;
  transition: all var(--transition-fast);
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
  outline: none;
  border-color: var(--haiven-cyan);
  box-shadow: 0 0 0 3px rgba(31, 182, 255, 0.1);
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--gray-500);
}

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

.form-error {
  color: var(--error);
  font-size: var(--text-sm);
  margin-top: var(--space-1);
}

.form-helper {
  color: var(--gray-400);
  font-size: var(--text-sm);
  margin-top: var(--space-1);
}

/* ========================================
   LOADING STATES
   ======================================== */
.skeleton {
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.02) 0%,
    rgba(255, 255, 255, 0.05) 50%,
    rgba(255, 255, 255, 0.02) 100%
  );
  background-size: 200% 100%;
  animation: skeleton 1.5s ease-in-out infinite;
  border-radius: var(--radius-md);
}

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

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--haiven-cyan);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.spinner-sm {
  width: 20px;
  height: 20px;
  border-width: 2px;
}

/* ========================================
   ALERTS & NOTIFICATIONS
   ======================================== */
.alert {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
}

.alert-info {
  background: rgba(31, 182, 255, 0.1);
  border: 1px solid rgba(31, 182, 255, 0.3);
  color: var(--haiven-cyan);
}

.alert-success {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: var(--success);
}

.alert-warning {
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: var(--warning);
}

.alert-error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--error);
}

/* ========================================
   UTILITY CLASSES
   ======================================== */
/* Spacing */
.m-0 {
  margin: 0;
}
.mt-1 {
  margin-top: var(--space-1);
}
.mt-2 {
  margin-top: var(--space-2);
}
.mt-3 {
  margin-top: var(--space-3);
}
.mt-4 {
  margin-top: var(--space-4);
}
.mb-1 {
  margin-bottom: var(--space-1);
}
.mb-2 {
  margin-bottom: var(--space-2);
}
.mb-3 {
  margin-bottom: var(--space-3);
}
.mb-4 {
  margin-bottom: var(--space-4);
}

.p-0 {
  padding: 0;
}
.p-1 {
  padding: var(--space-1);
}
.p-2 {
  padding: var(--space-2);
}
.p-3 {
  padding: var(--space-3);
}
.p-4 {
  padding: var(--space-4);
}

/* Flexbox */
.flex {
  display: flex;
}
.flex-col {
  flex-direction: column;
}
.items-center {
  align-items: center;
}
.justify-center {
  justify-content: center;
}
.justify-between {
  justify-content: space-between;
}
.gap-1 {
  gap: var(--space-1);
}
.gap-2 {
  gap: var(--space-2);
}
.gap-3 {
  gap: var(--space-3);
}
.gap-4 {
  gap: var(--space-4);
}

/* Text Alignment */
.text-left {
  text-align: left;
}
.text-center {
  text-align: center;
}
.text-right {
  text-align: right;
}

/* Display */
.hidden {
  display: none;
}
.block {
  display: block;
}
.inline-block {
  display: inline-block;
}

/* Width */
.w-full {
  width: 100%;
}
.max-w-full {
  max-width: 100%;
}

/* ========================================
   ANIMATIONS
   ======================================== */
.fade-in {
  animation: fadeIn 0.6s ease-out;
}

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

.slide-up {
  animation: slideUp 0.6s ease-out;
}

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

/* ========================================
   RESPONSIVE BREAKPOINTS
   ======================================== */
@media (max-width: 768px) {
  :root {
    --space-4: 20px;
    --space-5: 32px;
    --space-6: 40px;
  }

  .nav-container {
    padding: 16px 20px;
  }

  .nav-links {
    gap: var(--space-2);
  }

  .nav-link {
    display: none;
  }

  .btn {
    padding: 10px 20px;
    font-size: var(--text-sm);
  }

  section {
    padding: 100px 20px 60px;
  }

  .container {
    padding: 0 var(--space-2);
  }

  h1 {
    font-size: 40px;
  }

  /* Mobile-specific utilities */
  .mobile-hide {
    display: none !important;
  }

  .mobile-show {
    display: block !important;
  }

  .mobile-flex {
    display: flex !important;
  }

  .mobile-stack {
    flex-direction: column !important;
  }

  .mobile-full {
    width: 100% !important;
  }
}

@media (max-width: 480px) {
  .btn {
    padding: 10px 16px;
    font-size: 14px;
  }

  .glass-card,
  .card {
    padding: var(--space-2);
  }
}
