/* ==========================================================================
   NEW MOBILE BAZAR - GLOBAL MOBILE RESPONSIVE PRESETS & PREMIUM ESSENTIALS
   Applied globally via includes/topbar.php to all user-facing screens
   ========================================================================== */

/* --- 0. Global Resets & Mobile Screen Fixer (এটি স্ক্রিন কাটা বন্ধ করবে) --- */
*, *::before, *::after {
    box-sizing: border-box !important;
}

html, body {
    width: 100%;
    max-width: 100vw;
    margin: 0;
    padding: 0;
    overflow-x: hidden !important; /* Strict horizontal lock */
    -webkit-text-size-adjust: 100%;
}

img, video, canvas, svg {
    max-width: 100%;
    height: auto;
}

/* --- 1. Global Variables & Modern Root Core --- */
:root {
    --primary: #2874f0;
    --primary-grad: linear-gradient(135deg, #1d4ed8 0%, #2874f0 100%);
    --primary-glow: rgba(40, 116, 240, 0.15);
    --accent: #fb641b;
    --accent-grad: linear-gradient(135deg, #e05510 0%, #fb641b 100%);
    --bg-light: #f4f6f9;
    --text-dark: #0f172a;
    --text-muted: #64748b;
    --white: #ffffff;
    --border-light: #e2e8f0;
    --glass-bg: rgba(255, 255, 255, 0.75);
    --glass-border: rgba(255, 255, 255, 0.5);
    --shadow-premium: 0 10px 30px -5px rgba(15, 23, 42, 0.05);
    --shadow-soft: 0 4px 15px rgba(0, 0, 0, 0.03);
    --radius-premium: 16px;
    --radius-card: 12px;
}

/* --- 2. Custom Sleek Scrollbar for Desktop/Tablet --- */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Ensure smooth user scrolling, tap colors, and eliminate horizontal overflows */
html {
    scroll-behavior: smooth;
    -webkit-tap-highlight-color: transparent;
}
body {
    background-color: var(--bg-light) !important;
    color: var(--text-dark) !important;
    position: relative;
    padding-bottom: 75px !important; /* Ensure content is never blocked by sticky bottom nav */
}

/* --- 3. Sticky Bottom Navigation Bar (App-Like Layout) --- */
.nmb-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: var(--glass-bg);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-top: 1px solid var(--glass-border);
    display: none; /* Desktop/Tablet: Hidden */
    justify-content: space-around;
    align-items: center;
    z-index: 9999;
    padding: 0 10px;
    box-shadow: 0 -8px 24px rgba(15, 23, 42, 0.08);
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none !important;
    color: var(--text-muted);
    font-size: 10.5px;
    font-weight: 700;
    width: 60px;
    height: 100%;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    gap: 4px;
}

/* Ensure any clicks on inner icons, text, or profile pictures propagate directly to the <a> tag */
.bottom-nav-item i,
.bottom-nav-item span,
.bottom-nav-profile-pic,
.bottom-nav-profile-letter {
    pointer-events: none !important;
}

.bottom-nav-item i {
    font-size: 20px;
    transition: transform 0.2s;
}

.bottom-nav-item:hover, 
.bottom-nav-item.active {
    color: var(--primary);
}

.bottom-nav-item.active i {
    transform: translateY(-4px) scale(1.1);
    color: var(--primary);
    text-shadow: 0 4px 10px rgba(40, 116, 240, 0.2);
}

.bottom-nav-item.active::after {
    content: '';
    position: absolute;
    bottom: 6px;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--primary);
    box-shadow: 0 0 6px var(--primary);
}

/* Floating Badge inside bottom navigation */
.bottom-nav-badge {
    position: absolute;
    top: 5px;
    right: 12px;
    background: var(--accent-grad);
    color: #fff;
    font-size: 9px;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: 50px;
    border: 2.5px solid #ffffff;
    box-shadow: 0 3px 6px rgba(251, 100, 27, 0.3);
    line-height: 1;
}

/* Profile Picture Frame for Bottom Nav */
.bottom-nav-profile-pic {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    object-fit: cover;
    border: 1.5px solid var(--text-muted);
    transition: 0.2s;
}
.bottom-nav-item.active .bottom-nav-profile-pic {
    border-color: var(--primary);
    transform: translateY(-4px) scale(1.1);
    box-shadow: 0 4px 10px rgba(40, 116, 240, 0.25);
}

/* Initial letter fallback */
.bottom-nav-profile-letter {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #e0f2fe;
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 800;
    border: 1.5px solid var(--text-muted);
    transition: 0.2s;
}
.bottom-nav-item.active .bottom-nav-profile-letter {
    border-color: var(--primary);
    background: var(--primary-light);
    transform: translateY(-4px) scale(1.1);
}

