/* ===== SITE-WIDE RESPONSIVE ===== */

/* Prevent horizontal scroll */
html {
  -webkit-text-size-adjust: 100%;
}
body,
main {
  max-width: 100%;
  overflow-x: clip;
}

/* Fluid media & grids */
img,
video,
svg {
  max-width: 100%;
  height: auto;
}

.products-grid {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
}

/* Unified search page: columns sized for sidebar + RTL */
.catalog-products-grid.products-grid {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 232px), 1fr));
  gap: clamp(18px, 2.6vw, 28px);
}

.category-page-grid {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
}

.blog-grid {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr));
}

.pagination-nav {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  margin-top: 32px;
  flex-wrap: wrap;
}

.pagination-nav .page-info {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.empty-state-msg {
  text-align: center;
  margin: 0;
}

/* ----- Large laptop / small desktop (≤1200px) ----- */
@media (max-width: 1200px) {
  .nav a {
    padding: 8px 12px;
    font-size: 0.85rem;
  }

  .header-inner {
    padding-inline: var(--container-padding-x);
  }

  .footer-grid {
    gap: 28px;
  }
}

/* ----- Tablet landscape (≤1024px) ----- */
@media (max-width: 1024px) {
  :root {
    --container-padding-x: 20px;
  }
  .hero h1 {
    font-size: 2.4rem;
  }

  .hero-image {
    display: none;
  }

  .hero-content {
    flex-direction: column;
    gap: 32px;
    text-align: center;
  }

  .hero-text {
    display: flex;
    flex-direction: column;
    align-items: center;
  }

  .hero p {
    max-width: 100%;
  }

  .hero-btns {
    justify-content: center;
  }

  .hero-stats {
    gap: 24px;
    justify-content: center;
    width: 100%;
  }

  .footer-grid {
    grid-template-columns: 1fr 1fr;
  }

  .cart-page,
  .checkout-layout {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .order-summary {
    position: static;
  }

  .about-hero {
    grid-template-columns: 1fr;
    gap: 32px;
  }

  .about-stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .policy-layout {
    grid-template-columns: 1fr;
  }

  .policy-sidebar {
    position: static;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 8px;
  }

  .policy-sidebar h4 {
    width: 100%;
    margin-bottom: 8px;
  }

  .policy-sidebar a {
    display: inline-block;
    margin-bottom: 0;
  }

  #homeCategoriesCarousel .category-card {
    width: calc((100% - 36px) / 4);
  }
}

/* ----- Tablet portrait / large phone (≤768px) ----- */
@media (max-width: 768px) {
  :root {
    --container-padding-x: 16px;
  }

  .home-banner-link img {
    max-height: min(50vh, 420px);
    width: 100%;
    height: auto;
  }
  .hb-nav {
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
  }
  .hb-nav.prev { left: 6px; }
  .hb-nav.next { right: 6px; }
  :root {
    --header-h: 76px;
    --logo-max-h: 58px;
    --logo-max-w: 200px;
  }

  .section {
    padding: 48px 0;
  }

  .section-title {
    font-size: 1.5rem;
  }

  .section-subtitle {
    margin-bottom: 32px;
    font-size: 0.95rem;
  }

  /* Header */
  .nav {
    display: none;
  }

  .mobile-toggle {
    display: flex;
  }

  .mobile-nav {
    display: flex;
  }

  .header-inner {
    padding-inline: var(--container-padding-x);
    gap: 4px;
  }

  .header-actions {
    gap: 0;
    flex-shrink: 0;
  }

  .header-btn {
    width: 40px;
    height: 40px;
    font-size: 1rem;
  }

  .lang-toggle {
    padding: 0 8px;
    font-size: 0.72rem;
  }

  .logo {
    padding: 4px 8px 4px 0;
    min-width: 0;
    max-width: 42%;
  }

  [dir="rtl"] .logo {
    padding: 4px 0 4px 8px;
  }

  /* Page header */
  .page-header {
    padding: 28px 0;
  }

  .page-header h1 {
    font-size: 1.5rem;
  }

  .page-header p,
  .page-header .section-subtitle {
    font-size: 0.9rem;
  }

  /* Hero */
  .hero {
    min-height: auto;
    padding: 40px 0 48px;
  }

  .hero-content {
    gap: 32px;
  }

  .hero h1 {
    font-size: 2rem;
  }

  .hero p {
    font-size: 1rem;
  }

  .hero-stats {
    flex-wrap: wrap;
    gap: 20px;
    margin-top: 32px;
    padding-top: 24px;
  }

  .hero-stat {
    flex: 1;
    min-width: 90px;
  }

  .hero-stat-num {
    font-size: 1.6rem;
  }

  /* Home category sections — stack: category image, then product carousel */
  .home-cat-section {
    padding: 32px 0;
  }
  .home-cat-section-grid,
  .home-cat-section--img-start .home-cat-section-grid {
    grid-template-columns: 1fr;
    grid-template-areas:
      "category"
      "products";
    gap: 20px;
  }
  /* Product cards stay narrow; section image uses full container content width. */
  .home-cat-category-card {
    width: min(var(--home-cat-product-card-width), calc(100vw - 7.5rem));
    max-width: 100%;
    margin-inline: auto;
    align-self: auto;
  }
  .home-cat-section-image-link.home-cat-category-card {
    height: auto;
    width: 100%;
    max-width: none;
    margin-inline: 0;
    align-self: start;
  }
  .home-cat-section-image-link .home-cat-category-card__media,
  .home-cat-section-image-link .category-section-image-wrapper {
    position: relative;
    inset: auto;
    width: 100%;
    height: auto;
    aspect-ratio: 2 / 1;
    flex: none;
    overflow: hidden;
    padding: 0;
  }
  .home-cat-products-viewport {
    margin: 0 36px;
  }
  .home-cat-product-slide {
    flex-basis: min(var(--home-cat-product-card-width), calc(100vw - 7.5rem));
    width: min(var(--home-cat-product-card-width), calc(100vw - 7.5rem));
  }
  .home-cat-prod-nav {
    width: 34px;
    height: 34px;
  }

  /* Home categories carousel */
  .home-top-container {
    padding-top: 14px;
  }

  .home-promo-banners-section {
    padding: 24px 0;
  }

  .home-banners-block {
    margin-bottom: 14px;
  }

  .categories-viewport {
    margin: 0 36px;
  }

  .cat-nav {
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
  }

  .categories-carousel .category-card {
    padding: 8px 6px 10px;
    gap: 6px;
  }

  #homeCategoriesCarousel .category-card {
    width: calc((100% - 24px) / 3);
    padding: 6px 5px 8px;
  }

  #homeCategoriesCarousel .category-card h3 {
    font-size: 0.78125rem;
  }

  .categories-carousel .category-icon {
    padding: 3px;
  }

  #homeCategoriesCarousel .category-icon {
    padding: 0;
  }

  .category-card h3 {
    font-size: 0.8125rem;
  }

  /* Product cards */
  .products-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
  }

  .product-info {
    padding: 14px;
  }

  .product-name {
    font-size: 0.92rem;
  }

  .product-card-actions {
    gap: 6px;
  }

  .product-wishlist-btn {
    flex: 0 0 40px;
    width: 40px;
    min-width: 40px;
  }

  /* Banners & promos */
  .promo-banner {
    padding: 32px 20px;
    flex-direction: column;
    text-align: center;
    gap: 20px;
  }

  .promo-banner h2 {
    font-size: 1.5rem;
  }

  .promo-banner p {
    font-size: 0.95rem;
  }

  /* Category listing page */
  .category-page-grid {
    gap: 16px;
  }

  .category-page-card .cat-img {
    padding: 0;
  }

  .category-page-card .cat-info {
    padding: 12px 14px 14px;
  }

  /* Product detail (legacy layout only — v2 uses product-detail.css) */
  .product-detail:not(.product-detail--v2) {
    grid-template-columns: 1fr;
    gap: 24px;
    padding: 32px 0;
  }

  .product-detail:not(.product-detail--v2) .product-detail-info .pd-name {
    font-size: 1.4rem;
  }

  .product-detail:not(.product-detail--v2) .pd-price {
    font-size: 1.65rem;
  }

  .product-detail:not(.product-detail--v2) .pd-actions {
    flex-direction: column;
  }

  .product-detail:not(.product-detail--v2) .pd-actions .btn {
    min-width: 0;
    width: 100%;
  }

  .product-detail:not(.product-detail--v2) .pd-price-block {
    flex-wrap: wrap;
  }

  .specs-table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .pd-file-item {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  /* Cart */
  .cart-page {
    grid-template-columns: 1fr;
    padding: 32px 0;
  }

  .cart-table-header {
    display: none;
  }

  .cart-row {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin-bottom: 12px;
  }

  .cart-row-product {
    flex-direction: row;
    text-align: start;
    align-items: center;
  }

  .cart-row-price,
  .cart-row-total {
    font-size: 0.9rem;
  }

  .cart-row .qty-control {
    width: fit-content;
  }

  .cart-row {
    position: relative;
    padding-top: 8px;
  }

  .cart-row-remove {
    position: absolute;
    top: 12px;
    right: 12px;
  }

  [dir="rtl"] .cart-row-remove {
    right: auto;
    left: 12px;
  }

  .cart-row-product {
    padding-right: 44px;
  }

  [dir="rtl"] .cart-row-product {
    padding-right: 0;
    padding-left: 44px;
  }

  /* Checkout */
  .checkout-layout {
    grid-template-columns: 1fr;
  }

  .checkout-page {
    padding: 32px 0;
  }

  .checkout-form {
    padding: 20px;
  }

  .checkout-form h2 {
    font-size: 1.15rem;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .method-grid {
    grid-template-columns: 1fr;
  }

  .payment-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .checkout-stepper {
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 28px;
  }

  .step-label {
    display: none;
  }

  .step-line {
    width: 24px;
    margin: 0 4px;
  }

  .checkout-btns {
    flex-direction: column-reverse;
    align-items: stretch;
  }

  .checkout-btns .btn {
    min-width: 0;
    width: 100%;
  }

  /* Checkout maps / saved address — see pages.css for full mobile rules */

  .home-about-section {
    padding: 32px 0;
  }

  .home-about-card {
    padding: 1.25rem 1rem;
  }

  .home-about-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .home-about-read-more {
    width: 100%;
    justify-content: center;
  }

  /* About / blog / policy */
  .about-hero {
    padding: 40px 0;
  }

  .about-hero-text h2 {
    font-size: 1.6rem;
  }

  .about-stats {
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    padding: 32px 0;
  }

  .about-stat .num {
    font-size: 2rem;
  }

  .blog-grid {
    grid-template-columns: 1fr;
  }

  .policy-layout {
    padding: 32px 0;
  }

  .policy-content {
    padding: 24px 20px;
  }

  .policy-content h2 {
    font-size: 1.25rem;
  }

  /* Filter bar */
  .filter-bar {
    gap: 8px;
    margin-bottom: 24px;
  }

  .filter-btn {
    padding: 8px 14px;
    font-size: 0.8rem;
  }

  /* Footer */
  .footer {
    padding-top: 48px;
  }

  .footer-brand-logo .brand-logo {
    max-width: min(200px, 80vw);
    max-height: 52px;
  }

  .footer-grid {
    grid-template-columns: 1fr;
    gap: 32px;
    padding-bottom: 32px;
  }

  .footer-bottom {
    flex-direction: column;
    justify-content: center;
    text-align: center;
    padding-block: 14px;
  }

  /* Drawers & overlays */
  .cart-drawer,
  .wishlist-drawer {
    width: 100%;
  }

  .search-overlay {
    padding-top: 24px;
    align-items: flex-start;
  }

  .search-box {
    width: calc(100% - 32px);
    max-width: none;
  }

  .auth-modal {
    width: calc(100% - 24px);
    max-height: calc(100vh - 48px);
    overflow-y: auto;
  }

  /* Floating UI */
  .whatsapp-float {
    width: 50px;
    height: 50px;
    font-size: 1.35rem;
    bottom: 16px;
    right: 16px;
  }

  [dir="rtl"] .whatsapp-float {
    right: auto;
    left: 16px;
  }

  .back-to-top {
    bottom: 76px;
    right: 16px;
    width: 40px;
    height: 40px;
  }

  [dir="rtl"] .back-to-top {
    right: auto;
    left: 16px;
  }

  .toast {
    left: 16px;
    right: 16px;
    transform: translateX(0) translateY(100px);
    max-width: none;
  }

  .toast.show {
    transform: translateX(0) translateY(0);
  }

  /* Confirmation */
  .confirmation-page {
    padding: 48px 0;
  }

  .confirmation-page h1 {
    font-size: 1.5rem;
  }

  .confirm-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .confirm-actions .btn {
    width: 100%;
    justify-content: center;
  }

  .contact-grid {
    grid-template-columns: 1fr;
  }

  .features-grid {
    grid-template-columns: 1fr;
  }

  .values-grid {
    grid-template-columns: 1fr;
  }

  .coupon-input {
    flex-direction: column;
  }

  .coupon-input button {
    width: 100%;
  }
}

/* ----- Home categories carousel breakpoints (homepage banner block only) ----- */
@media (max-width: 639.98px) {
  #homeCategoriesCarousel .category-card {
    width: calc((100% - 12px) / 2);
  }
}

