/* ==========================================================================
   GasanDisk - Market V3 Mobile Stylesheet
   Responsive enhancements for smartphones and tablets (< 992px)
   ========================================================================== */

@media (max-width: 991.98px) {
    /* --------------------------------------------------------------------------
       1. General Layout & Safe Areas
       -------------------------------------------------------------------------- */
    body {
        padding-bottom: calc(65px + env(safe-area-inset-bottom, 15px)) !important;
        overflow-x: hidden;
    }

    .container, .container-fluid {
        padding-left: 12px;
        padding-right: 12px;
    }

    /* --------------------------------------------------------------------------
       2. Mobile Sticky Header & Topbar
       -------------------------------------------------------------------------- */
    .market-mobile-header {
        background-color: var(--mv3-bg-card, #ffffff) !important;
        border-bottom: 1px solid var(--mv3-border, rgba(0, 0, 0, 0.08)) !important;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
        transition: background-color 0.3s ease, border-color 0.3s ease;
    }

    html.dark .market-mobile-header {
        background-color: var(--mv3-bg-dark, #0f172a) !important;
        border-bottom-color: rgba(255, 255, 255, 0.08) !important;
    }

    html.dark .market-mobile-header .text-dark {
        color: #f8fafc !important;
    }

    html.dark .market-mobile-header .bg-light {
        background-color: rgba(255, 255, 255, 0.06) !important;
        border-color: rgba(255, 255, 255, 0.1) !important;
    }

    html.dark .market-mobile-header input[type="search"] {
        color: #f8fafc !important;
    }

    /* --------------------------------------------------------------------------
       3. Offcanvas Navigation Drawer
       -------------------------------------------------------------------------- */
    .market-mobile-drawer {
        background-color: var(--mv3-bg-card, #ffffff);
        color: var(--mv3-text, #1e293b);
        box-shadow: 0 0 25px rgba(0, 0, 0, 0.25);
    }

    html.dark .market-mobile-drawer {
        background-color: var(--mv3-bg-dark, #0f172a) !important;
        color: #f8fafc !important;
    }

    html.dark .market-mobile-drawer .list-group-item {
        background-color: transparent !important;
        color: #e2e8f0 !important;
    }

    html.dark .market-mobile-drawer .list-group-item:hover,
    html.dark .market-mobile-drawer .list-group-item:active {
        background-color: rgba(255, 255, 255, 0.05) !important;
        color: var(--mv3-primary, #3b82f6) !important;
    }

    html.dark .market-mobile-drawer .bg-light {
        background-color: rgba(255, 255, 255, 0.04) !important;
        border-color: rgba(255, 255, 255, 0.08) !important;
    }

    /* --------------------------------------------------------------------------
       4. Floating Mobile Bottom Navigation
       -------------------------------------------------------------------------- */
    .mobile-bottom-nav {
        background-color: var(--mv3-bg-card, #ffffff) !important;
        backdrop-filter: blur(16px);
        -webkit-backdrop-filter: blur(16px);
        border-top: 1px solid var(--mv3-border, rgba(0, 0, 0, 0.08));
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.06) !important;
        height: calc(56px + env(safe-area-inset-bottom, 0px)) !important;
        padding-bottom: env(safe-area-inset-bottom, 0px) !important;
        padding-left: 6px;
        padding-right: 6px;
    }

    html.dark .mobile-bottom-nav {
        background-color: rgba(15, 23, 42, 0.95) !important;
        border-top-color: rgba(255, 255, 255, 0.08) !important;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.35) !important;
    }

    .mobile-nav-item {
        color: var(--mv3-text-muted, #64748b) !important;
        font-size: 0.7rem !important;
        font-weight: 500;
        transition: all 0.2s ease;
        padding: 0 4px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .mobile-nav-item.active {
        color: var(--mv3-primary, #3b82f6) !important;
        font-weight: 700 !important;
        transform: translateY(-2px);
    }

    .mobile-nav-cart-btn {
        width: 46px !important;
        height: 46px !important;
        margin-top: -16px !important;
        background: linear-gradient(135deg, var(--mv3-primary, #3b82f6), #1d4ed8) !important;
        box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35) !important;
        border: 3px solid var(--mv3-bg-card, #ffffff);
        transition: transform 0.2s ease;
        flex-shrink: 0;
    }

    .mobile-nav-cart-btn:active {
        transform: scale(0.92);
    }

    /* --------------------------------------------------------------------------
       5. Product Card Grid & Carousel Responsive Adjustments
       -------------------------------------------------------------------------- */
    .el-products-grid,
    .el-product-grid,
    .products-grid,
    .market-v3-listing__grid {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px !important;
    }

    .el-product-card,
    .product-card,
    .market-v3-product-card {
        border-radius: 0.75rem !important;
        padding: 0.5rem !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: space-between !important;
        background-color: var(--mv3-bg-card, #ffffff) !important;
        border: 1px solid var(--mv3-border, rgba(0, 0, 0, 0.08)) !important;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03) !important;
        overflow: hidden;
    }

    .market-v3-product-card__img-wrap,
    .el-product-card__img-wrap {
        aspect-ratio: 1 / 1 !important;
        width: 100% !important;
        border-radius: 0.5rem !important;
        overflow: hidden;
        position: relative;
        background-color: #f8fafc;
        display: flex;
        align-items: center;
        justify-content: center;
        margin-bottom: 0.4rem !important;
    }

    .market-v3-product-card__img,
    .el-product-card__img {
        max-height: 100% !important;
        max-width: 100% !important;
        object-fit: contain !important;
    }

    .el-product-card__wishlist {
        position: absolute !important;
        top: 6px !important;
        inset-inline-end: 6px !important;
        width: 28px !important;
        height: 28px !important;
        border-radius: 50% !important;
        background: rgba(255, 255, 255, 0.9) !important;
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12) !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        color: #64748b !important;
        z-index: 3;
    }

    .el-product-card__title,
    .product-title,
    .market-v3-product-card__title {
        font-size: 0.82rem !important;
        line-height: 1.35 !important;
        height: 2.7em !important;
        overflow: hidden;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        margin: 0.25rem 0 !important;
        font-weight: 600 !important;
        text-align: center !important;
    }

    .el-product-card__stars,
    .product-rating {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 3px !important;
        font-size: 0.72rem !important;
        color: #f59e0b !important;
        margin: 2px 0 6px !important;
    }

    .el-product-card__price-row {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 4px !important;
        margin-bottom: 6px !important;
        white-space: nowrap !important;
    }

    .el-product-card__price,
    .product-price,
    .market-v3-product-card__price {
        font-size: 0.95rem !important;
        font-weight: 800 !important;
        color: var(--mv3-primary, #dc2626) !important;
        white-space: nowrap !important;
    }

    .el-product-card__price-old {
        font-size: 0.72rem !important;
        text-decoration: line-through !important;
        color: #94a3b8 !important;
        white-space: nowrap !important;
    }

    .el-product-card__actions-stack {
        display: flex !important;
        align-items: center !important;
        gap: 4px !important;
        width: 100% !important;
        margin-top: auto !important;
    }

    .el-product-card__cart,
    .market-v3-product-card__cart {
        flex: 1 !important;
        padding: 0.35rem 0.5rem !important;
        font-size: 0.78rem !important;
        border-radius: 6px !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 4px !important;
        min-height: 34px !important;
        font-weight: 700 !important;
    }

    .el-product-card__wa-share {
        width: 34px !important;
        height: 34px !important;
        border-radius: 6px !important;
        padding: 0 !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        flex-shrink: 0 !important;
    }

    /* --------------------------------------------------------------------------
       6. Product Details Page (PDP) Mobile Refinements
       -------------------------------------------------------------------------- */
    .pdp-gallery-card {
        border-radius: 1rem !important;
        margin-bottom: 1rem;
    }

    .pdp-main-image-wrapper {
        min-height: 260px !important;
        max-height: 320px !important;
    }

    .pdp-trust-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.5rem !important;
    }

    .pdp-trust-card {
        padding: 0.75rem 0.5rem !important;
    }

    .pdp-trust-card i {
        font-size: 1.25rem !important;
    }

    .pdp-trust-title {
        font-size: 0.78rem !important;
    }

    /* --------------------------------------------------------------------------
       7. RTL Mobile Refinements (Arabic)
       -------------------------------------------------------------------------- */
    html[dir="rtl"] .el-product-card__rating {
        flex-direction: row-reverse;
        justify-content: flex-end;
    }

    html[dir="rtl"] .market-mobile-drawer.offcanvas-end {
        border-left: 1px solid rgba(0, 0, 0, 0.08);
    }
}
