/* Optimized font loading with display=swap for better performance */
@import url("https://fonts.googleapis.com/css2?family=Geist:wght@100..900&family=Geist+Mono:wght@100..900&display=swap");
@import "leaflet/dist/leaflet.css";

@import "tailwindcss";
@import "tw-animate-css";
@plugin "@tailwindcss/typography";

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

@theme inline {
  --font-sans:
    "Geist", ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji",
    "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
  --font-mono:
    "Geist Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", "Courier New", monospace;
  --font-serif:
    "Noto Serif", ui-serif, Georgia, Cambria, "Times New Roman", Times, serif;

  --radius-sm: calc(var(--radius) - 4px);
  --radius-md: calc(var(--radius) - 2px);
  --radius-lg: var(--radius);
  --radius-xl: calc(var(--radius) + 4px);
  --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-border: var(--border);
  --color-input: var(--input);
  --color-ring: var(--ring);
  --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);
  --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);
}

:root {
  --radius: 0.5rem;
  --background: oklch(0.98 0.005 240);
  --foreground: oklch(0.2 0.01 240);
  --card: oklch(1 0 0);
  --card-foreground: oklch(0.2 0.01 240);
  --popover: oklch(1 0 0);
  --popover-foreground: oklch(0.2 0.01 240);
  --primary: oklch(0.5 0.18 240);
  --primary-foreground: oklch(0.99 0 0);
  --secondary: oklch(0.65 0.02 240);
  --secondary-foreground: oklch(0.99 0 0);
  --muted: oklch(0.95 0.01 240);
  --muted-foreground: oklch(0.5 0.02 240);
  --accent: oklch(0.75 0.15 85);
  --accent-foreground: oklch(0.15 0.01 85);
  --destructive: oklch(0.577 0.245 27.325);
  --border: oklch(0.9 0.01 240);
  --input: oklch(0.9 0.01 240);
  --ring: oklch(0.5 0.18 240);
  --chart-1: oklch(0.5 0.18 240);
  --chart-2: oklch(0.6 0.12 180);
  --chart-3: oklch(0.65 0.15 330);
  --chart-4: oklch(0.7 0.13 120);
  --chart-5: oklch(0.75 0.1 60);
  --sidebar: oklch(0.98 0.005 240);
  --sidebar-foreground: oklch(0.2 0.01 240);
  --sidebar-primary: oklch(0.5 0.18 240);
  --sidebar-primary-foreground: oklch(0.99 0 0);
  --sidebar-accent: oklch(0.95 0.01 240);
  --sidebar-accent-foreground: oklch(0.2 0.01 240);
  --sidebar-border: oklch(0.9 0.01 240);
  --sidebar-ring: oklch(0.5 0.18 240);
}

.dark {
  --background: oklch(0.15 0.01 240);
  --foreground: oklch(0.95 0.005 240);
  --card: oklch(0.2 0.01 240);
  --card-foreground: oklch(0.95 0.005 240);
  --popover: oklch(0.2 0.01 240);
  --popover-foreground: oklch(0.95 0.005 240);
  --primary: oklch(0.6 0.2 240);
  --primary-foreground: oklch(0.99 0 0);
  --secondary: oklch(0.55 0.02 240);
  --secondary-foreground: oklch(0.99 0 0);
  --muted: oklch(0.25 0.01 240);
  --muted-foreground: oklch(0.65 0.02 240);
  --accent: oklch(0.7 0.15 85);
  --accent-foreground: oklch(0.15 0.01 85);
  --destructive: oklch(0.704 0.191 22.216);
  --border: oklch(0.3 0.01 240);
  --input: oklch(0.3 0.01 240);
  --ring: oklch(0.6 0.2 240);
  --chart-1: oklch(0.6 0.2 240);
  --chart-2: oklch(0.7 0.15 180);
  --chart-3: oklch(0.75 0.17 330);
  --chart-4: oklch(0.8 0.15 120);
  --chart-5: oklch(0.85 0.12 60);
  --sidebar: oklch(0.2 0.01 240);
  --sidebar-foreground: oklch(0.95 0.005 240);
  --sidebar-primary: oklch(0.6 0.2 240);
  --sidebar-primary-foreground: oklch(0.99 0 0);
  --sidebar-accent: oklch(0.25 0.01 240);
  --sidebar-accent-foreground: oklch(0.95 0.005 240);
  --sidebar-border: oklch(0.3 0.01 240);
  --sidebar-ring: oklch(0.6 0.2 240);
}

@layer base {
  * {
    @apply border-border outline-ring/50;
  }
  body {
    @apply bg-background text-foreground;
  }
}

/* Custom button colors */
.btn-create-listing {
  background-color: #FBC02D !important;
  color: #000 !important;
}

.btn-create-listing:hover {
  background-color: #F9A825 !important;
}

.btn-make-offer {
  background-color: #FF9800 !important;
  color: #fff !important;
}

.btn-make-offer:hover {
  background-color: #FB8C00 !important;
}

/* Hide scrollbar but keep functionality */
.scrollbar-hide {
  -ms-overflow-style: none;  /* IE and Edge */
  scrollbar-width: none;  /* Firefox */
}

.scrollbar-hide::-webkit-scrollbar {
  display: none;  /* Chrome, Safari and Opera */
}

/* Smooth Animations & Transitions */
@layer base {
  * {
    @apply transition-colors duration-200;
  }
  
  /* Smooth scrolling */
  html {
    scroll-behavior: smooth;
  }
}

