/* Removed blocking Google Fonts import - fonts should be loaded via HTML link tag with preconnect */

/* System font stack to avoid remote font overhead */

/* Responsive Utilities - Inlined to avoid @import issues */
/* Fluid Typography Base Classes */
.text-fluid-xs { font-size: clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem); }
.text-fluid-sm { font-size: clamp(0.875rem, 0.8rem + 0.375vw, 1rem); }
.text-fluid-base { font-size: clamp(1rem, 0.9rem + 0.5vw, 1.125rem); }
.text-fluid-lg { font-size: clamp(1.125rem, 1rem + 0.625vw, 1.25rem); }
.text-fluid-xl { font-size: clamp(1.25rem, 1.1rem + 0.75vw, 1.5rem); }
.text-fluid-2xl { font-size: clamp(1.5rem, 1.3rem + 1vw, 1.875rem); }
.text-fluid-3xl { font-size: clamp(1.875rem, 1.6rem + 1.375vw, 2.25rem); }
.text-fluid-4xl { font-size: clamp(2.25rem, 1.9rem + 1.75vw, 3rem); }
.text-fluid-5xl { font-size: clamp(3rem, 2.5rem + 2.5vw, 4rem); }

/* Mobile-Safe Input Sizes (prevents iOS zoom) */
.text-input-mobile { font-size: max(1rem, 16px); }
.text-button-mobile { font-size: clamp(0.875rem, 0.8rem + 0.375vw, 1rem); }
.text-label-mobile { font-size: clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem); }

/* Touch-Friendly Sizing */
.min-touch-target, .touch-target-sm { min-width: 2.75rem; min-height: 2.75rem; }
.touch-target-md { min-width: 3rem; min-height: 3rem; }

/* Mobile Animations - Inlined to avoid @import issues */
:root {
  --animation-duration: 300ms;
  --animation-easing: cubic-bezier(0.4, 0, 0.2, 1);
  --animation-delay: 0ms;
  --theme-transition: all 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

.perf-high { --animation-duration: 300ms; --animation-easing: cubic-bezier(0.4, 0, 0.2, 1); }
.perf-low { --animation-duration: 150ms; --animation-easing: ease-out; }
.perf-disabled { --animation-duration: 0ms; --animation-easing: none; }

.animations-disabled *, .animations-disabled *::before, .animations-disabled *::after {
  animation-duration: 0.01ms !important; animation-delay: 0.01ms !important;
  transition-duration: 0.01ms !important; transition-delay: 0.01ms !important;
}

.gpu-accelerated {
  transform: translateZ(0); backface-visibility: hidden; perspective: 1000px; will-change: transform, opacity;
}

.optimized-transition {
  transition-property: transform, opacity; transition-duration: var(--animation-duration);
  transition-timing-function: var(--animation-easing); will-change: transform, opacity;
}

/* Touch Interactions - Inlined to avoid @import issues */
.touch-optimized { touch-action: manipulation; user-select: none; -webkit-tap-highlight-color: transparent; }

.haptic-feedback { cursor: pointer; transition: transform 0.1s ease; }
.haptic-feedback:active { transform: scale(0.98); }

.swipe-enabled { touch-action: pan-x pan-y; overflow: hidden; }
.swipe-area { touch-action: pan-x; overflow-x: auto; overflow-y: hidden; }

.touch-scroll { overflow: auto; -webkit-overflow-scrolling: touch; scroll-behavior: smooth; }

.touch-safe-area { padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }

@tailwind base;
@tailwind components;
@tailwind utilities;

@layer utilities {
  .pb-safe {
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
  }
}

/* Global touch optimizations */
a, button, [role="button"], input[type="button"], input[type="submit"], .touch-target {
  touch-action: manipulation;
}

/* Prefer-reduced-motion: disable non-essential animations/transitions */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

/* Optimized theme transitions - reduced to prevent layout shift */
html {
  background-color: hsl(var(--background));
  /* Removed transform properties that can cause layout shift */
}

body {
  background-color: hsl(var(--background));
  min-height: 100vh;
  /* Prevent content layout shift */
  overflow-y: scroll;
  /* Simplified transitions - removed will-change to prevent layout shift */
  transition: background-color 0.2s ease, color 0.2s ease;
}

/* Ensure consistent scrollbar behavior */
html {
  overflow-y: scroll; /* Always show scrollbar to prevent layout shift */
  scroll-behavior: smooth;
}

/* AGGRESSIVE SCROLL LOCK PREVENTION - HIGHEST PRIORITY */
body[data-scroll-locked],
body[style*="overflow: hidden"],
body[style*="overflow:hidden"],
body.scroll-lock,
body.no-scroll,
body.overflow-hidden {
  overflow: auto !important;
  overflow-y: scroll !important;
  padding-right: 0 !important;
  margin-right: 0 !important;
  position: static !important;
}

/* Prevent any modal from locking scroll */
html:has([data-radix-dialog-content]),
html:has([role="dialog"]),
html:has([role="alertdialog"]) {
  overflow: auto !important;
}

/* Prevent sidebar highlighting when dialogs are open */
html:has([data-radix-dialog-content]) .sidebar-number,
html:has([data-radix-dialog-content]) .filter-badge,
html:has([data-radix-dialog-content]) .count-badge,
html:has([role="dialog"]) .sidebar-number,
html:has([role="dialog"]) .filter-badge,
html:has([role="dialog"]) .count-badge,
html:has([data-radix-dialog-overlay]) .sidebar-number,
html:has([data-radix-dialog-overlay]) .filter-badge,
html:has([data-radix-dialog-overlay]) .count-badge {
  animation: none !important;
  transform: none !important;
  transition: none !important;
  scale: 1 !important;
  background-color: inherit !important;
  border-color: inherit !important;
  color: inherit !important;
}

/* Remove focus outline when data-focus-visible is false */
[data-focus-visible="false"] {
  outline: none !important;
}

/* Disable all hover effects when dialogs are open */
html:has([data-radix-dialog-content]) .group:hover .sidebar-number,
html:has([data-radix-dialog-content]) .group:hover .filter-badge,
html:has([data-radix-dialog-content]) .group:hover .count-badge,
html:has([role="dialog"]) .group:hover .sidebar-number,
html:has([role="dialog"]) .group:hover .filter-badge,
html:has([role="dialog"]) .group:hover .count-badge {
  background-color: inherit !important;
  border-color: inherit !important;
  color: inherit !important;
}

html:has([data-radix-dialog-content]) body,
html:has([role="dialog"]) body,
html:has([role="alertdialog"]) body {
  overflow: auto !important;
  overflow-y: scroll !important;
  padding-right: 0 !important;
  margin-right: 0 !important;
  position: static !important;
}

/* Ultra-specific overrides for Radix UI */
body[data-scroll-locked="true"],
body[data-scroll-locked="1"] {
  overflow: auto !important;
  overflow-y: scroll !important;
  padding-right: 0 !important;
  margin-right: 0 !important;
}

/* Inline style overrides */
body[style*="overflow"] {
  overflow: auto !important;
  overflow-y: scroll !important;
}

body[style*="padding-right"] {
  padding-right: 0 !important;
}

body[style*="margin-right"] {
  margin-right: 0 !important;
}

#root {
  background-color: hsl(var(--background));
  min-height: 100vh;
  /* Smooth transitions for root element */
  transition: background-color 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Instant theme switching - no global transitions */
:root {
  color-scheme: light;
}

.dark {
  color-scheme: dark;
}

/* Smooth transitions for page navigation */
.page-transition {
  transition: opacity 150ms ease-in-out;
}

/* Prevent flash of unstyled content */
.loading-container {
  background-color: hsl(var(--background));
  min-height: 100vh;
}

/* Optimize skeleton animations */
@keyframes skeleton-pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
}

