/* Global anti-overflow & smooth layout rules */
* {
  min-width: 0;
  box-sizing: border-box;
}

html, body {
  overflow-x: hidden;
  width: 100%;
  position: relative;
  -webkit-text-size-adjust: 100%;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

.card-equal-height {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.card-pin-bottom {
  margin-top: auto;
}

/* Base typography & sticky header offset */
html {
  scroll-padding-top: 85px;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  color-scheme: light;
}

/* Lenis Momentum Smooth Scroll Recommended Styles */
html.lenis, html.lenis body {
  height: auto;
}

.lenis.lenis-smooth {
  scroll-behavior: auto !important;
}

.lenis.lenis-smooth [data-lenis-prevent] {
  overscroll-behavior: contain;
}

.lenis.lenis-stopped {
  overflow: hidden;
}

.lenis.lenis-scrolling iframe {
  pointer-events: none;
}

body {
  background-color: #ffffff;
  color: #0f172a; /* slate-900 */
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}

::-webkit-scrollbar-track {
  background: #f1f5f9;
}

::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #0284c7;
}

/* Utility to hide scrollbars while retaining touch swipe scrolling */
.scrollbar-none {
  -ms-overflow-style: none; /* IE and Edge */
  scrollbar-width: none; /* Firefox */
  -webkit-overflow-scrolling: touch;
}

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

/* Screen Reader Only Accessible Utility */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* Header Glass Effect & Fixed Container */
.glass-header {
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid #e2e8f0;
  width: 100%;
}

.header-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  height: 76px;
  box-sizing: border-box;
  gap: 16px;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  text-decoration: none;
  margin-right: 8px;
}

/* Header Navigation Links */
.header-nav {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.header-nav a {
  white-space: nowrap !important;
  font-size: 14px;
  font-weight: 500;
  transition: color 0.2s ease;
  display: inline-flex;
  align-items: center;
}

/* Header Contacts & CTA */
.header-contacts {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}

/* Header Breakpoint Adaptation: <= 1023px (lg breakpoint) */
@media (min-width: 1024px) {
  .header-nav {
    display: flex !important;
  }
  .header-contacts {
    display: flex !important;
  }
  .header-mobile-call {
    display: none !important;
  }
  .mobile-menu-btn {
    display: none !important;
  }
}

@media (max-width: 1023px) {
  .header-nav {
    display: none !important;
  }
  .header-contacts {
    display: none !important;
  }
  .header-mobile-call {
    display: flex !important;
  }
  .mobile-menu-btn {
    display: flex !important;
  }
}

/* Crisp Clean Card Styles with Hardware Acceleration */
.clean-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.04), 0 2px 4px -2px rgba(0, 0, 0, 0.03);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform;
}

.clean-card:hover {
  border-color: #94a3b8;
  box-shadow: 0 12px 24px -4px rgba(2, 132, 199, 0.12), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
  transform: translateY(-2px);
}

/* Advantage Interactive Cards with Hardware Acceleration */
.advantage-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform;
}

.advantage-card:hover {
  border-color: #0284c7;
  transform: translateY(-4px);
  box-shadow: 0 16px 30px -8px rgba(2, 132, 199, 0.16), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
}

/* Quick Model Chips & Brand Tags */
.model-chip {
  transition: all 0.2s ease-in-out;
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
}

.model-chip.active {
  background-color: #0284c7;
  color: #ffffff;
  border-color: #0284c7;
  box-shadow: 0 2px 6px rgba(2, 132, 199, 0.25);
}

html.dark .model-chip:not(.active) {
  background-color: #1e293b;
  color: #cbd5e1;
  border-color: #334155;
}

html.dark .model-chip:not(.active):hover {
  background-color: #334155;
  color: #f8fafc;
  border-color: #475569;
}

/* Series Chip */
.series-chip {
  transition: all 0.2s ease-in-out;
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
}

.series-chip.active {
  background-color: #e0f2fe;
  color: #0369a1;
  border-color: #7dd3fc;
  font-weight: 700;
}

.series-chip:hover:not(.active) {
  background-color: #f1f5f9;
  border-color: #cbd5e1;
}

html.dark .series-chip:not(.active) {
  background-color: #1e293b;
  color: #cbd5e1;
  border-color: #334155;
}

html.dark .series-chip:not(.active):hover {
  background-color: #334155;
  color: #f8fafc;
  border-color: #475569;
}

html.dark .series-chip.active {
  background-color: rgba(2, 132, 199, 0.25);
  color: #38bdf8;
  border-color: #0284c7;
}

/* Price filter button */
.price-filter-btn {
  transition: all 0.2s ease-in-out;
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
}

/* Category Quick Filter Pills */
.category-pill {
  transition: all 0.2s ease-in-out;
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
}

.category-pill:hover, .category-pill.active {
  background-color: #0284c7;
  color: #ffffff;
  border-color: #0284c7;
}

/* Brand badge in hero */
.brand-pill {
  transition: all 0.2s ease;
  user-select: none;
  touch-action: manipulation;
}
.brand-pill:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 10px -2px rgba(0,0,0,0.08);
}

/* MAX Messenger Button */
.btn-messenger-max {
  background-color: #4f46e5;
  color: #ffffff;
  transition: all 0.2s ease;
}

.btn-messenger-max:hover {
  background-color: #4338ca;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.35);
}

/* Form input focus styling */
.form-input-light {
  transition: all 0.2s ease-in-out;
}

.form-input-light:focus {
  border-color: #0284c7;
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
  outline: none;
}

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

