/* =========================================
   WARAP MOBILE UX (The "App-like" Experience)
   ========================================= */

@media (max-width: 768px) {

    /* --- 1. GLOBAL TOUCH & INPUTS --- */

    /* Avoid zoom on iOS inputs */
    input,
    select,
    textarea,
    button {
        font-size: 16px !important;
    }

    /* Larger touch targets for all buttons */
    .btn,
    button,
    .nav-link,
    .mobile-nav-link,
    input[type="submit"],
    input[type="button"],
    input[type="reset"] {
        min-height: 48px;
        /* Recommended touch target size */
        display: inline-flex;
        align-items: center;
        justify-content: center;

        /* FIX: Remove default OS styling (surrounded look) */
        -webkit-appearance: none;
        -moz-appearance: none;
        appearance: none;
        outline: none !important;
        border: none;
        background-color: transparent;
        /* Reset default gray bg */
    }

    /* Restore background for specific classes if needed, usually handled by component CSS */
    .btn-modern,
    .btn-primary,
    .btn-gold {
        border: 1px solid transparent;
        /* Clean border for styled buttons */
    }

    button:focus,
    .btn:focus,
    input:focus {
        outline: none !important;
        -webkit-tap-highlight-color: transparent;
    }

    /* Smoother scrolling */
    html,
    body {
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
    }

    /* --- 2. BOTTOM NAVIGATION BAR (The Core Feature) --- */
    body {
        padding-bottom: calc(85px + env(safe-area-inset-bottom, 20px));
        /* Space for the bar + extra breathing room */
    }

    .mobile-bottom-nav {
        display: flex;
        /* Visible only on mobile via media query */
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        /* Ensure full width anchor */
        width: 100%;
        height: calc(65px + env(safe-area-inset-bottom, 0px));
        background: #ffffff;
        border-top: 1px solid #e2e8f0;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.08);
        z-index: 10001;
        /* Higher than everything */
        justify-content: space-around;
        align-items: center;
        /* Center vertically in the available space */
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }

    .nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        color: #64748b;
        font-size: 0.7rem;
        font-family: 'Inter', sans-serif;
        font-weight: 500;
        text-decoration: none;
        flex: 1;
        height: 100%;
        transition: color 0.2s;
    }

    .nav-item i {
        font-size: 1.3rem;
        margin-bottom: 4px;
        transition: transform 0.2s;
    }

    .nav-item.active {
        color: #6366f1;
        /* Primary Color */
    }

    .nav-item.active i {
        transform: translateY(-2px);
    }

    /* "Vendre" Special Button */
    .nav-item.sell-btn {
        position: relative;
        top: -20px;
    }

    .nav-item.sell-btn .sell-icon-circle {
        width: 56px;
        height: 56px;
        background: linear-gradient(135deg, #f59e0b, #d97706);
        /* Gold Gradient */
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        color: white;
        box-shadow: 0 4px 12px rgba(245, 158, 11, 0.4);
        border: 4px solid #fff;
        /* Space around */
    }

    .nav-item.sell-btn i {
        font-size: 1.4rem;
        margin: 0;
        margin-bottom: 0;
    }

    .nav-item.sell-btn span {
        position: absolute;
        bottom: -18px;
        width: 100%;
        text-align: center;
    }

    /* --- 3. STICKY SEARCH BAR (Marketplace) --- */
    /* Ensure the search bar sticks to the top below the header if needed, 
       or replace header on scroll. For now, let's make the container sticky */
    .search-container {
        position: sticky;
        top: 0;
        z-index: 990;
        background: var(--bg-card, #fff);
        padding: 10px;
        margin-top: -1px;
        /* Hack to remove gap */
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    }

    .search-input {
        height: 44px !important;
        border-radius: 22px !important;
        background: #f1f5f9;
        border: none !important;
    }

    /* --- 4. STEPPER & POST LISTING --- */
    /* Floating Action Button logic for Next/Submit */
    .submit-section,
    .modal-actions {
        position: fixed;
        bottom: 70px;
        /* Above nav bar */
        left: 0;
        width: 100%;
        background: white;
        padding: 15px;
        border-top: 1px solid #eee;
        z-index: 1000;
        display: flex;
        justify-content: space-between;
        gap: 10px;
        box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.05);
    }

    /* Add padding to body page to prevent content hidden behind sticky footer */
    body.has-sticky-footer {
        padding-bottom: 150px;
    }

    /* --- 5. MODALS AS BOTTOM SHEETS --- */
    .modal-content,
    .auth-modal-content {
        width: 100% !important;
        max-width: 100% !important;
        height: auto;
        min-height: 50vh;
        max-height: 90vh;
        border-radius: 20px 20px 0 0 !important;
        position: fixed !important;
        bottom: 0 !important;
        top: auto !important;
        left: 0 !important;
        margin: 0 !important;
        transform: translateY(100%);
        transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    }

    .modal-overlay.active .modal-content,
    .modal-overlay.active .auth-modal-content,
    .auth-modal.show .auth-modal-content,
    .modal.show .modal-content {
        transform: translateY(0);
    }

    /* Close button for sheets */
    .modal-close,
    .auth-close {
        top: 15px;
        right: 15px;
        background: #f1f5f9;
        width: 32px;
        height: 32px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* --- 6. FLOATING WHATSAPP & THEME TOGGLE --- */
    /* Adjust position to be above bottom bar */
    .wa-float {
        bottom: 90px !important;
        /* Raised slightly more */
        z-index: 995;
        /* Below modals (9999/10000) but above content */
        right: 20px !important;
    }

    .theme-toggle {
        bottom: 160px !important;
        /* Stack above WhatsApp */
        right: 20px !important;
        width: 45px !important;
        height: 45px !important;
        font-size: 18px !important;
        z-index: 995;
    }
}

/* Desktop: Hide Bottom Nav */
@media (min-width: 769px) {
    .mobile-bottom-nav {
        display: none;
    }
}