/* Custom Mobile Optimizations for Le Cœur des Champs */

/* 1. Header & Navigation Menu Mobile Responsiveness */
@media (max-width: 991.98px) {
    /* Set navbar item sizes smaller on mobile */
    .navbar-brand-coeur {
        font-size: 1.15rem !important;
    }
    .navbar-brand-coeur img {
        height: 38px !important;
        margin-right: 8px !important;
    }
    .navbar-coeur {
        padding: 10px 0 !important;
    }
    /* Style the collapsible mobile menu */
    #navbarMobileMenu {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background-color: #ffffff;
        border-bottom: 1px solid var(--coeur-border);
        box-shadow: 0 10px 15px rgba(0,0,0,0.05);
        z-index: 1000;
    }
    /* Remove padding and customize container inside menu */
    #navbarMobileMenu .container {
        padding-top: 15px !important;
        padding-bottom: 20px !important;
    }
}

/* 2. Horizontal scroll for tabs, categories & filter buttons on mobile */
@media (max-width: 767.98px) {
    /* Horizontal scroll for category filter buttons */
    .filter-buttons-wrapper, 
    .nav-tabs {
        display: flex !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        padding-bottom: 8px !important;
        margin-bottom: 15px !important;
        scrollbar-width: none; /* Hide scrollbar for clean UI on Firefox */
    }
    .filter-buttons-wrapper::-webkit-scrollbar,
    .nav-tabs::-webkit-scrollbar {
        display: none; /* Hide scrollbar for Chrome/Safari */
    }
    .filter-buttons-wrapper .btn,
    .nav-tabs .nav-item {
        flex: 0 0 auto !important;
    }
    
    /* Ensure tabs look like pills/nice segments on mobile */
    .nav-tabs {
        border-bottom: none !important;
        gap: 8px;
    }
    .nav-tabs .nav-link {
        border: 1px solid var(--coeur-border) !important;
        border-radius: 30px !important;
        padding: 8px 16px !important;
        background-color: #ffffff !important;
        color: var(--coeur-text) !important;
        font-size: 0.85rem !important;
    }
    .nav-tabs .nav-link.active {
        background-color: var(--coeur-green) !important;
        border-color: var(--coeur-green) !important;
        color: #ffffff !important;
    }
}

/* 3. Product & Recipe Card Spacing & Image Sizing on Mobile */
@media (max-width: 575.98px) {
    .product-grid {
        gap: 16px !important;
    }
    .product-card-body {
        padding: 15px !important;
    }
    .product-card-title {
        font-size: 1.05rem !important;
        margin-bottom: 6px !important;
    }
    .product-card-desc {
        font-size: 0.8rem !important;
        margin-bottom: 12px !important;
    }
    .format-buttons-group {
        margin-bottom: 12px !important;
        gap: 4px !important;
    }
    .btn-format {
        padding: 4px 6px !important;
        font-size: 0.7rem !important;
    }
    .product-price {
        font-size: 1.2rem !important;
    }
    
    /* Responsive Recipe Card adjustments */
    .recipe-card .recipe-img-wrapper {
        height: 160px !important;
    }
    .recipe-card .card-body {
        padding: 15px !important;
    }
}

/* 4. Checkout Progress Steps Mobile optimization */
@media (max-width: 575.98px) {
    .checkout-steps {
        margin-bottom: 20px !important;
    }
    .checkout-steps::before {
        top: 14px !important;
        left: 15% !important;
        right: 15% !important;
    }
    .checkout-step {
        padding: 0 5px !important;
    }
    .checkout-step-num {
        width: 28px !important;
        height: 28px !important;
        font-size: 0.8rem !important;
        margin-bottom: 4px !important;
    }
    .checkout-step span {
        font-size: 0.7rem !important;
        display: block;
        max-width: 75px;
        line-height: 1.2;
        margin: 0 auto;
    }
}

