/* United We Rise - Responsive Design System */

/* ========================================
   RESPONSIVE BREAKPOINTS
   - Mobile: < 768px
   - Tablet: 768px - 1024px  
   - Desktop: > 1024px
======================================== */

/* ========================================
   TABLET ADJUSTMENTS (768px - 1024px)
======================================== */

@media screen and (max-width: 1024px) and (min-width: 768px) {
    
    /* Hide donation widget on tablet */
    .donation-widget {
        display: none !important;
    }
    
    /* Adjust search bar for tablet */
    .desktop-search {
        width: 200px;
    }
    
    /* Sidebar adjustments for tablet */
    .sidebar {
        width: 60px; /* Fixed width instead of vw */
    }
    
    .sidebar.expanded {
        width: 200px; /* Fixed width instead of vw */
    }
    
    /* Sidebar toggle button adjustments for tablet */
    .sidebar-toggle-edge {
        left: 60px; /* Match fixed sidebar width */
        transform: translateY(-50%) translateX(-50%); /* Keep centered on edge */
    }
    
    .sidebar.expanded ~ .sidebar-toggle-edge {
        left: 200px; /* Match expanded sidebar width */
    }
    
    /* Main content area adjustments */
    .main {
        margin-left: 60px; /* Match sidebar width */
        margin-right: 30%; /* Larger percentage for map on tablet */
    }
    
    .sidebar.expanded ~ .main {
        margin-left: 200px;
    }
    
    /* Posts container adjustments */
    .posts-container {
        left: 60px;
        right: 30%;
        margin: 0 0.5rem;
    }
    
    /* Map container adjustments */
    #mapContainer.collapsed {
        width: 28%;
        height: 35%;
    }
    
    /* Trending updates adjustments */
    .trending-updates {
        width: 28%;
    }
    
    /* Search container adjustments */
    .search-container {
        left: 60px;
        width: calc(60vw - 60px);
    }
    
    /* Panel adjustments */
    [data-offset="1"] { left: 60px; }
    [data-offset="2"] { left: 360px; }
    .sidebar.expanded ~ [data-offset="1"] { left: 200px; }
    .sidebar.expanded ~ [data-offset="2"] { left: 500px; }
}

/* ========================================
   MOBILE LAYOUT (< 768px)
======================================== */

