/* ============================================
   KRMU ECHOSENSE Design System - Tokens
   Shadcn/UI Inspired Variables + Base Styles
   ============================================ */

/* ---------- Color Tokens (Light Theme Default) ---------- */
:root {
  /* Background layers - #ffffff */
  --background: 0 0% 100%;
  --foreground: 240 10% 4%;

  /* Card / Surface - #ffffff */
  --card: 0 0% 100%;
  --card-foreground: 240 10% 4%;

  /* Background Pattern (Light) */
  --bg-pattern: none;

  /* Muted (secondary text, disabled states) - #71717a for text */
  --muted: 240 5% 96%;
  --muted-foreground: 240 4% 46%;

  /* Borders & Dividers - #e4e4e7 */
  --border: 240 6% 90%;

  /* Primary (Green Accent) */
  --primary: 142 64% 32%;
  --primary-foreground: 0 0% 100%;

  /* Volunteer (Teal/Cyan Accent) */
  --volunteer: 174 72% 40%;
  --volunteer-foreground: 174 100% 98%;

  /* Secondary */
  --secondary: 240 5% 96%;
  --secondary-foreground: 240 10% 4%;

  /* Accent (hover states) - #f4f4f5 */
  --accent: 240 5% 96%;
  --accent-foreground: 240 10% 4%;

  /* Destructive (errors) */
  --destructive: 0 84.2% 60.2%;
  --destructive-foreground: 0 0% 98%;

  /* Focus ring */
  --ring: 142 64% 32%;

  /* Input - #e4e4e7 */
  --input: 240 6% 90%;

  /* Alias variables for compatibility */
  --text-color: hsl(240 10% 4%);
  --text-muted: hsl(240 4% 46%);
  --border-color: hsl(240 6% 90%);
  --card-bg: hsl(0 0% 100%);
  --button-bg: hsl(240 10% 4%);
  --button-text: hsl(0 0% 100%);
  --hover-bg-color: hsl(240 5% 96%);

  /* ---------- Radius Scale ---------- */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-full: 9999px;

  /* ---------- Spacing Scale ---------- */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;

  /* ---------- Shadow Scale ---------- */
  --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);

  /* ---------- Typography ---------- */
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", "Fira Code", Consolas, Monaco, monospace;

  /* Font sizes */
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 1.875rem;

  /* Line heights */
  --leading-tight: 1.25;
  --leading-normal: 1.5;
  --leading-relaxed: 1.625;

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

  /* ---------- Transitions ---------- */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);

  /* ---------- Z-index Scale ---------- */
  --z-dropdown: 50;
  --z-modal: 100;
  --z-toast: 150;
}

/* ---------- Dark Theme ---------- */
[data-theme="dark"] {
  /* Background layers */
  --background: 240 10% 3.9%;
  --foreground: 0 0% 98%;

  /* Card / Surface */
  --card: 240 10% 3.9%;
  --card-foreground: 0 0% 98%;

  /* Background Pattern (Dark) */
  --bg-pattern: radial-gradient(circle at 50% 0%, rgba(34, 197, 94, 0.1), transparent 40%);

  /* Muted (secondary text, disabled states) */
  --muted: 240 3.7% 15.9%;
  --muted-foreground: 240 5% 64.9%;

  /* Borders & Dividers */
  --border: 240 3.7% 15.9%;

  /* Primary (Green Accent) */
  --primary: 142 76% 36%;
  --primary-foreground: 144 100% 98%;

  /* Secondary */
  --secondary: 240 3.7% 15.9%;
  --secondary-foreground: 0 0% 98%;

  /* Accent (hover states) */
  --accent: 240 3.7% 15.9%;
  --accent-foreground: 0 0% 98%;

  /* Destructive (errors) */
  --destructive: 0 62.8% 50.6%;
  --destructive-foreground: 0 0% 98%;

  /* Focus ring */
  --ring: 142 76% 36%;

  /* Input */
  --input: 240 3.7% 15.9%;

  /* Alias variables for compatibility */
  --text-color: hsl(0 0% 98%);
  --text-muted: hsl(240 5% 64.9%);
  --border-color: hsl(240 3.7% 15.9%);
  --card-bg: hsl(240 10% 3.9%);
  --button-bg: hsl(0 0% 98%);
  --button-text: hsl(240 10% 3.9%);
  --hover-bg-color: hsl(240 3.7% 15.9%);
}

/* ---------- CSS Reset + Base Styles ---------- */
*,
*::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;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: hsl(var(--foreground));
  background-color: hsl(var(--background));
  background-image: var(--bg-pattern, none);
  background-attachment: fixed;
  min-height: 100vh;
  min-height: 100dvh;
}

/* Accessibility: Respect reduced motion */
@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Focus visible for keyboard navigation */
:focus-visible {
  outline: 2px solid hsl(var(--ring));
  outline-offset: 2px;
}

:focus:not(:focus-visible) {
  outline: none;
}

/* Links */
a {
  color: hsl(var(--primary));
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  text-decoration: underline;
  text-underline-offset: 4px;
}

/* Selection color */
::selection {
  background-color: hsl(var(--primary) / 0.3);
  color: hsl(var(--foreground));
}

/* Smooth scrolling (respects prefers-reduced-motion via media query above) */
html {
  scroll-behavior: smooth;
}

/* Hidden but accessible (screen readers) */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Loading spinner keyframe */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}