/* =============================================================
   Mobile Responsive 4-Column + Compact Zoom + Show More/Show Less
   Only active on mobile (max-width:600px) - desktop unchanged
   Applied to: index (latest/featured), products (productsGrid)
   ============================================================= */

/* Base card refinements - desktop & mobile common - FIX 4-col SAME as home */
html, body{ overflow-x:hidden; max-width:100vw; }
#productsGrid, #latest-products-container, #featured-products-container{
    box-sizing:border-box;
    max-width:100%;
    overflow:hidden;
}
.product-card{
    background:#fff;
    border-radius:7px;
    overflow:hidden;
    border:1px solid #eee;
    position:relative;
    min-width:0;
    max-width:100%;
    min-height:0;
    height:auto;
    box-sizing:border-box;
    transition:border-color 0.25s ease, box-shadow 0.25s ease;
    display:flex;
    flex-direction:column;
}
#productsGrid .product-card, #latest-products-container .product-card, #featured-products-container .product-card{ min-height:0; height:auto; }
/* index + products cards: image fills card, no white gap below - override inline bg */
#latest-products-container .product-card, #featured-products-container .product-card, #productsGrid .product-card{
    background:transparent !important;
    border:none !important;
    box-shadow:none !important;
    overflow:visible !important;
}
#latest-products-container .product-card .product-image, #featured-products-container .product-card .product-image, #productsGrid .product-card .product-image,
#latest-products-container .product-card .product-zoom-container, #featured-products-container .product-card .product-zoom-container, #productsGrid .product-card .product-zoom-container{
    border:1px solid #eee;
    border-radius:7px;
    overflow:hidden;
    background:#f8f8f8;
}
.product-card:hover{
    border-color:#FA5206 !important;
    box-shadow:0 4px 12px rgba(250,82,6,0.15);
}
#latest-products-container .product-card:hover .product-image, #featured-products-container .product-card:hover .product-image, #productsGrid .product-card:hover .product-image,
#latest-products-container .product-card:hover .product-zoom-container, #featured-products-container .product-card:hover .product-zoom-container, #productsGrid .product-card:hover .product-zoom-container{
    border-color:#FA5206 !important;
    box-shadow:0 4px 12px rgba(250,82,6,0.15);
}
.product-card .product-image,
.product-card .product-zoom-container{
    position:relative;
    width:100%;
    aspect-ratio:1 / 1;
    background:#f8f8f8;
    overflow:hidden;
}
.product-card .product-image img,
.product-card .product-zoom-container img{
    width:100%;
    height:223px !important;
    display:block;
    object-fit:cover !important;
    object-position:center;
    transition:transform .2s ease;
}
@media(max-width:768px){
    .product-card .product-image,
    .product-card .product-zoom-container{ aspect-ratio:1/1 !important; height:auto !important; }
    .product-card .product-image img,
    .product-card .product-zoom-container img{ height:95px !important; max-height:95px !important; }
}
@media(max-width:360px){
    .product-card .product-image img,
    .product-card .product-zoom-container img{ height:85px !important; max-height:85px !important; }
}

/* Zoom button - REMOVED per request */
.product-card .zoom-btn{ display:none !important; visibility:hidden !important; opacity:0 !important; pointer-events:none !important; }

/* Discount badge - compact */
.product-card .discount-badge-mobile{
    position:absolute;
    top:5px;
    left:5px;
    background:#e53935;
    color:#fff;
    font-size:10px;
    font-weight:700;
    padding:3px 5px;
    border-radius:3px;
    z-index:4;
    line-height:1;
}

/* Product content inside card - no white gap below image when collapsed */
.product-card .product-content{
    padding:0;
    box-sizing:border-box;
    max-width:100%;
    overflow:hidden;
    background:transparent;
}
/* when NOT active, overlay show-more-row on image bottom - removes white empty area */
#latest-products-container .product-card:not(.active) .product-content,
#featured-products-container .product-card:not(.active) .product-content,
#productsGrid .product-card:not(.active) .product-content{
    position:absolute;
    bottom:0;
    left:0;
    right:0;
    z-index:3;
    padding:0 !important;
    background:transparent !important;
    pointer-events:none;
}
#latest-products-container .product-card:not(.active) .product-content .show-more-row,
#featured-products-container .product-card:not(.active) .product-content .show-more-row,
#productsGrid .product-card:not(.active) .product-content .show-more-row{
    pointer-events:auto;
}
#latest-products-container .product-card.active .product-content,
#featured-products-container .product-card.active .product-content,
#productsGrid .product-card.active .product-content{
    position:static;
    padding:6px !important;
    background:#fff !important;
    border:1px solid #eee;
    border-top:none;
    border-radius:0 0 7px 7px;
    margin-top:-1px;
}
.product-card .product-title{
    font-size:12px;
    line-height:16px;
    height:32px;
    overflow:hidden;
    margin-bottom:4px;
    display:-webkit-box;
    -webkit-line-clamp:2;
    -webkit-box-orient:vertical;
}
.product-card .price-main{
    font-size:14px;
    font-weight:700;
    color:#111;
}
.product-card .old-price{
    font-size:10px;
    color:#999;
    text-decoration:line-through;
    margin-left:3px;
}