.skeleton-loading {
  animation: skeleton-pulse 1.5s ease-in-out infinite;
}

/* Mobile scroll improvements */
.horizontal-scroll {
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE/Edge */
}

.horizontal-scroll::-webkit-scrollbar {
  display: none; /* Chrome/Safari */
}

/* Smooth scrolling for mobile */
.scroll-smooth {
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

/* Animation keyframes */
@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

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

@keyframes scale-in {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes grid-item-enter {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes shimmer {
  0% {
    background-position: -200px 0;
  }
  100% {
    background-position: calc(200px + 100%) 0;
  }
}

@keyframes gradient-x {
  0%, 100% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
}

@keyframes gradient-y {
  0%, 100% {
    background-position: 50% 0%;
  }
  50% {
    background-position: 50% 100%;
  }
}

@keyframes gradient-xy {
  0%, 100% {
    background-position: 0% 0%;
  }
  25% {
    background-position: 100% 0%;
  }
  50% {
    background-position: 100% 100%;
  }
  75% {
    background-position: 0% 100%;
  }
}

@keyframes float {
  0%, 100% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(-20px);
  }
}

@keyframes pulse-glow {
  0%, 100% {
    box-shadow: 0 0 20px rgba(var(--primary), 0.5);
  }
  50% {
    box-shadow: 0 0 40px rgba(var(--primary), 0.8);
  }
}

@keyframes particle-float {
  0% {
    transform: translateY(0) rotate(0deg);
    opacity: 0;
  }
  10% {
    opacity: 1;
  }
  90% {
    opacity: 1;
  }
  100% {
    transform: translateY(-100vh) rotate(720deg);
    opacity: 0;
  }
}

/* Enhanced detail grid animations */
.detail-grid-enter {
  animation: grid-item-enter 0.3s ease-out;
}

.detail-grid-enter:nth-child(1) { animation-delay: 0ms; }
.detail-grid-enter:nth-child(2) { animation-delay: 50ms; }
.detail-grid-enter:nth-child(3) { animation-delay: 100ms; }
.detail-grid-enter:nth-child(4) { animation-delay: 150ms; }
.detail-grid-enter:nth-child(5) { animation-delay: 200ms; }
.detail-grid-enter:nth-child(6) { animation-delay: 250ms; }

/* Enhanced skeleton loading */
.detail-skeleton {
  background: linear-gradient(
    90deg,
    hsl(var(--muted)) 0%,
    hsl(var(--muted-foreground) / 0.1) 50%,
    hsl(var(--muted)) 100%
  );
  background-size: 200px 100%;
  animation: shimmer 1.5s infinite;
}

/* Better hover transitions */
.detail-card-hover {
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.detail-card-hover:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px hsl(var(--muted-foreground) / 0.15);
}

/* Quick edit animations */
.quick-edit-enter {
  animation: scale-in 0.2s ease-out;
}

.action-button-hover {
  transition: all 0.15s ease-in-out;
}

.action-button-hover:hover {
  transform: scale(1.1);
}

@keyframes pulse-border {
  0%, 100% {
    border-color: hsl(var(--border));
  }
  50% {
    border-color: hsl(var(--primary));
  }
}

.edit-mode-border {
  animation: pulse-border 2s ease-in-out infinite;
}

@keyframes slide-out-right {
  from {
    transform: translateX(0);
  }
  to {
    transform: translateX(100%);
  }
}

@keyframes slide-in-bottom {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

/* Animation classes */
.animate-fade-in {
  animation: fade-in 0.6s ease-out forwards;
}

.animate-slide-up {
  animation: slide-up 0.5s ease-out forwards;
}

.animate-slide-down {
  animation: slide-down 0.5s ease-out forwards;
}

.animate-scale-in {
  animation: scale-in 0.3s ease-out forwards;
}

.animate-slide-in-right {
  animation: slide-in-right 0.3s ease-out forwards;
}

.animate-slide-out-right {
  animation: slide-out-right 0.3s ease-out forwards;
}

.animate-slide-in-bottom {
  animation: slide-in-bottom 0.3s ease-out forwards;
}

.animate-gentle-pulse {
  animation: gentle-pulse 2s ease-in-out infinite;
}

/* Mobile Navigation Adjustments */
@media (max-width: 768px) {
  /* Add padding to main content to account for bottom nav */
  .mobile-nav-padding {
    padding-bottom: 4rem; /* 64px for bottom navigation */
  }
  
  /* Prevent body scroll when mobile menu is open */
  body.mobile-menu-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
  }
}

/* Prevent layout shift on navigation load */
.nav-placeholder {
  height: 3.5rem; /* 56px - same as nav height */
}

/* Smooth transitions between responsive states */
@media (min-width: 768px) and (max-width: 1023px) {
  /* Tablet-specific navigation adjustments */
  .nav-responsive-transition {
    transition: all 0.3s ease;
  }
}

/* Stagger animations for lists */
.animate-stagger > * {
  opacity: 0;
  animation: fade-in 0.5s ease-out forwards;
}

.animate-stagger > *:nth-child(1) { animation-delay: 0ms; }
.animate-stagger > *:nth-child(2) { animation-delay: 50ms; }
.animate-stagger > *:nth-child(3) { animation-delay: 100ms; }
.animate-stagger > *:nth-child(4) { animation-delay: 150ms; }
.animate-stagger > *:nth-child(5) { animation-delay: 200ms; }
.animate-stagger > *:nth-child(6) { animation-delay: 250ms; }
.animate-stagger > *:nth-child(7) { animation-delay: 300ms; }
.animate-stagger > *:nth-child(8) { animation-delay: 350ms; }
.animate-stagger > *:nth-child(9) { animation-delay: 400ms; }
.animate-stagger > *:nth-child(10) { animation-delay: 450ms; }

:root {
  /* Navigation & App Shell - Exact Specifications */
  --nav-height: 56px; /* Fixed navigation height */
  --nav-bg: 0 0% 100%; /* #FFFFFF - Navigation background */
  --nav-border: 218 10% 82%; /* #D1D5DB - 1px bottom border */
  --nav-text: 210 16% 12%; /* #1C2128 - Logo and navigation text */
  --nav-text-muted: 215 13% 42%; /* #656D76 - Inactive nav items */
  --nav-text-hover: 210 16% 12%; /* #1C2128 - Hover state */
  --nav-active: 212 92% 43%; /* #0969DA - Active nav item with 2px bottom border */
  
  /* Search Bar Specifications */
  --search-bg: 220 13% 97%; /* #F7F7F8 - Search background */
  --search-border: transparent; /* Transparent default border */
  --search-border-focus: 212 92% 43%; /* #0969DA - Focus border */
  --search-placeholder: 215 13% 56%; /* #8B949E - Placeholder text */
  --search-shadow-focus: 212 92% 43% / 10%; /* Focus shadow with 10% opacity */
  
  /* App Shell Background */
  --app-bg: 0 0% 99%; /* #FCFCFC - Main app background */
  
  /* Theme Variables - Professional & Technical */
  --background: 0 0% 99%; /* #FCFCFC - hint of warmth in white */
  --foreground: 210 16% 12%; /* #1C2128 - warm black */
  --muted: 220 13% 97%; /* #F7F7F8 - warm gray-white */
  --muted-foreground: 215 13% 42%; /* #656D76 - warm gray */
  --popover: 0 0% 100%; /* #FFFFFF - pure white */
  --popover-foreground: 210 16% 12%; /* #1C2128 - warm black */
  --card: 0 0% 100%; /* #FFFFFF - pure white for cards */
  --card-foreground: 210 16% 12%; /* #1C2128 - warm black */
  --border: 220 13% 84%; /* #D1D5DB - neutral gray */
  --input: 220 13% 84%; /* #D1D5DB - neutral gray */
  --primary: 212 92% 43%; /* #0969DA - professional blue */
  --primary-foreground: 0 0% 100%; /* #FFFFFF */
  --secondary: 215 16% 47%; /* #6E7781 - warm gray for secondary */
  --secondary-foreground: 0 0% 100%; /* #FFFFFF */
  --accent: 212 92% 43%; /* #0969DA - matches primary */
  --accent-foreground: 0 0% 100%; /* #FFFFFF */
  --destructive: 356 83% 47%; /* #CF222E - muted red */
  --destructive-foreground: 0 0% 100%;
  --ring: 212 92% 43%; /* #0969DA - professional blue */
  --radius: 0.25rem; /* 4px - more technical feel */
  --chart-1: 212 92% 43%;
  --chart-2: 142 76% 36%;
  --chart-3: 221 83% 53%;
  --chart-4: 262 83% 58%;
  --chart-5: 0 84% 60%;
  
  /* Success, Warning, Info colors */
  --success: 137 72% 32%; /* #1F883D - muted green */
  --warning: 35 100% 30%; /* #9A6700 - muted amber */
  --info: 212 92% 43%; /* #0969DA - matches primary */
  
  /* Version history highlight color */
  --version-highlight: 27 96% 61%; /* #FB923C - orange-400 */
  
  /* Responsive Typography System - Fluid Sizes */
  --text-xs: clamp(0.75rem, 2vw, 0.875rem);
  --text-sm: clamp(0.875rem, 2.5vw, 1rem);
  --text-base: clamp(1rem, 3vw, 1.125rem);
  --text-lg: clamp(1.125rem, 3.5vw, 1.25rem);
  --text-xl: clamp(1.25rem, 4vw, 1.5rem);
  --text-2xl: clamp(1.5rem, 5vw, 2rem);
  --text-3xl: clamp(1.875rem, 6vw, 2.5rem);
  --text-4xl: clamp(2.25rem, 8vw, 3rem);
  
  /* Responsive Spacing System */
  --space-xs: clamp(0.25rem, 1vw, 0.5rem);
  --space-sm: clamp(0.5rem, 1.5vw, 0.75rem);
  --space-md: clamp(1rem, 2vw, 1.5rem);
  --space-lg: clamp(1.5rem, 3vw, 2rem);
  --space-xl: clamp(2rem, 4vw, 3rem);
  --space-2xl: clamp(3rem, 6vw, 4rem);
}

.dark {
  /* Dark Navigation & App Shell */
  --nav-bg: 220 13% 14%; /* #1C2128 - Dark navigation background */
  --nav-border: 215 27% 17%; /* #30363D - Dark border */
  --nav-text: 213 27% 84%; /* #C9D1D9 - Dark theme text */
  --nav-text-muted: 217 10% 65%; /* #8B949E - Dark muted text */
  --nav-text-hover: 213 27% 84%; /* #C9D1D9 - Dark hover */
  --nav-active: 212 92% 56%; /* #1F6FEB - Dark active blue */
  
  /* Dark Search Bar */
  --search-bg: 215 28% 11%; /* #21262D - Dark search background */
  --search-border-focus: 212 92% 56%; /* #1F6FEB - Dark focus border */
  --search-placeholder: 217 10% 65%; /* #8B949E - Dark placeholder */
  --search-shadow-focus: 212 92% 56% / 10%; /* Dark focus shadow */
  
  /* Dark App Background */
  --app-bg: 220 13% 7%; /* #0D1117 - Dark app background */
  
  /* Dark Theme Variables - Cool Professional */
  --background: 220 13% 7%; /* #0D1117 - cool dark base */
  --foreground: 213 27% 84%; /* #C9D1D9 - cool light gray */
  --muted: 215 28% 9%; /* #161B22 - cool dark gray */
  --muted-foreground: 217 10% 65%; /* #8B949E - lighter cool gray */
  --popover: 220 13% 7%; /* #0D1117 - cool dark base */
  --popover-foreground: 213 27% 84%; /* #C9D1D9 - cool light gray */
  --card: 215 28% 11%; /* #21262D - cool card background */
  --card-foreground: 213 27% 84%; /* #C9D1D9 - cool light gray */
  --border: 215 27% 17%; /* #30363D - cool border */
  --input: 215 27% 17%; /* #30363D - cool border */
  --primary: 212 92% 56%; /* #1F6FEB - brighter blue for dark */
  --primary-foreground: 220 13% 7%; /* #0D1117 */
  --secondary: 217 10% 47%; /* #6E7681 - cool secondary */
  --secondary-foreground: 213 27% 84%; /* #C9D1D9 */
  --accent: 212 92% 56%; /* #1F6FEB - matches primary */
  --accent-foreground: 220 13% 7%; /* #0D1117 */
  --destructive: 356 77% 60%; /* #E5534B - muted red for dark */
  --destructive-foreground: 220 13% 7%;
  --ring: 212 92% 56%; /* #1F6FEB - brighter blue for dark */
  
  /* Dark theme semantic colors */
  --success: 137 45% 55%; /* #56D364 - muted green for dark */
  --warning: 35 84% 62%; /* #E3B341 - muted amber for dark */
  --info: 212 92% 56%; /* #1F6FEB - matches primary */
  
  /* Version history highlight color for dark */
  --version-highlight: 25 95% 53%; /* #F97316 - orange-500 for dark */
}

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

  body {
    @apply bg-background text-foreground;
    font-family: "Inter", system-ui, -apple-system, sans-serif;
    font-weight: 400;
    line-height: 1.6;
    letter-spacing: -0.025em;
  }

  /* Navigation Specific Styles */
  .nav-logo {
    font-family: "Inter", system-ui, -apple-system, sans-serif;
    font-weight: 600;
    font-size: 18px;
    color: hsl(var(--nav-text));
    transition: color 150ms ease;
  }

  .nav-item {
    padding: 0 16px;
    height: 56px;
    display: flex;
    align-items: center;
    color: hsl(var(--nav-text-muted));
    transition: color 150ms ease;
    position: relative;
  }

  .nav-item:hover {
    color: hsl(var(--nav-text-hover));
  }

  .nav-item.active {
    color: hsl(var(--nav-active));
  }

  .nav-item.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background-color: hsl(var(--nav-active));
  }

  /* Search Bar Styles */
  .search-input {
    width: 400px;
    height: 36px;
    background-color: hsl(var(--search-bg));
    border: 1px solid hsl(var(--search-border));
    border-radius: 4px;
    padding: 0 40px 0 40px;
    font-size: 14px;
    transition: all 150ms ease;
  }

  .search-input:focus {
    border-color: hsl(var(--search-border-focus));
    box-shadow: 0 0 0 3px hsl(var(--search-shadow-focus));
    outline: none;
  }

  .search-input::placeholder {
    color: hsl(var(--search-placeholder));
  }

  /* User Avatar Styles */
  .user-avatar {
    width: 32px;
    height: 32px;
    border: 1px solid hsl(var(--nav-border));
    border-radius: 50%;
  }

  /* Dropdown Menu Styles */
  .dropdown-menu {
    background-color: hsl(var(--nav-bg));
    border: 1px solid hsl(var(--nav-border));
    border-radius: 4px;
    box-shadow: 0 8px 24px rgba(140, 149, 159, 0.2);
  }

  .dark .dropdown-menu {
    box-shadow: 0 8px 24px rgba(1, 4, 9, 0.8);
  }

  .dropdown-item {
    padding: 8px 12px;
    font-size: 14px;
    transition: background-color 150ms ease;
  }

  .dropdown-item:hover {
    background-color: hsl(var(--search-bg));
  }

  /* Enhanced Typography Hierarchy */
  h1 {
    @apply text-4xl font-bold tracking-tight;
    line-height: 1.2;
  }

  h2 {
    @apply text-3xl font-semibold tracking-tight;
    line-height: 1.3;
  }

  h3 {
    @apply text-2xl font-semibold tracking-tight;
    line-height: 1.4;
  }

  h4 {
    @apply text-xl font-medium tracking-tight;
  }

  h5 {
    @apply text-lg font-medium;
  }

  h6 {
    @apply text-base font-medium;
  }

  p {
    @apply text-foreground;
    line-height: 1.7;
  }

  code, pre {
    font-family: "JetBrains Mono", "Menlo", "Monaco", "Consolas", monospace;
  }

  /* Enhanced spacing for clean layout */
  .ultra-clean-spacing > * + * {
    margin-top: 2rem;
  }

  .generous-padding {
    padding: 2rem;
  }

  @media (min-width: 768px) {
    .generous-padding {
      padding: 3rem;
    }
  }

  /* Icon styling for consistent appearance and interactions */
  .icon-interactive {
    @apply transition-all duration-150 hover:text-primary hover:drop-shadow-[0_0_4px_rgba(9,105,218,0.3)];
  }

  .icon-glow {
    @apply drop-shadow-[0_0_6px_rgba(9,105,218,0.2)];
  }
}

