/* ==========================================================================
   FITBULLS - MOBILE RESPONSIVE BUG FIXES
   SCOPE: Mobile ONLY (max-width: 767px / 480px)
   DO NOT AFFECT: Desktop, Laptop, Tablet layouts
   ========================================================================== */

/* =====================================================
   1. GLOBAL MOBILE OVERFLOW PREVENTION
   ===================================================== */
@media screen and (max-width: 767px) {
    .product-slider,
    .product-card,
    .product-image-wrap,
    .product-info,
    .swiper-slide,
    .cart-items-wrapper,
    .cart-item,
    .cart-product-info,
    .checkout-panel,
    .summary-item {
        max-width: 100%;
        box-sizing: border-box;
    }

    /* Global image safety */
    img {
        max-width: 100%;
        height: auto;
    }
}

/* =====================================================
   2. CONTAINER PADDING ON MOBILE
   ===================================================== */
@media screen and (max-width: 767px) {
    .container {
        padding: 0 12px !important;
    }
}

@media screen and (max-width: 360px) {
    .container {
        padding: 0 8px !important;
    }
}

/* =====================================================
   3. PRODUCT CARD - FIX MIN-WIDTH & NAME/PRICE
   ===================================================== */
@media screen and (max-width: 767px) {
    /* CRITICAL FIX: min-width:260px overrides flex-basis on small screens,
       causing cards to overflow the slider container and overlap each other */
    .product-card {
        min-width: 0 !important;
    }

    /* Fix: Product name - allow proper multi-line wrapping */
    .product-name {
        white-space: normal !important;
        word-break: break-word !important;
        overflow: visible !important;
        display: block !important;
        -webkit-line-clamp: unset !important;
        -webkit-box-orient: unset !important;
        line-height: 1.4 !important;
        max-height: none !important;
    }

    /* Fix: Price - prevent cut-off and overlap */
    .product-price {
        flex-wrap: wrap !important;
        width: 100% !important;
        min-width: 0 !important;
        gap: 4px !important;
    }

    .old-price,
    .new-price {
        max-width: 100% !important;
        white-space: nowrap !important;
    }

    /* On very small screens if needed allow price wrapping */
    .product-info {
        padding: 10px 8px !important;
        overflow: hidden;
        word-wrap: break-word;
    }

    .product-category {
        font-size: 11px !important;
        margin-bottom: 3px !important;
    }
}

/* =====================================================
   4. HOMEPAGE PRODUCT SWIPER / SLIDER FIX
   ===================================================== */
@media screen and (max-width: 767px) {
    /* Prevent swiper wrapper from overflowing viewport */
    .swiper-container-wrapper {
        padding: 0 !important;
        overflow: hidden !important;
        width: 100% !important;
    }

    .category-product-swiper {
        overflow: hidden !important;
    }

    .category-product-swiper .swiper-slide {
        height: auto !important;
        box-sizing: border-box !important;
    }

    /* Product card inside swiper: must fit slide width exactly */
    .category-product-swiper .product-card,
    .swiper-slide .product-card {
        min-width: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        height: 100% !important;
    }

    /* Image container: constrain inside card */
    .product-image-wrap {
        width: 100% !important;
        max-width: 100% !important;
        overflow: hidden !important;
        box-sizing: border-box !important;
    }

    .product-image-wrap img {
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
        object-fit: contain !important;
        padding: 10px !important;
        display: block !important;
    }
}

/* Extra small screens: ensure no overflow */
@media screen and (max-width: 480px) {
    .product-card {
        min-width: 0 !important;
        box-sizing: border-box !important;
    }
}

/* =====================================================
   5. CATEGORY PAGE GRID - PRODUCT CARD FIX
   ===================================================== */
@media screen and (max-width: 767px) {
    .category-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px 8px !important;
        overflow: hidden !important;
    }

    .category-grid .product-card {
        min-width: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        overflow: hidden !important;
        box-sizing: border-box !important;
    }

    .category-grid .product-image-wrap {
        width: 100% !important;
        overflow: hidden !important;
    }

    .category-grid .product-image-wrap img {
        width: 100% !important;
        height: auto !important;
        object-fit: contain !important;
        padding: 8px !important;
    }

    .category-grid .product-name {
        font-size: 13px !important;
        line-height: 1.35 !important;
    }

    .category-grid .product-info {
        padding: 8px 6px !important;
    }
}

/* =====================================================
   6. PRODUCT DETAIL PAGE - MOBILE FIXES
   ===================================================== */