/* --- 4. Global Responsive Overrides (Under 768px Width) --- */
@media (max-width: 768px) {
    /* Show Bottom Navigation Bar */
    .nmb-bottom-nav {
        display: flex;
    }

    /* Prevent content overlap near footer */
    .nmb-footer {
        padding-bottom: 95px !important;
    }

    /* --- Topbar Responsive Fine-Tuning --- */
    .nmb-header {
        padding: 8px 0 !important;
    }
    .nmb-logo {
        font-size: 17px !important;
    }
    .nmb-search {
        order: 3;
        min-width: 100%;
        margin-top: 4px;
        box-shadow: none !important;
        border: 1px solid var(--border-light);
    }
    .nmb-search button {
        padding: 0 15px !important;
    }
    .hide-mobile {
        display: none !important;
    }

    /* --- Index/Product Card Premium Overrides --- */
    .sec-head h3 {
        font-size: 16px !important;
    }
    .view-all {
        font-size: 10.5px !important;
        padding: 6px 12px !important;
    }
    .p-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
        width: 100% !important; /* Fixed width breaking */
    }
    .p-card {
        padding: 10px !important;
        border-radius: var(--radius-card) !important;
        border-color: #f1f5f9 !important;
        box-shadow: var(--shadow-soft) !important;
    }
    .p-img-box {
        height: 130px !important;
        margin-bottom: 8px !important;
    }
    .p-name {
        font-size: 12.5px !important;
        height: 35px !important;
        margin-bottom: 6px !important;
        line-height: 1.3 !important;
    }
    .p-price {
        font-size: 16.5px !important;
    }
    .add-btn {
        width: 32px !important;
        height: 32px !important;
        font-size: 12px !important;
    }

    /* --- Unified Shopping Cart Page overrides (cart.php) --- */
    .page-wrap {
        grid-template-columns: 1fr !important;
        gap: 15px !important;
        margin: 10px auto !important;
        padding: 0 10px !important;
    }
    .cart-box-header {
        padding: 14px 16px !important;
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 10px !important;
    }
    .cart-box-header h2 {
        font-size: 16px !important;
    }
    .delivery-progress-wrap {
        text-align: left !important;
        width: 100% !important;
    }
    .dp-bar-bg {
        width: 100% !important;
    }

    /* Card stack layout for cart items */
    .cart-item {
        flex-direction: column !important;
        padding: 15px !important;
        gap: 12px !important;
    }
    .item-img-wrap {
        width: 90px !important;
        height: 90px !important;
        margin: 0 auto !important;
    }
    .item-details {
        display: flex;
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
    .item-name {
        font-size: 13.5px !important;
        margin-bottom: 8px !important;
    }
    .item-price-row {
        justify-content: center !important;
        flex-direction: column !important;
        align-items: center !important;
        gap: 4px !important;
        margin-bottom: 12px !important;
    }
    .item-price {
        font-size: 18px !important;
    }
    .qty-form {
        width: 100%;
        justify-content: center;
    }
    .item-actions {
        width: 100% !important;
        justify-content: center !important;
        flex-wrap: nowrap !important;
    }
    .btn-update {
        padding: 6px 12px !important;
        font-size: 11px !important;
    }
    .btn-remove {
        padding: 6px 12px !important;
        font-size: 11px !important;
    }
    .divider-dot {
        display: none !important;
    }

    /* Price Summary Cards on Mobile */
    .summary-card {
        position: static !important;
        margin-top: 10px !important;
        width: 100% !important;
    }
    .summary-head {
        padding: 12px 15px !important;
        font-size: 11.5px !important;
    }
    .summary-body {
        padding: 15px !important;
    }
    .checkout-btn {
        padding: 13px !important;
        font-size: 13.5px !important;
    }

    /* --- Form Controls & Custom Overrides (checkout.php, login.php, register.php) --- */
    .card {
        padding: 20px 15px !important;
        border-radius: var(--radius-card) !important;
        width: 100% !important;
    }
    .card-title {
        font-size: 15px !important;
        margin-bottom: 15px !important;
        padding-bottom: 10px !important;
    }
    .pay-option {
        padding: 12px 14px !important;
    }
    .pay-option div div:first-child {
        font-size: 13.5px !important;
    }
    .pay-option div div:last-child {
        font-size: 11px !important;
    }
    .btn-order {
        padding: 14px !important;
        font-size: 14px !important;
    }
}