/* CodeMirror overrides for light and dark theme support */
.cm-editor {
  font-family: "SF Mono", "Monaco", "Inconsolata", "Roboto Mono", "Consolas", monospace !important;
  font-size: 14px;
  border: 1px solid hsl(var(--border));
  border-radius: 4px; /* More technical feel */
  background-color: 220 13% 98%; /* #FAFAFA - Editor background */
  color: hsl(var(--foreground)) !important;
  min-height: 200px;
  /* Prevent flash during initialization */
  opacity: 1;
  transition: opacity 150ms ease-in-out, background-color 150ms ease-in-out, color 150ms ease-in-out;
}

.cm-editor.cm-focused {
  outline: 2px solid hsl(var(--primary));
  outline-offset: 2px;
}

.cm-content {
  padding: 12px;
  background-color: hsl(220 14% 96%) !important; /* #F6F8FA - Code background */
  color: hsl(var(--foreground)) !important;
}

.cm-scroller {
  line-height: 1.5;
  background-color: transparent !important;
}

/* Light theme specific styles */
:root .cm-editor {
  background-color: hsl(220 13% 98%) !important; /* #FAFAFA - Editor background */
}

:root .cm-content {
  background-color: hsl(220 14% 96%) !important; /* #F6F8FA - Code background */
}

