/* =====================================================
   COMMUNITY LAYOUT - Responsive Grid and Layout
   Source: communitiesdesign/incontrol-community-li.html
   Mobile-First Approach
   ===================================================== */

/* =====================================================
   MOBILE BASE (320px+) - Default styles
   ===================================================== */

.main-container {
    display: grid;
    grid-template-columns: 1fr;
    padding: 0 1rem;
    gap: 1rem;
    margin: 0.5rem auto;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
}

/* Hide sidebars on mobile */
.profile-card,
.hot-topics,
.right-sidebar,
.community-card {
    display: none;
}

/* Filter tabs horizontal scroll on mobile */
.filter-tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    scrollbar-width: none;
    -ms-overflow-style: none;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

.filter-tabs::-webkit-scrollbar {
    display: none;
}

.filter-tab {
    scroll-snap-align: start;
    flex-shrink: 0;
    min-height: 44px;
}

/* Hide search on mobile */
.search-container {
    display: none;
}

/* Mobile cards */
.post,
.create-post {
    padding: 1rem;
    margin-bottom: 1rem;
}

/* =====================================================
   MOBILE POST STATS
   ===================================================== */

@media (max-width: 767px) {
    .post-stats {
        padding: 0.75rem 0.5rem;
        font-size: 0.8125rem;
        gap: 0.5rem;
    }

    .post-stat-item {
        gap: 0.375rem;
        flex: 1;
        justify-content: center;
        padding: 0.5rem 0.25rem;
        position: relative;
    }

    .post-stat-item:not(:last-child)::after {
        content: '';
        position: absolute;
        right: 0;
        top: 20%;
        height: 60%;
        width: 1px;
        background: var(--glass-border);
    }

    .post-stat-item i {
        font-size: 0.875rem;
    }

    .post-stat-item span {
        white-space: nowrap;
        font-weight: 500;
    }

    .reactions-summary {
        gap: 0.375rem;
    }

    .reaction-icons {
        flex-shrink: 0;
    }

    .reaction-icon {
        width: 18px;
        height: 18px;
        font-size: 0.5625rem;
        margin-left: -3px;
    }

    .reaction-icon:first-child {
        margin-left: 0;
    }
}

/* =====================================================
   MOBILE POST OPTIONS DROPDOWN
   ===================================================== */

.mobile-dropdown-icon {
    display: none;
    margin-left: 0.25rem;
    font-size: 0.75rem;
    transition: transform 0.3s;
}

@media (max-width: 767px) {
    .post-options-wrapper {
        position: relative;
    }

    .post-options {
        display: flex;
        flex-direction: column;
        gap: 0;
    }

    .post-option-trigger .mobile-dropdown-icon {
        display: inline-block;
    }

    .post-option-trigger[aria-expanded="true"] .mobile-dropdown-icon {
        transform: rotate(180deg);
    }

    .post-option-dropdown-item {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        background: white;
        border: 1px solid var(--glass-border);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
        z-index: 100;
        min-width: 150px;
        margin-top: 0.25rem;
    }

    .post-options.dropdown-open .post-option-dropdown-item {
        display: flex;
        position: relative;
        border: none;
        border-bottom: 1px solid var(--glass-border);
        box-shadow: none;
        margin-top: 0;
        border-radius: 0;
    }

    .post-options.dropdown-open .post-option-dropdown-item:last-child {
        border-bottom: none;
        border-radius: 0 0 0.5rem 0.5rem;
    }

    .post-options.dropdown-open {
        background: white;
        border: 1px solid var(--glass-border);
        border-radius: 0.5rem;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
        overflow: hidden;
    }

    .post-options.dropdown-open .post-option-trigger {
        border-radius: 0.5rem 0.5rem 0 0;
        border-bottom: 1px solid var(--glass-border);
    }

    .post-option {
        min-height: 44px;
    }
}

@media (min-width: 768px) {
    .post-options {
        flex-direction: row;
        gap: 1rem;
    }

    /* Mobile dropdown icon is hidden by default (base style).
       No override needed here since mobile rules are scoped to max-width: 767px */

    .post-option-dropdown-item {
        /* Override mobile display:none - always visible on desktop */
        display: flex;
        position: relative;
    }
}

/* =====================================================
   TABLET BREAKPOINT (768px+)
   ===================================================== */

@media (min-width: 768px) {
    .main-container {
        padding: 0 2rem;
        gap: 1.5rem;
        margin: 1rem auto;
    }

    .filter-tabs {
        display: flex;
        overflow-x: visible;
        flex-wrap: wrap;
    }

    /* Show community card on tablets and above */
    .community-card {
        display: block;
    }

    /* Reset mobile padding for posts - let component-specific padding take over */
    .post {
        padding: 0;
        margin-bottom: 0;
    }

    /* Keep create-post padding at 1.5rem (defined in feed.css) */
    .create-post {
        padding: 1.5rem;
        margin-bottom: 0;
    }
}

