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

@layer base {
  :root {
    --background: 0 0% 100%;
    --foreground: 220 39% 11%;
    
    --card: 0 0% 100%;
    --card-foreground: 220 39% 11%;
    
    --popover: 0 0% 100%;
    --popover-foreground: 220 39% 11%;
    
    /* Primary blue: #2563eb */
    --primary: 217 91% 60%;
    --primary-foreground: 0 0% 100%;
    
    /* Secondary/Light backgrounds */
    --secondary: 210 40% 98%; /* #f8fafc */
    --secondary-foreground: 220 39% 11%;
    
    /* Muted backgrounds & borders */
    --muted: 210 40% 98%;
    --muted-foreground: 220 9% 46%; /* #6b7280 */
    
    --accent: 210 40% 98%;
    --accent-foreground: 220 39% 11%;
    
    --destructive: 0 84% 60%;
    --destructive-foreground: 0 0% 100%;
    
    /* Borders: #e5e7eb, #d1d5db */
    --border: 220 13% 91%;
    --input: 220 13% 91%;
    --ring: 217 91% 60%;
    
    --radius: 0.75rem;

    /* Product Card Link Tokens */
    --product-link-bg: hsl(var(--primary));
    --product-link-text: hsl(var(--primary-foreground));
    --product-link-border: hsl(var(--primary) / 0.5);
    --product-link-shadow: hsl(var(--primary) / 0.4);
    --product-link-hover-bg: hsl(var(--primary) / 0.9);

    /* Button Variants */
    --button-windows: 191 91% 36%; /* cyan-600 approx */
    --button-windows-foreground: 0 0% 100%;
    --button-glazing: 271 81% 56%; /* purple-600 approx */
    --button-glazing-foreground: 0 0% 100%;

    /* Accordion Custom Properties */
    --accordion-gap: 1.5rem;
    --accordion-padding-x: 2rem;
    --accordion-padding-y: 2rem;
    --accordion-title-size: 1.5rem;
    --accordion-icon-size: 2rem;
  }

  .dark {
    --background: 222 47% 11%;
    --foreground: 210 40% 98%;
    
    --card: 222 47% 11%;
    --card-foreground: 210 40% 98%;
    
    --popover: 222 47% 11%;
    --popover-foreground: 210 40% 98%;
    
    --primary: 45 93% 58%;
    --primary-foreground: 222 47% 11%;
    
    --secondary: 217 33% 17%;
    --secondary-foreground: 210 40% 98%;
    
    --muted: 217 33% 17%;
    --muted-foreground: 215 20% 65%;
    
    --accent: 217 33% 17%;
    --accent-foreground: 210 40% 98%;
    
    --destructive: 0 84% 60%;
    --destructive-foreground: 210 40% 98%;
    
    --border: 217 33% 17%;
    --input: 217 33% 17%;
    --ring: 45 93% 58%;

    /* Product Card Link Tokens - Dark */
    --product-link-bg: hsl(var(--primary));
    --product-link-text: hsl(var(--primary-foreground));
    --product-link-border: hsl(var(--primary) / 0.5);
    --product-link-shadow: hsl(var(--primary) / 0.2);
    --product-link-hover-bg: hsl(var(--primary) / 0.9);

    /* Button Variants - Dark */
    --button-windows: 191 91% 36%;
    --button-windows-foreground: 0 0% 100%;
    --button-glazing: 271 81% 56%;
    --button-glazing-foreground: 0 0% 100%;
  }
}

@layer base {
  * {
    @apply border-border;
  }
  body {
    @apply bg-background text-foreground;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }
}

@layer components {
  /* Search Dropdown Container */
  .search-dropdown-container {
    position: fixed;
    z-index: 9999;
    background: rgba(2, 6, 23, 0.95);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 1.5rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    padding: 0.75rem;
    overflow: hidden;
  }

  /* Desktop positioning */
  @media (min-width: 768px) {
    .search-dropdown-container {
      top: 88px;
      left: 50%;
      transform: translateX(-50%);
      width: min(94vw, 860px);
      max-height: calc(100vh - 120px);
    }
  }

  /* Mobile positioning */
  @media (max-width: 767px) {
    .search-dropdown-container {
      top: 80px;
      left: 3vw;
      right: 3vw;
      width: 94vw;
      max-width: 94vw;
      max-height: calc(100vh - 100px);
      transform: none;
    }
  }

  /* Search Results Grid */
  .search-dropdown-results {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
    max-height: 70vh;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    padding-right: 0.25rem;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
  }

  @media (min-width: 768px) {
    .search-dropdown-results {
      grid-template-columns: repeat(2, 1fr);
    }
  }

  /* Mobile specific constraints */
  @media (max-width: 767px) {
    .search-dropdown-results {
      max-height: calc(100vh - 200px);
    }
  }

  /* Scrollbar styling for search dropdown */
  .search-dropdown-results::-webkit-scrollbar {
    width: 6px;
  }

  .search-dropdown-results::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
  }

  .search-dropdown-results::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
  }

  .search-dropdown-results::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
  }

  /* Search Result Link */
  .search-result-link {
    display: block;
    border-radius: 0.75rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.04);
    padding: 1rem;
    transition: all 0.3s ease;
    cursor: pointer;
    pointer-events: auto;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    min-height: 44px;
  }

  .search-result-link:hover,
  .search-result-link:focus {
    background: rgba(255, 255, 255, 0.09);
    border-color: rgba(251, 191, 36, 0.4);
    outline: none;
  }

  .search-result-link:active {
    transform: scale(0.98);
  }

  /* Mobile touch targets */
  @media (max-width: 767px) {
    .search-result-link {
      min-height: 56px;
      padding: 1.25rem 1rem;
    }
  }

  /* Ensure proper spacing on mobile */
  @media (max-width: 767px) {
    .search-dropdown-container {
      padding: 0.5rem;
    }

    .search-dropdown-results {
      gap: 0.5rem;
      padding-right: 0.125rem;
    }
  }

  /* Product Card Link Styling */
  .product-link-container {
    background-color: var(--product-link-bg);
    color: var(--product-link-text);
    border: 1px solid var(--product-link-border);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  }

  .product-link-container:hover {
    background-color: var(--product-link-hover-bg);
    transform: translateY(-4px);
    box-shadow: 0 10px 15px -3px var(--product-link-shadow);
  }

  .product-link-icon-animated {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .product-link-container:hover .product-link-icon-animated {
    transform: translateX(6px) scale(1.1);
  }
}

@layer utilities {
  .animate-shimmer {
    animation: shimmer 1.5s ease-in-out;
  }
  
  /* Edge-to-edge layout utility */
  .edge-to-edge {
    @apply w-full px-4 sm:px-8 md:px-12 lg:px-16;
  }

  @keyframes shimmer {
    0% {
      transform: translateX(-100%);
    }
    100% {
      transform: translateX(100%);
    }
  }
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  padding: 0;
  overflow-x: hidden;
}

#root {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.text-balance {
  text-wrap: balance;
}