/* ==========================================================================
   Mipeluco Mobile Responsive & Simplification Styles
   ========================================================================== */

/* 1. Global Viewport & Mobile Safe Sizing */
:root {
    --mobile-nav-height: 60px;
    --mobile-nav-safe-bottom: env(safe-area-inset-bottom, 0px);
    --primary-red: #e22454;
    --primary-red-hover: #c81e46;
    --primary-red-light: #fee2e2;
}

html, body {
    max-width: 100vw;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

@media (max-width: 767.98px) {
    body {
        padding-bottom: calc(var(--mobile-nav-height) + var(--mobile-nav-safe-bottom) + 12px) !important;
    }

    /* Prevent iOS zoom on form input focus */
    input[type="text"],
    input[type="number"],
    input[type="email"],
    input[type="password"],
    input[type="search"],
    input[type="tel"],
    select,
    textarea {
        font-size: 16px !important;
    }

    /* Better touch tap area */
    button, 
    a, 
    .btn, 
    .nav-link,
    .page-link {
        touch-action: manipulation;
    }
}

/* 2. Unified Modern Mobile Bottom Navigation Bar */
.mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: calc(var(--mobile-nav-height) + var(--mobile-nav-safe-bottom));
    padding-bottom: var(--mobile-nav-safe-bottom);
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.05);
    z-index: 1040;
}

.mobile-nav-container {
    display: flex;
    align-items: center;
    justify-content: space-around;
    height: var(--mobile-nav-height);
    max-width: 540px;
    margin: 0 auto;
    padding: 0 4px;
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    height: 100%;
    color: #64748b;
    text-decoration: none;
    transition: all 0.2s ease;
    user-select: none;
    position: relative;
    padding: 4px 0;
}

.mobile-nav-item .mobile-nav-icon {
    position: relative;
    font-size: 20px;
    line-height: 1;
    margin-bottom: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mobile-nav-item .icon-active {
    display: none;
}
.mobile-nav-item .icon-inactive {
    display: block;
}

.mobile-nav-item.active {
    color: var(--primary-red);
}

.mobile-nav-item.active .icon-active {
    display: block;
}
.mobile-nav-item.active .icon-inactive {
    display: none;
}

.mobile-nav-item.active .mobile-nav-label {
    font-weight: 700;
    color: var(--primary-red);
}

.mobile-nav-label {
    font-size: 10.5px;
    font-weight: 500;
    letter-spacing: 0.1px;
    line-height: 1;
    white-space: nowrap;
}

.mobile-badge {
    position: absolute;
    top: -6px;
    right: -10px;
    background: var(--primary-red);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    min-width: 17px;
    height: 17px;
    line-height: 17px;
    text-align: center;
    border-radius: 10px;
    padding: 0 4px;
    box-shadow: 0 2px 5px rgba(226, 36, 84, 0.4);
}

/* Hide legacy menu-mobile-box if still referenced */
.menu-mobile-box {
    display: none !important;
}

/* 3. Mobile Header & Hamburger Menu Optimization */
@media (max-width: 991.98px) {
    .header-4 {
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
    }

    .sub-header {
        padding: 6px 0;
        font-size: 11.5px;
    }

    .sub-header p {
        margin: 0;
        font-size: 11.5px;
        line-height: 1.3;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .header-wrapper {
        padding: 10px 0;
        display: flex;
        align-items: center;
        justify-content: space-between;
    }

    .header-logo-anniversary img.light {
        height: 32px;
    }

    /* Mobile Drawer */
    .navbar-collapse {
        position: fixed;
        top: 0;
        left: -100%;
        width: 300px;
        max-width: 85vw;
        height: 100vh;
        background: #ffffff;
        z-index: 1050;
        padding: 0;
        transition: left 0.35s cubic-bezier(0.4, 0, 0.2, 1);
        overflow-y: auto;
        box-shadow: 4px 0 25px rgba(0, 0, 0, 0.15);
        display: block !important;
    }

    .navbar-collapse.show {
        left: 0;
    }

    .side-menu-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 16px 20px;
        background: #f8fafc;
        border-bottom: 1px solid #e2e8f0;
    }

    .side-menu-header h3 {
        font-size: 16px;
        font-weight: 700;
        margin: 0;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        color: #1e293b;
    }

    .side-menu-header .close-btn {
        background: #ffffff;
        border: 1px solid #e2e8f0;
        width: 32px;
        height: 32px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        color: #64748b;
        font-size: 18px;
        cursor: pointer;
    }

    .navbar-nav {
        padding: 12px 0;
    }

    .navbar-nav .nav-item {
        border-bottom: 1px solid #f1f5f9;
    }

    .navbar-nav .nav-link {
        padding: 12px 20px !important;
        font-size: 15px;
        font-weight: 600;
        color: #1e293b;
        display: flex;
        align-items: center;
        justify-content: space-between;
    }

    .navbar-nav .nav-link:hover,
    .navbar-nav .nav-link:active {
        color: var(--primary-red);
        background: #fff1f2;
    }

    /* Mobile Mega Menu simplified */
    .mega-menu {
        position: static !important;
        box-shadow: none !important;
        border: none !important;
        padding: 0 20px 10px 20px !important;
        background: #f8fafc;
        width: 100% !important;
        visibility: visible !important;
        opacity: 1 !important;
        display: none;
    }

    .mega-menu-wrapper.open-mobile .mega-menu,
    .nav-item.show .mega-menu {
        display: block !important;
    }

    .mega-menu .side-links .link-header {
        margin-bottom: 8px;
    }

    .mega-menu .side-links .link-header h6 {
        font-size: 12px;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        color: #64748b;
    }

    .mega-links li {
        margin-bottom: 6px;
    }

    .mega-links li a {
        font-size: 13.5px;
        color: #334155;
        display: block;
        padding: 4px 0;
    }

    .navbar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background: rgba(0, 0, 0, 0.5);
        backdrop-filter: blur(3px);
        z-index: 1045;
        display: none;
        opacity: 0;
        transition: opacity 0.3s ease;
    }

    .navbar-overlay.show {
        display: block;
        opacity: 1;
    }
}