/* SHOW MORE + Quick + split - overlay on image, no white gap - colors via admin settings */
.product-card .show-more-row{
    display:flex !important;
    gap:4px !important;
    margin:0 !important;
    max-width:100% !important;
    box-sizing:border-box !important;
    padding:4px !important;
    background:var(--show-more-row-bg, rgba(255,255,255,0.92)) !important;
    color:var(--show-more-row-text, #333333);
    backdrop-filter:blur(2px);
    border-radius:0;
}
#latest-products-container .product-card:not(.active) .show-more-row,
#featured-products-container .product-card:not(.active) .show-more-row,
#productsGrid .product-card:not(.active) .show-more-row{
    border-radius:0 0 7px 7px;
    border-top:1px solid rgba(0,0,0,0.06);
}
.product-card.active .show-more-row{
    background:#fff !important;
    padding:0 0 6px 0 !important;
    border-radius:0;
}
.product-card .show-more{
    flex:1 1 auto !important;
    width:auto !important;
    max-width:100% !important;
    box-sizing:border-box !important;
    border:0;
    background:var(--show-more-btn-bg, #f1f1f1);
    margin:0 !important;
    padding:5px 3px;
    font-size:10px;
    font-weight:700;
    cursor:pointer;
    border-radius:4px;
    display:block;
    text-align:center;
    color:var(--show-more-btn-text, #333333);
    overflow:hidden;
    white-space:nowrap;
    text-overflow:ellipsis;
}
.product-card .show-more:hover{ background:var(--show-more-btn-hover-bg, #e8e8e8) !important; color:var(--show-more-btn-hover-text, #333333) !important; }
.product-card .show-more-row:hover{ background:var(--show-more-row-hover-bg, rgba(255,255,255,1)) !important; }
.product-card .quick-add-btn{
    flex:0 0 38px !important;
    width:38px !important;
    min-width:38px !important;
    max-width:38px !important;
    box-sizing:border-box !important;
    border:0;
    background:var(--quick-add-btn-bg, #111111);
    color:var(--quick-add-btn-text, #ffffff);
    border-radius:4px;
    cursor:pointer;
    display:flex !important;
    align-items:center;
    justify-content:center;
    font-size:14px;
    font-weight:700;
    line-height:1;
    padding:5px 0;
}
.product-card .quick-add-btn:hover{ background:var(--quick-add-btn-hover, #FA5206); }
.product-card .quick-add-btn i{ pointer-events:none; }

/* Hidden details + product info hidden until SHOW MORE */
.product-card .product-details{
    display:none;
    margin-top:6px;
    padding:7px;
    background:#fafafa;
    border-radius:4px;
    font-size:10px;
    line-height:14px;
    color:#444;
}
.product-card.active .product-details{ display:block; }

/* Title, price and Buy/Cart buttons hidden until SHOW MORE */
.product-card:not(.active) .product-title,
.product-card:not(.active) .price-main,
.product-card:not(.active) .price,
.product-card:not(.active) .product-price,
.product-card:not(.active) .product-content > .d-flex.gap-2,
.product-card:not(.active) .product-content > .d-flex.gap-2.mt-1.flex-nowrap,
.product-card:not(.active) .product-info > .d-flex.gap-2,
.product-card:not(.active) .product-info > .d-flex.justify-content-between,
.product-card:not(.active) .product-content .d-flex.gap-2.mt-1.flex-nowrap,
.product-card:not(.active) .product-content .price-main,
.product-card:not(.active) .product-content .product-title{
    display:none !important;
}
/* When active, restore layout */
.product-card.active .product-title{ display:block !important; display:-webkit-box !important; }
.product-card.active .price-main,
.product-card.active .price,
.product-card.active .product-price{ display:block !important; }
.product-card.active .product-content > .d-flex.gap-2,
.product-card.active .product-content > .d-flex.gap-2.mt-1.flex-nowrap,
.product-card.active .product-info > .d-flex.gap-2,
.product-card.active .product-info > .d-flex.justify-content-between,
.product-card.active .product-content .d-flex.gap-2.mt-1.flex-nowrap{ display:flex !important; }

/* Also handle inner details: when title/price/btns are moved inside .product-details, always show them when details visible */
.product-card .product-details .product-title,
.product-card .product-details .price-main,
.product-card .product-details .price,
.product-card .product-details .product-price,
.product-card .product-details .d-flex.gap-2,
.product-card .product-details .d-flex.gap-2.mt-1.flex-nowrap{ display:block !important; }
.product-card .product-details .d-flex.gap-2,
.product-card .product-details .d-flex.gap-2.mt-1.flex-nowrap{ display:flex !important; }

/* Separate show-more-card - keep for backward compat but hide when inside card used */
.show-more-card.show{ display:block !important; }
.show-more-btn{ display:none; } /* hide old external button when new inside-card button exists */
.product-card .show-more{ display:block !important; }

/* Image zoom modal - global */
.image-modal{
    display:none;
    position:fixed;
    z-index:9999;
    inset:0;
    background:rgba(0,0,0,.8);
    align-items:center;
    justify-content:center;
    padding:20px;
}
.image-modal.active{ display:flex; }
.image-modal img{
    max-width:95%;
    max-height:85vh;
    object-fit:contain;
    border-radius:8px;
    background:#fff;
}
.image-modal .close-modal{
    position:absolute;
    right:15px;
    top:15px;
    width:35px;
    height:35px;
    border:0;
    border-radius:50%;
    background:#fff;
    font-size:20px;
    cursor:pointer;
    line-height:35px;
    text-align:center;
}

/* Load more wrap */
.load-more-wrap{ text-align:center; margin:18px 0; }
.load-more{
    border:0;
    background:#111;
    color:#fff;
    padding:10px 30px;
    border-radius:5px;
    font-size:13px;
    cursor:pointer;
}
.load-more.loading{ opacity:.6; pointer-events:none; }

/* =============================================================
    MOBILE GRID - respect 2,4,6,8 columns (fix btn-group not working)
     ============================================================= */
@media(max-width:768px){
    /* Container 0 padding - edge-to-edge */
    .container{ padding:0 !important; }
    section .container{ padding-left:0 !important; padding-right:0 !important; }
    section.py-5{ padding-top:8px !important; padding-bottom:8px !important; }
    section.py-5 .section-header{ margin-bottom:8px !important; padding-left:4px !important; padding-right:4px !important; }
    section.py-5 .section-header h2{ font-size:1rem !important; }
    section.py-5 .section-header p{ font-size:0.75rem !important; margin-bottom:0 !important; }

    /* Grid containers - wrap grid, not scroll */
    #productsGrid,
    #latest-products-container,
    #featured-products-container{
        --bs-gutter-x:0 !important;
        --bs-gutter-y:0 !important;
        gap:0 !important;
        row-gap:0 !important;
        justify-content:flex-start !important;
        margin-left:0 !important;
        margin-right:0 !important;
        padding:0 !important;
        flex-wrap:wrap !important;
        overflow:visible !important;
        scroll-snap-type:none !important;
    }
    /* Default fallback for plain div without lg class (25% = 4 col) */
    #productsGrid > [class*="col-"],
    #latest-products-container > [class*="col-"],
    #featured-products-container > [class*="col-"],
    #productsGrid > div,
    #latest-products-container > div,
    #featured-products-container > div{
        padding:1px !important;
        margin:0 !important;
        box-sizing:border-box !important;
        scroll-snap-align:none !important;
    }
    /* Respect column classes: 2 cols = 50%, 4 cols = 25%, 6 cols = 16.66%, 8 cols = 12.5% */
    #latest-products-container > .col-lg-12, #featured-products-container > .col-lg-12, #productsGrid > .col-lg-12{ flex:0 0 100% !important; max-width:100% !important; width:100% !important; min-width:100% !important; }
    #latest-products-container > .col-lg-6, #featured-products-container > .col-lg-6, #productsGrid > .col-lg-6{ flex:0 0 50% !important; max-width:50% !important; width:50% !important; min-width:50% !important; }
    #latest-products-container > .col-lg-4, #featured-products-container > .col-lg-4, #productsGrid > .col-lg-4{ flex:0 0 33.3333% !important; max-width:33.3333% !important; width:33.3333% !important; min-width:33.3333% !important; }
    #latest-products-container > .col-lg-3, #featured-products-container > .col-lg-3, #productsGrid > .col-lg-3{ flex:0 0 25% !important; max-width:25% !important; width:25% !important; min-width:25% !important; }
    #latest-products-container > .col-lg-2, #featured-products-container > .col-lg-2, #productsGrid > .col-lg-2{ flex:0 0 33.3333% !important; max-width:33.3333% !important; width:33.3333% !important; min-width:33.3333% !important; }
    #latest-products-container > .col-lg-1-5, #featured-products-container > .col-lg-1-5, #productsGrid > .col-lg-1-5{ flex:0 0 25% !important; max-width:25% !important; width:25% !important; min-width:25% !important; }
    #latest-products-container > .col-lg-20pct, #featured-products-container > .col-lg-20pct, #productsGrid > .col-lg-20pct{ flex:0 0 25% !important; max-width:25% !important; width:25% !important; min-width:25% !important; }
    /* Also handle row g-4 override */
    #productsGrid.row,
    #latest-products-container.row,
    #featured-products-container.row{
        margin-left:0 !important;
        margin-right:0 !important;
        display:flex !important;
        flex-wrap:wrap !important;
    }

    /* Card compact */
    .product-card{ border-radius:5px; }
    .product-card .product-content{ padding:4px; }
    .product-card .product-title{
        font-size:10px;
        line-height:13px;
        height:26px;
    }
    .product-card .price-main{ font-size:12px; }
    .product-card .old-price{
        display:block;
        margin-left:0;
        font-size:9px;
    }
    .product-card .discount-badge-mobile{
        font-size:8px;
        padding:2px 3px;
        top:3px;
        left:3px;
    }
    /* discount-badge from server (ds-*) also shrink */
    .product-card .discount-badge{
        font-size:8px !important;
        padding:2px 5px !important;
        top:3px !important;
        left:3px !important;
    }
    .product-card .show-more{
        font-size:8px;
        padding:4px 1px;
        margin-top:4px;
    }
    .product-card .product-details{
        font-size:9px;
        line-height:12px;
        padding:5px;
    }
    /* Hide desktop scroll snap - force grid */
    #latest-products-container,
    #featured-products-container{
        flex-wrap:wrap !important;
        overflow:visible !important;
        scroll-snap-type:none !important;
    }
    #latest-products-container > [class*="col-"],
    #featured-products-container > [class*="col-"]{
        scroll-snap-align:none !important;
    }
    /* Price bdt */
    .product-card .bdt-price strong{ font-size:11px; }
    .product-card .bdt-price small{ font-size:8px; }
    /* Buttons inside card stack? keep side by side but smaller */
    .product-card .d-flex.gap-2{
        gap:3px !important;
    }
    .product-card .buy-now-btn-index,
    .product-card .add-to-cart-btn-index{
        font-size:9px !important;
        padding:3px 5px !important;
    }
    /* Keep old show-more-card hidden on mobile when using inline */
    .show-more-card{ margin-top:0 !important; }
}

/* DESKTOP - respect 2,4,6,8 columns */
@media(min-width:769px){
    #productsGrid,
    #latest-products-container,
    #featured-products-container{
        display:flex !important;
        flex-wrap:wrap !important;
        --bs-gutter-x:1.5rem !important;
        gap:0 !important;
    }
    #productsGrid > div,
    #latest-products-container > div,
    #featured-products-container > div{
        box-sizing:border-box !important;
    }
    #latest-products-container > .col-lg-12, #featured-products-container > .col-lg-12, #productsGrid > .col-lg-12{ flex:0 0 100% !important; max-width:100% !important; width:100% !important; }
    #latest-products-container > .col-lg-6, #featured-products-container > .col-lg-6, #productsGrid > .col-lg-6{ flex:0 0 50% !important; max-width:50% !important; width:50% !important; }
    #latest-products-container > .col-lg-4, #featured-products-container > .col-lg-4, #productsGrid > .col-lg-4{ flex:0 0 33.3333% !important; max-width:33.3333% !important; width:33.3333% !important; }
    #latest-products-container > .col-lg-3, #featured-products-container > .col-lg-3, #productsGrid > .col-lg-3{ flex:0 0 25% !important; max-width:25% !important; width:25% !important; }
    #latest-products-container > .col-lg-2, #featured-products-container > .col-lg-2, #productsGrid > .col-lg-2{ flex:0 0 16.6667% !important; max-width:16.6667% !important; width:16.6667% !important; }
    #latest-products-container > .col-lg-1-5, #featured-products-container > .col-lg-1-5, #productsGrid > .col-lg-1-5{ flex:0 0 12.5% !important; max-width:12.5% !important; width:12.5% !important; }
    #latest-products-container > .col-lg-20pct, #featured-products-container > .col-lg-20pct, #productsGrid > .col-lg-20pct{ flex:0 0 20% !important; max-width:20% !important; width:20% !important; }
    /* keep bootstrap md fallback when lg not set */
    #latest-products-container > .col-6.col-md-4:not([class*="col-lg-"]), #featured-products-container > .col-6.col-md-4:not([class*="col-lg-"]), #productsGrid > .col-6.col-md-4:not([class*="col-lg-"]){ flex:0 0 33.3333% !important; max-width:33.3333% !important; width:33.3333% !important; }
}

/* Very small mobile still 4 columns */
@media(max-width:360px){
    #productsGrid,
    #latest-products-container,
    #featured-products-container{ gap:3px !important; }
    .container{ padding:0 2px !important; }
    .product-card .product-title{
        font-size:9px;
        line-height:12px;
        height:24px;
    }
    .product-card .price-main{ font-size:11px; }
    .product-card .show-more{ font-size:7px; }
}
