/* =====================================================
   RESPONSIVE FIXES & IMPROVEMENTS
   كازابلانكا - Casablanca E-Commerce
   ===================================================== */

/* =====================================================
   HEADER MOBILE FIXES
   ===================================================== */
@media (max-width: 768px) {
  /* Hide header-top on mobile - too cluttered */
  .header-top {
    display: none;
  }

  /* Make header sticky and cleaner */
  .header {
    position: sticky;
    top: 0;
    z-index: 1000;
    background-color: var(--bg-white, #ffffff);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  }

  .header-main {
    padding: 12px 0;
  }

  .header-main-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
  }

  .main-nav {
    display: none;
  }

  .logo {
    flex-shrink: 0;
  }

  .logo img {
    height: 35px;
  }

  .logo span {
    font-size: 1.1rem;
  }

  .header-icons {
    flex-shrink: 0;
    display: flex;
    gap: 8px;
    align-items: center;
  }

  .header-icons button,
  .header-icons a {
    padding: 8px;
    min-width: 40px;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* Search bar full width on mobile */
  .search-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1001;
    background: white;
    padding: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transform: translateY(-100%);
    transition: transform 0.3s ease;
  }

  .search-bar.active {
    transform: translateY(0);
  }

  .search-form {
    display: flex;
    gap: 8px;
    max-width: 100%;
  }

  .search-form input {
    flex: 1;
    min-height: 44px;
    padding: 10px 15px;
    font-size: 16px;
    border: 1px solid #ddd;
    border-radius: 8px;
  }

  .search-form button {
    min-width: 44px;
    min-height: 44px;
  }
}

@media (max-width: 480px) {
  .header-main {
    padding: 10px 0;
  }

  .logo img {
    height: 30px;
  }

  .logo span {
    font-size: 1rem;
  }

  .header-icons {
    gap: 4px;
  }

  .header-icons button,
  .header-icons a {
    min-width: 36px;
    min-height: 36px;
    padding: 6px;
    font-size: 0.9rem;
  }

  .cart-count {
    font-size: 0.7rem;
    min-width: 16px;
    height: 16px;
    line-height: 16px;
  }
}

/* Improve header on very small screens */
@media (max-width: 360px) {
  .logo span {
    display: none; /* Hide text, keep logo only */
  }

  .header-icons {
    gap: 2px;
  }
}

/* =====================================================
   1. BUTTON TOUCH TARGETS - 44px Minimum (WCAG 2.5)
   ===================================================== */
.btn {
  min-height: 44px;
  padding: 12px 28px;
}

.btn-sm {
  min-height: 44px; /* Override small button */
  padding: 10px 20px;
}

.btn-lg {
  min-height: 48px;
  padding: 16px 36px;
}

/* Header icon buttons */
.header-icons button,
.header-icons a {
  min-width: 44px;
  min-height: 44px;
}

/* Cart quantity buttons */
.quantity-btn,
.quantity-control button {
  min-width: 44px !important;
  min-height: 44px !important;
}

/* Mobile menu button */
.mobile-menu-btn {
  min-width: 44px;
  min-height: 44px;
}

/* Search button */
.search-btn {
  min-width: 44px;
  min-height: 44px;
}

/* =====================================================
   2. SWIPER HERO SLIDER FIXES
   ===================================================== */
.hero-slider {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  min-height: 300px;
  max-height: 600px;
  overflow: hidden;
}

.hero-swiper {
  width: 100%;
  height: 100%;
}

.hero-swiper .swiper-slide {
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  position: relative;
}

.hero-swiper .swiper-slide::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.3);
  z-index: 1;
}

.hero-swiper .slide-content {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  z-index: 2;
  color: white;
  max-width: 90%;
}

.hero-swiper .slide-content h1 {
  color: white;
  font-size: clamp(1.5rem, 5vw, 2.5rem);
  margin-bottom: 1rem;
}