@media (max-width: 575.98px) {
    .header-anniversary-badge {
        display: none !important; /* Keep mobile header clean and tight on small phones */
    }
    
    .header-option li:not(.cart-option) {
        display: none; /* User/Search in header are accessible via bottom bar */
    }

    .header-wrapper .logo {
        max-width: 140px;
    }
}

/* 4. Product Cards Grid on Mobile (2 columns clean layout) */
@media (max-width: 767.98px) {
    .product-tab-content .row,
    .grid-section.row,
    .recommended-products-box .row,
    .shop-section .row-cols-2 {
        --bs-gutter-x: 10px;
        --bs-gutter-y: 12px;
    }

    .product-box.style-3,
    .product-box.style-4 {
        border-radius: 12px;
        background: #ffffff;
        border: 1px solid #f1f5f9;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
        height: 100%;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        padding: 10px;
        position: relative;
    }

    .product-box .product-img-box {
        position: relative;
        background: #f8fafc;
        border-radius: 8px;
        padding: 8px;
        display: flex;
        align-items: center;
        justify-content: center;
        aspect-ratio: 1 / 1;
        overflow: hidden;
    }

    .product-box .product-img-box img {
        max-height: 100%;
        width: auto;
        object-fit: contain;
    }

    .product-box .sale-ribbon {
        top: 6px;
        left: 6px;
        padding: 2px 6px;
        font-size: 10px;
        font-weight: 700;
        border-radius: 4px;
    }

    .product-box .option-box {
        top: 6px;
        right: 6px;
        gap: 4px;
    }

    .product-box .option-box li a {
        width: 28px;
        height: 28px;
        font-size: 14px;
        border-radius: 50%;
        background: rgba(255, 255, 255, 0.9);
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
    }

    .product-box .product-details {
        padding: 8px 2px 2px 2px;
        display: flex;
        flex-direction: column;
        flex-grow: 1;
    }

    .product-box .food-label {
        font-size: 10px;
        color: #94a3b8;
        text-transform: uppercase;
        font-weight: 600;
        margin-bottom: 2px;
        display: inline-block;
    }

    .product-box .name,
    .product-box h2 .name {
        font-size: 13px !important;
        font-weight: 600 !important;
        color: #1e293b !important;
        line-height: 1.3 !important;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
        height: 34px;
        margin-bottom: 4px;
    }

    .product-box .price,
    .product-box h4.price {
        font-size: 15px !important;
        font-weight: 700 !important;
        color: var(--primary-red) !important;
        margin: 4px 0 8px 0;
    }

    .product-box .bottom-panel,
    .product-box .cart-btn {
        margin-top: auto;
    }

    .product-box .cart-btn .btn,
    .product-box .bottom-panel .btn {
        width: 100%;
        padding: 6px 8px;
        font-size: 12px;
        font-weight: 600;
        border-radius: 6px;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 4px;
    }
}

