/* ===== MOBILE-FIRST BASE STYLES ===== */
@media (max-width: 767px) {
  :root {
    --header-h: 3.5rem;
    --section-spacing: 3rem;
    --border-radius: 12px;
  }

  /* Improved touch targets */
  button, a, input[type="radio"] + label {
    min-height: 44px;
    min-width: 44px;
  }

  /* Base layout adjustments */
  body {
    font-size: 16px;
    line-height: 1.5;
  }

  /* Header optimizations */
  header {
    padding: 0 1rem;
    height: var(--header-h);
  }

  .header-logo {
    font-size: 1.5rem;
  }

  .cart-btn {
    width: 38px;
    height: 38px;
    font-size: 1.2rem;
  }

  /* Hero section */
  .hero {
    flex-direction: column;
    padding: 2rem 1rem;
    min-height: auto;
    gap: 2rem;
  }

  .hero-left {
    text-align: center;
    align-items: center;
  }

  .hero-left h2 {
    font-size: 2rem;
    margin-bottom: 1rem;
  }

  .hero-left p {
    font-size: 1rem;
    max-width: 100%;
    margin-bottom: 1.5rem;
  }

  .shop-btn {
    padding: 1rem 2rem;
    font-size: 1rem;
    align-self: center;
  }

  /* Product cards */
  .product-card {
    height: auto;
    max-height: none;
    perspective: none;
  }

  .product-card-inner {
    height: auto;
    transform-style: flat;
  }

  .product-card-front, 
  .product-card-back {
    position: relative;
    transform: none;
    backface-visibility: visible;
  }

  .product-card-back {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    z-index: 1000;
    padding: 1rem;
    border-radius: 0;
    overflow-y: auto;
    background: var(--bg);
  }

  .product-card-back.active {
    display: block;
  }

  .btn-close-details {
    position: sticky;
    bottom: 1rem;
    margin-top: 1rem;
  }

  .product-media {
    height: 200px;
  }

  /* Mobile card interactions */
  .btn-view-details {
    display: none;
  }

  .mobile-details-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.8rem;
    background: var(--primary);
    color: white;
    border-radius: 8px;
    font-weight: 600;
    margin-top: 1rem;
  }

  /* Swiper adjustments */
  .product-swiper {
    padding: 1rem 0;
  }

  .swiper-slide {
    padding: 0.5rem;
  }

  /* Cart dropdown */
  .cart-dropdown {
    width: 100%;
    max-width: 100%;
    border-radius: 0;
  }

  .cart-item {
    flex-direction: column;
    align-items: flex-start;
  }

  .cart-item-img {
    width: 100%;
    height: 150px;
  }

  .remove-item {
    position: absolute;
    top: 1rem;
    right: 0;
  }

  /* Sections */
  section {
    padding: 2rem 1rem;
  }

  .section-title {
    font-size: 1.8rem;
    margin-bottom: 1.5rem;
  }

  /* About section */
  .about-section {
    flex-direction: column;
    padding: 2rem 1rem;
    gap: 2rem;
  }

  .about-content .section-title {
    text-align: center;
    left: 50%;
    transform: translateX(-50%);
  }

  /* Contact form */
  .contact-card {
    padding: 1.5rem;
  }

  .contact-form input,
  .contact-form textarea {
    padding: 0.8rem 1rem;
  }

  /* Footer */
  footer {
    padding: 2rem 1rem;
  }

  .footer-links {
    flex-direction: column;
    gap: 1rem;
  }

  /* Modal adjustments */
  .modal-content {
    width: 95%;
    padding: 1.5rem;
  }

  /* Improved form inputs */
  input, textarea, select {
    font-size: 16px !important; /* Prevent iOS zoom */
  }

  /* Custom dropdowns */
  select {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1rem;
  }

  /* Button feedback */
  button:active {
    transform: scale(0.98);
  }

  /* Hide desktop elements */
  .desktop-only {
    display: none !important;
  }
}

/* ===== TABLET STYLES (768px - 1023px) ===== */
@media (min-width: 768px) and (max-width: 1023px) {
  :root {
    --header-h: 4rem;
    --section-spacing: 4rem;
  }

  /* Show mobile elements */
  .mobile-only {
    display: none !important;
  }

  /* Product cards */
  .product-card {
    max-width: 300px;
    height: 450px;
  }

  .product-media {
    height: 220px;
  }

  /* Hero section */
  .hero {
    padding: 3rem 2rem;
  }

  .hero-left h2 {
    font-size: 2.5rem;
  }

  /* Sections */
  section {
    padding: 3rem 2rem;
  }
}