/* Dark theme specific styles */
.dark .cm-editor {
  background-color: hsl(215 28% 9%) !important; /* #161B22 - Dark editor */
}

.dark .cm-content {
  background-color: hsl(215 28% 11%) !important; /* #21262D - Dark code background */
}

/* Text selection highlighting for CodeMirror */
.cm-editor .cm-selectionBackground,
.cm-editor .cm-content ::selection {
  background-color: hsl(212 92% 43% / 0.3) !important; /* Light theme selection */
}

.cm-editor .cm-selectionMatch {
  background-color: hsl(212 92% 43% / 0.2) !important;
}

/* Dark theme text selection */
.dark .cm-editor .cm-selectionBackground,
.dark .cm-editor .cm-content ::selection {
  background-color: hsl(212 92% 56% / 0.3) !important; /* Dark theme selection */
}

.dark .cm-editor .cm-selectionMatch {
  background-color: hsl(212 92% 56% / 0.2) !important;
}

/* Focused selection (when editor is active) */
.cm-editor.cm-focused .cm-selectionBackground,
.cm-editor.cm-focused .cm-content ::selection {
  background-color: hsl(212 92% 43% / 0.4) !important;
}

.dark .cm-editor.cm-focused .cm-selectionBackground,
.dark .cm-editor.cm-focused .cm-content ::selection {
  background-color: hsl(212 92% 56% / 0.4) !important;
}

