/* Mobile Responsive Styles for Simplified Garden Planning Tool */

/* Tablet (768px - 1024px) */
@media (max-width: 1024px) {
    :root {
        --sidebar-width: 240px;
    }
    
    .goals-grid {
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    }
    
    .plant-grid {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    }
}

/* Mobile (max-width: 768px) */
@media (max-width: 768px) {
    /* Prevent horizontal scrollbar when search slides off */
    body {
        overflow-x: hidden;
    }
    
    .main-content {
        overflow-x: hidden;
    }
    /* Header Adjustments */
    .main-header {
        height: auto;
        min-height: var(--header-height);
        position: relative;
        z-index: 90;
    }
    
    .header-content {
        position: relative;
        flex-direction: row;
        flex-wrap: wrap;
        padding: 10px 60px; /* Equal padding for hamburger/filter */
        gap: 8px;
        align-items: center;
        justify-content: center; /* Center the logo/zone combo */
    }
    
    .logo-link {
        order: 1;
        margin-right: 8px;
    }
    
    .header-logo {
        height: 35px;
    }
    
    /* Mobile Zone Selector - Show and position on mobile */
    .mobile-zone-selector {
        display: flex !important;
        align-items: center;
        gap: 4px;
        order: 2;
        background: rgba(112, 178, 70, 0.1);
        padding: 5px 8px;
        border-radius: 20px;
        border: 2px solid var(--primary-green);
    }
    
    .mobile-zone-selector label {
        font-weight: 600;
        color: var(--dark-green);
        font-size: 0.8rem;
        white-space: nowrap;
    }
    
    .mobile-zone-select {
        padding: 3px 6px;
        border: 1px solid #ddd;
        border-radius: 4px;
        background-color: white;
        font-size: 0.8rem;
        min-width: 55px;
        font-weight: 600;
        color: var(--dark-green);
    }
    
    /* Pulse animation for attention */
    .mobile-zone-selector.needs-attention {
        animation: attention-pulse 2s ease-in-out infinite;
    }
    
    @keyframes attention-pulse {
        0%, 100% {
            transform: scale(1);
            box-shadow: 0 0 0 0 rgba(112, 178, 70, 0.4);
        }
        50% {
            transform: scale(1.05);
            box-shadow: 0 0 0 8px rgba(112, 178, 70, 0);
        }
    }
    
    .header-text {
        order: 3;
        width: 100%;
        text-align: center;
        margin-top: var(--spacing-sm);
    }
    
    .header-text h1 {
        font-size: 1.25rem;
    }
    
    .tagline {
        font-size: 0.75rem;
    }
    
    /* Navigation Mobile */
    .nav {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100vh;
        background-color: var(--white);
        flex-direction: column;
        padding: 60px var(--spacing-lg) var(--spacing-lg);
        overflow-y: auto;
        z-index: 100;
    }
    
    .nav.responsive {
        display: flex;
    }
    
    .nav-links {
        flex-direction: column;
        width: 100%;
        gap: var(--spacing-md);
        margin-bottom: var(--spacing-xl);
    }
    
    .nav-links a {
        width: 100%;
        text-align: center;
        padding: var(--spacing-md);
        background-color: var(--light-gray);
        border: 1px solid #e0e0e0;
    }
    
    .nav-controls {
        flex-direction: column;
        width: 100%;
        gap: var(--spacing-md);
    }
    
    /* Hide Zone Selector in Mobile Nav - Using mobile selector in header instead */
    .zone-selector-nav {
        display: none !important;
    }
    
    #search {
        width: 100%;
    }
    
    .search_field {
        width: 100%;
        padding-left: 36px;
        background-position: 8px 50%;
    }
    
    .search_field:focus {
        width: 100%;
    }
    
    .cart-link,
    .nav-controls a {
        justify-content: center;
        padding: var(--spacing-md);
        background-color: var(--light-gray);
        border: 1px solid #e0e0e0;
        border-radius: var(--border-radius);
        width: 100%;
    }
    
    .cartnumber {
        position: absolute;
        top: 50%;
        transform: translateY(-50%);
        right: var(--spacing-lg);
    }
    
    .login-link {
        width: 100%;
        text-align: center;
    }
    
    /* Show hamburger icon on mobile */
    .icon {
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Goals Bar Mobile */
    .goals-bar {
        position: relative;
        top: 0;
    }
    
    .goals-grid {
        grid-template-columns: 1fr;
    }
    
    .goal-item {
        padding: var(--spacing-sm);
    }
    
    /* Layout Adjustments */
    .app-layout {
        flex-direction: column;
        padding: var(--spacing-md);
    }
    
    /* Filter Sidebar Mobile - Overlay */
    .filter-sidebar {
        position: fixed;
        top: 0;
        left: -100%;
        width: 80%;
        max-width: 300px;
        height: 100vh;
        z-index: 1001;
        border-radius: 0;
        transition: left 0.3s ease;
        max-height: 100vh;
        display: flex;
        flex-direction: column;
        background: var(--white);
    }
    
    .filter-sidebar.open {
        left: 0;
        box-shadow: 2px 0 20px rgba(0,0,0,0.3);
    }
    
    /* Make the sidebar header sticky with close button */
    .filter-sidebar .sidebar-header {
        position: sticky;
        top: 0;
        background: var(--white);
        z-index: 10;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
        padding: var(--spacing-md);
        border-bottom: 2px solid var(--primary-green);
        flex-shrink: 0;
    }
    
    /* Make sidebar content scrollable */
    .filter-sidebar .sidebar-content {
        flex: 1;
        overflow-y: auto;
        padding: var(--spacing-md);
    }
    
    .sidebar-toggle {
        display: flex;
        background: var(--red, #e74c3c);
        color: white;
        border: none;
        border-radius: 25px;
        padding: 8px 16px;
        font-size: 1rem;
        font-weight: bold;
        align-items: center;
        justify-content: center;
        gap: 8px;
        box-shadow: 0 2px 8px rgba(0,0,0,0.2);
        transition: all 0.2s ease;
        cursor: pointer;
    }
    
    .sidebar-toggle:hover,
    .sidebar-toggle:focus {
        transform: scale(1.05);
        background: #c0392b;
        box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    }
    
    .sidebar-toggle::before {
        content: '✕';
        font-size: 1.2rem;
        font-weight: bold;
    }
    
    .sidebar-toggle .close-text {
        font-size: 0.9rem;
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }
    
    /* Pulse animation to draw attention when first opened */
    @keyframes pulse-attention {
        0% {
            transform: scale(1);
            box-shadow: 0 2px 8px rgba(231, 76, 60, 0.3);
        }
        50% {
            transform: scale(1.1);
            box-shadow: 0 4px 16px rgba(231, 76, 60, 0.5);
        }
        100% {
            transform: scale(1);
            box-shadow: 0 2px 8px rgba(231, 76, 60, 0.3);
        }
    }
    
    .filter-sidebar.open .sidebar-toggle {
        animation: pulse-attention 1s ease-in-out 2;
    }
    
    /* Mobile Filter Button */
    .mobile-filter-btn {
        display: flex;
        align-items: center;
        gap: var(--spacing-sm);
    }
    
    /* Sidebar Overlay Background - create a separate overlay element */
    .sidebar-overlay {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background-color: rgba(0, 0, 0, 0.3);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s ease;
        z-index: 98;
        display: none;
    }
    
    .sidebar-overlay.active {
        display: block;
        opacity: 1;
        pointer-events: auto;
    }
    
    /* Main Content Mobile */
    .main-content {
        width: 100%;
    }
    
    /* Search Section Mobile - Sticky with slide animation */
    .search-section {
        position: sticky;
        position: -webkit-sticky;
        top: 0;
        z-index: 88;
        background: var(--white);
        margin-bottom: var(--spacing-md);
        transform: translateY(0);
        transition: transform 0.3s ease-out;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    }
    
    /* Hide by sliding up out of view */
    .search-section.search-hidden {
        transform: translateY(-120%);
    }
    
    /* No padding changes needed */
    .main-content {
        padding-top: 0;
    }
    
    /* Ensure active filters stay in place */
    .active-filters {
        margin-top: 0;
    }
    
    #searchBar {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: var(--spacing-sm);
    }
    
    .view-controls {
        flex-direction: column;
        align-items: stretch;
        gap: var(--spacing-sm);
    }
    
    .sort-dropdown {
        width: 100%;
        justify-content: space-between;
    }
    
    .sort-select {
        flex: 1;
        margin-left: var(--spacing-sm);
    }
    
    .results-count {
        text-align: center;
        padding: var(--spacing-sm);
        background-color: var(--light-green);
        border-radius: var(--border-radius);
    }
    
    /* Plant Grid Mobile */
    .plant-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: var(--spacing-md);
    }
    
    .plant-card {
        font-size: 0.875rem;
    }
    
    .plant-image {
        height: 150px;
    }
    
    .plant-info {
        padding: var(--spacing-sm);
    }
    
    .plant-name {
        font-size: 0.95rem;
    }
    
    .plant-common-name {
        font-size: 0.75rem;
    }
    
    /* Favorites Panel Mobile */
    .favorites-panel {
        width: 100%;
        right: -100%;
    }
    
    .favorites-floating-btn {
        bottom: 20px;
        left: 20px;
        width: 50px;
        height: 50px;
    }
    
    /* Modal Mobile */
    .modal-content {
        padding: var(--spacing-lg);
        margin: var(--spacing-md);
    }
}