/* ===== DESKTOP STYLES (1024px and up) ===== */
@media (min-width: 1024px) {
  /* Hide mobile elements */
  .mobile-only {
    display: none !important;
  }
}

/* ===== IMPROVED MOBILE INTERACTIONS ===== */
/* Prevent zoom on input focus in mobile Safari */
@media (max-width: 767px) {
  input[type="color"],
  input[type="date"],
  input[type="datetime"],
  input[type="datetime-local"],
  input[type="email"],
  input[type="month"],
  input[type="number"],
  input[type="password"],
  input[type="search"],
  input[type="tel"],
  input[type="text"],
  input[type="time"],
  input[type="url"],
  input[type="week"],
  select:focus,
  textarea {
    font-size: 16px !important;
  }
}

/* Smooth scrolling for anchor links */
@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

/* Improved tap highlights */
a, button, input, label {
  -webkit-tap-highlight-color: rgba(0,0,0,0);
}

/* Prevent long-press menu on images */
img {
  -webkit-touch-callout: none;
}

/* ===== MOBILE-SPECIFIC COMPONENT IMPROVEMENTS ===== */
/* Bottom navigation for mobile */
.mobile-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 0.5rem 0;
  background: var(--glass-ivory);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
  z-index: 900;
}

.mobile-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 0.8rem;
  color: var(--text-light);
  transition: all 0.3s ease;
}

.mobile-nav-item.active {
  color: var(--primary-dark);
}

.mobile-nav-item i {
  font-size: 1.4rem;
  margin-bottom: 0.2rem;
}

/* Mobile product details overlay */
.product-details-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  background: var(--bg);
  z-index: 1000;
  overflow-y: auto;
  padding: 1rem;
  transform: translateY(100%);
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.product-details-overlay.active {
  transform: translateY(0);
}

.close-details-btn {
  position: fixed;
  top: 1rem;
  right: 1rem;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--glass);
  backdrop-filter: blur(5px);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1001;
}

/* Improved mobile forms */
.mobile-form-group {
  margin-bottom: 1.5rem;
}

.mobile-form-label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: var(--text);
}

.mobile-form-input {
  width: 100%;
  padding: 1rem;
  border: 1px solid var(--border-dark);
  border-radius: 8px;
  font-size: 1rem;
  transition: all 0.3s ease;
}

.mobile-form-input:focus {
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.2);
}

/* Mobile quantity selector */
.quantity-selector {
  display: flex;
  align-items: center;
  border: 1px solid var(--border-dark);
  border-radius: 8px;
  overflow: hidden;
}

.quantity-btn {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--glass);
  border: none;
  font-size: 1.2rem;
  color: var(--primary-dark);
}

.quantity-input {
  width: 50px;
  text-align: center;
  border: none;
  border-left: 1px solid var(--border-dark);
  border-right: 1px solid var(--border-dark);
  padding: 0.5rem;
  font-size: 1rem;
}

/* Mobile filter drawer */
.filter-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: 85%;
  max-width: 320px;
  height: 100vh;
  background: var(--bg);
  z-index: 1100;
  transform: translateX(100%);
  transition: transform 0.3s ease-out;
  padding: 1.5rem;
  overflow-y: auto;
  box-shadow: -5px 0 15px rgba(0,0,0,0.1);
}

.filter-drawer.active {
  transform: translateX(0);
}

.filter-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  background: rgba(0,0,0,0.5);
  z-index: 1099;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.filter-overlay.active {
  opacity: 1;
  pointer-events: all;
}

/* Mobile search bar */
.mobile-search-bar {
  position: fixed;
  top: var(--header-h);
  left: 0;
  width: 100%;
  padding: 0.5rem 1rem;
  background: var(--glass-ivory);
  backdrop-filter: blur(10px);
  z-index: 800;
  transform: translateY(-100%);
  transition: transform 0.3s ease;
}

.mobile-search-bar.active {
  transform: translateY(0);
}

.mobile-search-input {
  width: 100%;
  padding: 0.8rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--glass);
  backdrop-filter: blur(5px);
}

/* ===== PERFORMANCE OPTIMIZATIONS ===== */
/* Will-change for performance */
.product-card,
.product-media video,
.btn-add-to-cart,
.nav-link {
  will-change: transform, opacity;
}

/* Reduced motion alternatives */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ===== SAFARI SPECIFIC FIXES ===== */
@supports (-webkit-touch-callout: none) {
  /* Fix for Safari viewport units */
  .product-card-back {
    height: -webkit-fill-available;
  }
}

/* ===== ACCESSIBILITY IMPROVEMENTS ===== */
/* Focus styles for keyboard navigation */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Screen reader only 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;
}