/* FitCoin MVP - Base Styles & Design System */

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* Performance optimizations */
  scroll-behavior: smooth;
  overflow-x: hidden;
}

body {
  line-height: 1.6;
  font-family: 'Maven Pro', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  overflow-x: hidden;
}

/* Design System Variables */
:root {
  /* Brand Colors (consistent across themes) */
  --color-primary: #0696AF;
  --color-secondary: #73C64F;
  --color-accent: #FF6B35;
  --color-warning: #FFD93D;
  --color-error: #FF6B6B;
  --color-success: #4ECDC4;

  /* Gradients (consistent across themes) */
  --gradient-primary: linear-gradient(135deg, #0696AF 0%, #73C64F 100%);
  --gradient-secondary: linear-gradient(135deg, #73C64F 0%, #A8E6CF 100%);
  --gradient-warm: linear-gradient(135deg, #FF6B35 0%, #FFD93D 100%);
  --gradient-cool: linear-gradient(135deg, #4ECDC4 0%, #0696AF 100%);

  /* Light Theme Colors (enhanced) */
  --color-white: #FFFFFF;
  --color-background: #F8FAFC;
  --color-surface: #FFFFFF;
  --color-surface-alt: #F1F5F9;
  --color-surface-elevated: #FFFFFF;
  --color-border: #E2E8F0;
  --color-border-light: #F1F5F9;
  --color-border-subtle: #CBD5E1;

  /* Light Theme Text Colors (improved contrast) */
  --color-text-primary: #1E293B;
  --color-text-secondary: #475569;
  --color-text-tertiary: #94A3B8;
  --color-text-inverse: #FFFFFF;
  --color-text-muted: #64748B;

  /* Light Theme Shadows (enhanced) */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-xl: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-2xl: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  --shadow-inner: inset 0 2px 4px 0 rgba(0, 0, 0, 0.06);

  /* Border Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 50%;

  /* Spacing Scale */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
  --space-3xl: 64px;

  /* Typography Scale */
  --font-size-xs: 12px;
  --font-size-sm: 14px;
  --font-size-base: 16px;
  --font-size-lg: 18px;
  --font-size-xl: 20px;
  --font-size-2xl: 24px;
  --font-size-3xl: 32px;
  --font-size-4xl: 40px;

  /* Font Weights */
  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;

  /* Line Heights */
  --line-height-tight: 1.2;
  --line-height-normal: 1.5;
  --line-height-relaxed: 1.6;

  /* Z-Index Scale */
  --z-dropdown: 1000;
  --z-sticky: 1020;
  --z-fixed: 1030;
  --z-modal-backdrop: 1040;
  --z-modal: 1050;
  --z-popover: 1060;
  --z-tooltip: 1070;

  /* Transitions */
  --transition-fast: all 0.15s ease-out;
  --transition-base: all 0.3s ease-out;
  --transition-slow: all 0.5s ease-out;

  /* Mobile-first breakpoints */
  --bp-xs: 375px;
  --bp-sm: 640px;
  --bp-md: 768px;
  --bp-lg: 1024px;
  --bp-xl: 1280px;
  --bp-xxl: 1536px;

  /* Responsive spacing */
  --space-responsive-sm: clamp(8px, 2vw, 16px);
  --space-responsive-md: clamp(16px, 4vw, 32px);
  --space-responsive-lg: clamp(24px, 6vw, 48px);

  /* Responsive typography */
  --font-responsive-sm: clamp(14px, 3.5vw, 16px);
  --font-responsive-base: clamp(16px, 4vw, 18px);
  --font-responsive-lg: clamp(18px, 4.5vw, 24px);
  --font-responsive-xl: clamp(20px, 5vw, 32px);
}

/* Dark Theme Variables */
[data-theme="dark"] {
  /* Dark Theme Colors */
  --color-white: #1E1E1E;
  --color-background: #121212;
  --color-surface: #1E1E1E;
  --color-surface-alt: #2D2D2D;
  --color-border: #404040;
  --color-border-light: #505050;

  /* Dark Theme Text Colors - Improved contrast */
  --color-text-primary: #FFFFFF;
  --color-text-secondary: #C0C0C0;
  --color-text-tertiary: #909090;
  --color-text-inverse: #1E1E1E;

  /* Dark Theme Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.4);
  --shadow-xl: 0 12px 48px rgba(0, 0, 0, 0.5);
}

/* Auto Dark Mode (respects system preference when no manual setting) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]):not([data-theme-initialized]) {
    /* Dark Theme Colors */
    --color-white: #1E1E1E;
    --color-background: #121212;
    --color-surface: #1E1E1E;
    --color-surface-alt: #2D2D2D;
    --color-surface-elevated: #2D2D2D;
    --color-border: #404040;
    --color-border-light: #505050;
    --color-border-subtle: #505050;

    /* Dark Theme Text Colors - Improved contrast */
    --color-text-primary: #FFFFFF;
    --color-text-secondary: #C0C0C0;
    --color-text-tertiary: #909090;
    --color-text-muted: #A0A0A0;
    --color-text-inverse: #1E1E1E;

    /* Dark Theme Shadows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.4);
    --shadow-xl: 0 12px 48px rgba(0, 0, 0, 0.5);
    --shadow-2xl: 0 25px 50px rgba(0, 0, 0, 0.7);
    --shadow-inner: inset 0 2px 4px 0 rgba(0, 0, 0, 0.6);
  }
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  color: var(--color-text-primary);
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-tight);
  margin-bottom: var(--space-md);
}

h1 {
  font-size: var(--font-size-3xl);
  font-weight: var(--font-weight-bold);
}

h2 {
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-bold);
}

h3 {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-semibold);
}

h4 {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
}

p {
  color: var(--color-text-secondary);
  font-size: var(--font-size-base);
  line-height: var(--line-height-relaxed);
  margin-bottom: var(--space-md);
}

.text-primary { color: var(--color-text-primary); }
.text-secondary { color: var(--color-text-secondary); }
.text-tertiary { color: var(--color-text-tertiary); }
.text-muted { color: var(--color-text-muted); }
.text-inverse { color: var(--color-text-inverse); }

.text-xs { font-size: var(--font-size-xs); }
.text-sm { font-size: var(--font-size-sm); }
.text-base { font-size: var(--font-size-base); }
.text-lg { font-size: var(--font-size-lg); }
.text-xl { font-size: var(--font-size-xl); }
.text-2xl { font-size: var(--font-size-2xl); }
.text-3xl { font-size: var(--font-size-3xl); }

.font-normal { font-weight: var(--font-weight-normal); }
.font-medium { font-weight: var(--font-weight-medium); }
.font-semibold { font-weight: var(--font-weight-semibold); }
.font-bold { font-weight: var(--font-weight-bold); }

.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

/* Layout Utilities */
.container {
  width: 100%;
  max-width: 428px;
  margin: 0 auto;
  padding: 0 var(--space-md);
}

.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

.flex-row {
  flex-direction: row;
}

.items-center {
  align-items: center;
}

.items-start {
  align-items: flex-start;
}

.items-end {
  align-items: flex-end;
}

.justify-center {
  justify-content: center;
}

.justify-between {
  justify-content: space-between;
}

.justify-around {
  justify-content: space-around;
}

.gap-xs { gap: var(--space-xs); }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }
.gap-xl { gap: var(--space-xl); }

.w-full { width: 100%; }
.h-full { height: 100%; }
.min-h-screen { min-height: 100vh; }

/* Spacing */
.p-xs { padding: var(--space-xs); }
.p-sm { padding: var(--space-sm); }
.p-md { padding: var(--space-md); }
.p-lg { padding: var(--space-lg); }
.p-xl { padding: var(--space-xl); }

.px-xs { padding-left: var(--space-xs); padding-right: var(--space-xs); }
.px-sm { padding-left: var(--space-sm); padding-right: var(--space-sm); }
.px-md { padding-left: var(--space-md); padding-right: var(--space-md); }
.px-lg { padding-left: var(--space-lg); padding-right: var(--space-lg); }

.py-xs { padding-top: var(--space-xs); padding-bottom: var(--space-xs); }
.py-sm { padding-top: var(--space-sm); padding-bottom: var(--space-sm); }
.py-md { padding-top: var(--space-md); padding-bottom: var(--space-md); }
.py-lg { padding-top: var(--space-lg); padding-bottom: var(--space-lg); }

.m-xs { margin: var(--space-xs); }
.m-sm { margin: var(--space-sm); }
.m-md { margin: var(--space-md); }
.m-lg { margin: var(--space-lg); }
.m-xl { margin: var(--space-xl); }

.mx-auto { margin-left: auto; margin-right: auto; }

.mb-xs { margin-bottom: var(--space-xs); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.mb-xl { margin-bottom: var(--space-xl); }

.mt-xs { margin-top: var(--space-xs); }
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mt-xl { margin-top: var(--space-xl); }

/* Background Colors */
.bg-primary { background-color: var(--color-primary); }
.bg-secondary { background-color: var(--color-secondary); }
.bg-accent { background-color: var(--color-accent); }
.bg-white { background-color: var(--color-white); }
.bg-background { background-color: var(--color-background); }
.bg-surface { background-color: var(--color-surface); }
.bg-surface-alt { background-color: var(--color-surface-alt); }
.bg-surface-elevated { background-color: var(--color-surface-elevated); }

.bg-gradient-primary { background: var(--gradient-primary); }
.bg-gradient-secondary { background: var(--gradient-secondary); }
.bg-gradient-warm { background: var(--gradient-warm); }
.bg-gradient-cool { background: var(--gradient-cool); }

/* Border Radius */
.rounded-sm { border-radius: var(--radius-sm); }
.rounded-md { border-radius: var(--radius-md); }
.rounded-lg { border-radius: var(--radius-lg); }
.rounded-xl { border-radius: var(--radius-xl); }
.rounded-full { border-radius: var(--radius-full); }

/* Shadows */
.shadow-sm { box-shadow: var(--shadow-sm); }
.shadow-md { box-shadow: var(--shadow-md); }
.shadow-lg { box-shadow: var(--shadow-lg); }
.shadow-xl { box-shadow: var(--shadow-xl); }
.shadow-2xl { box-shadow: var(--shadow-2xl); }
.shadow-inner { box-shadow: var(--shadow-inner); }
.shadow-none { box-shadow: none; }

/* Transitions */
.transition-fast { transition: var(--transition-fast); }
.transition-base { transition: var(--transition-base); }
.transition-slow { transition: var(--transition-slow); }

/* Visibility */
.hidden { display: none !important; }
.visible { display: block !important; }

/* Interactive States */
.interactive {
  cursor: pointer;
  transition: var(--transition-base);
}

.interactive:hover {
  transform: translateY(-1px);
}

.interactive:active {
  transform: translateY(0);
}

/* Mobile-first responsive design */
@media (max-width: 374px) {
  :root {
    --font-size-3xl: 28px;
    --font-size-2xl: 22px;
  }

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

@media (min-width: 640px) {
  .container {
    padding: 0 var(--space-lg);
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  :root {
    --color-border: #000000;
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.4);
  }
}

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

/* Focus styles for accessibility */
:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* Selection colors */
::selection {
  background-color: var(--color-primary);
  color: var(--color-white);
}

::-moz-selection {
  background-color: var(--color-primary);
  color: var(--color-white);
}