/* Prevent layout shift during CodeMirror load */
.cm-editor:not(.cm-focused):empty::before {
  content: '';
  display: block;
  height: 200px;
  background-color: hsl(var(--card));
}

/* SQL syntax highlighting colors for light and dark themes - GitHub inspired */
:root {
  --sql-keyword: #cf222e; /* Muted red for keywords */
  --sql-string: #0969da; /* Professional blue for strings */
  --sql-comment: #6e7781; /* Warm gray for comments */
  --sql-number: #0969da; /* Professional blue for numbers */
  --sql-operator: #953800; /* Muted orange for operators */
  --sql-function: #8250df; /* Purple for functions */
}

.dark {
  --sql-keyword: #ff7b72; /* Light red for keywords */
  --sql-string: #79c0ff; /* Light blue for strings */
  --sql-comment: #8b949e; /* Cool gray for comments */
  --sql-number: #79c0ff; /* Light blue for numbers */
  --sql-operator: #ffa657; /* Light orange for operators */
  --sql-function: #d2a8ff; /* Light purple for functions */
}

.github-colors {
  --sql-keyword: var(--sql-keyword);
  --sql-string: var(--sql-string);
  --sql-comment: var(--sql-comment);
  --sql-number: var(--sql-number);
  --sql-operator: var(--sql-operator);
  --sql-function: var(--sql-function);
}

/* Theme transition styles */
.theme-transitioning,
.theme-transitioning *,
.theme-transitioning *::before,
.theme-transitioning *::after {
  transition-property: background-color, border-color, color, fill, stroke, opacity, box-shadow, transform !important;
  transition-duration: var(--theme-transition-duration, 300ms) !important;
  transition-timing-function: ease-in-out !important;
}

