/* ============================================================
   FRONTEND — RESPONSIVE ENHANCEMENT SYSTEM
   Mobile-first: 320px → 375px → 425px → 576px → 768px →
                 992px → 1200px → 1440px → 1920px
   ============================================================ */

/* ════════════════════════════════════════════════════════════
   GLOBAL RESPONSIVE UTILITIES
   ════════════════════════════════════════════════════════════ */

/* Prevent horizontal scroll globally */
html, body { overflow-x: hidden; max-width: 100vw; }
img, video, svg, iframe { max-width: 100%; height: auto; }
* { min-width: 0; }

/* ── Section Padding Scale ───────────────────────────────── */
.section-pad { padding: 40px 0; }
@media (max-width: 991px) { .section-pad { padding: 28px 0; } }
@media (max-width: 767px) { .section-pad { padding: 20px 0; } }
@media (max-width: 479px) { .section-pad { padding: 16px 0; } }

/* ── Section Title Scale ─────────────────────────────────── */
.section-title { font-size: clamp(1rem, 2.5vw, 1.25rem); }

/* ── Typography Scale ────────────────────────────────────── */
@media (max-width: 767px) {
    h1 { font-size: clamp(1.4rem, 5vw, 2rem) !important; }
    h2 { font-size: clamp(1.25rem, 4.5vw, 1.75rem) !important; }
    h3 { font-size: clamp(1.1rem, 4vw, 1.5rem) !important; }
    h4 { font-size: clamp(1rem, 3.5vw, 1.25rem) !important; }
    h5 { font-size: clamp(.9rem, 3vw, 1.1rem) !important; }
}

/* ════════════════════════════════════════════════════════════
   HERO / BANNER
   ════════════════════════════════════════════════════════════ */
.banner-swiper { width: 100%; }
.banner-swiper .swiper-slide img {
    width: 100%; height: auto;
    object-fit: cover;
    aspect-ratio: 16 / 5;
    display: block;
}
@media (max-width: 991px)  { .banner-swiper .swiper-slide img { aspect-ratio: 16 / 6; } }
@media (max-width: 767px)  { .banner-swiper .swiper-slide img { aspect-ratio: 4 / 3; } }
@media (max-width: 479px)  { .banner-swiper .swiper-slide img { aspect-ratio: 1 / 1; } }

/* ════════════════════════════════════════════════════════════
   PRODUCT GRID
   ════════════════════════════════════════════════════════════ */

/* Fluid 2-column minimum on tiny screens */
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(160px, 100%), 1fr));
    gap: 12px;
}
@media (min-width: 576px)  { .product-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; } }
@media (min-width: 768px)  { .product-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; } }
@media (min-width: 992px)  { .product-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 18px; } }
@media (min-width: 1200px) { .product-grid { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 20px; } }

