@import "tailwindcss";
@import "tw-animate-css";

/* ==========================================================================
   CSS Custom Properties & Theme Configuration
   ========================================================================== */

@custom-variant dark (&:is(.dark *));

@theme inline {
  /* Color System */
  --color-background: var(--background);
  --color-foreground: var(--foreground);
  --color-card: var(--card);
  --color-card-foreground: var(--card-foreground);
  --color-popover: var(--popover);
  --color-popover-foreground: var(--popover-foreground);
  --color-primary: var(--primary);
  --color-primary-foreground: var(--primary-foreground);
  --color-secondary: var(--secondary);
  --color-secondary-foreground: var(--secondary-foreground);
  --color-muted: var(--muted);
  --color-muted-foreground: var(--muted-foreground);
  --color-accent: var(--accent);
  --color-accent-foreground: var(--accent-foreground);
  --color-destructive: var(--destructive);
  --color-destructive-foreground: var(--destructive-foreground);
  --color-border: var(--border);
  --color-input: var(--input);
  --color-ring: var(--ring);

  /* Chart Colors */
  --color-chart-1: var(--chart-1);
  --color-chart-2: var(--chart-2);
  --color-chart-3: var(--chart-3);
  --color-chart-4: var(--chart-4);
  --color-chart-5: var(--chart-5);

  /* Sidebar Colors */
  --color-sidebar: var(--sidebar);
  --color-sidebar-foreground: var(--sidebar-foreground);
  --color-sidebar-primary: var(--sidebar-primary);
  --color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
  --color-sidebar-accent: var(--sidebar-accent);
  --color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
  --color-sidebar-border: var(--sidebar-border);
  --color-sidebar-ring: var(--sidebar-ring);

  /* Typography */
  --font-sans: var(--font-geist);
  --font-mono: var(--font-geist-mono);
  --font-serif: Georgia, serif;

  /* Border Radius System */
  --radius-sm: calc(var(--radius) - 4px);
  --radius-md: calc(var(--radius) - 2px);
  --radius-lg: var(--radius);
  --radius-xl: calc(var(--radius) + 4px);

  /* Shadow System */
  --shadow-2xs: var(--shadow-2xs);
  --shadow-xs: var(--shadow-xs);
  --shadow-sm: var(--shadow-sm);
  --shadow: var(--shadow);
  --shadow-md: var(--shadow-md);
  --shadow-lg: var(--shadow-lg);
  --shadow-xl: var(--shadow-xl);
  --shadow-2xl: var(--shadow-2xl);

  /* Animation System */
  --animate-accordion-down: accordion-down 0.2s ease-out;
  --animate-accordion-up: accordion-up 0.2s ease-out;

  /* Easing Functions */
  --expo-out: cubic-bezier(0.16, 1, 0.3, 1);
  --expo-in: cubic-bezier(0.7, 0, 0.84, 0);
  --ease-spring: cubic-bezier(0.175, 0.885, 0.32, 1.275);
  --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);

  /* Animation Keyframes */
  @keyframes accordion-down {
    from {
      height: 0;
    }
    to {
      height: var(--radix-accordion-content-height);
    }
  }

  @keyframes accordion-up {
    from {
      height: var(--radix-accordion-content-height);
    }
    to {
      height: 0;
    }
  }
}

/* ==========================================================================
   Root Variables
   ========================================================================== */

