/* Responsive Design for Mobile and Tablet */

/* When screen is narrow enough that search bar would be less than 200px, move it to second row */
@media (max-width: 700px) {
    .header {
        overflow: visible;
        min-height: auto;
    }
    
    .header-container {
        height: auto;
        min-height: 42px;
        padding-top: 8px;
        padding-right: 10px;
        padding-bottom: 8px;
        padding-left: 10px;
        flex-wrap: wrap;
        align-items: center;
        box-sizing: border-box;
    }
    
    /* First row items (logo and header-right) should be vertically centered */
    .header-logo {
        flex: 0 0 auto;
        min-width: 120px;
        align-self: center;
    }
    
    .header-logo a {
        font-size: 18px;
    }
    
    .site-logo-image {
        max-height: 32px;
        max-width: 120px;
    }
    
    .header-logo-link span {
        font-size: 18px;
    }
    
    .header-right {
        gap: 8px;
        flex-wrap: nowrap;
        flex: 0 0 auto;
        order: 2;
        align-self: center;
        display: flex;
        align-items: center;
    }
    
    .header-right .user-link,
    .logout-link {
        font-size: 12px;
        padding: 4px 8px;
    }
    
    .notifications-link {
        font-size: 16px;
        padding: 4px 6px;
    }
    
    /* Search bar moves to second row on narrow screens */
    /* Balance spacing: reduce margin-top to match padding-bottom for equal blue space */
    .search-container {
        order: 3;
        flex: 1 1 100%;
        min-width: 200px;
        max-width: 100%;
        margin: 0;
        margin-top: 8px;
        width: 100%;
        box-sizing: border-box;
    }
    
    .search-input {
        font-size: 12px;
        padding: 6px 35px 6px 10px;
    }
}

/* Mobile First Approach - smaller screens */
@media (max-width: 480px) {
    .header-container {
        height: auto;
        padding-top: 8px;
        padding-right: 10px;
        padding-bottom: 8px;
        padding-left: 10px;
        flex-wrap: wrap;
        box-sizing: border-box;
    }
    
    .header-logo {
        flex: 0 0 auto;
        min-width: 120px;
    }
    
    .header-logo a {
        font-size: 18px;
    }
    
    .site-logo-image {
        max-height: 28px;
        max-width: 100px;
    }
    
    .header-logo-link span {
        font-size: 16px;
    }
    
    .header-right {
        gap: 8px;
        flex-wrap: nowrap;
        flex: 0 0 auto;
        order: 2;
    }
    
    .header-right .user-link,
    .logout-link {
        font-size: 12px;
        padding: 4px 8px;
    }
    
    .notifications-link {
        font-size: 16px;
        padding: 4px 6px;
    }
    
    .header-nav {
        width: 100%;
        justify-content: center;
        margin-top: 5px;
        gap: 10px;
    }
    
    .header-nav a {
        padding: 6px 12px;
    }
    
    /* Search bar on second row with full width */
    .search-container {
        order: 3;
        flex: 1 1 100%;
        min-width: 200px;
        max-width: 100%;
        margin: 8px 0 0 0;
        width: 100%;
    }
    
    .search-input {
        font-size: 12px;
        padding: 6px 35px 6px 10px;
    }
    
    .main-container {
        padding: 10px;
        flex-direction: column;
    }
    
    /* Todo pages should not be constrained by main-container max-width */
    .todo-main-container {
        max-width: none !important;
        padding: 0 !important;
    }
    
    /* Sidebar as wrapping button grid on mobile */
    .sidebar {
        width: 100%;
        order: -1;
        margin-bottom: 10px;
        padding: 10px;
    }
    
    .sidebar-section ul {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px;
        padding: 0;
        margin: 0;
    }
    
    .sidebar-section ul li {
        flex: 0 0 auto;
        list-style: none;
        margin: 0;
    }
    
    .sidebar-section ul li a {
        white-space: nowrap;
        padding: 8px 14px;
        display: block;
        background: #f0f0f0;
        border-radius: 3px;
        font-size: 12px;
        text-align: center;
        transition: background 0.2s;
    }
    
    .sidebar-section ul li a:hover {
        background: #e0e0e0;
    }
    
    .sidebar-section h3 {
        display: none; /* Hide "Quick Links" heading on mobile */
    }
    
    .card {
        padding: 10px;
    }
    
    .form-group input,
    .form-group textarea {
        font-size: 16px; /* Prevent zoom on iOS */
    }
    
    /* Cover photo responsive - smaller on mobile (reduced by 1/4 from original 150px) */
    .cover-photo-container {
        height: 113px !important; /* 150px * 3/4 = 112.5px, rounded to 113px */
    }
    
    /* Ensure cover photo doesn't overlap sidebar on mobile */
    .card {
        position: relative;
    }
}

/* Tablet */
@media (min-width: 481px) and (max-width: 768px) {
    .header-container {
        padding: 0 15px;
    }
    
    .header-right {
        gap: 12px;
    }
    
    .main-container {
        flex-direction: column;
    }
    
    /* Todo pages should not be constrained by main-container max-width */
    .todo-main-container {
        max-width: none !important;
        padding: 0 !important;
    }
    
    .sidebar {
        width: 100%;
        order: -1; /* Show sidebar first on tablet too, so it appears above cover photos */
        margin-bottom: 10px;
        padding: 10px;
    }
    
    .sidebar-section ul {
        display: flex;
        flex-wrap: wrap;
        justify-content: center; /* Center the buttons on tablet */
        gap: 8px;
        padding: 0;
        margin: 0;
    }
    
    .sidebar-section ul li {
        flex: 0 0 auto;
        list-style: none;
    }
    
    .sidebar-section ul li a {
        white-space: nowrap;
        padding: 8px 14px;
        display: block;
        background: #f0f0f0;
        border-radius: 3px;
        font-size: 12px;
        text-align: center;
        transition: background 0.2s;
    }
    
    .sidebar-section ul li a:hover {
        background: #e0e0e0;
    }
    
    .sidebar-section h3 {
        display: none; /* Hide "Quick Links" heading on tablet too */
    }
    
    .main-content {
        order: 1;
    }
    
    /* Cover photo smaller on tablet (already reduced by 1/3 from 300px) */
    .cover-photo-container {
        height: 200px !important; /* 300px * 2/3 = 200px */
    }
}

/* Desktop */
@media (min-width: 769px) {
    .main-container {
        display: flex;
    }
    
    /* Todo pages should not be constrained by main-container max-width */
    .todo-main-container {
        max-width: none !important;
        padding: 0 !important;
    }
    
    .sidebar {
        width: 200px;
        flex-shrink: 0;
    }
    
    .main-content {
        flex: 1;
    }
}