.hero-swiper .slide-content p {
  font-size: clamp(0.9rem, 3vw, 1.25rem);
  margin-bottom: 1.5rem;
}

/* Swiper navigation buttons */
.hero-swiper .swiper-button-next,
.hero-swiper .swiper-button-prev {
  color: white;
  width: 44px;
  height: 44px;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 50%;
}

.hero-swiper .swiper-button-next::after,
.hero-swiper .swiper-button-prev::after {
  font-size: 20px;
}

.hero-swiper .swiper-pagination-bullet {
  width: 12px;
  height: 12px;
  background: white;
  opacity: 0.7;
}

.hero-swiper .swiper-pagination-bullet-active {
  opacity: 1;
  background: var(--accent-color, #f78080);
}

/* =====================================================
   3. FORM INPUT FIXES FOR MOBILE
   ===================================================== */
.form-group input,
.form-group textarea,
.form-group select,
.form-control,
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="password"],
input[type="number"],
textarea,
select {
  min-height: 44px;
  padding: 12px 16px;
  font-size: 1rem;
}

@media (max-width: 768px) {
  .form-group input,
  .form-group textarea,
  .form-group select,
  .form-control,
  input[type="text"],
  input[type="email"],
  input[type="tel"],
  input[type="password"],
  input[type="number"],
  textarea,
  select {
    min-height: 48px;
    padding: 15px 18px;
    font-size: 16px; /* Prevent iOS auto-zoom */
  }
}

/* =====================================================
   4. PRODUCT GRID RESPONSIVE IMPROVEMENTS
   ===================================================== */
/* Ensure product cards have minimum width in swipers */
.products-swiper .swiper-slide .product-card {
  min-width: 0;
  max-width: 100%;
  height: 100%;
}