/* 5. Shop Filters Mobile Offcanvas / Drawer */
@media (max-width: 1199.98px) {
    .shop-filter {
        position: fixed;
        top: 0;
        left: -100%;
        width: 320px;
        max-width: 88vw;
        height: 100vh;
        background: #ffffff;
        z-index: 1055;
        overflow-y: auto;
        padding: 0;
        transition: left 0.35s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 4px 0 30px rgba(0, 0, 0, 0.15);
    }

    .shop-filter.show {
        left: 0;
    }

    .shop-filter-block {
        padding: 0;
    }

    .shop-mobile-back {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 16px 20px;
        background: #f8fafc;
        border-bottom: 1px solid #e2e8f0;
    }

    .shop-mobile-back button {
        border: none;
        background: transparent;
        font-weight: 700;
        font-size: 15px;
        color: #1e293b;
        display: flex;
        align-items: center;
        gap: 6px;
        width: 100%;
        justify-content: space-between;
    }

    .shop-filter-box {
        padding: 16px;
    }

    /* Mobile filter overlay */
    .filter-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background: rgba(0, 0, 0, 0.5);
        backdrop-filter: blur(2px);
        z-index: 1050;
        display: none;
    }

    .filter-overlay.show {
        display: block;
    }
}

@media (max-width: 575.98px) {
    .filter-options {
        padding: 8px 0;
    }

    .filter-options .select-options {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        gap: 8px;
    }

    .filter-options .grid-option {
        display: none !important;
    }

    .filter-options .filter-btn {
        padding: 7px 12px;
        font-size: 13px;
        border-radius: 8px;
        background: #f1f5f9;
        color: #1e293b;
        font-weight: 600;
        border: 1px solid #e2e8f0;
    }

    .filter-options .select-featured .btn {
        padding: 7px 10px;
        font-size: 12.5px;
        border-radius: 8px;
    }
}

/* 6. Sticky Buy / Add to Cart Bar on Product Page (Mobile) */
.mobile-sticky-pdp-bar {
    position: fixed;
    bottom: calc(var(--mobile-nav-height) + var(--mobile-nav-safe-bottom));
    left: 0;
    right: 0;
    background: #ffffff;
    border-top: 1px solid #e2e8f0;
    padding: 8px 16px;
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    z-index: 1030;
    box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.08);
    animation: slideUpSticky 0.3s ease-out;
}

@keyframes slideUpSticky {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

.mobile-sticky-pdp-bar.visible {
    display: flex;
}

.mobile-sticky-pdp-info {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex: 1;
}

.mobile-sticky-pdp-img {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    object-fit: contain;
    background: #f8fafc;
    flex-shrink: 0;
}

.mobile-sticky-pdp-text {
    min-width: 0;
}

.mobile-sticky-pdp-title {
    font-size: 12px;
    font-weight: 600;
    color: #1e293b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
    margin: 0;
}

.mobile-sticky-pdp-price {
    font-size: 14px;
    font-weight: 700;
    color: var(--primary-red);
    margin: 0;
    line-height: 1.2;
}

.mobile-sticky-pdp-btn {
    flex-shrink: 0;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 700;
    border-radius: 8px;
    background: var(--primary-red);
    color: #ffffff;
    border: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
}

/* 7. Responsive Cart & Checkout on Mobile */
@media (max-width: 767.98px) {
    .cart-table-container .table-responsive {
        border: none;
    }

    .cart-table thead {
        display: none;
    }

    .cart-table, 
    .cart-table tbody, 
    .cart-table tr, 
    .cart-table td {
        display: block;
        width: 100%;
    }

    .cart-table tr {
        background: #ffffff;
        border: 1px solid #f1f5f9;
        border-radius: 12px;
        margin-bottom: 12px;
        padding: 12px;
        position: relative;
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.02);
    }

    .cart-table td {
        padding: 4px 0 !important;
        border: none !important;
    }

    .cart-table .product-detail {
        display: flex;
        gap: 12px;
        align-items: center;
        margin-bottom: 8px;
    }

    .cart-table .product-detail .product-img {
        width: 60px;
        height: 60px;
        border-radius: 8px;
        background: #f8fafc;
        padding: 4px;
        flex-shrink: 0;
    }

    .cart-table .product-detail .product-img img {
        width: 100%;
        height: 100%;
        object-fit: contain;
    }

    .cart-table .product-detail .product-info h5 {
        font-size: 14px;
        font-weight: 600;
        margin-bottom: 2px;
        line-height: 1.3;
    }

    .cart-table .qty-box-simple {
        display: inline-flex;
        align-items: center;
        border: 1px solid #e2e8f0;
        border-radius: 6px;
        overflow: hidden;
    }

    .cart-table .qty-box-simple .btn-qty {
        width: 32px;
        height: 32px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: #f8fafc;
        color: #334155;
        text-decoration: none;
    }

    .cart-table .qty-box-simple .input-qty {
        width: 36px;
        height: 32px;
        text-align: center;
        border: none;
        font-size: 14px;
        font-weight: 600;
    }

    .cart-table .delete-btn {
        position: absolute;
        top: 10px;
        right: 10px;
        color: #94a3b8;
        font-size: 18px;
    }
}

