/**
 * 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 {
        padding: 2rem 1rem;
    }

    #nx-help-modal .nx-modal-content {
        padding: 8px 6px;
    }

    .nx-intel-tip {
        margin: unset;
    }

    .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-links {
        display: none;
    }

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

/* 5. MODAL & QR RESPONSIVE */
@media screen and (max-width: 480px) {
    .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 (Centering & Stability) */
@media screen and (max-width: 1150px) {
    .main-navigation {
        top: 8px !important;
        left: 8px !important;
        right: 8px !important;
        width: auto !important;
        transform: none !important;
        margin: 0 !important;
        padding: 4px 8px !important;
        box-sizing: border-box !important;
        border-radius: 12px !important;
    }

    .nav-brand {
        font-size: 1rem !important;
        flex-shrink: 1 !important;
        padding-left: 8px;
    }

    .nav-brand span {}

    .nav-links {
        position: fixed;
        top: 60px;
        left: 89px !important;
        width: 213px;
        height: auto;
        background: var(--nav-bg);
        backdrop-filter: blur(125px);
        flex-direction: column;
        align-items: stretch;
        padding: 13px 12px;
        /* display: none; */
        border-bottom: 1px solid var(--glass-border);
        z-index: 1001;
    }

    .nav-links.is-active {
        top: 58px !important;
        left: 16px !important;
        right: 0 !important;
        opacity: 1;
        border-radius: 0 0 12px 12px !important;
    }

    .btn-primary {
        padding: 9px 12px !important;
        font-size: 11px !important;
    }
}

@media screen and (max-width: 600px) {
    .nav-links.is-active {
        display: flex !important;
        align-items: stretch !important;
    }
}

/* 9. FOOTER CLEANUP */
@media screen and (max-width: 768px) {
    .footer-top {
        flex-direction: column !important;
        text-align: center !important;
        gap: 32px !important;
    }

    .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;
    }
}


/* 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;
}