/* --- 5. User Dashboard Sidebar — Sleek Horizontal Swiper (screens <= 992px) --- */
@media (max-width: 992px) {
    /* Main dashboard layout converts into 1-column stack */
    .dashboard-container {
        grid-template-columns: 1fr !important;
        margin: 10px auto !important;
        padding: 0 10px !important;
        gap: 15px !important;
        width: 100% !important;
    }

    /* Convert Sidebar into horizontal swipeable layout */
    .sidebar {
        background: transparent !important;
        box-shadow: none !important;
        border-radius: 0 !important;
        width: 100% !important; /* Fixed from 100vw to prevent breaking */
        overflow-x: auto !important;
        scrollbar-width: none !important; /* Hide standard Firefox scrollbars */
    }
    .sidebar::-webkit-scrollbar {
        display: none !important; /* Hide scrollbar in Webkit browsers */
    }

    /* Hide User Profile info block in swipe-bar (Already visible in topbar) */
    .user-profile-box {
        display: none !important;
    }

    /* Convert nav items menu into scrollable horizontal bar of pills */
    .nav-menu {
        display: flex !important;
        flex-direction: row !important;
        padding: 10px 15px !important;
        gap: 8px !important;
        width: max-content !important; /* Forces row list to stay in single line */
    }

    /* Hide navigation structural section titles */
    .nav-section-title {
        display: none !important;
    }

    .nav-menu li {
        margin: 0 !important;
    }

    /* Transform vertical list links into modern rounded glassmorphic pills */
    .nav-menu li a {
        padding: 8px 16px !important;
        font-size: 13px !important;
        font-weight: 700 !important;
        white-space: nowrap !important;
        background: var(--white);
        border: 1px solid var(--border-light);
        border-radius: 50px !important;
        color: var(--text-muted) !important;
        display: flex !important;
        align-items: center !important;
        gap: 8px !important;
        box-shadow: var(--shadow-soft);
        transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    }

    /* Styled active pill with beautiful blue gradient and subtle glow */
    .nav-menu li a:hover,
    .nav-menu li a.active {
        background: var(--primary-grad) !important;
        color: #ffffff !important;
        border-color: var(--primary) !important;
        box-shadow: 0 4px 12px var(--primary-glow) !important;
    }
    
    .nav-menu li a i {
        font-size: 14px !important;
    }
    
    .nav-menu li a:hover i,
    .nav-menu li a.active i {
        color: #ffffff !important;
    }

    /* Unify dashboard panels content area padding on mobile */
    .content-area {
        padding: 20px 15px !important;
        border-radius: var(--radius-card) !important;
        width: 100% !important;
    }
}

/* --- 6. Product Details Page overrides (product.php) --- */
@media (max-width: 768px) {
    /* Set page padding and grid layout to 1 column */
    .product-container, .container {
        padding: 10px !important;
        margin-top: 5px !important;
        padding-bottom: 140px !important; /* Ensure content is not hidden behind fixed buttons */
        width: 100% !important;
    }
    .product-layout {
        grid-template-columns: 1fr !important;
        gap: 20px !important;
        width: 100% !important;
    }
    
    /* Make image fit perfectly on screen */
    .image-box {
        position: static !important;
        width: 100% !important;
        height: auto !important;
        min-height: 250px !important;
        max-height: 320px !important;
        padding: 15px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        border-radius: var(--radius-card) !important;
    }
    .image-box img {
        max-height: 250px !important;
        width: auto !important;
        object-fit: contain !important;
    }

    /* Info Box spacing */
    .info-box {
        padding: 5px !important;
        width: 100% !important;
    }
    .p-title {
        font-size: 18px !important;
        line-height: 1.4 !important;
    }
    .price-container {
        align-items: flex-baseline !important;
        gap: 8px !important;
    }
    .p-price-big {
        font-size: 24px !important;
    }
    .p-price-old {
        font-size: 13.5px !important;
    }
    .p-discount {
        font-size: 13.5px !important;
    }

    /* Style the attributes (color and size selectors) as sleek touch-friendly cards */
    .color-grid, .var-grid {
        gap: 8px !important;
        width: 100% !important;
    }
    .color-box, .var-box {
        padding: 10px 15px !important;
        font-size: 12.5px !important;
        border-radius: 8px !important;
        min-width: auto !important;
    }

    /* Stack Bank Offer cards nicely on mobile */
    .bank-grid {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
    }
    .bank-card {
        padding: 12px !important;
        width: 100% !important;
    }

    /* Sticky Bottom Actions Bar (Matches premium Amazon/Flipkart look!) */
    .action-btns {
        position: fixed !important;
        bottom: 64px !important; /* Locks exactly above the 64px bottom sticky nav bar! */
        left: 0 !important;
        right: 0 !important;
        background: #ffffff !important; /* Solid white background to prevent text overlap */
        padding: 10px 15px !important;
        margin: 0 !important;
        display: flex !important;
        gap: 10px !important;
        box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.12) !important;
        z-index: 10005 !important; /* Extremely high z-index to stay on top of everything */
        border-top: 1px solid var(--border-light) !important;
    }
    .action-btns .btn {
        flex: 1 !important;
        padding: 12px !important;
        font-size: 13.5px !important;
        font-weight: 800 !important;
        text-transform: uppercase !important;
        border-radius: 8px !important;
        margin: 0 !important;
        height: 46px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        box-shadow: none !important;
    }
}