/**
 * Marketplace Responsive & RTL Architecture
 * UI-01: Breakpoints & Internationalization
 *
 * Breakpoints:
 * - Mobile: < 640px
 * - Tablet: 640px - 1023px
 * - Desktop: 1024px+
 * - Large Desktop: 1280px+
 *
 * @package Marketplace_Child
 */

/* =========================================================================
   1. TABLET BREAKPOINT (640px - 1023px)
   ========================================================================= */

@media (max-width: 1023px) {
    .container,
    .col-full {
        padding-inline: var(--container-pad-tablet);
    }

    /* Product Grid: 3 columns on tablet */
    .grid-products,
    ul.products {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: var(--space-4) !important;
    }

    /* Store Grid: 2 columns on tablet */
    .grid-stores,
    .dokan-seller-wrap {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    /* Category Grid: 3 columns on tablet */
    .grid-categories {
        grid-template-columns: repeat(3, 1fr);
    }

    .site-header .col-full {
        gap: var(--space-4);
    }
}

/* =========================================================================
   2. SMALL TABLET BREAKPOINT (640px - 768px)
   ========================================================================= */

@media (max-width: 768px) {
    /* Product Grid: 2 columns on small tablet */
    .grid-products,
    ul.products {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    /* Cart & Checkout Stacking */
    .woocommerce-cart-form,
    .cart-collaterals,
    .woocommerce-checkout #customer_details,
    .woocommerce-checkout #order_review_heading,
    .woocommerce-checkout #order_review {
        width: 100% !important;
        float: none !important;
    }

    /* Table Horizontal Scroll */
    .table-responsive,
    .shop_table.cart,
    .shop_table.woocommerce-checkout-review-order-table,
    .woocommerce-orders-table,
    .dokan-table {
        display: block !important;
        width: 100% !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
    }
}

/* =========================================================================
   3. MOBILE BREAKPOINT (< 640px)
   ========================================================================= */

@media (max-width: 639px) {
    .container,
    .col-full {
        padding-inline: var(--container-pad-mobile);
    }

    /* Header Mobile Layout */
    .site-header .col-full {
        flex-wrap: wrap;
        padding-block: var(--space-2);
        gap: var(--space-3);
    }

    .mp-main-header-row .container {
        flex-direction: column;
        align-items: stretch !important;
        gap: var(--space-3) !important;
    }

    .mp-header-logo {
        justify-content: center;
    }

    .mp-header-search {
        max-width: 100% !important;
        width: 100% !important;
    }

    .mp-header-actions {
        justify-content: space-around;
        width: 100%;
    }

    .mp-category-navigation-bar .container {
        padding-inline: var(--space-2);
    }

    .header-search-wrap,
    .marketplace-search-form {
        order: 3;
        max-width: 100%;
        width: 100%;
    }

    /* Product Grid: 2 columns on mobile */
    .grid-products,
    ul.products {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: var(--space-3) !important;
    }

    /* Store Grid: 1 column on mobile */
    .grid-stores,
    .dokan-seller-wrap {
        grid-template-columns: 1fr !important;
    }

    /* Category Grid: 2 columns on mobile */
    .grid-categories {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Buttons minimum touch target */
    .btn,
    .button,
    input[type="submit"] {
        min-height: 44px;
        width: 100%;
        justify-content: center;
    }

    /* Modal Mobile Full Width */
    .modal-dialog {
        width: 95%;
        padding: var(--space-4);
    }

    /* Footer Mobile Stacking */
    .site-footer .footer-bottom {
        flex-direction: column;
        gap: var(--space-3);
        text-align: center;
    }
}

/* =========================================================================
   4. SMALL MOBILE (< 400px)
   ========================================================================= */

@media (max-width: 399px) {
    .grid-products,
    ul.products {
        grid-template-columns: 1fr !important;
    }
}

/* =========================================================================
   5. LARGE DESKTOP (1280px+)
   ========================================================================= */

@media (min-width: 1280px) {
    .container-wide {
        max-width: var(--container-max-lg);
    }
}

/* =========================================================================
   6. RTL (RIGHT-TO-LEFT) READINESS
   Logical properties and direction mirroring for Urdu/Arabic localization
   ========================================================================= */

[dir="rtl"] {
    text-align: right;
}

[dir="rtl"] .star-rating {
    float: right;
}

[dir="rtl"] .header-search-btn {
    inset-inline-end: 4px;
    inset-inline-start: auto;
}

[dir="rtl"] .arrow-right {
    transform: rotate(180deg);
}

[dir="rtl"] .product-card-vendor,
[dir="rtl"] .sold-by-meta {
    text-align: right;
}

/* =========================================================================
   7. P11: MOBILE APP BOTTOM NAVIGATION & APP-LIKE PWA UX
   ========================================================================= */

.mp-mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: #ffffff;
    border-top: 1px solid #e2e8f0;
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.06);
    z-index: 99999;
    justify-content: space-around;
    align-items: center;
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

.mp-nav-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    height: 100%;
    color: #64748b;
    text-decoration: none;
    background: none;
    border: none;
    padding: 4px;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: color 0.15s ease;
}

.mp-nav-tab:hover,
.mp-nav-tab.active {
    color: #166534;
}

.mp-nav-icon,
.mp-nav-label-icon {
    font-size: 19px;
    margin-bottom: 2px;
    line-height: 1;
}

.mp-cart-icon-wrap {
    position: relative;
    display: inline-block;
}

.mp-cart-badge {
    position: absolute;
    top: -5px;
    right: -9px;
    background: #dc2626;
    color: #ffffff;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 10px;
}

/* P11 Offline Toast */
.mp-offline-toast {
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    background: #0f172a;
    color: #ffffff;
    padding: 10px 18px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    z-index: 100000;
    box-shadow: 0 4px 14px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* P11 PWA Install Prompt Banner */
.mp-pwa-install-banner {
    position: fixed;
    bottom: 68px;
    left: 12px;
    right: 12px;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 12px;
    padding: 12px 16px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    z-index: 99998;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.mp-install-content {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
}

.mp-install-content p {
    margin: 2px 0 0;
    font-size: 11px;
    color: #64748b;
}

.mp-install-actions {
    display: flex;
    gap: 6px;
}

@media (max-width: 768px) {
    .mp-mobile-bottom-nav {
        display: flex;
    }
    body {
        padding-bottom: 64px; /* Ensure content does not hide behind mobile bottom bar */
    }
}