.animate-fadeIn {
  animation: fadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Cookie Banner Slide-Up Animation */
@keyframes slideUp {
  from {
    transform: translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.animate-slideUp {
  animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* ==========================================================================
   SCROLL REVEAL ANIMATIONS (INTERSECTION OBSERVER)
   ========================================================================== */
.reveal-on-scroll {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.5s cubic-bezier(0.16, 1, 0.3, 1), 
              transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: opacity, transform;
}

.reveal-on-scroll.is-visible {
  opacity: 1;
  transform: translateY(0);
  will-change: auto;
}

.reveal-delay-100 { transition-delay: 100ms; }
.reveal-delay-200 { transition-delay: 200ms; }
.reveal-delay-300 { transition-delay: 300ms; }
.reveal-delay-400 { transition-delay: 400ms; }

@media (prefers-reduced-motion: reduce) {
  .reveal-on-scroll {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }
}

/* ==========================================================================
   VIEW TRANSITIONS API (SMOOTH THEME SWITCHING)
   ========================================================================== */
::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 0.35s;
  animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==========================================================================
   GLOBAL THEME TRANSITION FALLBACK
   ========================================================================== */
html.theme-transitioning body,
html.theme-transitioning header,
html.theme-transitioning section,
html.theme-transitioning footer,
html.theme-transitioning .clean-card,
html.theme-transitioning .advantage-card,
html.theme-transitioning input,
html.theme-transitioning textarea,
html.theme-transitioning select,
html.theme-transitioning button {
  transition: background-color 0.3s ease, border-color 0.3s ease, color 0.25s ease, box-shadow 0.3s ease !important;
}

/* Smooth Sun/Moon Icon Transitions */
.theme-toggle-btn .icon-sun {
  opacity: 0;
  transform: rotate(90deg) scale(0);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.theme-toggle-btn .icon-moon {
  opacity: 1;
  transform: rotate(0) scale(1);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

html.dark .theme-toggle-btn .icon-sun {
  opacity: 1;
  transform: rotate(0) scale(1);
}

html.dark .theme-toggle-btn .icon-moon {
  opacity: 0;
  transform: rotate(-90deg) scale(0);
}

/* ==========================================================================
   DARK MODE ARCHITECTURE & REFINED SURFACES
   ========================================================================== */
html.dark {
  color-scheme: dark;
}

html.dark body {
  background-color: #0b0f19;
  color: #f8fafc;
}

html.dark .glass-header {
  background: rgba(11, 15, 25, 0.94);
  border-bottom-color: rgba(255, 255, 255, 0.08);
}

html.dark .header-nav a {
  color: #94a3b8;
}

html.dark .header-nav a:hover,
html.dark .header-nav a.active {
  color: #38bdf8;
  background-color: rgba(56, 189, 248, 0.12);
}

html.dark .clean-card {
  background-color: #1e293b;
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.4);
}

html.dark .clean-card:hover {
  border-color: #38bdf8;
  box-shadow: 0 12px 30px -4px rgba(2, 132, 199, 0.25);
}

html.dark .advantage-card {
  background-color: #1e293b;
  border-color: rgba(255, 255, 255, 0.08);
}

html.dark .advantage-card:hover {
  border-color: #38bdf8;
  box-shadow: 0 16px 32px -6px rgba(2, 132, 199, 0.28);
}

html.dark .price-row {
  background-color: #1e293b;
  border-color: rgba(255, 255, 255, 0.08);
}

html.dark .price-row:hover {
  border-color: #38bdf8;
}

html.dark ::-webkit-scrollbar-track {
  background: #0f172a;
}

html.dark ::-webkit-scrollbar-thumb {
  background: #334155;
}

html.dark ::-webkit-scrollbar-thumb:hover {
  background: #38bdf8;
}

/* ==========================================================================
   RESPONSIVE MEDIA QUERIES (MOBILE & TABLET OPTIMIZATION)
   ========================================================================== */

/* Medium Screens & Tablets (max-width: 1023px) */
@media (max-width: 1023px) {
  html {
    scroll-padding-top: 75px;
  }
  
  .clean-card:hover {
    transform: none; /* Avoid sticky hover on touch */
  }

  .advantage-card:hover {
    transform: none;
  }
}

/* Small Screens & Mobile Devices (max-width: 767px) */
@media (max-width: 767px) {
  .header-container {
    height: 68px;
    gap: 8px;
  }

  /* Ensure container full width and no margins overflow */
  .clean-card {
    padding: 1.25rem !important;
  }

  /* Interactive price rows on mobile */
  .price-row {
    flex-direction: column;
    align-items: stretch;
    gap: 0.625rem;
  }

  .price-row > div:first-child {
    width: 100%;
  }

  .price-row > div:last-child {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-top: 1px dashed #e2e8f0;
    padding-top: 0.5rem;
  }

  html.dark .price-row > div:last-child {
    border-top: 1px dashed rgba(255, 255, 255, 0.1);
  }

  /* Modal responsive constraints */
  .modal-container > div {
    max-height: 92vh;
    overflow-y: auto;
    margin: 1rem;
    padding: 1.25rem !important;
  }
}

/* Extra Small Phones (max-width: 480px) */
@media (max-width: 480px) {
  /* Brand pills touch area */
  .brand-pill {
    padding: 0.35rem 0.6rem !important;
    font-size: 11px !important;
  }

  /* Series chips touch area */
  .series-chip {
    padding: 0.4rem 0.6rem !important;
    font-size: 11px !important;
  }

  /* Form inputs & buttons touch targets */
  button, .form-input-light, a.min-h-\[44px\] {
    min-height: 44px;
  }
}