/* Card Hover Effects */
.card-hover {
  @apply transition-all duration-300 ease-out;
}

.card-hover:hover {
  @apply -translate-y-1 shadow-lg;
}

/* Button Animations */
.btn-scale {
  @apply transition-transform duration-150 active:scale-95;
}

.btn-pulse {
  @apply animate-pulse;
}

/* Fade In Animation */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in {
  animation: fadeIn 0.4s ease-out;
}

/* Slide In Animation */
@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

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

/* Scale In Animation */
@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

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

/* Shimmer Loading Effect */
@keyframes shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

.shimmer {
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.1),
    transparent
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

/* Bounce Animation for Badges */
@keyframes bounce-subtle {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-2px);
  }
}

.bounce-subtle {
  animation: bounce-subtle 2s infinite;
}

/* Gradient Animation */
@keyframes gradient-shift {
  0%, 100% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
}

.gradient-animate {
  background-size: 200% 200%;
  animation: gradient-shift 3s ease infinite;
}

/* Mobile optimizations */
@media (max-width: 768px) {
  /* Touch-friendly buttons */
  button {
    min-height: 44px;
    min-width: 44px;
  }
  
  /* Better touch target for inputs */
  input, textarea, select {
    font-size: 16px; /* Prevents zoom on iOS */
  }
  
  /* Reduce animations on mobile for performance */
  @media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
      animation-duration: 0.01ms !important;
      animation-iteration-count: 1 !important;
      transition-duration: 0.01ms !important;
    }
  }
}

/* Mobile-specific improvements */
@media (max-width: 768px) {
  /* Sticky mobile header */
  .mobile-sticky-header {
    position: sticky;
    top: 0;
    z-index: 40;
    background: oklch(var(--background) / 0.95);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid oklch(var(--border));
  }

  /* Bottom sticky action bar */
  .mobile-sticky-bottom {
    position: fixed;
    bottom: 64px; /* Above mobile nav */
    left: 0;
    right: 0;
    z-index: 30;
    padding: 1rem;
    background: linear-gradient(to top, oklch(var(--background)), transparent);
    pointer-events: none;
  }

  .mobile-sticky-bottom > * {
    pointer-events: auto;
  }

  /* Touch feedback */
  button:active, a:active {
    transform: scale(0.97);
    opacity: 0.8;
  }

  /* Larger touch targets for mobile nav */
  .mobile-nav-item {
    min-height: 56px;
    min-width: 56px;
  }

  /* Prevent horizontal scroll */
  body {
    overflow-x: hidden;
  }

  /* Better spacing for mobile forms */
  .mobile-form-spacing {
    padding: 1rem;
    gap: 1rem;
  }

  /* Mobile-optimized cards */
  .mobile-card {
    border-radius: 0.75rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  }

  /* Safe area insets for notched devices */
  .mobile-safe-top {
    padding-top: env(safe-area-inset-top);
  }

  .mobile-safe-bottom {
    padding-bottom: env(safe-area-inset-bottom);
  }

  /* Better input focus states */
  input:focus, textarea:focus, select:focus {
    outline: 2px solid oklch(var(--primary));
    outline-offset: 2px;
  }

  /* Prevent zoom on input focus */
  input, select, textarea {
    font-size: 16px !important;
  }

  /* Improve tap targets */
  a, button, [role="button"] {
    min-height: 23px;
    min-width: 44px;
  }

  /* Better scrolling */
  * {
    -webkit-overflow-scrolling: touch;
  }

  /* Optimize images */
  img {
    max-width: 100%;
    height: auto;
  }
}

/* PWA-like experience */
@media (display-mode: standalone) {
  /* Hide unnecessary UI when installed as PWA */
  .hide-on-pwa {
    display: none;
  }

  /* Add safe area padding */
  body {
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
  }
}

/* Landscape mobile optimizations */
@media (max-width: 896px) and (orientation: landscape) {
  /* Reduce header heights */
  .mobile-sticky-header {
    height: auto;
    min-height: 48px;
  }

  /* Stack navigation horizontally */
  .mobile-nav {
    flex-direction: row;
  }
}

/* Pull-to-refresh indicator (visual only) */
@keyframes pull-to-refresh {
  0% {
    transform: translateY(-100%) rotate(0deg);
  }
  50% {
    transform: translateY(0) rotate(180deg);
  }
  100% {
    transform: translateY(-100%) rotate(360deg);
  }
}

.pull-to-refresh-indicator {
  animation: pull-to-refresh 1s ease-in-out infinite;
}

/* Smooth keyboard appearance */
@media (max-width: 768px) {
  input:focus, textarea:focus, select:focus {
    scroll-margin-top: 100px;
    transition: all 0.3s ease;
  }
  
  /* Native Mobile App Feel */
  body {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    user-select: none;
  }
  
  input, textarea, [contenteditable] {
    user-select: text;
  }
  
  /* Smooth scrolling like native */
  * {
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
  }
  
  /* Cards behave like native */
  .card, [class*="card"] {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
  }
  
  .card:active, [class*="card"]:active {
    transform: scale(0.98);
  }
  
  /* Native-like headers */
  header {
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
  }
  
  /* Remove default mobile styles */
  button, input, select, textarea {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
  }
  
  /* Improve text rendering */
  * {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }
}