.products-swiper .product-image {
  width: 100%;
  height: 0;
  padding-bottom: 100%;
  padding-top: 0;
  position: relative;
  background: linear-gradient(
    135deg,
    var(--bg-light, #f8f5f2) 0%,
    var(--border-color, #e5e5e5) 100%
  );
}

/* Ensure consistent card dimensions */
.product-card {
  display: flex;
  flex-direction: column;
}

.product-card .product-image {
  width: 100%;
  height: 0;
  padding-bottom: 100%;
  padding-top: 0;
  flex-shrink: 0;
}

.product-card .product-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.product-card .product-name {
  flex: 1;
  min-height: 2.8em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.product-card .product-price {
  margin-top: auto;
}

/* Handle missing product images - Enhanced fallback */
.product-image::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23c5a992'%3E%3Cpath d='M21 19V5c0-1.1-.9-2-2-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2zM8.5 13.5l2.5 3.01L14.5 12l4.5 6H5l3.5-4.5z'/%3E%3C/svg%3E");
  background-size: 50%;
  background-repeat: no-repeat;
  background-position: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 1;
}

.product-image.no-image::after {
  opacity: 1;
}

.product-image img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 2;
}

.product-image.no-image img {
  display: none;
}

.products-swiper .product-info {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.products-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: clamp(0.75rem, 2vw, 1.25rem);
}

@media (max-width: 1024px) {
  .products-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 768px) {
  .products-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 480px) {
  .products-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Ensure all product cards have consistent dimensions */
  .product-card {
    display: flex !important;
    flex-direction: column !important;
  }

  .product-image {
    width: 100% !important;
    height: 0 !important;
    padding-bottom: 100% !important;
    padding-top: 0 !important;
    flex-shrink: 0 !important;
    background-color: var(--bg-light, #f8f5f2) !important;
    overflow: hidden !important;
  }

  .product-image img {
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    width: 100% !important;
    height: 100% !important;
    min-width: 100% !important;
    min-height: 100% !important;
    object-fit: cover !important;
    object-position: center !important;
    display: block !important;
  }

  .product-info {
    flex: 1 !important;
    display: flex !important;
    flex-direction: column !important;
  }

  .product-name {
    min-height: 2.8em !important;
    max-height: 2.8em !important;
  }

  .product-price {
    margin-top: auto !important;
  }
}

/* =====================================================
   PRODUCT SWIPER FIXES - CRITICAL FOR MOBILE
   ===================================================== */
.products-swiper,
.categories-swiper {
  width: 100%;
  padding: 0.625rem 0 1.25rem;
  overflow: hidden;
  position: relative;
  height: auto;
}

/* Ensure swiper container clips content properly */
#categories-swiper,
#featured-swiper,
#new-swiper {
  overflow: hidden;
  width: 100%;
  max-width: 100%;
}

.products-swiper .swiper-wrapper,
.categories-swiper .swiper-wrapper {
  display: flex;
  align-items: stretch;
}

.products-swiper .swiper-slide,
.categories-swiper .swiper-slide {
  height: auto;
  display: flex;
  flex-direction: column;
}

.products-swiper .product-card {
  height: 100%;
  display: flex;
  flex-direction: column;
  width: 100%;
}

/* Ensure images are truly uniform - ONLY for swipers, not grids */
.products-swiper .product-image {
  width: 100% !important;
  height: 0 !important;
  padding-bottom: 100% !important;
  padding-top: 0 !important;
  position: relative !important;
  overflow: hidden !important;
  background-color: var(--bg-light, #f8f5f2) !important;
}

.products-swiper .product-image img {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 100% !important;
  height: 100% !important;
  min-width: 100% !important;
  min-height: 100% !important;
  max-width: 100% !important;
  max-height: 100% !important;
  object-fit: cover !important;
  object-position: center !important;
  display: block !important;
}

.products-swiper .swiper-pagination,
.categories-swiper .swiper-pagination {
  display: none !important;
}

.products-swiper .swiper-button-next,
.products-swiper .swiper-button-prev,
.categories-swiper .swiper-button-next,
.categories-swiper .swiper-button-prev {
  color: var(--primary-color, #5c3d2e);
  background: white;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 50%;
  box-shadow: 0 0.1875rem 0.75rem rgba(0, 0, 0, 0.18);
  transition: all 0.3s ease;
}

.products-swiper .swiper-button-next:hover,
.products-swiper .swiper-button-prev:hover,
.categories-swiper .swiper-button-next:hover,
.categories-swiper .swiper-button-prev:hover {
  background: var(--primary-color, #5c3d2e);
  color: white;
  transform: scale(1.1);
}

.products-swiper .swiper-button-next::after,
.products-swiper .swiper-button-prev::after,
.categories-swiper .swiper-button-next::after,
.categories-swiper .swiper-button-prev::after {
  font-size: 1.125rem;
  font-weight: bold;
}

.products-swiper .swiper-button-disabled,
.categories-swiper .swiper-button-disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* Swiper slide widths for auto mode */
.products-swiper .swiper-slide {
  width: 280px;
  max-width: 80vw;
}

.categories-swiper .swiper-slide {
  width: 200px;
  max-width: 60vw;
}

/* Mobile specific fixes */
@media (max-width: 768px) {
  .products-swiper,
  .categories-swiper {
    padding: 0.625rem 0 1.25rem;
  }

  .products-swiper .swiper-slide {
    width: 48vw;
    max-width: 280px;
  }

  .categories-swiper .swiper-slide {
    width: 60vw;
    max-width: 200px;
  }

  .products-swiper .swiper-button-next,
  .products-swiper .swiper-button-prev,
  .categories-swiper .swiper-button-next,
  .categories-swiper .swiper-button-prev {
    display: none;
  }

  /* Prevent horizontal scroll on section containers */
  .categories-section,
  .products-section,
  .featured-section,
  .new-arrivals-section {
    overflow-x: hidden;
    max-width: 100vw;
  }

  /* Show add to cart button on mobile */
  .product-actions {
    opacity: 1 !important;
    transform: translateY(0) !important;
    pointer-events: auto !important;
  }

  .product-actions .btn {
    pointer-events: auto !important;
  }

  /* Force consistent card dimensions on mobile */
  .products-swiper .swiper-slide {
    min-height: 320px !important;
  }

  .products-swiper .product-card {
    display: flex !important;
    flex-direction: column !important;
    height: 100% !important;
    min-height: 320px !important;
  }

  .products-swiper .product-image {
    width: 100% !important;
    height: 0 !important;
    padding-bottom: 100% !important;
    padding-top: 0 !important;
    flex-shrink: 0 !important;
    position: relative !important;
    background-color: var(--bg-light, #f8f5f2) !important;
    overflow: hidden !important;
  }

  .products-swiper .product-image img {
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    right: auto !important;
    bottom: auto !important;
    transform: translate(-50%, -50%) !important;
    width: 100% !important;
    height: 100% !important;
    min-width: 100% !important;
    min-height: 100% !important;
    max-width: none !important;
    max-height: none !important;
    object-fit: cover !important;
    object-position: center !important;
    display: block !important;
  }

  .products-swiper .product-info {
    flex: 1 !important;
    display: flex !important;
    flex-direction: column !important;
    padding: 15px !important;
  }

  .products-swiper .product-name {
    flex: 1 !important;
    min-height: 2.8em !important;
    max-height: 2.8em !important;
    line-height: 1.4 !important;
    overflow: hidden !important;
    display: -webkit-box !important;
    -webkit-line-clamp: 2 !important;
    line-clamp: 2 !important;
    -webkit-box-orient: vertical !important;
  }

  .products-swiper .product-price {
    margin-top: auto !important;
    flex-shrink: 0 !important;
  }
}

/* =====================================================
   5. CATEGORY CARDS RESPONSIVE SCALING
   ===================================================== */
/* Improved category card styling */
.categories-swiper .category-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5625rem 0.9375rem;
  background: linear-gradient(
    135deg,
    var(--bg-white, #ffffff) 0%,
    var(--bg-light, #f8f5f2) 100%
  );
  border-radius: 1rem;
  text-align: center;
  transition: all 0.3s ease;
  box-shadow: 0 0.125rem 0.5rem rgba(0, 0, 0, 0.08);
  border: 0.0625rem solid rgba(0, 0, 0, 0.05);
  min-height: clamp(11.25rem, 20vh, 15rem);
}

.categories-swiper .category-card:hover {
  transform: translateY(-0.3125rem);
  box-shadow: 0 0.5rem 1.25rem rgba(0, 0, 0, 0.15);
  background: var(--bg-white, #ffffff);
}

.category-image {
  width: clamp(4.375rem, 15vw, 6.25rem);
  height: clamp(4.375rem, 15vw, 6.25rem);
  aspect-ratio: 1;
  margin-bottom: 0.9375rem;
  border-radius: 50%;
  overflow: hidden;
  background: linear-gradient(
    135deg,
    var(--primary-color, #5c3d2e) 0%,
    var(--primary-light, #8b6b5d) 100%
  );
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0.25rem 0.75rem rgba(92, 61, 46, 0.2);
  position: relative;
}

/* Handle missing category images */
.category-image::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white' opacity='0.9'%3E%3Cpath d='M20 6h-2.18c.11-.31.18-.65.18-1a2.996 2.996 0 0 0-5.5-1.65l-.5.67-.5-.68C10.96 2.54 10.05 2 9 2 7.34 2 6 3.34 6 5c0 .35.07.69.18 1H4c-1.11 0-1.99.89-1.99 2L2 19c0 1.11.89 2 2 2h16c1.11 0 2-.89 2-2V8c0-1.11-.89-2-2-2zm-5-2c.55 0 1 .45 1 1s-.45 1-1 1-1-.45-1-1 .45-1 1-1zM9 4c.55 0 1 .45 1 1s-.45 1-1 1-1-.45-1-1 .45-1 1-1zm11 15H4v-2h16v2zm0-5H4V8h5.08L7 10.83 8.62 12 11 8.76l1-1.36 1 1.36L15.38 12 17 10.83 14.92 8H20v6z'/%3E%3C/svg%3E");
  background-size: 50%;
  background-repeat: no-repeat;
  background-position: center;
  opacity: 0;
  pointer-events: none;
  z-index: 1;
  transition: opacity 0.3s ease;
}

.category-image.no-image::after {
  opacity: 1;
}

.category-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 2;
}

.category-image.no-image img {
  display: none;
}

.category-image i {
  font-size: 2rem;
  color: white;
  z-index: 3;
  position: relative;
}

.categories-swiper .category-card h3 {
  font-size: clamp(0.95rem, 2.5vw, 1.1rem);
  font-weight: 600;
  margin-bottom: 0.3125rem;
  color: var(--primary-color, #5c3d2e);
}

.categories-swiper .category-card .products-count {
  font-size: clamp(0.75rem, 2vw, 0.875rem);
  color: var(--text-light, #96989c);
  font-weight: 500;
}

@media (max-width: 480px) {
  .categories-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }

  .categories-swiper .category-card {
    padding: 1.25rem 0.75rem;
    min-height: 10rem;
  }
}

/* =====================================================
   6. MOBILE MENU IMPROVEMENTS
   ===================================================== */
.mobile-menu {
  width: min(300px, 85vw);
  right: calc(-1 * min(300px, 85vw));
}

[dir="ltr"] .mobile-menu {
  left: calc(-1 * min(300px, 85vw));
  right: auto;
}

.mobile-menu.active {
  right: 0;
}

[dir="ltr"] .mobile-menu.active {
  left: 0;
  right: auto;
}

/* =====================================================
   7. FLUID TYPOGRAPHY
   ===================================================== */
html {
  font-size: clamp(14px, 2vw, 16px);
}

h1 {
  font-size: clamp(1.75rem, 5vw, 2.5rem);
}

h2 {
  font-size: clamp(1.5rem, 4vw, 2rem);
}

h3 {
  font-size: clamp(1.25rem, 3vw, 1.5rem);
}

h4 {
  font-size: clamp(1rem, 2.5vw, 1.25rem);
}

p {
  font-size: clamp(0.9rem, 2.5vw, 1rem);
}

/* =====================================================
   8. TABLET SPECIFIC FIXES (768px - 1024px)
   ===================================================== */
@media (max-width: 1024px) and (min-width: 769px) {
  /* Tablet landscape - optimize sidebar */
  .admin-sidebar {
    width: 220px;
  }

  .admin-content {
    margin-right: 220px;
  }

  [dir="ltr"] .admin-content {
    margin-left: 220px;
    margin-right: 0;
  }
}

/* =====================================================
   9. SMALL PHONE OPTIMIZATIONS (<375px)
   ===================================================== */
@media (max-width: 375px) {
  .container {
    padding: 0 15px;
  }

  .hero-slider {
    aspect-ratio: 1;
    min-height: 200px;
  }

  .section-header {
    flex-direction: column;
    gap: 10px;
    align-items: flex-start;
  }

  .btn {
    width: 100%;
    justify-content: center;
  }
}

/* =====================================================
   10. TOUCH-FRIENDLY IMPROVEMENTS
   ===================================================== */
@media (hover: none) and (pointer: coarse) {
  /* Mobile devices with touch */
  button,
  a,
  .btn,
  [role="button"],
  input[type="button"],
  input[type="submit"] {
    min-height: 44px;
    min-width: 44px;
  }

  /* Increase tap target spacing */
  .header-icons {
    gap: 8px;
  }

  /* Make links more touch-friendly */
  a {
    padding: 4px;
    margin: -4px;
  }
}

/* =====================================================
   11. STICKY POSITIONING FIXES
   ===================================================== */
@media (max-width: 768px) {
  .product-gallery,
  .cart-summary {
    position: relative !important;
    top: auto !important;
    max-height: none !important;
  }
}

/* =====================================================
   12. RESPONSIVE IMAGES
   ===================================================== */
img {
  max-width: 100%;
  height: auto;
}

.product-image img,
.category-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* =====================================================
   13. ADMIN PANEL RESPONSIVE FIXES
   ===================================================== */
@media (max-width: 1024px) {
  .admin-sidebar {
    transform: translateX(100%);
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    z-index: 1000;
    transition: transform 0.3s ease;
  }

  [dir="ltr"] .admin-sidebar {
    transform: translateX(-100%);
    left: 0;
    right: auto;
  }

  .admin-sidebar.active {
    transform: translateX(0);
  }

  .sidebar-toggle {
    display: flex !important;
  }

  .admin-content {
    margin-right: 0 !important;
    margin-left: 0 !important;
  }
}

@media (max-width: 768px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .table-container {
    font-size: 0.875rem;
  }

  table th,
  table td {
    padding: 10px 8px;
  }
}

/* =====================================================
   14. CART PAGE IMPROVEMENTS
   ===================================================== */
@media (max-width: 768px) {
  .cart-layout {
    grid-template-columns: 1fr;
  }

  .cart-item {
    grid-template-columns: 80px 1fr;
    gap: 12px;
  }

  .cart-item-details {
    grid-column: 1 / -1;
  }
}

/* =====================================================
   15. CHECKOUT PAGE IMPROVEMENTS
   ===================================================== */
@media (max-width: 768px) {
  .checkout-layout {
    grid-template-columns: 1fr;
  }

  .order-summary {
    position: static;
    order: -1; /* Show summary first on mobile */
  }
}

/* =====================================================
   16. LOADING & ANIMATION PERFORMANCE
   ===================================================== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* =====================================================
   17. HIGH DPI / RETINA DISPLAYS
   ===================================================== */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  /* Use higher quality images for retina displays */
  .product-image,
  .category-image,
  .hero-slider {
    image-rendering: -webkit-optimize-contrast;
  }
}

/* =====================================================
   18. LANDSCAPE ORIENTATION FIXES
   ===================================================== */
@media (max-height: 500px) and (orientation: landscape) {
  .hero-slider {
    min-height: 200px;
    max-height: 400px;
  }

  .mobile-menu {
    overflow-y: auto;
  }
}

/* =====================================================
   19. PRINT STYLES
   ===================================================== */
@media print {
  .header,
  .footer,
  .mobile-menu,
  .btn,
  .cart-btn,
  .whatsapp-float {
    display: none !important;
  }

  body {
    background: white;
    color: black;
  }
}

/* =====================================================
   20. MOBILE SLIDER BOUNDARY FIXES
   Prevents sliders from swiping out of view on mobile
   ===================================================== */
@media (max-width: 768px) {
  /* Prevent horizontal page scroll - use clip instead of hidden to preserve sticky positioning */
  html,
  body {
    overflow-x: clip;
  }

  /* Hero slider */
  .hero-slider {
    overflow: hidden;
  }

  /* Section containers - clip overflow but don't affect swiper internals */
  .categories-section,
  .products-section,
  .featured-section,
  .new-arrivals-section {
    overflow: hidden;
  }
}

/* =====================================================
   21. PRODUCT PAGE MOBILE FIXES
   ===================================================== */
@media (max-width: 768px) {
  .product-page {
    padding: 20px 0;
  }

  .product-page .container {
    padding: 0 15px;
  }

  .product-container {
    grid-template-columns: 1fr !important;
    gap: 20px !important;
    padding: 15px !important;
  }

  /* Product Gallery */
  .product-gallery {
    position: relative;
  }

  .main-image {
    border-radius: 12px;
    aspect-ratio: 1;
  }

  .thumbnails {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 10px 0;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
  }

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

  .thumbnail {
    width: 60px !important;
    height: 60px !important;
    flex-shrink: 0;
    scroll-snap-align: start;
  }

  /* Product Details */
  .product-details h1 {
    font-size: 1.5rem !important;
    margin-bottom: 8px;
  }

  .product-price-main {
    font-size: 1.5rem !important;
    margin-bottom: 15px;
  }

  .product-description {
    font-size: 0.95rem;
    line-height: 1.7;
    margin-bottom: 20px;
    padding-bottom: 15px;
  }

  /* Size Selector */
  .size-selector,
  .addon-group {
    margin-bottom: 20px;
  }

  .size-selector h4,
  .addon-group-title {
    font-size: 0.95rem;
    margin-bottom: 10px;
  }

  .size-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }

  .size-option {
    padding: 10px 14px !important;
    font-size: 0.9rem;
    min-height: 44px;
    flex: 1 1 calc(50% - 4px);
    justify-content: center;
    text-align: center;
  }

  /* Addon Options */
  .addon-options {
    gap: 8px;
  }

  .addon-option {
    padding: 12px !important;
    min-height: 44px;
  }

  .addon-option input[type="checkbox"],
  .addon-option input[type="radio"] {
    width: 20px;
    height: 20px;
  }

  /* Quantity Selector */
  .quantity-selector {
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
  }

  .qty-control {
    flex: 1;
    justify-content: center;
  }

  .qty-btn {
    width: 50px !important;
    height: 50px !important;
    font-size: 1.2rem;
  }

  .qty-input {
    width: 70px !important;
    height: 50px !important;
    font-size: 1.2rem;
  }

  /* Total Price */
  .total-price {
    padding: 15px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
  }

  .total-price .price {
    font-size: 1.5rem !important;
  }

  /* Product Actions */
  .product-page .product-actions {
    flex-direction: column !important;
    gap: 12px !important;
    position: static !important;
  }

  .product-page .product-actions .btn {
    width: 100% !important;
    min-width: unset !important;
    padding: 16px 20px !important;
    font-size: 1rem !important;
    min-height: 50px;
    justify-content: center;
  }

  /* Breadcrumb */
  .breadcrumb {
    font-size: 0.85rem;
    margin-bottom: 15px;
    flex-wrap: wrap;
  }
}

/* =====================================================
   22. PRODUCTS LISTING PAGE MOBILE FIXES
   ===================================================== */
/* Hide mobile-only elements on desktop */
.sidebar-header,
.sidebar-overlay {
  display: none;
}

@media (max-width: 768px) {
  .products-page {
    padding: 20px 0;
  }

  .products-page .container {
    padding: 0 15px;
  }

  .products-layout {
    grid-template-columns: 1fr !important;
    gap: 15px;
  }

  /* Hide sidebar by default on mobile */
  .products-sidebar {
    display: none !important;
    position: fixed !important;
    top: 0;
    right: 0;
    width: 85vw;
    max-width: 300px;
    height: 100vh;
    z-index: 1001;
    background: var(--bg-white, #fff);
    padding: 20px;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
    overflow-y: auto;
    transform: translateX(100%);
    transition: transform 0.3s ease;
  }

  [dir="ltr"] .products-sidebar {
    right: auto;
    left: 0;
    transform: translateX(-100%);
  }

  .products-sidebar.active {
    display: block !important;
    transform: translateX(0) !important;
  }

  /* Sidebar Header - show on mobile */
  .sidebar-header {
    display: flex !important;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 15px;
    margin-bottom: 15px;
    border-bottom: 2px solid var(--border-color, #ddd);
  }

  .sidebar-header h4 {
    margin: 0;
    font-size: 1.1rem;
  }

  .sidebar-close-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-light, #f5f5f5);
    border: none;
    border-radius: 50%;
    font-size: 1.1rem;
    cursor: pointer;
    color: var(--text-dark, #333);
  }

  .sidebar-close-btn:hover {
    background: var(--primary-color, #5c3d2e);
    color: white;
  }

  /* Sidebar Overlay */
  .sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
  }

  .sidebar-overlay.active {
    display: block;
  }

  body.sidebar-open {
    overflow: hidden;
  }

  /* Mobile filter button */
  .mobile-filter-btn {
    display: flex !important;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    min-height: 44px;
    font-size: 0.95rem;
    background: var(--bg-white, #fff);
    border: 1px solid var(--border-color, #ddd);
    border-radius: 8px;
  }

  /* Products Header */
  .products-header {
    flex-direction: column;
    align-items: stretch !important;
    gap: 12px;
    margin-bottom: 20px;
  }

  .products-header > div:first-child {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
  }

  .products-count {
    font-size: 0.9rem;
  }

  .products-sort {
    width: 100%;
  }

  .products-sort select {
    flex: 1;
    min-height: 44px;
    font-size: 16px; /* Prevent iOS zoom */
  }

  /* Products Grid - 2 columns on mobile */
  .products-page .products-grid {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 12px !important;
  }

  /* Product Cards in Grid - Override any swiper styles */
  .products-page .products-grid .product-card {
    display: flex !important;
    flex-direction: column !important;
    height: 100% !important;
    border-radius: 10px !important;
    overflow: hidden !important;
    background: var(--bg-white, #fff) !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08) !important;
  }

  .products-page .products-grid .product-image {
    width: 100% !important;
    height: 0 !important;
    padding-bottom: 100% !important;
    padding-top: 0 !important;
    position: relative !important;
    overflow: hidden !important;
    flex-shrink: 0 !important;
    background: var(--bg-light, #f5f5f5) !important;
  }

  .products-page .products-grid .product-image img {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    object-position: center !important;
  }

  .products-page .products-grid .product-info {
    padding: 12px !important;
    flex: 1 !important;
    display: flex !important;
    flex-direction: column !important;
  }

  .products-page .products-grid .product-category {
    font-size: 0.75rem;
    color: var(--text-light, #888);
    margin-bottom: 4px;
  }

  .products-page .products-grid .product-name {
    font-size: 0.9rem !important;
    line-height: 1.3 !important;
    min-height: 2.4em !important;
    max-height: 2.6em !important;
    overflow: hidden !important;
    display: -webkit-box !important;
    -webkit-line-clamp: 2 !important;
    line-clamp: 2 !important;
    -webkit-box-orient: vertical !important;
    margin-bottom: 8px !important;
  }

  .products-page .products-grid .product-name a {
    color: var(--text-dark, #333) !important;
    text-decoration: none !important;
  }

  .products-page .products-grid .product-price {
    font-size: 0.95rem !important;
    font-weight: 600 !important;
    color: var(--primary-color, #5c3d2e) !important;
    margin-top: auto !important;
  }

  .products-page .products-grid .product-actions {
    position: absolute !important;
    bottom: 8px !important;
    left: 8px !important;
    right: 8px !important;
    opacity: 1 !important;
    transform: none !important;
    pointer-events: auto !important;
  }

  .products-page .products-grid .product-actions .btn {
    width: 100% !important;
    padding: 10px !important;
    font-size: 0.8rem !important;
    min-height: 40px !important;
  }

  /* Pagination */
  .pagination {
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 30px;
  }

  .pagination-btn {
    width: 44px;
    height: 44px;
    font-size: 0.9rem;
  }

  /* Filter list */
  .filter-list a {
    padding: 12px 15px;
    min-height: 44px;
  }

  .filter-section h4 {
    padding: 15px 0;
    border-bottom: 1px solid var(--border-color, #ddd);
  }
}

/* Very small screens */
@media (max-width: 380px) {
  .products-page .products-grid {
    gap: 8px !important;
  }

  .products-page .products-grid .product-info {
    padding: 10px !important;
  }

  .products-page .products-grid .product-name {
    font-size: 0.8rem !important;
    min-height: 2.2em !important;
  }

  .products-page .products-grid .product-actions .btn {
    padding: 8px !important;
    font-size: 0.75rem !important;
  }

  .size-option {
    flex: 1 1 100%;
  }
}