:root {
  --background: oklch(0.99 0.005 240);
  --foreground: oklch(0.2 0.01 240);
  --card: oklch(0.98 0.005 240);
  --card-foreground: oklch(0.25 0.01 240);
  --popover: oklch(1 0 0);
  --popover-foreground: oklch(0.25 0.01 240);

  --primary: oklch(0.65 0.22 265);
  --primary-foreground: oklch(1 0 0);
  --secondary: oklch(0.94 0.01 240);
  --secondary-foreground: oklch(0.25 0.01 240);

  --muted: oklch(0.95 0.005 240);
  --muted-foreground: oklch(0.4 0.01 240);
  --accent: oklch(0.94 0.01 240);
  --accent-foreground: oklch(0.15 0.01 240);
  --destructive: oklch(0.6 0.19 25);
  --destructive-foreground: oklch(1 0 0);

  --border: oklch(0.85 0.005 240);
  --input: oklch(0.9 0.005 240);
  --ring: oklch(0.65 0.22 265 / 0.7);

  --chart-1: oklch(0.81 0.1 252);
  --chart-2: oklch(0.62 0.19 260);
  --chart-3: oklch(0.55 0.22 263);
  --chart-4: oklch(0.49 0.22 264);
  --chart-5: oklch(0.42 0.18 266);

  --sidebar: oklch(0.98 0.005 240);
  --sidebar-foreground: oklch(0.25 0.01 240);
  --sidebar-primary: oklch(0.94 0.01 240);
  --sidebar-primary-foreground: oklch(0.2 0.01 240);
  --sidebar-accent: oklch(0.96 0.005 240);
  --sidebar-accent-foreground: oklch(0.15 0.01 240);
  --sidebar-border: oklch(0.88 0.005 240);
  --sidebar-ring: oklch(0.65 0.22 265);

  --font-sans:
    ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif,
    "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
  --font-serif: ui-serif, Georgia, Cambria, "Times New Roman", Times, serif;
  --font-mono:
    ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    "Courier New", monospace;

  --radius: 0.35rem;
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;

  --shadow-2xs: 0 1px 3px 0px hsl(0 0% 0% / 0.05);
  --shadow-xs: 0 1px 3px 0px hsl(0 0% 0% / 0.05);
  --shadow-sm:
    0 1px 3px 0px hsl(0 0% 0% / 0.1), 0 1px 2px -1px hsl(0 0% 0% / 0.1);
  --shadow: 0 1px 3px 0px hsl(0 0% 0% / 0.1), 0 1px 2px -1px hsl(0 0% 0% / 0.1);
  --shadow-md:
    0 1px 3px 0px hsl(0 0% 0% / 0.1), 0 2px 4px -1px hsl(0 0% 0% / 0.1);
  --shadow-lg:
    0 1px 3px 0px hsl(0 0% 0% / 0.1), 0 4px 6px -1px hsl(0 0% 0% / 0.1);
  --shadow-xl:
    0 1px 3px 0px hsl(0 0% 0% / 0.1), 0 8px 10px -1px hsl(0 0% 0% / 0.1);
  --shadow-2xl: 0 1px 3px 0px hsl(0 0% 0% / 0.25);

  --success: oklch(0.55 0.22 150);
  --success-foreground: oklch(0.99 0 0);
  --warning: oklch(0.7 0.17 76);
  --warning-foreground: oklch(0.15 0.01 260);
  --info: oklch(0.6 0.2 220);
  --info-foreground: oklch(0.99 0 0);

  --scrollbar-size: 3px;
  --scrollbar-track: transparent;
  --scrollbar-thumb: hsl(var(--border));
  --scrollbar-thumb-hover: hsl(var(--muted-foreground) / 0.4);

  --focus-ring: 0 0 0 2px var(--ring);
  --focus-ring-offset: 2px;
}

/* ==========================================================================
   Dark Theme (optional)  
   ========================================================================== */

.dark {
  --background: oklch(0.1 0.015 240);
  --foreground: oklch(0.85 0.01 240);
  --card: oklch(0.15 0.02 240);
  --card-foreground: oklch(0.88 0.01 240);
  --popover: oklch(0.2 0.02 240);
  --popover-foreground: oklch(0.88 0.01 240);

  --primary: oklch(0.7 0.22 265);
  --primary-foreground: oklch(0.15 0.02 240);
  --secondary: oklch(0.3 0.025 240);
  --secondary-foreground: oklch(0.9 0.01 240);

  --muted: oklch(0.25 0.02 240);
  --muted-foreground: oklch(0.65 0.015 240);
  --accent: oklch(0.22 0.02 240);
  --accent-foreground: oklch(0.9 0.01 240);
  --destructive: oklch(0.65 0.18 25);
  --destructive-foreground: oklch(1 0 0);

  --border: oklch(0.3 0.02 240);
  --input: oklch(0.22 0.02 240);
  --ring: oklch(0.7 0.22 265);

  --chart-1: oklch(0.81 0.1 252);
  --chart-2: oklch(0.62 0.19 260);
  --chart-3: oklch(0.55 0.22 263);
  --chart-4: oklch(0.49 0.22 264);
  --chart-5: oklch(0.42 0.18 266);

  --sidebar: oklch(0.08 0.02 240);
  --sidebar-foreground: oklch(0.85 0.01 240);
  --sidebar-primary: oklch(0.15 0.025 240);
  --sidebar-primary-foreground: oklch(0.9 0.01 240);
  --sidebar-accent: oklch(0.12 0.02 240);
  --sidebar-accent-foreground: oklch(0.88 0.01 240);
  --sidebar-border: oklch(0.25 0.02 240);
  --sidebar-ring: oklch(0.7 0.22 265);

  --font-sans:
    ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif,
    "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
  --font-serif: ui-serif, Georgia, Cambria, "Times New Roman", Times, serif;
  --font-mono:
    ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    "Courier New", monospace;
  --radius: 0.35rem;
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --shadow-2xs: 0 1px 3px 0px hsl(0 0% 0% / 0.05);
  --shadow-xs: 0 1px 3px 0px hsl(0 0% 0% / 0.05);
  --shadow-sm:
    0 1px 3px 0px hsl(0 0% 0% / 0.1), 0 1px 2px -1px hsl(0 0% 0% / 0.1);
  --shadow: 0 1px 3px 0px hsl(0 0% 0% / 0.1), 0 1px 2px -1px hsl(0 0% 0% / 0.1);
  --shadow-md:
    0 1px 3px 0px hsl(0 0% 0% / 0.1), 0 2px 4px -1px hsl(0 0% 0% / 0.1);
  --shadow-lg:
    0 1px 3px 0px hsl(0 0% 0% / 0.1), 0 4px 6px -1px hsl(0 0% 0% / 0.1);
  --shadow-xl:
    0 1px 3px 0px hsl(0 0% 0% / 0.1), 0 8px 10px -1px hsl(0 0% 0% / 0.1);
  --shadow-2xl: 0 1px 3px 0px hsl(0 0% 0% / 0.25);

  --scrollbar-size: 2px;
  --scrollbar-track: transparent;
  --scrollbar-thumb: hsl(var(--border));
  --scrollbar-thumb-hover: hsl(var(--muted-foreground) / 0.3);
}