/* Prevent transitions on initial load */
html:not(.theme-loaded) *,
html:not(.theme-loaded) *::before,
html:not(.theme-loaded) *::after {
  transition: none !important;
}

/* Smooth color transitions for theme-aware elements */
[data-theme-transition="smooth"] {
  transition: background-color 300ms ease-in-out, 
              border-color 300ms ease-in-out,
              color 300ms ease-in-out,
              box-shadow 300ms ease-in-out;
}

/* Prevent layout shift during transitions */
.theme-transitioning img,
.theme-transitioning video,
.theme-transitioning iframe,
.theme-transitioning .cm-editor {
  opacity: 0.99; /* Force GPU acceleration */
}

/* Responsive Typography Utility Classes */
.text-xs-responsive {
  font-size: var(--text-xs);
}

.text-sm-responsive {
  font-size: var(--text-sm);
}

.text-base-responsive {
  font-size: var(--text-base);
}

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

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

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

.text-3xl-responsive {
  font-size: var(--text-3xl);
}

.text-4xl-responsive {
  font-size: var(--text-4xl);
}

/* Responsive Spacing Utility Classes */
.space-xs-responsive {
  gap: var(--space-xs);
}

.space-sm-responsive {
  gap: var(--space-sm);
}

.space-md-responsive {
  gap: var(--space-md);
}

.space-lg-responsive {
  gap: var(--space-lg);
}

.space-xl-responsive {
  gap: var(--space-xl);
}

.space-2xl-responsive {
  gap: var(--space-2xl);
}

/* Responsive Padding Classes */
.p-responsive-xs {
  padding: var(--space-xs);
}

.p-responsive-sm {
  padding: var(--space-sm);
}

.p-responsive-md {
  padding: var(--space-md);
}

.p-responsive-lg {
  padding: var(--space-lg);
}

/* Responsive Margin Classes */
.m-responsive-xs {
  margin: var(--space-xs);
}

.m-responsive-sm {
  margin: var(--space-sm);
}

.m-responsive-md {
  margin: var(--space-md);
}

.m-responsive-lg {
  margin: var(--space-lg);
}

/* Readable Line Length Utilities */
.prose-narrow {
  max-width: 45ch;
}

.prose {
  max-width: 65ch;
}

.prose-wide {
  max-width: 80ch;
}

/* Apply optimal line height for readability */
.readable-text {
  line-height: 1.6;
  max-width: 65ch;
}

/* Mobile-optimized text containers */
@media (max-width: 640px) {
  .mobile-readable {
    max-width: 100%;
    padding-left: 1rem;
    padding-right: 1rem;
    line-height: 1.7;
  }
}

/* Prevent orphans and widows */
.prevent-orphans {
  overflow-wrap: break-word;
  word-wrap: break-word;
  hyphens: auto;
}

/* Skip Links - Hidden by default, visible on focus */
.mobile-skip-links {
  position: absolute;
  top: -100vh;
  left: 0;
  z-index: 9999;
}

.skip-link {
  position: absolute;
  top: -100vh;
  left: 0;
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  padding: 8px 16px;
  text-decoration: none;
  border-radius: 0 0 4px 0;
  font-weight: 500;
  font-size: 14px;
  z-index: 10000;
  transition: top 0.2s ease;
}

.skip-link:focus {
  top: 0;
  outline: 2px solid hsl(var(--ring));
  outline-offset: 2px;
}

/* Mobile-optimized touch targets */
@media (max-width: 640px) {
  .touch-target {
    min-height: 44px;
    min-width: 44px;
  }
  
  /* Increase clickable area for small buttons */
  .touch-target-sm {
    position: relative;
  }
  
  .touch-target-sm::before {
    content: '';
    position: absolute;
    top: -8px;
    right: -8px;
    bottom: -8px;
    left: -8px;
  }
}

/* Reduced motion preferences */
@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;
  }
}

/* Reduced motion utility classes */
.reduce-motion * {
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.01ms !important;
}

/* Smooth scrolling with reduced motion support */
html {
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

/* Performance optimizations for mobile */
@media (max-width: 640px) {
  /* Disable hover effects on mobile */
  .hover\:shadow-md:hover {
    box-shadow: none !important;
  }
  
  /* Optimize scrolling performance */
  .overflow-auto,
  .overflow-scroll {
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
  }
  
  /* Reduce blur effects on mobile for performance */
  .backdrop-blur-sm {
    backdrop-filter: none;
    background-color: rgba(255, 255, 255, 0.95);
  }
  
  .dark .backdrop-blur-sm {
    background-color: rgba(0, 0, 0, 0.95);
  }
  
  .backdrop-blur,
  .backdrop-blur-md,
  .backdrop-blur-lg {
    backdrop-filter: none;
    background-color: rgba(255, 255, 255, 0.98);
  }
  
  .dark .backdrop-blur,
  .dark .backdrop-blur-md,
  .dark .backdrop-blur-lg {
    background-color: rgba(0, 0, 0, 0.98);
  }
  
  /* Optimize transform performance */
  .transform {
    will-change: transform;
    transform: translateZ(0);
  }
  
  /* Reduce animation complexity */
  .animate-stagger > * {
    animation-delay: 0ms !important;
  }
  
  /* Simplify animations on mobile */
  @keyframes fade-in-mobile {
    from { opacity: 0; }
    to { opacity: 1; }
  }
  
  .animate-fade-in,
  .animate-slide-up,
  .animate-slide-down {
    animation: fade-in-mobile 0.2s ease-out forwards;
  }
  
  /* Disable complex shadows during animation */
  [data-state="open"],
  [data-state="closed"] {
    box-shadow: none !important;
  }
  
  /* GPU acceleration for commonly animated elements */
  .sheet-content,
  .dialog-content,
  .dropdown-content,
  .mobile-menu {
    transform: translateZ(0);
    will-change: transform, opacity;
  }
}

/* Touch-friendly interaction states */
@media (hover: none) and (pointer: coarse) {
  /* Replace hover with active states on touch devices */
  button:active,
  a:active,
  [role="button"]:active {
    opacity: 0.8;
    transform: scale(0.98);
    transition: all 0.1s ease;
  }
  
  /* Remove hover effects on touch devices */
  button:hover,
  a:hover,
  [role="button"]:hover {
    opacity: 1;
    transform: scale(1);
  }
  
  /* Enhanced focus states for touch */
  button:focus-visible,
  a:focus-visible,
  input:focus-visible,
  textarea:focus-visible,
  select:focus-visible,
  [role="button"]:focus-visible {
    outline: 3px solid var(--ring);
    outline-offset: 2px;
  }
}

/* Active states for all devices */
.touch-active:active {
  opacity: 0.8;
  transform: scale(0.98);
  transition: all 0.1s ease;
}

/* Tap highlight color */
@media (max-width: 640px) {
  button,
  a,
  [role="button"] {
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
  }
  
  /* Prevent text selection on buttons */
  button,
  [role="button"] {
    -webkit-user-select: none;
    user-select: none;
  }
}

/* Google Apps Script-style Diff Viewer Styles */
.google-script-diff-viewer {
  border: 1px solid hsl(var(--border));
  border-radius: 8px;
  overflow: hidden;
  background: hsl(var(--card));
  font-family: 'SF Mono', Monaco, Consolas, 'Courier New', monospace;
  font-size: 13px;
  line-height: 21px;
  width: 100%; /* Ensure it fills its container */
}

.google-diff-header {
  background: hsl(var(--muted));
  border-bottom: 1px solid hsl(var(--border));
  padding: 8px 0;
}

.google-diff-version-labels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: hsl(var(--border));
}