/* Bootstrap col-based grid overrides */
@media (max-width: 575.98px) {
    .row.g-3 > .col-6   { flex: 0 0 50%; max-width: 50%; }
    .row.g-3 > .col-12  { flex: 0 0 100%; max-width: 100%; }
    /* Products: 2 per row on mobile */
    .row.g-3 > [class*="col-lg-"],
    .row.g-3 > [class*="col-md-"] {
        flex: 0 0 50%;
        max-width: 50%;
    }
}
@media (max-width: 374.98px) {
    /* Very small phones: allow 1 column for product cards */
    .row.g-3 > [class*="col-"]:not(.col-6) {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

/* ════════════════════════════════════════════════════════════
   PRODUCT CARD RESPONSIVE
   ════════════════════════════════════════════════════════════ */
@media (max-width: 575.98px) {
    .product-card .card-body { padding: 8px 10px; }
    .product-card .product-name { font-size: 12.5px; margin: 3px 0 5px; }
    .product-card .sale-price { font-size: 14px; }
    .product-card .regular-price { font-size: 11px; }
    .product-card .btn-cart { padding: 7px; font-size: 12px; }
    .product-card .img-wrap img { padding: 8px; }
    .product-card .badge-discount,
    .product-card .badge-new { font-size: 9.5px; padding: 2px 6px; }
    /* Hide hover actions on touch */
    .product-card .card-actions { opacity: 1; }
    .action-btn { width: 28px; height: 28px; font-size: 12px; }
}

/* ════════════════════════════════════════════════════════════
   NAVBAR RESPONSIVE ENHANCEMENTS
   ════════════════════════════════════════════════════════════ */
@media (max-width: 991.98px) {
    .navbar-brand img { height: 36px; }
    .search-form .search-input { font-size: 13px; }
}

@media (max-width: 767.98px) {
    .main-navbar .navbar-inner { gap: 8px; padding: 8px 0; }
    .navbar-brand { font-size: 1.2rem !important; }
    .navbar-brand img { height: 32px; }
    .nav-icon { padding: 5px 7px; }
    .nav-icon i { font-size: 19px; }
    .nav-icon span { display: none; }
    /* Mobile search bar */
    .mobile-search-bar { padding: 6px 0 8px; }
    .mobile-search-bar .search-input { height: 38px; font-size: 13px; }
    .mobile-search-bar .btn-search { height: 38px; padding: 0 14px; }
}

@media (max-width: 374.98px) {
    .navbar-brand { font-size: 1.05rem !important; }
    .nav-icon { padding: 4px 5px; }
    .nav-icon i { font-size: 18px; }
}

/* ════════════════════════════════════════════════════════════
   CATEGORY NAV RESPONSIVE
   ════════════════════════════════════════════════════════════ */
@media (max-width: 991.98px) {
    .cat-nav { display: block !important; }
    .cat-nav .nav-link { padding: 10px 12px; font-size: 12.5px; }
}
@media (max-width: 767.98px) {
    /* Keep cat-nav hidden on mobile — mobile offcanvas has categories */
    .cat-nav { display: none !important; }
}

/* ════════════════════════════════════════════════════════════
   MOBILE BOTTOM NAV
   ════════════════════════════════════════════════════════════ */
.mobile-bottom-nav { display: none !important; }
@media (max-width: 767.98px) {
    .mobile-bottom-nav { display: flex !important; }
    body { padding-bottom: 60px; }
}
@media (max-width: 374.98px) {
    .mob-nav-item { font-size: 9px; padding: 6px 2px; }
    .mob-nav-item i { font-size: 18px; }
}

/* ════════════════════════════════════════════════════════════
   MINI CART SIDEBAR
   ════════════════════════════════════════════════════════════ */
@media (max-width: 575.98px) {
    .cart-sidebar { width: 100% !important; right: -100% !important; }
    .cart-sidebar.open { right: 0 !important; }
}

/* ════════════════════════════════════════════════════════════
   HOMEPAGE SECTIONS
   ════════════════════════════════════════════════════════════ */

/* Feature/Trust Badges */
.trust-bar .row > [class*="col-"] {
    text-align: center;
}
@media (max-width: 575.98px) {
    .trust-bar .row > [class*="col-"] { flex: 0 0 50%; max-width: 50%; }
    .trust-bar .trust-icon { font-size: 1.5rem; }
    .trust-bar .trust-title { font-size: 0.8rem; }
}

/* Category scroll row on mobile */
@media (max-width: 767.98px) {
    .cat-scroll-row {
        display: flex;
        overflow-x: auto;
        gap: 10px;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 4px;
    }
    .cat-scroll-row::-webkit-scrollbar { display: none; }
    .cat-scroll-row .cat-card { min-width: 100px; flex-shrink: 0; padding: 12px 8px; }
    .cat-card .cat-icon { width: 48px; height: 48px; }
    .cat-card .cat-name { font-size: 12px; }
}

/* Flash Sale countdown */
@media (max-width: 575.98px) {
    .countdown-unit { font-size: 14px; min-width: 34px; padding: 4px 7px; }
    .countdown-sep { font-size: 16px; }
}

/* ════════════════════════════════════════════════════════════
   PRODUCT DETAIL PAGE
   ════════════════════════════════════════════════════════════ */

/* Gallery thumbnails horizontal on mobile */
@media (max-width: 767.98px) {
    .product-gallery { flex-direction: column !important; }
    .thumb-col {
        width: 100% !important;
        order: 2 !important;
        flex-direction: row !important;
        overflow-x: auto !important;
        gap: 8px !important;
    }
    .thumb-col .thumb-item {
        width: 64px !important;
        height: 64px !important;
        min-width: 64px !important;
        flex-shrink: 0 !important;
    }
    .main-img-col { order: 1 !important; width: 100% !important; }
}

/* Sticky Add to Cart on mobile */
@media (max-width: 767.98px) {
    .sticky-atc {
        position: fixed;
        bottom: 60px; /* above bottom nav */
        left: 0; right: 0;
        z-index: 900;
        padding: 10px 16px;
        background: #fff;
        border-top: 1px solid #e5e7eb;
        box-shadow: 0 -4px 16px rgba(0,0,0,.08);
        display: flex;
        gap: 10px;
        align-items: center;
    }
    .sticky-atc .btn-cart-main {
        flex: 1;
        height: 44px;
        font-size: 0.9rem;
        font-weight: 700;
        border-radius: 8px;
    }
    .sticky-atc .price-mini {
        font-size: 1rem;
        font-weight: 800;
        color: #e53935;
        white-space: nowrap;
    }
    /* Add bottom padding to product page content above sticky ATC */
    .product-detail-wrap { padding-bottom: 70px; }
}

/* Variation buttons */
@media (max-width: 575.98px) {
    .variation-btn { min-width: 38px; min-height: 38px; font-size: 12px; }
    .color-swatch  { width: 30px; height: 30px; }
}

/* ════════════════════════════════════════════════════════════
   SHOP / CATEGORY PAGE
   ════════════════════════════════════════════════════════════ */

/* Filter sidebar: drawer on mobile */
@media (max-width: 991.98px) {
    .shop-sidebar {
        position: fixed;
        top: 0; left: -280px;
        width: 280px; height: 100vh;
        background: #fff;
        z-index: 1100;
        overflow-y: auto;
        transition: left .3s ease;
        box-shadow: 4px 0 24px rgba(0,0,0,.15);
        padding: 16px;
    }
    .shop-sidebar.open { left: 0; }
    .shop-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,.5);
        z-index: 1099;
    }
    .shop-overlay.open { display: block; }
    .shop-content { width: 100% !important; max-width: 100% !important; flex: none !important; }
    .filter-toggle-btn { display: inline-flex !important; }
}
@media (min-width: 992px) {
    .shop-sidebar { position: static; width: auto; height: auto; transform: none; box-shadow: none; }
    .filter-toggle-btn { display: none !important; }
}