/* ==========================================================================
   Base Styles & Reset
   ========================================================================== */

@layer base {
  * {
    @apply border-border;
  }

  *,
  *::before,
  *::after {
    box-sizing: border-box;
  }

  html {
    scroll-behavior: smooth;
    text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }

  body {
    @apply bg-background text-foreground font-sans;
    font-feature-settings:
      "rlig" 1,
      "calt" 1,
      "kern" 1;
    font-variant-ligatures: common-ligatures;
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
  }

  p {
    text-wrap: pretty;
    max-width: 65ch;
  }

}

/* ==========================================================================
   Scrollbar Styling
   ========================================================================== */

::-webkit-scrollbar {
  width: var(--scrollbar-size);
  height: var(--scrollbar-size);
}

::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
}

::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: calc(var(--scrollbar-size) / 2);
  transition: all 0.2s var(--ease-smooth);
  min-height: 20px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover);
  transform: scaleX(1.2);
}

::-webkit-scrollbar-thumb:active {
  background: hsl(var(--muted-foreground) / 0.7);
  transform: scaleX(1.4);
}

::-webkit-scrollbar-corner {
  background: var(--scrollbar-track);
}

/* Firefox Scrollbar */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

/* Enhanced scrollbar for specific containers */
.scrollbar-thin::-webkit-scrollbar {
  width: 3px;
  height: 3px;
}

.scrollbar-none {
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.scrollbar-none::-webkit-scrollbar {
  display: none;
}

@media (max-width: 768px) {
  /* Smooth scrolling on mobile */
  .mobile-scroll {
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
  }

  /* Edge swipe indicator */
  @keyframes swipe-hint {
    0% {
      transform: translateX(-100%) translateY(-50%);
    }
    50% {
      transform: translateX(0) translateY(-50%);
    }
    100% {
      transform: translateX(-100%) translateY(-50%);
    }
  }

  .swipe-hint-animation {
    animation: swipe-hint 2s ease-in-out infinite;
  }

  /* Mobile-specific typography */
  body {
    font-size: 16px; /* Prevent zoom on iOS */
  }

  /* Improved mobile forms */
  input,
  textarea,
  select {
    font-size: 16px; /* Prevent zoom on iOS */
  }
}

/* Tablet optimizations */
@media (min-width: 769px) and (max-width: 1024px) {
  .tablet-optimized {
    padding: 1.5rem;
  }
}

/* ==========================================================================
   Accessibility & User Preferences
   ========================================================================== */

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

  .sidebar-transition {
    transition: none;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  :root {
    --border: oklch(0.5 0 0);
    --ring: oklch(0.3 0 0);
  }

  .dark {
    --border: oklch(0.7 0 0);
    --ring: oklch(0.8 0 0);
  }

  .sidebar-backdrop {
    background-color: rgba(0, 0, 0, 0.8);
  }
}