.google-diff-version-label {
  background: hsl(var(--muted));
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 500;
  color: hsl(var(--muted-foreground));
  text-align: center;
}

/* Removed .google-diff-scroll-container - using individual pane scrolling instead */

/* Scrollbar styling for diff panes */
.google-diff-pane::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.google-diff-pane::-webkit-scrollbar-track {
  background: hsl(var(--muted));
}

.google-diff-pane::-webkit-scrollbar-thumb {
  background: hsl(var(--border));
  border-radius: 4px;
}

.google-diff-pane::-webkit-scrollbar-thumb:hover {
  background: hsl(var(--muted-foreground) / 0.3);
}

.google-diff-pane::-webkit-scrollbar-corner {
  background: hsl(var(--muted));
}

.google-diff-panes-wrapper {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: hsl(var(--border));
  height: 600px; /* Fixed height for scrolling */
}

.google-diff-pane {
  position: relative;
  background: hsl(var(--card));
  overflow: auto; /* Each pane has its own scrollbar */
}

.google-diff-pane-left {
  border-right: 1px solid hsl(var(--border));
}

.google-diff-pane-right {
  position: relative;
}

.google-diff-content {
  position: relative;
  z-index: 1;
  width: max-content; /* Content determines width for horizontal scrolling */
  min-width: 100%; /* But at least fill the pane */
}

/* Ensure lines don't wrap */
.google-diff-content .flex {
  white-space: nowrap;
}

/* Google Apps Script-style striped overlay for right pane */
.google-striped-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  z-index: 0;
  background-image: repeating-linear-gradient(
    -45deg,
    transparent,
    transparent 10px,
    rgba(0, 0, 0, 0.02) 10px,
    rgba(0, 0, 0, 0.02) 20px
  );
}

.dark .google-striped-overlay {
  background-image: repeating-linear-gradient(
    -45deg,
    transparent,
    transparent 10px,
    rgba(255, 255, 255, 0.02) 10px,
    rgba(255, 255, 255, 0.02) 20px
  );
}

/* Line styles */
.google-line-number {
  display: inline-block;
  width: 40px;
  padding: 0 8px;
  text-align: right;
  color: hsl(var(--muted-foreground));
  opacity: 0.7;
  user-select: none;
  flex-shrink: 0;
}

.google-line-content {
  padding: 0 12px 0 4px;
  white-space: pre;
  overflow: visible; /* Don't clip content */
}

/* Google Apps Script color scheme for diff highlights */
.google-line-removed {
  background-color: #ffebee; /* Light red/pink background */
}

.dark .google-line-removed {
  background-color: rgba(244, 67, 54, 0.15); /* Dark mode red */
}

.google-line-added {
  background-color: #e8f5e9; /* Light green background */
}

.dark .google-line-added {
  background-color: rgba(76, 175, 80, 0.15); /* Dark mode green */
}

.google-line-modified {
  background-color: #fff3e0; /* Light orange background */
}

.dark .google-line-modified {
  background-color: rgba(255, 152, 0, 0.15); /* Dark mode orange */
}

/* Footer styles */
.google-diff-footer {
  border-top: 1px solid hsl(var(--border));
  padding: 12px 16px;
  background: hsl(var(--muted));
}

/* Custom checkbox styling to match Google Apps Script */
.google-checkbox {
  width: 16px;
  height: 16px;
  border-radius: 3px;
}

/* Scrollbar styling for Google-like appearance - single scrollbar in the middle */
.google-diff-scroll-container::-webkit-scrollbar {
  width: 14px;
  height: 14px;
}

.google-diff-scroll-container::-webkit-scrollbar-track {
  background: hsl(var(--muted));
  border-left: 1px solid hsl(var(--border));
  border-right: 1px solid hsl(var(--border));
}

.google-diff-scroll-container::-webkit-scrollbar-thumb {
  background: hsl(var(--muted-foreground) / 0.4);
  border-radius: 7px;
  border: 3px solid transparent;
  background-clip: padding-box;
}