/* 8. Cookie Bar & Modals Mobile Positioning */
@media (max-width: 767.98px) {
    .cookie-bar-box {
        bottom: calc(var(--mobile-nav-height) + var(--mobile-nav-safe-bottom) + 8px) !important;
        left: 10px !important;
        right: 10px !important;
        width: calc(100% - 20px) !important;
        padding: 12px 14px !important;
        border-radius: 12px !important;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15) !important;
    }

    .cookie-bar-box .cookie-content {
        gap: 8px;
    }

    .cookie-bar-box .cookie-text p {
        font-size: 11.5px !important;
        line-height: 1.35 !important;
    }

    .cookie-bar-box .cookie-btns {
        margin-top: 8px;
    }

    .cookie-bar-box .btn-accept {
        padding: 6px 14px !important;
        font-size: 12px !important;
        border-radius: 6px !important;
    }

    .tap-to-top {
        bottom: calc(var(--mobile-nav-height) + var(--mobile-nav-safe-bottom) + 16px) !important;
        right: 16px !important;
        width: 38px !important;
        height: 38px !important;
        font-size: 16px !important;
    }
}

/* 9. Offcanvas Cart & Wishlist Mobile Width */
@media (max-width: 480px) {
    .offcanvas.offcanvas-end {
        width: 100% !important;
    }
}

/* 10. Home & General Mobile Layout Enhancements */
@media (max-width: 767.98px) {
    .home-video-section {
        min-height: auto;
        padding: 24px 0 32px 0;
    }

    .hero-main-title {
        font-size: 22px !important;
        line-height: 1.25 !important;
        text-align: center;
        margin-top: 12px;
    }

    .hero-content h2 {
        font-size: 13.5px !important;
        line-height: 1.4 !important;
        text-align: center;
        margin-top: 8px;
    }

    .home-watch-brands-sidebar {
        max-height: 320px;
        margin-bottom: 16px;
    }

    .search-content-wrap {
        padding: 0 4px;
    }

    .search-header .search-title {
        font-size: 18px !important;
    }

    .search-form-modern {
        border-radius: 10px;
        padding: 4px;
    }

    .search-form-modern input {
        padding: 8px 10px 8px 38px;
        font-size: 14px !important;
    }

    .search-form-modern .btn-search-submit {
        padding: 8px 14px;
        font-size: 13px;
        border-radius: 8px;
    }

    .trending-keywords {
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 4px;
        scrollbar-width: none;
    }
    .trending-keywords::-webkit-scrollbar {
        display: none;
    }

    .trending-keywords .keyword-tags {
        display: inline-flex;
        flex-wrap: nowrap;
        gap: 6px;
    }

    .trending-keywords .keyword-tags .tag-link {
        font-size: 12px;
        padding: 4px 10px;
    }

    /* Category Swiper on Mobile */
    .category-section-4 .category-box,
    .menu-category-slider .category-box {
        padding: 8px;
    }

    .category-section-4 .category-box h6 {
        font-size: 12px;
        margin-top: 6px;
    }

    /* Title Box */
    .title-box h2 {
        font-size: 20px !important;
        line-height: 1.3 !important;
    }
    .title-box p {
        font-size: 13px !important;
    }

    /* Blog Cards on Mobile */
    .blog-box {
        margin-bottom: 16px;
    }
    .blog-box .blog-content h5,
    .blog-box .blog-content h3 {
        font-size: 15px !important;
        line-height: 1.35 !important;
    }
    .blog-box .blog-content p {
        font-size: 13px !important;
    }

    /* Footer Mobile Simplification */
    footer .footer-title {
        font-size: 15px;
        margin-bottom: 12px;
    }
    footer .footer-content li {
        margin-bottom: 8px;
    }
    footer .footer-content a {
        font-size: 13px;
    }
}
