/* --- Global & Layout --- */
body {
    background-color: #0f172a; /* Slate-900 */
    overflow: hidden;
}

/* Glassmorphism Panel Style */
.glass-panel {
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(20px) saturate(160%);
    -webkit-backdrop-filter: blur(20px) saturate(160%);
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.15);
}

/* --- Mobile Specific Styles (under 768px) --- */
@media (max-width: 767px) {
    #search-aside {
        position: fixed;
        bottom: 0;
        left: 0;
        z-index: 100;
        height: 85vh; /* Large height for mobile utility */
        width: 100%;
        border-radius: 40px 40px 0 0;
        transition: transform 0.5s cubic-bezier(0.33, 1, 0.68, 1);
        will-change: transform;
    }

    /* Class toggled by JS to hide the panel */
    #search-aside.panel-hidden {
        transform: translateY(110%);
    }

    /* Adjust the "Drop Pin" indicator to not hit the top-right button */
    #pin-indicator {
        left: 1rem;
        right: auto;
        transform: none;
        width: auto;
        max-width: 65%;
    }
}

/* --- Desktop Specific Styles (768px and up) --- */
@media (min-width: 768px) {
    #search-aside {
        /* Force visibility regardless of JS classes */
        transform: none !important;
        position: relative !important;
        height: 100% !important;
        z-index: 10;
    }

    /* Hide the mobile-only toggle button */
    #mobile-view-toggle {
        display: none !important;
    }
}

/* --- Collapsible Header Styles --- */
.header-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.1);
    border: none;
    cursor: pointer;
    font-size: 10px;
    line-height: 1;
    vertical-align: middle;
    flex-shrink: 0;
}

.header-toggle:hover {
    background: rgba(0, 0, 0, 0.2);
}

.header-toggle:focus {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}

/* Collapsed header state */
.border-b.collapsed {
    padding-bottom: 1rem !important;
    transition: padding 0.3s ease;
}

/* Hide elements when collapsed */
.border-b.collapsed .space-y-3,
.border-b.collapsed #filter-container {
    display: none !important;
}

/* Smooth transitions for collapsing */
.border-b .space-y-3,
.border-b #filter-container {
    transition: opacity 0.2s ease;
}

/* Short screen optimizations for DESKTOP (wide but short) */
@media (max-height: 600px) and (min-width: 768px) {
    #search-aside .border-b:not(.collapsed) {
        padding: 1rem !important;
    }

    #search-aside .header-main {
        margin-bottom: 0.75rem !important;
    }

    #search-aside h1 {
        font-size: 1.25rem !important;
        display: flex;
        align-items: center;
    }

    #search-aside .space-y-3 {
        gap: 0.5rem !important;
    }

    #filter-container {
        margin-top: 0.5rem !important;
    }

    #park-list {
        min-height: 200px;
    }

    #btn-geolocate,
    #btn-drop-pin {
        padding: 0.5rem 0.75rem !important;
        font-size: 0.75rem !important;
    }

    #search-input {
        padding: 0.5rem 1rem !important;
    }
}

/* Short screen optimizations for MOBILE (narrow and short) */
@media (max-height: 600px) and (max-width: 767px) {
    #search-aside .border-b:not(.collapsed) {
        padding: 1rem !important;
    }

    #search-aside .header-main {
        margin-bottom: 0.5rem !important;
    }

    #search-aside h1 {
        font-size: 1.25rem !important;
        display: flex;
        align-items: center;
        justify-content: space-between;
    }

    #search-aside .space-y-3 {
        gap: 0.5rem !important;
    }

    #filter-container {
        margin-top: 0.5rem !important;
    }

    /* More aggressive space saving for mobile */
    #btn-geolocate,
    #btn-drop-pin {
        padding: 0.5rem 0.75rem !important;
        font-size: 0.75rem !important;
    }

    #search-input {
        padding: 0.5rem 0.75rem !important;
        font-size: 0.875rem !important;
    }

    /* Smaller toggle button for mobile */
    .header-toggle {
        width: 18px;
        height: 18px;
        font-size: 9px;
    }

    /* Ensure adequate space for park list on mobile landscape */
    #park-list {
        min-height: 150px;
    }
}

/* For very short screens - even more aggressive space saving */
@media (max-height: 480px) {
    #search-aside .border-b:not(.collapsed) {
        padding: 0.75rem !important;
    }

    #search-aside .header-main {
        margin-bottom: 0.5rem !important;
    }

    #search-aside h1 {
        font-size: 1.125rem !important;
    }

    .header-toggle {
        width: 16px;
        height: 16px;
        font-size: 8px;
    }

    /* Very compact buttons for very short screens */
    #btn-geolocate,
    #btn-drop-pin {
        padding: 0.375rem 0.5rem !important;
        font-size: 0.75rem !important;
    }

    #search-input {
        padding: 0.375rem 0.5rem !important;
    }

    /* Minimal spacing */
    #search-aside .space-y-3 {
        gap: 0.375rem !important;
    }

    #filter-container {
        margin-top: 0.375rem !important;
    }
}

/* Collapsed state adjustments for mobile */
@media (max-width: 767px) {
    .border-b.collapsed {
        padding: 0.75rem 1rem !important;
    }
}

/* Collapsible filter container */
.show-more-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.1);
    border: none;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    margin-left: 4px;
    transition: background 0.2s;
    flex-shrink: 0;
}

.show-more-btn:hover {
    background: rgba(0, 0, 0, 0.2);
}

.show-more-btn:focus {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}

#filter-container.collapsed {
    max-height: 40px; /* Approx. 2 lines, adjust as needed */
    overflow: hidden;
}

/* --- UI Elements & Animations --- */
.filter-pill {
    padding: 6px 14px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 700;
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(0, 0, 0, 0.05);
    color: #475569;
    transition: all 0.2s ease;
}

.filter-pill.active {
    background: #2563eb;
    color: white;
    border-color: transparent;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.park-card:hover {
    transform: translateY(-2px);
    background: rgba(255, 255, 255, 0.9);
}

/* Custom Scrollbar for the Park List */
#park-list::-webkit-scrollbar {
    width: 5px;
}

#park-list::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 10px;
}

/* Map Interaction */
.cursor-crosshair .leaflet-interactive {
    cursor: crosshair !important;
}

/* Modal Animation */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.animate-fade-in-up {
    animation: fadeInUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Prevent interaction with map when modal is open */
body.modal-open {
    overflow: hidden;
}

/* Infinite Scroll - Fade in animation for new items */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.park-card.animate-new {
    animation: fadeIn 0.3s ease-out forwards;
}

/* Hide pagination footer when empty */
#pagination:empty {
    display: none;
}

/* Broken image fallback */
.park-card img,
#modal-main-img {
    background-color: #e2e8f0;
    min-height: 1px;
}