.google-diff-scroll-container::-webkit-scrollbar-thumb:hover {
  background: hsl(var(--muted-foreground) / 0.6);
}

/* Ensure scrollbar appears between the panes */
.google-diff-scroll-container {
  scrollbar-gutter: stable;
  scrollbar-color: hsl(var(--muted-foreground) / 0.4) hsl(var(--muted));
}

/* Ensure proper spacing and alignment */
.google-diff-content > div {
  min-height: 21px;
  border-bottom: 1px solid transparent;
}

.google-diff-content > div:hover {
  background-color: hsl(var(--muted) / 0.5);
}

/* Native-like transitions */
@keyframes slide-in-from-right {
  from {
    transform: translateX(100%);
  }
  to {
    transform: translateX(0);
  }
}

@keyframes slide-in-from-left {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(0);
  }
}

@keyframes slide-in-from-bottom {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

@keyframes slide-in-from-top {
  from {
    transform: translateY(-100%);
  }
  to {
    transform: translateY(0);
  }
}

@keyframes slide-out-to-right {
  from {
    transform: translateX(0);
  }
  to {
    transform: translateX(100%);
  }
}

@keyframes slide-out-to-left {
  from {
    transform: translateX(0);
  }
  to {
    transform: translateX(-100%);
  }
}

@keyframes zoom-in-95 {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Animation utilities */
.animate-in {
  animation-duration: 300ms;
  animation-fill-mode: both;
}

.animate-out {
  animation-duration: 300ms;
  animation-fill-mode: both;
}

.slide-in-from-right {
  animation-name: slide-in-from-right;
}

.slide-in-from-left {
  animation-name: slide-in-from-left;
}

.slide-in-from-bottom {
  animation-name: slide-in-from-bottom;
}

.slide-in-from-top {
  animation-name: slide-in-from-top;
}

.slide-out-to-right {
  animation-name: slide-out-to-right;
}

.slide-out-to-left {
  animation-name: slide-out-to-left;
}

.zoom-in-95 {
  animation-name: zoom-in-95;
}

/* iOS-style spring animations */
@media (prefers-reduced-motion: no-preference) {
  .spring-bounce {
    transition-timing-function: cubic-bezier(0.68, -0.55, 0.265, 1.55);
  }
  
  .spring-smooth {
    transition-timing-function: cubic-bezier(0.4, 0.0, 0.2, 1);
  }
}

/* Hide scrollbar for carousel/swipe components */
.scrollbar-hide {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

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

/* Prevent Layout Shifts */
/* Reserve space for navigation */
.nav-skeleton {
  height: 56px;
  background: hsl(var(--background));
}

/* Reserve space for common UI elements */
.button-skeleton {
  min-height: 44px;
  border-radius: var(--radius);
}

.card-skeleton {
  aspect-ratio: 16/9;
  min-height: 200px;
}

.avatar-skeleton {
  width: 40px;
  height: 40px;
  border-radius: 50%;
}

/* Prevent CLS from images */
img {
  aspect-ratio: attr(width) / attr(height);
}

/* Font loading optimization */
.font-loading body {
  font-family: system-ui, -apple-system, sans-serif;
}

/* Reserve space for async content */
.content-placeholder {
  min-height: 100vh;
  contain: layout style;
}

/* CSS Containment for performance */
.contain-layout {
  contain: layout;
}

.contain-paint {
  contain: paint;
}

.contain-strict {
  contain: strict;
}

/* Prevent shifts during theme transitions */
* {
  min-height: 0;
  min-width: 0;
}

/* Stable scrollbar to prevent layout shift */
html {
  scrollbar-gutter: stable;
}

/* Progressive Enhancement Classes */
/* High Performance Mode - All effects enabled */
.perf-high {
  --enable-blur: 1;
  --enable-shadows: 1;
  --enable-animations: 1;
  --animation-duration: 300ms;
}

/* Balanced Performance Mode - Reduced effects */
.perf-balanced {
  --enable-blur: 0;
  --enable-shadows: 1;
  --enable-animations: 1;
  --animation-duration: 200ms;
}

.perf-balanced .backdrop-blur-sm,
.perf-balanced .backdrop-blur-md,
.perf-balanced .backdrop-blur-lg {
  backdrop-filter: none;
  background-color: rgba(255, 255, 255, 0.95);
}

.perf-balanced .dark .backdrop-blur-sm,
.perf-balanced .dark .backdrop-blur-md,
.perf-balanced .dark .backdrop-blur-lg {
  background-color: rgba(0, 0, 0, 0.95);
}

/* Low Performance Mode - Minimal effects */
.perf-low {
  --enable-blur: 0;
  --enable-shadows: 0;
  --enable-animations: 0;
  --animation-duration: 0ms;
}

.perf-low * {
  animation: none !important;
  transition: none !important;
}

.perf-low .shadow-sm,
.perf-low .shadow,
.perf-low .shadow-md,
.perf-low .shadow-lg,
.perf-low .shadow-xl {
  box-shadow: none !important;
}

.perf-low .backdrop-blur-sm,
.perf-low .backdrop-blur-md,
.perf-low .backdrop-blur-lg {
  backdrop-filter: none !important;
  background-color: rgba(255, 255, 255, 0.98);
}

.perf-low .dark .backdrop-blur-sm,
.perf-low .dark .backdrop-blur-md,
.perf-low .dark .backdrop-blur-lg {
  background-color: rgba(0, 0, 0, 0.98);
}

/* Network-aware loading */
@media (prefers-reduced-data: reduce) {
  /* Hide decorative images */
  .decorative-image {
    display: none;
  }
  
  /* Use system fonts */
  body {
    font-family: system-ui, -apple-system, sans-serif !important;
  }
  
  /* Disable background images */
  .bg-image {
    background-image: none !important;
  }
}