@media screen and (max-width: 767px) {
    
    /* Hide desktop elements that don't work on mobile */
    .sidebar {
        display: none;
    }
    
    /* Hide sidebar toggle button on mobile */
    .sidebar-toggle-edge {
        display: none;
    }
    
    /* Create mobile navigation */
    .mobile-nav {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: #4b5c09;
        height: 60px;
        display: flex;
        justify-content: space-around;
        align-items: center;
        z-index: 1000;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    }
    
    .mobile-nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        color: white;
        font-size: 0.7rem;
        text-decoration: none;
        padding: 0.25rem;
        border-radius: 4px;
        transition: background 0.2s;
    }
    
    .mobile-nav-item:hover,
    .mobile-nav-item.active {
        background: rgba(255,255,255,0.1);
    }
    
    .mobile-nav-icon {
        font-size: 1.5rem;
        margin-bottom: 0.25rem;
    }
    
    /* Hide donation widget on mobile */
    .donation-widget {
        display: none !important;
    }
    
    /* Hide desktop search, show mobile search button */
    .desktop-search {
        display: none;
    }
    
    .mobile-search-btn {
        display: block !important;
    }
    
    /* Adjust top bar for mobile */
    .top-bar {
        height: 60px;
        padding: 0.5rem;
    }
    
    .top-bar-left {
        flex: 0;
    }
    
    .logo {
        font-size: 1rem;
    }
    
    .logo-circle {
        height: 45px;
        width: 45px;
    }
    
    .desktop-nav {
        gap: 0.5rem;
    }
    
    .nav-link {
        font-size: 0.9rem;
        padding: 0.25rem 0.5rem;
    }
    
    .login-btn {
        font-size: 0.9rem;
        padding: 0.5rem 0.75rem;
    }
    
    /* Main container adjustments */
    .container {
        margin-top: 60px;
        height: calc(100vh - 120px); /* Account for top bar and bottom nav */
    }
    
    .main {
        margin-left: 0;
        margin-right: 0;
        padding: 0.5rem;
        height: calc(100vh - 120px);
    }
    
    /* Posts container mobile layout */
    .posts-container {
        position: static;
        height: 100%;
        top: auto;
        bottom: auto;
        left: auto;
        right: auto;
        margin: 0;
        border-radius: 0;
    }
    
    .posts-feed {
        padding: 0.5rem;
        margin-bottom: 60px; /* Account for mobile nav */
    }
    
    /* Map becomes full-screen modal on mobile */
    #mapContainer {
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        z-index: 9999;
        display: none; /* Hidden by default, shown when map button clicked */
    }
    
    #mapContainer.mobile-active {
        display: block;
    }
    
    #mapContainer.collapsed {
        position: fixed;
        width: 100vw;
        height: 100vh;
        top: 0;
        right: 0;
        border: none;
        border-radius: 0;
    }
    
    /* Mobile map toggle */
    #mapToggleBtn {
        display: none; /* Hide desktop toggle */
    }
    
    .mobile-map-close {
        position: fixed;
        top: 20px;
        right: 20px;
        z-index: 10000;
        background: white;
        border: 2px solid #4b5c09;
        padding: 8px 12px;
        font-weight: bold;
        cursor: pointer;
        border-radius: 6px;
        box-shadow: 0 2px 8px rgba(0,0,0,0.3);
        display: none;
    }
    
    #mapContainer.mobile-active .mobile-map-close {
        display: block;
    }
    
    /* Hide trending updates on mobile */
    .trending-updates {
        display: none !important;
    }
    
    /* Mobile search adjustments */
    .search-container {
        position: fixed;
        top: 60px;
        left: 0;
        width: 100vw;
        height: calc(100vh - 120px);
        border-radius: 0;
        border: none;
        border-top: 1px solid #ddd;
    }
    
    /* Hide desktop panels on mobile */
    .info-panel,
    .detail-panel {
        display: none;
    }
    
    /* Mobile modal adjustments */
    .modal-content {
        width: 95%;
        max-width: none;
        padding: 1.5rem;
    }
    
    /* Mobile form adjustments */
    .form-group input {
        font-size: 1rem; /* Prevent zoom on iOS */
    }
    
    /* Profile panel mobile adjustments */
    .profile-panel {
        position: fixed;
        top: 60px;
        left: 0;
        width: 100vw;
        max-width: none;
        height: calc(100vh - 120px);
        border-radius: 0;
        border: none;
        border-top: 1px solid #ddd;
    }
    
    /* Messages container mobile adjustments */
    .messages-container {
        position: fixed;
        bottom: 70px; /* Above mobile nav */
        right: 10px;
        left: 10px;
        width: auto;
        max-height: 50vh;
    }
}

/* ========================================
   TOUCH IMPROVEMENTS
======================================== */

@media (hover: none) and (pointer: coarse) {
    /* Touch-friendly adjustments for tablets and phones */
    
    .sidebar .thumb {
        padding: 0.75rem 0.5rem;
        margin: 0.5rem 0;
        min-height: 44px; /* iOS touch target minimum */
    }
    
    .btn {
        min-height: 44px;
        padding: 0.75rem 1.5rem;
    }
    
    .mobile-nav-item {
        min-height: 44px;
        min-width: 44px;
    }
    
    .post-action {
        padding: 0.5rem;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* ========================================
   LANDSCAPE MOBILE ADJUSTMENTS
======================================== */

@media screen and (max-width: 767px) and (orientation: landscape) {
    .mobile-nav {
        height: 50px;
    }
    
    .container {
        height: calc(100vh - 110px);
    }
    
    .main {
        height: calc(100vh - 110px);
    }
    
    .top-bar {
        height: 50px;
    }
    
    .container {
        margin-top: 50px;
    }
}