/* ==========================================================================
   📦 DESIGN SYSTEM VARIABLES & CORE ARCHITECTURE
   ========================================================================== */
:root {
    --fk-blue: #2874F0;
    --fk-yellow: #FFE500;
    --fk-orange: #FF5615;
    --clean-white: #FFFFFF;
    --bg-canvas: #F1F3F6;
    --text-primary: #212121;
    --text-secondary: #878787;
    --border-smooth: #E0E0E0;
    --radius-premium: 8px;
    --radius-card: 4px;
    --shadow-subtle: 0 2px 12px rgba(0, 0, 0, 0.06);
    --shadow-elevated: 0 8px 24px rgba(0, 0, 0, 0.15);
    --transition-smooth: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --font-stack: -apple-system, BlinkMacSystemFont, Roboto, "Segoe UI", Arial, sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: var(--font-stack);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-canvas);
    color: var(--text-primary);
    padding-bottom: 68px; /* Prevents overlap with mobile bottom bar */
    overflow-x: hidden;
    line-height: 1.4;
}

/* ==========================================================================
   🌐 APPLICATION CONTAINER FRAMES
   ========================================================================== */
.navbar {
    background-color: var(--fk-blue);
    position: sticky;
    top: 0;
    z-index: 1000;
    padding: 12px 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.nav-container {
    width: 92%;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.hamburger-menu-btn {
    background: none;
    border: none;
    color: var(--clean-white);
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
}

.logo-wrapper {
    display: flex;
    align-items: center;
    cursor: pointer;
    flex-shrink: 0;
}

.search-bar {
    width: 100%;
    display: flex;
    background: var(--clean-white);
    border-radius: 4px;
    overflow: hidden;
    margin-top: 8px;
}

.search-bar input {
    width: 100%;
    padding: 11px 16px;
    border: none;
    outline: none;
    font-size: 14px;
    color: var(--text-primary);
}

.search-bar button {
    background: transparent;
    border: none;
    padding: 0 16px;
    cursor: pointer;
    color: var(--fk-blue);
}

.nav-buttons { display: none; }
.desktop-mega-nav, .hero-carousel-strip, .sidebar { display: none; }

/* ==========================================================================
   🔥 FIXED TOUCH HORIZONTAL SCROLL DECK (NO OVERFLOW/OUT-OF-PAGE SPICE)
   ========================================================================== */
.trending-section-wrapper {
    background: var(--clean-white);
    padding: 16px 12px;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--border-smooth);
    box-shadow: var(--shadow-subtle);
    width: 100%;
    overflow: hidden; /* Strict breakout protection */
}

.section-heading-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}

.section-title {
    font-size: 16px;
    font-weight: 700;
    color: #111;
}

.lightning-timer {
    background: #ffeaea;
    color: #d32f2f;
    font-weight: 700;
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 3px;
}

.trending-scroll-container {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    padding-bottom: 8px;
    -webkit-overflow-scrolling: touch;
    width: 100%;
}
.trending-scroll-container::-webkit-scrollbar { display: none; }

/* Forces horizontal carousel cards to stay uniform and bounded */
.trending-scroll-container .product-card {
    flex: 0 0 155px; /* Rigid constraint prevents squishing or expansion */
    max-width: 155px;
    scroll-snap-align: start;
    box-shadow: none;
    border: 1px solid #edf0f5;
}
.trending-scroll-container .image-wrapper { height: 110px; }

/* ==========================================================================
   🛍️ THE ANTI-OVERLAP CATALOG GRID MATRIX
   ========================================================================== */
.products-container {
    padding: 0 8px;
    margin-top: 8px;
    width: 100%;
    box-sizing: border-box;
}

.products-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr)); /* minmax(0) is critical to prevent contents from pushing columns out of bounds */
    gap: 8px;
    padding: 8px 0;
    width: 100%;
}

/* Explicit vertical stack handling avoids element layering */
.product-card {
    background: var(--clean-white);
    padding: 12px;
    border-radius: var(--radius-card);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    border: 1px solid #edf0f5;
    position: relative;
    cursor: pointer;
    min-width: 0; /* Standardizes flexible layout boundaries */
    height: 100%; /* Keeps all grid blocks uniform */
}

