/**
 * NEXUS PRIME - MOBILE ADAPTATION LAYER
 * This file handles all responsive overrides to ensure the marketplace 
 * is high-fidelity on mobile devices without touching main.css core logic.
 */

/* 1. GLOBAL LAYOUT RESET (Tablets & Phones < 992px) */
@media screen and (max-width: 991px) {
    .detail-tactical-layout {
        display: flex;
        flex-direction: column !important;
        gap: 24px;
    }

    .prop-sidebar {
        order: -1;
        position: static !important;
        width: -webkit-fill-available;
        max-width: -webkit-fill-available;
    }

    .prop-main {
        display: flex;
        width: 100% !important;
    }

    /* Header & Title Adjustments */
    .detail-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 15px !important;
        padding-bottom: 20px !important;
    }

    .detail-main-title {
        font-size: 1.6rem !important;
        width: 100%;
        line-height: 1.3 !important;
        margin-top: 10px !important;
    }

    .premium-listing-actions {
        width: 100% !important;
        flex-direction: row !important;
        justify-content: flex-start !important;
        gap: 20px !important;
    }

    /* Meta Grid: Force 2 columns on all mobile/tablet */
    .detail-meta-grid {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 15px !important;
        width: 100% !important;
        padding: 20px 0 !important;
        border-top: 1px solid var(--glass-border) !important;
        border-bottom: 1px solid var(--glass-border) !important;
        align-items: start;
    }

    .detail-meta-item {
        border: none !important;
        width: auto !important;
        text-align: center !important;
    }

    /* Card & Description: Remove problematic fixed heights */
    .nx-app-card {
        max-height: none !important;
        margin-bottom: 24px !important;
    }

    .nx-app-card form {
        padding: 24px 4px;
    }

    .detail-description {
        font-size: 1rem !important;
        line-height: 1.7 !important;
        padding: 15px 0 !important;
        color: var(--text-primary) !important;
    }

    .nx-app-card-header {
        padding: 15px !important;
        border-bottom: 1px solid var(--glass-border) !important;
    }

    /* Intel Box: Fix width and bleeding */
    .intel-box {
        width: 100% !important;
        box-sizing: border-box !important;
        padding: 15px !important;
        margin: 15px 0 !important;
        border-radius: 12px !important;
        background: var(--bg-accent) !important;
    }

    .intel-box-title {
        font-size: 0.85rem !important;
        margin-bottom: 8px !important;
    }
}


/* 2. GALLERY MOBILE (Phones < 768px) */
@media screen and (max-width: 767px) {
    #nx-help-modal .nx-modal-content {
        padding: 2.5rem 1.5rem !important;
        max-width: 90% !important;
        margin: auto;
    }

    .nx-intel-tip {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .premium-gallery-container {
        grid-template-columns: 1fr !important;
        grid-template-rows: 280px !important;
        height: auto !important;
        border-radius: 0;
        margin: 0 -15px 24px -15px !important;
    }

    .premium-gallery-item:not(.premium-gallery-main) {
        display: none !important;
    }

    .premium-gallery-main {
        grid-column: 1 / -1 !important;
        /* grid-row: 1 / -1 !important; */
    }

    .premium-gallery-view-all {
        bottom: 12px;
        right: 12px;
        font-size: 11px;
        padding: 4px 10px;
    }
}

o
/* 3. BOOKING WIDGET (Phones < 600px) */
@media screen and (max-width: 599px) {
    .premium-review-grid {
        grid-template-columns: 1fr !important;
    }

    .premium-booking-widget {
        padding: 15px !important;
        border-radius: 15px !important;
    }

    .premium-booking-price-value {
        font-size: 18px !important;
    }

    .premium-booking-field {
        min-width: 100% !important;
        border-right: none !important;
    }
}

/* 4. NAVBAR & FOOTER MOBILE TWEAKS */
@media screen and (max-width: 768px) {
    .nav-container {
        flex-direction: column !important;
        align-items: stretch !important;
        padding: 0 !important;
        gap: 1px !important;
    }



    .nav-brand i,
    .nav-brand svg {
        width: 22px;
        height: 22px;
    }

    /* Horizontal Scroll Navigation */
    .nav-links {}

    .nav-links::-webkit-scrollbar {
        display: none !important;
        /* Hide scrollbar for Chrome/Safari */
    }

    .nav-links li {
        scroll-snap-align: center !important;
        flex: 0 0 auto !important;
    }

    .nav-links li a {}

    .nav-links li a:active {
        transform: scale(0.95);
    }

    /* Stabilize Right Nav (Login/User) */
    .nav-right {
        padding: 5px 15px !important;
        width: 100% !important;
        gap: 15px !important;
        justify-content: flex-end;
        top: 66px;
    }

    .nav-right .btn-primary {
        width: 100% !important;
        max-width: 200px !important;
        text-align: center !important;
        padding: 7px 12px !important;
        border-radius: 7px !important;
    }

    .mobile-nav-toggle {
        display: none !important;
        /* No longer needed with horizontal scroll */
    }

    .listing-grid {
        grid-template-columns: 1fr !important;
    }
}

