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

@layer base {
  :root {
    --background: 0 0% 100%;
    --foreground: 222.2 84% 4.9%;

    --card: 0 0% 100%;
    --card-foreground: 222.2 84% 4.9%;

    --popover: 0 0% 100%;
    --popover-foreground: 222.2 84% 4.9%;

    --primary: 222.2 47.4% 11.2%;
    --primary-foreground: 210 40% 98%;

    --secondary: 210 40% 96.1%;
    --secondary-foreground: 222.2 47.4% 11.2%;

    --muted: 210 40% 96.1%;
    --muted-foreground: 215.4 16.3% 46.9%;

    --accent: 210 40% 96.1%;
    --accent-foreground: 222.2 47.4% 11.2%;

    --destructive: 0 84.2% 60.2%;
    --destructive-foreground: 210 40% 98%;

    --border: 214.3 31.8% 91.4%;
    --input: 214.3 31.8% 91.4%;
    --ring: 222.2 84% 4.9%;

    --radius: 0.5rem;

    /* Navy colors for trust badges */
    --navy: 222.2 84% 4.9%;
    --navy-foreground: 210 40% 98%;

    /* Loading spinner */
    --spinner-primary: 222.2 47.4% 11.2%;

    --sidebar-background: 0 0% 98%;

    --sidebar-foreground: 240 5.3% 26.1%;

    --sidebar-primary: 240 5.9% 10%;

    --sidebar-primary-foreground: 0 0% 98%;

    --sidebar-accent: 240 4.8% 95.9%;

    --sidebar-accent-foreground: 240 5.9% 10%;

    --sidebar-border: 220 13% 91%;

    --sidebar-ring: 217.2 91.2% 59.8%;
  }

  .dark {
    --background: 222.2 84% 4.9%;
    --foreground: 210 40% 98%;

    --card: 222.2 84% 4.9%;
    --card-foreground: 210 40% 98%;

    --popover: 222.2 84% 4.9%;
    --popover-foreground: 210 40% 98%;

    --primary: 210 40% 98%;
    --primary-foreground: 222.2 47.4% 11.2%;

    --secondary: 217.2 32.6% 17.5%;
    --secondary-foreground: 210 40% 98%;

    --muted: 217.2 32.6% 17.5%;
    --muted-foreground: 215 20.2% 65.1%;

    --accent: 217.2 32.6% 17.5%;
    --accent-foreground: 210 40% 98%;

    --destructive: 0 62.8% 30.6%;
    --destructive-foreground: 210 40% 98%;

    --border: 217.2 32.6% 17.5%;
    --input: 217.2 32.6% 17.5%;
    --ring: 212.7 26.8% 83.9%;

    /* Navy colors for trust badges */
    --navy: 210 40% 98%;
    --navy-foreground: 222.2 84% 4.9%;

    --sidebar-background: 240 5.9% 10%;
    --sidebar-foreground: 240 4.8% 95.9%;
    --sidebar-primary: 224.3 76.3% 48%;
    --sidebar-primary-foreground: 0 0% 100%;
    --sidebar-accent: 240 3.7% 15.9%;
    --sidebar-accent-foreground: 240 4.8% 95.9%;
    --sidebar-border: 240 3.7% 15.9%;
    --sidebar-ring: 217.2 91.2% 59.8%;
  }
}

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

  body {
    @apply bg-background text-foreground;
  }
}

/* Touch target optimization for mobile accessibility */
.touch-target-44 {
  min-height: 44px;
  min-width: 44px;
}

.touch-target {
  min-height: 48px;
  min-width: 48px;
  padding: 12px;
}

@media (max-width: 768px) {
  .touch-target-44 {
    min-height: 48px;
    min-width: 48px;
    padding: 12px 16px;
  }
}

/* Performance optimizations for lazy loading and mobile maps */
.property-card-skeleton {
  animation: optimizedPulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes optimizedPulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.6;
  }
}

/* High performance skeleton for map loading */
.map-skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: shimmer 2s infinite linear;
}

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

/* Map-specific optimizations */
.map-container {
  contain: layout style paint;
  will-change: transform;
  height: 100vh;
  min-height: 100vh;
  position: relative;
  overflow: hidden;
}

/* Performance optimized map tiles */
.map-tile-optimized {
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
  transform: translateZ(0);
  backface-visibility: hidden;
}

@media (max-width: 768px) {
  .map-container {
    /* Mobile-specific optimizations */
    transform: translateZ(0);
    backface-visibility: hidden;
    /* Prevent bouncing on iOS */
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }
  
  /* Reduce animation complexity on mobile for performance */
  .property-card-skeleton {
    animation: none;
    opacity: 0.7;
  }
  
  .map-skeleton {
    animation: none;
    background: #f0f0f0;
  }
}

/* Reduce motion for accessibility and performance */
@media (prefers-reduced-motion: reduce) {
  .property-card-skeleton,
  .map-skeleton {
    animation: none;
    opacity: 0.7;
  }
  
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Form accessibility enhancements */
form[role="form"] {
  scroll-behavior: smooth;
}

/* Improve focus visibility for form elements */
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
button:focus-visible {
  outline: 2px solid hsl(var(--ring));
  outline-offset: 2px;
}

/* Hide scrollbars */
.scrollbar-hide {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

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

/* Loading spinner styles */
.loading-spinner {
  width: 2rem;
  height: 2rem;
  border: 2px solid hsl(var(--spinner-primary));
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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