@media screen and (max-width: 767px) {
    /* Stack gallery and info panel */
    .product-top {
        grid-template-columns: 1fr !important;
        gap: 20px !important;
    }

    /* Main product image */
    .main-image-wrap {
        height: auto !important;
        min-height: 240px !important;
        padding: 10px !important;
    }

    .main-image-wrap img {
        max-height: 280px !important;
        width: 100% !important;
        object-fit: contain !important;
    }

    /* Product title: allow proper wrapping */
    .product-main-title {
        font-size: 22px !important;
        line-height: 1.3 !important;
        word-break: break-word !important;
        white-space: normal !important;
    }

    /* Price area */
    .product-price-large {
        flex-wrap: wrap !important;
        gap: 8px !important;
        align-items: baseline !important;
    }

    .product-price-large .new-price {
        font-size: 22px !important;
    }

    .product-price-large .old-price {
        font-size: 16px !important;
        white-space: normal !important;
    }

    /* Price + brochure row: stack to prevent overflow */
    .price-and-brochure {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 10px !important;
        width: 100% !important;
    }

    /* Brochure button: remove min-width:max-content causing overflow */
    .price-and-brochure a.btn {
        min-width: unset !important;
        max-width: 100% !important;
        width: 100% !important;
        box-sizing: border-box !important;
        flex: none !important;
        font-size: 13px !important;
    }

    /* Variant rows */
    .variant-row {
        flex-wrap: wrap !important;
        gap: 8px !important;
    }

    .variant-info {
        flex: 1 1 auto !important;
        min-width: 0 !important;
    }

    .variant-row .quantity-selector {
        flex-shrink: 0 !important;
        width: 90px !important;
        height: 36px !important;
    }

    /* Trust icons: allow wrapping */
    .trust-icons {
        flex-wrap: wrap !important;
        gap: 10px !important;
        justify-content: space-around !important;
    }

    .trust-item {
        font-size: 11px !important;
    }

    /* Thumbnails: horizontal scroll */
    .thumbnail-list {
        grid-template-columns: repeat(5, 58px) !important;
        overflow-x: auto !important;
        scrollbar-width: none !important;
        gap: 6px !important;
    }

    .thumbnail-list::-webkit-scrollbar {
        display: none !important;
    }

    .thumbnail img {
        height: 52px !important;
    }

    /* Specs table: horizontal scroll */
    .specs-table {
        display: block !important;
        overflow-x: auto !important;
        width: 100% !important;
    }

    .specs-table th,
    .specs-table td {
        padding: 10px 12px !important;
        font-size: 13px !important;
        word-break: break-word !important;
    }

    /* Product tabs: horizontal scroll on mobile */
    .product-tabs {
        overflow-x: auto !important;
        scrollbar-width: none !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        border-bottom: 2px solid #eee !important;
    }

    .product-tabs::-webkit-scrollbar {
        display: none !important;
    }

    .tab-link {
        display: inline-block !important;
        white-space: nowrap !important;
        padding: 12px 16px !important;
        font-size: 14px !important;
        border-bottom: none !important;
        flex-shrink: 0 !important;
    }

    .tab-link.active {
        background: transparent !important;
        border-left: none !important;
    }

    .tab-link.active::after {
        display: block !important;
    }

    /* Breadcrumb */
    .breadcrumb {
        font-size: 12px !important;
        word-break: break-word !important;
    }

    .breadcrumb .container {
        padding-top: 8px !important;
        padding-bottom: 8px !important;
    }

    /* Features grid */
    .features-grid {
        grid-template-columns: 1fr !important;
        gap: 15px !important;
    }

    .feature-box img {
        height: 160px !important;
        object-fit: cover !important;
    }

    .feature-box h4 {
        font-size: 15px !important;
    }

    .feature-box p {
        font-size: 13px !important;
    }
}

/* =====================================================
   7. CART PAGE - MOBILE LAYOUT FIX
   ===================================================== */
@media screen and (max-width: 767px) {
    .cart-page {
        padding: 30px 0 !important;
    }

    .cart-title {
        font-size: 24px !important;
        margin-bottom: 20px !important;
    }

    .cart-items-wrapper {
        padding: 15px !important;
        overflow: hidden !important;
    }

    /* Hide the desktop header row */
    .cart-header {
        display: none !important;
    }

    /* Cart item: switch 4-column grid to stacked flex */
    .cart-item {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: wrap !important;
        gap: 8px !important;
        padding: 15px 0 !important;
        align-items: center !important;
    }

    /* Product info: take full width on top row */
    .cart-item > .cart-product-info {
        width: 100% !important;
        flex: none !important;
        display: flex !important;
        align-items: flex-start !important;
        gap: 10px !important;
    }

    .cart-product-img {
        width: 65px !important;
        height: 65px !important;
        flex-shrink: 0 !important;
        object-fit: contain !important;
    }

    .cart-product-name {
        font-size: 14px !important;
        font-weight: 600 !important;
        line-height: 1.4 !important;
        word-break: break-word !important;
        white-space: normal !important;
        flex: 1 !important;
        min-width: 0 !important;
    }

    /* Price on second row */
    .cart-item > .cart-price {
        flex: 1 !important;
        min-width: 0 !important;
        font-size: 14px !important;
        font-weight: 600 !important;
    }

    /* Quantity selector */
    .cart-item > .quantity-selector {
        flex: 0 0 auto !important;
        width: 80px !important;
        height: 32px !important;
    }

    /* Remove button */
    .cart-item > .remove-btn {
        flex: 0 0 auto !important;
        font-size: 18px !important;
        padding: 0 4px !important;
    }

    /* Cart summary */
    .cart-summary {
        position: static !important;
        padding: 20px !important;
    }

    .summary-title {
        font-size: 20px !important;
    }

    .summary-row {
        font-size: 14px !important;
    }

    .summary-total {
        font-size: 18px !important;
    }

    .checkout-btn {
        font-size: 15px !important;
        padding: 14px !important;
    }
}