/* ----- Small phone (≤576px) ----- */
@media (max-width: 576px) {
  .hero h1 {
    font-size: 1.75rem;
  }

  .hero-badge {
    font-size: 0.78rem;
    padding: 6px 12px;
  }

  .btn {
    padding: 11px 22px;
    font-size: 0.9rem;
  }

  .products-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  .product-info {
    padding: 12px;
  }

  .add-to-cart-btn {
    font-size: 0.8rem;
    padding: 10px 9px;
    min-height: 44px;
  }

  .product-wishlist-btn {
    flex: 0 0 44px;
    width: 44px;
    min-width: 44px;
    min-height: 44px;
  }

  .category-page-grid {
    grid-template-columns: 1fr;
  }

  .payment-grid {
    grid-template-columns: 1fr;
  }

  .pd-thumb {
    width: 56px;
    height: 56px;
  }
}

/* ----- Extra small (≤480px) ----- */
@media (max-width: 480px) {
  :root {
    --header-h: 72px;
    --logo-max-h: 52px;
    --logo-max-w: 168px;
    --container-padding-x: 12px;
  }

  .header-inner {
    padding-inline: var(--container-padding-x);
  }

  .header-btn {
    width: 36px;
    height: 36px;
    font-size: 0.95rem;
  }

  .logo {
    max-width: 46%;
  }

  .hero h1 {
    font-size: 1.55rem;
  }

  .hero-btns {
    flex-direction: column;
    width: 100%;
  }

  .hero-btns .btn {
    width: 100%;
    justify-content: center;
  }

  .category-card {
    min-width: 130px;
  }

  .products-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .section-title {
    font-size: 1.35rem;
  }

  .page-header h1 {
    font-size: 1.35rem;
  }

  .breadcrumb {
    font-size: 0.8rem;
  }

  .footer-social a {
    width: 36px;
    height: 36px;
  }
}

/* Very narrow phones: single column product grid */
@media (max-width: 360px) {
  .products-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Touch: ensure bottom actions meet minimum tap size */
@media (hover: none) and (pointer: coarse) {
  .product-card-actions .add-to-cart-btn {
    min-height: 44px;
  }

  .product-wishlist-btn {
    min-height: 44px;
  }
}