/* =====================================================
   DESKTOP BREAKPOINT (1250px+) - Show nav/logo/sidebars
   ===================================================== */

@media (min-width: 1250px) {
    .main-container {
        grid-template-columns: 280px 1fr 320px;
        max-width: 1400px;
        padding: 0 2rem;
        gap: 2rem;
        margin-top: 3rem;
        margin-left: auto;
        margin-right: auto;
    }

    /* Show sidebars */
    .profile-card,
    .hot-topics,
    .community-card {
        display: block;
    }

    .right-sidebar {
        display: flex;
        flex-direction: column;
    }

    /* Show desktop nav */
    .nav {
        display: flex;
    }

    .search-container {
        display: block;
    }
}

/* =====================================================
   LARGE DESKTOP (1280px+)
   NOTE: Grid columns stay at 280px 1fr 320px per reference file.
   Only max-width changes at this breakpoint.
   ===================================================== */

@media (min-width: 1280px) {
    .main-container {
        max-width: 1400px;
    }
}

/* =====================================================
   MOBILE NAVIGATION DRAWER
   ===================================================== */

.mobile-nav-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 199;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

.mobile-nav-overlay.active {
    opacity: 1;
    visibility: visible;
}

.mobile-nav {
    position: fixed;
    top: 0;
    left: -300px;
    width: 280px;
    height: 100vh;
    background: var(--bg-white);
    z-index: 200;
    transition: left 0.3s ease-in-out;
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.1);
}

.mobile-nav.active {
    left: 0;
}

.mobile-nav-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid var(--glass-border);
}

.mobile-nav-title {
    font-weight: 600;
    font-size: var(--font-size-lg);
    color: var(--primary-color);
}

.mobile-nav-items {
    display: flex;
    flex-direction: column;
    padding: 1rem 0;
    flex: 1;
    overflow-y: auto;
}

.mobile-nav-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
    color: var(--text-primary);
    text-decoration: none;
    transition: background 0.3s;
    min-height: 56px;
}

.mobile-nav-item:hover {
    background: var(--glass-white);
}

.mobile-nav-item.active {
    background: rgba(106, 74, 158, 0.1);
    color: var(--primary-color);
    border-left: 3px solid var(--primary-color);
}

.mobile-nav-item .nav-icon {
    font-size: var(--font-size-xl);
    width: 24px;
    text-align: center;
}

.mobile-nav-item .nav-label {
    font-size: var(--font-size-base);
    font-weight: 500;
}

/* =====================================================
   MOBILE NAVIGATION USER SECTION
   Footer section with login/logout and user info
   ===================================================== */

.mobile-nav-footer {
    margin-top: auto;
    padding: 1rem;
    border-top: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* Authenticated user info row */
.mobile-nav-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0;
}

.mobile-nav-user-photo {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.mobile-nav-user-initials {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--accent-color) 100%);
    color: white;
    font-weight: 600;
    font-size: var(--font-size-sm);
}

.mobile-nav-user-name {
    font-weight: 500;
    font-size: var(--font-size-base);
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Login button for unauthenticated users */
.mobile-nav-login-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.875rem 1rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--border-radius-lg, 12px);
    font-size: var(--font-size-base);
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
    min-height: 48px;
}

.mobile-nav-login-btn:hover {
    background: var(--primary-dark, #5a3a8e);
    transform: translateY(-1px);
}

.mobile-nav-login-btn:focus-visible {
    outline: 3px solid var(--focus-color, var(--primary-color));
    outline-offset: 2px;
}

.mobile-nav-login-btn i {
    font-size: 1.125rem;
}

/* Logout button for authenticated users */
.mobile-nav-logout-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.75rem 1rem;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-lg, 12px);
    font-size: var(--font-size-base);
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
    min-height: 44px;
}

.mobile-nav-logout-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #dc2626;
    border-color: rgba(239, 68, 68, 0.3);
}

.mobile-nav-logout-btn:focus-visible {
    outline: 3px solid var(--focus-color, var(--primary-color));
    outline-offset: 2px;
}

.mobile-nav-logout-btn i {
    font-size: 1rem;
}

/* Hide mobile nav on desktop */
@media (min-width: 1250px) {
    .mobile-nav,
    .mobile-nav-overlay {
        display: none;
    }
}

/* =====================================================
   PRINT STYLES
   ===================================================== */

@media print {
    .header,
    .hamburger-btn,
    .mobile-nav,
    .mobile-nav-overlay,
    .background-gradient,
    .right-sidebar,
    .post-actions,
    .create-post,
    .filter-tabs {
        display: none !important;
    }

    body {
        padding-top: 0;
        background: white;
    }

    .main-container {
        display: block;
        max-width: 100%;
        padding: 0;
    }

    .post {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ccc;
        margin-bottom: 1rem;
        max-width: 100%;
        page-break-inside: avoid;
    }

    @page {
        margin: 2cm;
    }

    @page :first {
        margin-top: 1cm;
    }
}