/* =====================================================
   8. CHECKOUT PAGE - MOBILE FIXES
   ===================================================== */
@media screen and (max-width: 767px) {
    .checkout-page {
        padding: 20px 0 !important;
    }

    .checkout-panel {
        padding: 20px 15px !important;
    }

    .checkout-title {
        font-size: 20px !important;
        gap: 8px !important;
        flex-wrap: wrap !important;
    }

    .checkout-title img {
        width: 28px !important;
    }

    /* CRITICAL: Stack form rows vertically on mobile */
    .form-row {
        flex-direction: column !important;
        gap: 0 !important;
        margin-bottom: 0 !important;
    }

    .form-group {
        margin-bottom: 15px !important;
    }

    .form-group input,
    .form-group select {
        padding: 12px !important;
        font-size: 14px !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    /* Payment method */
    .payment-method {
        padding: 12px !important;
        gap: 10px !important;
    }

    .payment-method strong {
        font-size: 14px !important;
    }

    .payment-method span {
        font-size: 12px !important;
    }

    /* Order summary items */
    .summary-item {
        display: flex !important;
        align-items: flex-start !important;
        gap: 10px !important;
        flex-wrap: nowrap !important;
        width: 100% !important;
        box-sizing: border-box !important;
        margin-bottom: 12px !important;
    }

    .summary-item-img {
        width: 50px !important;
        height: 50px !important;
        flex-shrink: 0 !important;
        object-fit: contain !important;
    }

    .summary-item-details {
        flex: 1 !important;
        min-width: 0 !important;
    }

    .summary-item-name {
        font-size: 13px !important;
        font-weight: 600 !important;
        line-height: 1.35 !important;
        word-break: break-word !important;
        white-space: normal !important;
    }

    .summary-item-qty {
        font-size: 12px !important;
        color: #888 !important;
    }

    .summary-item-price {
        font-weight: 600 !important;
        font-size: 13px !important;
        flex-shrink: 0 !important;
        white-space: nowrap !important;
    }

    /* Totals */
    .totals-row {
        font-size: 14px !important;
    }

    .totals-row.grand-total {
        font-size: 18px !important;
    }

    #cod-breakdown {
        padding: 12px !important;
    }

    #cod-breakdown .totals-row {
        font-size: 13px !important;
    }

    .place-order-btn {
        font-size: 16px !important;
        padding: 15px !important;
    }

    /* Truck animation */
    .shipping-animation-container {
        height: 45px !important;
    }

    .truck {
        font-size: 28px !important;
    }
}

/* =====================================================
   9. PRODUCT BADGE ON SMALL SCREENS
   ===================================================== */
@media screen and (max-width: 480px) {
    .product-badge {
        font-size: 9px !important;
        padding: 3px 7px !important;
        top: 8px !important;
        left: 8px !important;
    }
}

/* =====================================================
   10. CIRCLE CATEGORIES SWIPER FIX
   ===================================================== */
@media screen and (max-width: 767px) {
    .circle-cat-swiper {
        overflow: hidden !important;
    }

    .circle-cat-swiper .swiper-slide {
        box-sizing: border-box !important;
    }

    .circle-cat-link {
        width: 100% !important;
        max-width: 100% !important;
    }

    .circle-cat-image {
        box-sizing: border-box !important;
        overflow: hidden !important;
    }
}

/* =====================================================
   11. HOMEPAGE CATEGORY CARDS
   ===================================================== */
@media screen and (max-width: 480px) {
    .categories-grid {
        grid-template-columns: 1fr !important;
        gap: 15px !important;
    }

    .card-content h3 {
        font-size: 16px !important;
    }
}

/* =====================================================
   12. DESKTOP LOGO SIZE FIX
   TARGET: Desktop & Laptop ONLY (min-width: 1025px)
   PROBLEM: The logo <img> has an inline style "height: 85px" (from DB)
            which overrides the CSS class ".brand-logo { height: 115px }".
            Inline styles beat CSS classes in specificity, so the logo
            appears too small on desktop.
   FIX:    Use !important inside a desktop-only media query to correctly
           enforce the intended logo height on desktop.
   MOBILE: .brand-logo-mobile is on a separate element (mobile panel)
           and is NOT targeted here, so mobile is 100% unaffected.
   ===================================================== */
@media screen and (min-width: 1025px) {
    /* Force desktop logo to its correct, clearly visible height */
    .header-logo .brand-logo {
        height: 110px !important;
        width: auto !important;
        max-width: none !important;
        object-fit: contain !important;
    }
}

/* Large desktop: slightly larger if screen is wide */
@media screen and (min-width: 1440px) {
    .header-logo .brand-logo {
        height: 115px !important;
        width: auto !important;
    }
}