/* Small Mobile (max-width: 480px) */
@media (max-width: 480px) {
    /* Even smaller plant cards */
    .plant-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: var(--spacing-sm);
    }
    
    .plant-image {
        height: 120px;
    }
    
    /* Compact filter options */
    .filter-option {
        font-size: 0.875rem;
    }
    
    .filter-group h4 {
        font-size: 0.875rem;
    }
    
    /* Active filters more compact */
    .filter-tag {
        font-size: 0.75rem;
        padding: 2px 8px;
    }
}

/* Very Small Mobile (max-width: 360px) */
@media (max-width: 360px) {
    /* Reduce header padding on very small screens */
    .header-content {
        padding: 8px 50px; /* Less padding for tight screens */
    }
    
    /* Make mobile zone selector more compact */
    .mobile-zone-selector {
        padding: 4px 6px;
    }
    
    .mobile-zone-selector label {
        font-size: 0.75rem;
    }
    
    .mobile-zone-select {
        padding: 2px 4px;
        font-size: 0.75rem;
        min-width: 50px;
    }
    
    /* Smaller logo */
    .header-logo {
        height: 30px;
    }
    
    /* Smaller header text */
    .header-text h1 {
        font-size: 1.1rem;
    }
    
    .tagline {
        font-size: 0.7rem;
    }
    
    /* Adjust filter button size */
    .mobile-filter-btn {
        padding: 8px 12px;
        font-size: 0.85rem;
    }
    
    /* Even smaller plant cards */
    .plant-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    }
}

/* Touch-friendly adjustments */
@media (hover: none) and (pointer: coarse) {
    /* Larger touch targets */
    .filter-option {
        min-height: 44px;
        padding: var(--spacing-sm);
    }
    
    .goal-item {
        min-height: 60px;
    }
    
    button {
        min-height: 44px;
    }
    
    .plant-card .favorite-btn {
        width: 44px;
        height: 44px;
    }
    
    /* Disable hover effects on touch devices */
    .plant-card:hover {
        transform: none;
    }
    
    .goal-item:hover {
        transform: none;
    }
}

/* Landscape orientation adjustments */
@media (max-width: 768px) and (orientation: landscape) {
    .main-header {
        position: relative;
    }
    
    .goals-bar {
        position: relative;
    }
    
    .filter-sidebar {
        max-height: 100vh;
        overflow-y: auto;
    }
    
    .plant-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }
}