/* Shop toolbar */
@media (max-width: 575.98px) {
    .shop-toolbar { flex-direction: column; align-items: stretch !important; gap: 8px !important; }
    .shop-toolbar .form-select { width: 100%; }
    .shop-toolbar .results-text { order: -1; }
}

/* ════════════════════════════════════════════════════════════
   CART PAGE
   ════════════════════════════════════════════════════════════ */
@media (max-width: 767.98px) {
    /* Cart table → card view */
    .cart-table thead { display: none; }
    .cart-table tbody tr { display: block; border: 1px solid #e5e7eb; border-radius: 10px; margin-bottom: 12px; padding: 12px; background: #fff; }
    .cart-table tbody tr td { display: flex; align-items: center; justify-content: space-between; border: none; padding: 4px 0; font-size: 13.5px; }
    .cart-table tbody tr td::before { content: attr(data-label); font-weight: 600; color: #6b7280; font-size: 12px; margin-right: 8px; white-space: nowrap; }
    .cart-table .product-cell { flex-direction: column; align-items: flex-start; }

    /* Cart summary full width */
    .cart-summary { width: 100% !important; }
}

/* ════════════════════════════════════════════════════════════
   CHECKOUT PAGE
   ════════════════════════════════════════════════════════════ */
@media (max-width: 767.98px) {
    /* Stack checkout columns */
    .checkout-form-col  { order: 1; }
    .checkout-order-col { order: 2; }

    .checkout-step { padding: 14px; }
    .checkout-step .step-number { width: 28px; height: 28px; font-size: 13px; }
}

/* ════════════════════════════════════════════════════════════
   FOOTER RESPONSIVE
   ════════════════════════════════════════════════════════════ */
@media (max-width: 767.98px) {
    .main-footer { padding: 36px 0 0; }
    .main-footer .row.g-5 { gap: 0 !important; --bs-gutter-y: 24px; }
    .footer-logo { font-size: 1.2rem; }
    .footer-bottom .d-flex { flex-direction: column; align-items: center !important; gap: 6px !important; text-align: center; }
}
@media (max-width: 575.98px) {
    .main-footer { padding: 28px 0 0; }
    .main-footer h6 { margin-bottom: 10px; }
    .main-footer a { line-height: 1.9; }
}

/* ════════════════════════════════════════════════════════════
   FORMS RESPONSIVE
   ════════════════════════════════════════════════════════════ */
@media (max-width: 575.98px) {
    .form-control, .form-select {
        font-size: 16px !important; /* prevent iOS zoom */
        min-height: 44px;
    }
    .btn { min-height: 42px; }
    .btn-sm { min-height: 34px; }
    .input-group { flex-wrap: nowrap; }
}

/* ════════════════════════════════════════════════════════════
   ORDER / ACCOUNT PAGES
   ════════════════════════════════════════════════════════════ */
@media (max-width: 767.98px) {
    .order-table thead { display: none; }
    .order-table tbody tr { display: block; border: 1px solid #e5e7eb; border-radius: 10px; margin-bottom: 10px; padding: 12px; }
    .order-table tbody td { display: flex; justify-content: space-between; align-items: center; border: none; padding: 3px 0; font-size: 13px; }
    .order-table tbody td::before { content: attr(data-label); font-weight: 600; color: #6b7280; font-size: 11px; }
}

/* ════════════════════════════════════════════════════════════
   BREADCRUMB
   ════════════════════════════════════════════════════════════ */
@media (max-width: 575.98px) {
    .custom-breadcrumb { padding: 8px 0; font-size: 11.5px; }
    .custom-breadcrumb .sep { margin: 0 4px; }
}

/* ════════════════════════════════════════════════════════════
   MODALS RESPONSIVE
   ════════════════════════════════════════════════════════════ */
@media (max-width: 575.98px) {
    .modal-dialog { margin: 8px; max-width: calc(100vw - 16px); }
    .modal-content { border-radius: 12px; }
    .modal-header, .modal-body, .modal-footer { padding: 14px 16px; }
    .modal-footer { gap: 8px; }
    .modal-footer .btn { flex: 1; }
}

/* ════════════════════════════════════════════════════════════
   SWIPER / SLIDER RESPONSIVE
   ════════════════════════════════════════════════════════════ */
@media (max-width: 767.98px) {
    .swiper-button-next, .swiper-button-prev {
        width: 30px !important; height: 30px !important;
    }
    .swiper-button-next::after, .swiper-button-prev::after { font-size: 11px !important; }
}
@media (max-width: 479px) {
    .swiper-button-next, .swiper-button-prev { display: none !important; }
}

/* ════════════════════════════════════════════════════════════
   AUTHENTICATION PAGES
   ════════════════════════════════════════════════════════════ */
@media (max-width: 575.98px) {
    .auth-card { border-radius: 0 !important; border: none !important; box-shadow: none !important; }
    .auth-wrapper { padding: 0; }
}

/* ════════════════════════════════════════════════════════════
   BLOG PAGE
   ════════════════════════════════════════════════════════════ */
@media (max-width: 767.98px) {
    .blog-card .card-img-top { aspect-ratio: 16/9; object-fit: cover; }
    .blog-card .card-title { font-size: 0.95rem; }
}

/* ════════════════════════════════════════════════════════════
   PAGINATION RESPONSIVE
   ════════════════════════════════════════════════════════════ */
@media (max-width: 575.98px) {
    .pagination { flex-wrap: wrap; gap: 4px; justify-content: center; }
    .page-link { padding: 6px 10px; font-size: 13px; min-width: 36px; min-height: 36px; display: flex; align-items: center; justify-content: center; }
}

/* ════════════════════════════════════════════════════════════
   REVIEW / RATING
   ════════════════════════════════════════════════════════════ */
@media (max-width: 575.98px) {
    .review-card { padding: 12px 14px; }
    .review-stars { font-size: 13px; }
    .review-text  { font-size: 13px; }
}

/* ════════════════════════════════════════════════════════════
   SEARCH PAGE
   ════════════════════════════════════════════════════════════ */
@media (max-width: 767.98px) {
    .search-header h4 { font-size: 1rem; }
    .search-header .sort-wrap { width: 100%; margin-top: 8px; }
    .search-header .sort-wrap .form-select { width: 100%; }
}

/* ════════════════════════════════════════════════════════════
   ULTRA-WIDE SCREENS (1920px+)
   ════════════════════════════════════════════════════════════ */
@media (min-width: 1920px) {
    .container { max-width: 1760px; }
    body { font-size: 16px; }
    .section-title { font-size: 1.4rem; }
    .product-card .product-name { font-size: 15px; }
}

/* ════════════════════════════════════════════════════════════
   ACCESSIBILITY & PERFORMANCE
   ════════════════════════════════════════════════════════════ */

/* Tap target minimum sizes */
a, button, [role="button"] { min-width: 44px; min-height: 44px; }
.badge, .breadcrumb-item a, .pagination .page-link { min-width: auto; min-height: auto; }

/* Reduce motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}

/* Focus visible for keyboard nav */
:focus-visible {
    outline: 2px solid #3498db;
    outline-offset: 2px;
}

/* ════════════════════════════════════════════════════════════
   LAZY LOADING PLACEHOLDER
   ════════════════════════════════════════════════════════════ */
img[loading="lazy"] {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
}
img[loading="lazy"].loaded { background: none; }