/* 5. Shopping Cart Table to Mobile-friendly Cards transition */
@media (max-width: 767.98px) {
    /* Stack checkout table cells */
    .table-coeur, 
    .table-coeur thead, 
    .table-coeur tbody, 
    .table-coeur th, 
    .table-coeur td, 
    .table-coeur tr {
        display: block !important;
        width: 100% !important;
    }
    
    .table-coeur thead {
        display: none !important; /* Hide standard headers */
    }
    
    .table-coeur tr {
        border: 1px solid var(--coeur-border) !important;
        border-radius: 12px !important;
        padding: 12px 15px !important;
        margin-bottom: 12px !important;
        background-color: #ffffff !important;
        position: relative !important;
        box-shadow: 0 2px 6px rgba(0,0,0,0.01) !important;
    }
    
    .table-coeur td {
        border: none !important;
        padding: 5px 0 !important;
        text-align: left !important;
    }
    
    /* Highlight the product name and delete button */
    .table-coeur td:first-child {
        padding-right: 40px !important; /* Leave space for delete button absolute positioning */
    }
    
    /* Absolute position for trash icon in card */
    .table-coeur td:last-child {
        position: absolute !important;
        top: 12px !important;
        right: 15px !important;
        width: auto !important;
        padding: 0 !important;
    }
    
    /* Display quantities and prices in a grid-like layout inside card */
    .table-coeur td:nth-child(2) {
        display: inline-block !important;
        width: 50% !important;
        font-size: 0.85rem !important;
        color: #8c867a !important;
    }
    .table-coeur td:nth-child(2)::before {
        content: "Prix unitaire : ";
        font-weight: 600;
    }
    
    .table-coeur td:nth-child(3) {
        display: block !important;
        width: 100% !important;
        margin: 8px 0 !important;
        border-top: 1px dashed var(--coeur-border) !important;
        border-bottom: 1px dashed var(--coeur-border) !important;
        padding: 8px 0 !important;
    }
    .table-coeur td:nth-child(3) .d-flex {
        justify-content: flex-start !important;
        flex-direction: row !important;
    }
    .table-coeur td:nth-child(3)::before {
        content: "Quantité :";
        font-weight: 600;
        margin-right: 15px;
        display: inline-block;
        align-self: center;
    }
    
    .table-coeur td:nth-child(4) {
        display: block !important;
        width: 100% !important;
        text-align: right !important;
        font-size: 1.05rem !important;
    }
    .table-coeur td:nth-child(4)::before {
        content: "Sous-total : ";
        font-weight: 600;
        color: var(--coeur-text);
        float: left;
        font-size: 0.9rem;
    }
}

/* 6. Point Relais Map height on Mobile */
@media (max-width: 991.98px) {
    #relais-map {
        height: 250px !important;
        margin-top: 15px !important;
    }
    .relais-list-container {
        max-height: 250px !important;
    }
}

/* 7. Topbar Mobile Optimization */
@media (max-width: 767.98px) {
    .topbar .container {
        justify-content: center !important;
        text-align: center;
    }
    .topbar .container > div {
        display: none !important; /* Hides the right block (Circuit Court Garanti) on mobile */
    }
    .topbar {
        font-size: 0.75rem !important;
        padding: 6px 0 !important;
    }
}

/* 8. Global Typography & Alignment Optimizations */
.font-monospace {
    font-family: 'Plus Jakarta Sans', 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
    font-variant-numeric: tabular-nums !important;
    font-feature-settings: "tnum" !important;
    letter-spacing: -0.01em;
}

/* 9. Floating Cart Button for Product Cards (with Cutout Effect) */
.cart-btn-wrapper {
    position: absolute !important;
    bottom: 0 !important;
    right: 0 !important;
    width: 60px !important;
    height: 60px !important;
    background-color: #ffffff !important;
    border-radius: 28px 0 0 0 !important; /* Beautiful rounded cutout */
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    z-index: 12 !important;
}

.btn-floating-cart {
    position: relative !important;
    width: 44px !important;
    height: 44px !important;
    border-radius: 50% !important;
    background-color: var(--coeur-green) !important;
    color: #ffffff !important;
    border: none !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: 0 4px 10px rgba(0,0,0,0.15) !important;
    z-index: 15 !important;
    transition: all 0.2s ease-in-out !important;
}
.btn-floating-cart:hover {
    background-color: var(--coeur-green-hover) !important;
    transform: scale(1.08) !important;
    color: #ffffff !important;
}
.btn-floating-cart i {
    font-size: 1.25rem !important;
}

/* 10. Hide collapsible mobile menu on desktop screens */
@media (min-width: 992px) {
    #navbarMobileMenu {
        display: none !important;
    }
}

/* 11. Cart Badge Bounce Animation */
@keyframes cartBadgeBounce {
    0% { transform: scale(1); }
    50% { transform: scale(1.6); }
    100% { transform: scale(1); }
}
.cart-badge-bounce {
    animation: cartBadgeBounce 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) !important;
    background-color: var(--coeur-earth) !important; /* Temporarily turns gold/orange on arrival */
}