/* 4.1 LEGIBILITY & CONTRAST REFINEMENTS */
[data-theme="light"] .nav-links li a {
    background: var(--area-product-bg);
    border-color: #e2e8f0 !important;
    color: var(--text-primary);
}

[data-theme="dark"] .nav-links li a {
    background: rgba(255, 255, 255, 0.05) !important;
    border-color: rgba(255, 255, 255, 0.1) !important;
    color: #f1f5f9 !important;
}


/* 5. MODAL & QR RESPONSIVE */
@media screen and (max-width: 480px) {
    .nav-container {
        gap: 16px !important;
    }

    .nexus-modal-content {
        padding: 24px 16px !important;
        width: 92% !important;
        border-radius: 16px !important;
    }

    #qr-large-img {
        max-width: 200px !important;
    }
}

/* 6. HOMEPAGE & FEED SPECIALS */
@media screen and (max-width: 991px) {

    h1,
    h2,
    h3,
    h4,
    p {
        font-size: 95% !important;
    }

    .hero-title {
        font-size: 27px !important;
        padding: 0 10px !important;
    }

    .nx-matchmaking-matrix {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
        padding: 0 12px !important;
    }

    .portal-stats-grid {
        grid-template-columns: 1fr 1fr !important;
        gap: 16px !important;
    }

    .listing-card {
        border-radius: 0 !important;
        margin-bottom: 16px !important;
    }
}

/* 8. GLOBAL NAVIGATION - REMOVED LEGACY CONFLICTS */
@media screen and (max-width: 1150px) {
    /* No-op: Overridden by Section 4 (Horizontal Scroll) */
}

/* 9. FOOTER CLEANUP */
.main-footer {
    padding: 4rem 1rem 8rem 1rem !important;
    margin-top: var(--gap-xl) !important;
}

.footer-top {
    flex-direction: column !important;
    text-align: center !important;
    gap: 32px !important;
}

.footer-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.footer-links ul {
    align-items: center;
}

.footer-bottom {
    flex-direction: column !important;
    text-align: center !important;
}
}

/* 10. BUTTONS & INPUTS UNIFORMITY */
@media screen and (max-width: 480px) {

    .btn-primary,
    .form-control {
        width: 100% !important;
    }

    .hero-search-container {
        display: flex;
        width: 100% !important;
        border-radius: 12px !important;
        flex-direction: row;
        align-items: center;
    }

    .hero-search-container input {
        padding: 12px !important;
    }

    .hero-search-container button {
        padding: 10px 13px !important;
        margin: unset;
        height: unset;
        width: unset;
    }
}


/* 12. AGENT TRIGGER ADAPTATION */
@media screen and (max-width: 768px) {
    .nx-agent-trigger {
        bottom: 5rem !important;
        right: 1rem !important;
        width: 50px !important;
        height: 50px !important;
        z-index: 1000;
    }
}


/* 11. APPS & PM SIDEBAR STABILITY (RESTORE SEMANTIC BALANCE) */
@media screen and (max-width: 991px) {

    /* Preserve Sidebar on the LEFT - DO NOT move to bottom */
    .nx-app-shell {
        display: flex !important;
        flex-direction: row !important;
        height: 100vh !important;
        overflow: hidden !important;
    }

    .nx-app-sidebar {
        width: 80px !important;
        position: relative !important;
        top: 0 !important;
        bottom: 0 !important;
        height: 100% !important;
        flex-shrink: 0 !important;
        display: flex !important;
        flex-direction: column !important;
        padding: 1px 0 !important;
        background: var(--sidebar-bg) !important;
        border-right: 1px solid var(--glass-border) !important;
    }

    /* Force icon-only mode for compact aside */
    .nx-app-sidebar .nx-app-logo span,
    .nx-app-sidebar .nx-app-nav-label,
    .nx-app-sidebar .nx-app-nav-link span,
    .nx-app-sidebar-footer {
        display: none !important;
    }

    .nx-app-nav-link {
        justify-content: center !important;
        padding: 15px 0 !important;
    }

    .nx-app-workspace {
        flex: 1 !important;
        height: 100% !important;
        overflow-y: auto !important;
    }

    .nx-app-header-bar {
        margin-left: 1rem !important;
        margin-right: 1rem !important;
        display: flex;
        position: relative;
        top: 0 !important;
        width: -webkit-fill-available;
    }
}

/* Specific Tablet adjustments for PM Aside visibility */
@media screen and (min-width: 769px) and (max-width: 1200px) {
    .nx-app-sidebar {
        width: 80px !important;
    }
}


/* Ensure detail sidebar stays top only on detail pages, not in PM app aside */
.is-pm-theme .prop-sidebar {
    order: unset !important;
}