.badge-trending {
    position: absolute;
    top: 8px;
    left: 8px;
    background: #e53935;
    color: var(--clean-white);
    font-size: 9px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 2px;
    z-index: 5;
}

/* Explicit scaling window for dynamic images */
.image-wrapper {
    width: 100%;
    height: 120px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 10px;
    background: #fafafa;
    border-radius: var(--radius-card);
    overflow: hidden;
    flex-shrink: 0;
}
.product-card img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    transition: transform 0.3s ease;
}

/* Dynamic Multiline Truncation Layer fixes overlapping strings */
.product-details-area {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    justify-content: flex-end;
    min-width: 0;
}

.brand-label {
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-weight: 700;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.product-title {
    font-size: 13px;
    font-weight: 400;
    line-height: 1.3;
    color: var(--text-primary);
    margin-bottom: 6px;
    
    /* Elegant multi-line text clamp */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    height: 34px; /* Fixed spacing window allocations prevent pushing up elements */
}

.meta-rating-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
    flex-wrap: wrap;
}
.product-rating {
    background: #26a541;
    color: var(--clean-white);
    font-size: 10px;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 2px;
}
.rating-count {
    font-size: 11px;
    color: var(--text-secondary);
}

.price-row {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap; /* Allows safe drops inside small components */
}
.actual-price { font-size: 14px; font-weight: 700; color: #000; }
.original-price { font-size: 11px; color: var(--text-secondary); text-decoration: line-through; }
.discount-tag { font-size: 11px; color: #388e3c; font-weight: 700; }

/* ==========================================================================
   🛒 PERSISTENT APP BASKET DRAWER ENGINE
   ========================================================================== */
.cart-drawer-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 5000;
    backdrop-filter: blur(3px);
}

.cart-drawer-sidebar {
    position: fixed;
    top: 0;
    right: -330px;
    width: 330px;
    height: 100%;
    background: var(--clean-white);
    z-index: 5500;
    transition: transform var(--transition-smooth);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-shadow: -4px 0 24px rgba(0,0,0,0.15);
}
.cart-drawer-sidebar.open {
    transform: translateX(-330px);
}

.cart-drawer-header {
    padding: 18px 16px;
    border-bottom: 1px solid var(--border-smooth);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.close-cart-drawer-btn { font-size: 28px; background: none; border: none; cursor: pointer; color: #777; }

.cart-drawer-items-list-container {
    flex: 1;
    overflow-y: auto;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.cart-drawer-item-card {
    display: flex;
    gap: 12px;
    background: #f9fbfd;
    padding: 12px;
    border-radius: var(--radius-card);
    border: 1px solid #eef2f7;
    align-items: center;
}
.cart-drawer-item-card img {
    width: 50px;
    height: 50px;
    object-fit: contain;
    background: var(--clean-white);
    border: 1px solid #eef2f7;
    padding: 2px;
}

.cart-item-details { flex: 1; min-width: 0; }
.cart-item-title { font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cart-item-price { font-size: 13px; font-weight: 700; margin-top: 2px; }

.cart-qty-controls-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 6px;
}
.cart-qty-btn {
    background: var(--clean-white);
    border: 1px solid #cbd5e1;
    width: 24px;
    height: 24px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}
.cart-item-qty-lbl { font-size: 13px; font-weight: 700; }
.cart-item-remove-trigger { font-size: 12px; color: #ef4444; cursor: pointer; margin-left: auto; }

.cart-drawer-footer-summary-card { padding: 18px 16px; border-top: 1px solid var(--border-smooth); background: #f8fafc; }
.summary-data-line { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 8px; }
.cart-checkout-trigger-btn {
    width: 100%;
    background: var(--fk-orange);
    color: var(--clean-white);
    border: none;
    padding: 14px;
    font-weight: 700;
    text-transform: uppercase;
    cursor: pointer;
}

/* ==========================================================================
   💳 SECURE COMPACT CHECKOUT INTERFACE VIEW
   ========================================================================== */
.checkout-page-container {
    width: 92%;
    max-width: 520px;
    margin: 16px auto;
    background: var(--clean-white);
    border-radius: var(--radius-premium);
    border: 1px solid var(--border-smooth);
    padding: 16px;
    box-shadow: var(--shadow-subtle);
}
.checkout-card-header h2 { font-size: 16px; font-weight: 700; }
.checkout-amount-display-block {
    background: #f0fdf4;
    padding: 12px;
    border-radius: var(--radius-card);
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 16px 0;
    border: 1px dashed #16a34a;
}
.checkout-amount-display-block h1 { font-size: 22px; color: #15803d; font-weight: 700; }
.checkout-tabs-header-row { display: flex; border-bottom: 2px solid #f1f5f9; margin-bottom: 16px; }
.checkout-tab-btn { flex: 1; padding: 12px; background: none; border: none; font-size: 13px; font-weight: 700; cursor: pointer; color: #64748b; }
.checkout-tab-btn.active { color: var(--fk-blue); border-bottom: 2px solid var(--fk-blue); }
.checkout-tab-content-panel { display: none; }
.checkout-tab-content-panel.active { display: block; }
.form-input-wrapper { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.form-input-wrapper input { padding: 10px; border: 1px solid #cbd5e1; border-radius: var(--radius-card); outline: none; }
.form-input-row-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.execute-payment-action-btn { width: 100%; background: #22c55e; color: var(--clean-white); font-weight: 700; padding: 12px; border: none; cursor: pointer; text-transform: uppercase; }
.checkout-simulation-loader-screen { display: none; position: absolute; inset: 0; background: rgba(255,255,255,0.96); z-index: 100; flex-direction: column; justify-content: center; align-items: center; }
.checkout-simulation-loader-screen.active { display: flex; }
.spinner-object { width: 40px; height: 40px; border: 4px solid #e2e8f0; border-top: 4px solid var(--fk-blue); border-radius: 50%; animation: spinRotate 0.8s linear infinite; }
@keyframes spinRotate { to { transform: rotate(360deg); } }

/* ==========================================================================
   📱 APP BOTTOM BAR NAVIGATION HOTBAR LAYER
   ========================================================================== */
.mobile-bottom-app-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: var(--clean-white);
    border-top: 1px solid var(--border-smooth);
    display: flex;
    z-index: 1200;
    box-shadow: 0 -2px 12px rgba(0,0,0,0.05);
}
.app-bar-tab { flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: center; font-size: 11px; color: #64748b; cursor: pointer; }
.app-bar-tab.active { color: var(--fk-blue); font-weight: 700; }
.tab-icon { font-size: 18px; position: relative; }
.mobile-cart-badge { position: absolute; top: -5px; right: -12px; background: #ef4444; color: var(--clean-white); border-radius: 50%; padding: 1px 5px; font-size: 9px; }

/* Mobile Filter System Sidebar Pull Up */
.sidebar.active {
    display: block !important;
    position: fixed;
    bottom: 56px;
    left: 0;
    right: 0;
    background: white;
    z-index: 2000;
    padding: 16px;
    border-radius: 12px 12px 0 0;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
    animation: slideUp 0.25s ease-out;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

/* --- NAVIGATION DRAWER PANELS --- */
.mobile-nav-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 2500; }
.mobile-nav-drawer { position: fixed; top: 0; left: -270px; width: 270px; height: 100%; background: var(--clean-white); z-index: 2600; transition: transform 0.25s ease-out; padding: 20px; }
.mobile-nav-drawer.open { transform: translateX(270px); }
.drawer-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; border-bottom: 1px solid #f1f5f9; padding-bottom: 12px; }
.close-drawer-btn { font-size: 26px; background: none; border: none; cursor: pointer; }
.drawer-links { list-style: none; }
.drawer-links li { padding: 14px 0; border-bottom: 1px solid #f8fafc; }
.drawer-links a { text-decoration: none; color: var(--text-primary); font-weight: 500; display: block; font-size: 14px; }

/* --- OVERLAY MODALS --- */
.modal { margin: auto; border: none; border-radius: var(--radius-premium); width: 92%; max-width: 420px; padding: 20px; box-shadow: var(--shadow-elevated); }
.modal::backdrop { background: rgba(0, 0, 0, 0.5); backdrop-filter: blur(2px); }
.close-modal { float: right; background: none; border: none; font-size: 26px; cursor: pointer; color: var(--text-secondary); }
.add-cart-btn { padding: 12px; width: 100%; font-weight: 700; border-radius: 2px; cursor: pointer; text-transform: uppercase; border: none; background: #ff9f00; color: #fff; margin-top: 12px; }

/* ==========================================================================
   🖥️ DESKTOP RESPONSIVE RE-BALANCING MATRIX (768px+)
   ========================================================================== */
@media (min-width: 768px) {
    body { padding-bottom: 0; }
    
    .nav-container { width: 85%; max-width: 1440px; gap: 24px; }
    .hamburger-menu-btn, .mobile-bottom-app-bar, .mobile-nav-backdrop { display: none !important; }
    
    .search-bar { margin-top: 0; flex: 1; max-width: 550px; }
    .nav-buttons { display: flex; align-items: center; gap: 24px; }
    
    .cart-icon-desktop {
        color: var(--clean-white);
        font-weight: 700;
        cursor: pointer;
        background: rgba(255, 255, 255, 0.16);
        padding: 9px 18px;
        border-radius: var(--radius-card);
        font-size: 13px;
    }

    .desktop-mega-nav {
        display: block;
        background: var(--clean-white);
        box-shadow: var(--shadow-subtle);
        padding: 14px 0;
        border-bottom: 1px solid var(--border-smooth);
    }
    .mega-nav-container { width: 85%; max-width: 1440px; margin: 0 auto; display: flex; gap: 36px; }
    .mega-item { font-size: 14px; font-weight: 500; cursor: pointer; color: #444; }
    .mega-item:hover, .mega-item.active { color: var(--fk-blue); font-weight: 700; }

    .hero-carousel-strip {
        display: block;
        width: 85%;
        max-width: 1440px;
        margin: 16px auto 0 auto;
        background: linear-gradient(90deg, #1e3c72 0%, #2a5298 100%);
        border-radius: var(--radius-card);
        color: var(--clean-white);
    }
    .carousel-slide { padding: 36px; min-height: 140px; display: flex; align-items: center; }
    .promo-text-wrap h2 { font-size: 24px; }

    /* Layout Split Dynamic Framing */
    .main-layout { display: flex; width: 85%; max-width: 1440px; margin: 20px auto; gap: 20px; align-items: flex-start; }
    
    .sidebar {
        display: block !important;
        position: static !important;
        width: 260px;
        flex-shrink: 0;
        background: var(--clean-white);
        padding: 18px;
        box-shadow: var(--shadow-subtle);
        border-radius: var(--radius-card);
        border: 1px solid var(--border-smooth);
        animation: none;
    }
    .sidebar-header { display: none; }
    .divider { border: 0; height: 1px; background: #f1f5f9; margin: 14px 0; }
    .filter-section h4 { font-size: 11px; text-transform: uppercase; color: var(--text-secondary); margin-bottom: 10px; font-weight: 700; }
    .form-select { width: 100%; padding: 8px; border: 1px solid #cbd5e1; border-radius: 4px; font-size: 13px; }
    .filter-section label { display: flex; align-items: center; gap: 8px; margin: 10px 0; font-size: 13px; cursor: pointer; }
    .slider { width: 100%; }
    .price-indicator { font-weight: 700; color: var(--fk-blue); margin-top: 8px; font-size: 13px; }

    /* Transform touch rows back into clean structural column metrics on desktop grids */
    .trending-scroll-container {
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 12px;
        overflow-x: visible;
        padding-bottom: 0;
    }
    .trending-scroll-container .product-card { min-width: auto; max-width: none; padding: 14px; }
    .trending-scroll-container .image-wrapper { height: 140px; }

    /* General Layout Grids */
    .products-container { padding: 0; margin-top: 0; flex: 1; min-width: 0; }
    .products-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; padding: 0; }
    .image-wrapper { height: 160px; }
    .product-card:hover img { transform: scale(1.04); }
    
    .checkout-page-container { margin: 40px auto; padding: 32px; }
    .cart-drawer-sidebar { width: 380px; right: -380px; }
    .cart-drawer-sidebar.open { transform: translateX(-380px); }
}

@media (min-width: 1200px) {
    .products-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}