/* =========================================
   NEXUS RESPONSIVE — Mobile, Tablet, Desktop
   ========================================= */

/* ── 1280px and below: shrink sidebars ───── */
@media (max-width: 1280px) {
    :root {
        --nx-sidebar-left-width: 240px;
        --nx-sidebar-right-width: 300px;
    }
    .nx-search-input { width: 180px; }
    .nx-search-input:focus { width: 220px; }
    .nx-nav-tab { width: 80px; }
}

/* ── 1024px and below: hide right sidebar ── */
@media (max-width: 1024px) {
    .nx-logged-in .nx-page-wrapper {
        grid-template-columns: var(--nx-sidebar-left-width) 1fr;
        grid-template-areas: "sidebar-left content";
    }
    .nx-sidebar-right { display: none; }
    .nx-main-content { max-width: 100%; }
}

/* ── 768px and below: hide left sidebar, show mobile nav ── */
@media (max-width: 768px) {
    :root { --nx-topbar-height: 52px; }

    .nx-logged-in .nx-page-wrapper {
        grid-template-columns: 1fr;
        grid-template-areas: "content";
        margin-bottom: 60px; /* mobile nav height */
    }
    .nx-sidebar-left  { display: none; }
    .nx-sidebar-right { display: none; }

    /* Topbar adjustments */
    .nx-topbar-center { display: none; }
    .nx-search-wrap   { display: none; }
    .nx-logo-text { font-size: 1.125rem; }

    /* Mobile bottom nav */
    .nx-mobile-nav {
        display: flex;
        position: fixed;
        bottom: 0; left: 0; right: 0;
        height: 60px;
        background: var(--nx-card);
        border-top: 1px solid var(--nx-border);
        z-index: var(--nx-z-sidebar);
        box-shadow: 0 -2px 8px rgba(0,0,0,0.08);
    }
    .nx-mobile-nav-item {
        flex: 1;
        display: flex; flex-direction: column; align-items: center; justify-content: center;
        gap: 2px;
        color: var(--nx-text-secondary);
        text-decoration: none;
        font-size: 0.625rem; font-weight: 500;
        transition: color var(--nx-transition);
        position: relative;
    }
    .nx-mobile-nav-item.is-active { color: var(--nx-primary); }
    .nx-mobile-nav-item svg { width: 22px; height: 22px; }
    .nx-mobile-nav-icon-wrap { position: relative; }
    .nx-mobile-nav-item .nx-badge { position: absolute; top: -4px; right: -8px; }

    /* Feed adjustments */
    .nx-main-content { padding: var(--nx-spacing-sm); }
    .nx-post-header  { padding: 12px 12px 0; }
    .nx-post-content { padding: 8px 12px 12px; }
    .nx-post-actions .nx-action-btn span { display: none; }

    /* Profile page adjustments */
    .nx-profile-cover { height: 180px; }
    .nx-profile-avatar { width: 100px; height: 100px; }
    .nx-profile-avatar-wrap { margin-top: -52px; margin-left: var(--nx-spacing-md); }
    .nx-profile-name  { font-size: 1.125rem; }
    .nx-profile-body  { grid-template-columns: 1fr; }
    .nx-profile-details { flex-direction: column; align-items: flex-start; }
    .nx-profile-actions { width: 100%; }
    .nx-profile-actions .nx-btn { flex: 1; }

    /* Messages page */
    .nx-messages-page { grid-template-columns: 1fr; }
    .nx-conv-panel    { display: none; }
    .nx-conv-panel.is-visible { display: flex; }
    .nx-thread-panel.has-conv  { display: flex; }
    .nx-thread-panel:not(.has-conv) { display: none; }

    /* Marketplace */
    .nx-listing-grid { grid-template-columns: repeat(2, 1fr); gap: var(--nx-spacing-sm); }
    .nx-listing-detail { grid-template-columns: 1fr; }

    /* Stories */
    .nx-story-card, .nx-story-add-card { width: 80px; height: 130px; }

    /* Modal */
    .nx-modal { padding: 0; align-items: flex-end; }
    .nx-modal-box { border-radius: var(--nx-radius-lg) var(--nx-radius-lg) 0 0; max-height: 85vh; }

    /* Reaction picker */
    .nx-reaction-picker { left: 50%; transform: translateX(-50%); }
}

/* ── 480px and below: very small screens ── */
@media (max-width: 480px) {
    .nx-topbar-icon-btn { width: 36px; height: 36px; }

    .nx-listing-grid { grid-template-columns: repeat(2,1fr); gap: var(--nx-spacing-xs); }
    .nx-listing-price { font-size: 1rem; }

    .nx-stories-bar .nx-story-card { width: 70px; height: 115px; }
    .nx-story-card-name { font-size: 0.7rem; }

    .nx-post-content { font-size: 0.9375rem; }

    .nx-profile-stats { flex-wrap: wrap; gap: 8px; }
    .nx-profile-avatar { width: 80px; height: 80px; }
    .nx-profile-avatar-wrap { margin-top: -42px; }

    /* Groups grid */
    .nx-groups-grid { grid-template-columns: 1fr; }

    /* Thread messages */
    .nx-msg-bubble-wrap { max-width: 88%; }
}

/* ── Print ───────────────────────────────── */
@media print {
    .nx-topbar, .nx-sidebar-left, .nx-sidebar-right, .nx-mobile-nav, .nx-post-actions { display: none !important; }
    .nx-logged-in .nx-page-wrapper { grid-template-columns: 1fr; margin-top: 0; }
}
