* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-900: #0c4a6e;
    --primary-800: #075985;
    --primary-700: #0e7490;
    --primary-600: #0891b2;
    --primary-500: #06b6d4;
    --accent-600: #2563eb;
    --accent-500: #3b82f6;
    --success-600: #16a34a;
    --danger-600: #dc2626;
    --neutral-50: #f8fafc;
    --neutral-100: #f1f5f9;
    --neutral-200: #e2e8f0;
    --neutral-300: #cbd5e1;
    --neutral-400: #94a3b8;
    --neutral-500: #64748b;
    --neutral-600: #475569;
    --neutral-700: #334155;
    --neutral-800: #1e293b;
    --neutral-900: #0f172a;
    
    --bg-primary: #ffffff;
    --bg-secondary: var(--neutral-50);
    --text-primary: var(--neutral-900);
    --text-secondary: var(--neutral-600);
    --border-color: var(--neutral-200);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    
    --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Professional blue-gray gradients for header/footer */
    --header-light-gradient: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    --header-dark-gradient: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
}

[data-theme="dark"] {
    --bg-primary: #1e293b;
    --bg-secondary: #0f172a;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --border-color: #334155;
    --neutral-50: #334155;
    --neutral-100: #1e293b;
    --neutral-200: #475569;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
    background: var(--bg-secondary);
    color: var(--text-primary);
}

body {
    display: flex;
    flex-direction: column;
}

/* Header */
.site-header {
    background: var(--header-light-gradient);
    color: var(--text-primary);
    padding: 0.75rem 1.5rem;
    box-shadow: var(--shadow-lg);
    position: sticky;
    top: 0;
    z-index: 1000;
    border-bottom: 1px solid var(--border-color);
}

[data-theme="dark"] .site-header {
    background: var(--header-dark-gradient);
    color: var(--text-primary);
}

.header-main {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 1600px;
    margin: 0 auto;
    gap: 1rem;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-shrink: 0;
}

.brand-wrapper {
    display: flex;
    flex-direction: column;
}

.brand {
    font-size: 1.25rem;
    margin: 0;
    font-weight: 600;
    letter-spacing: -0.025em;
    
    /* Light mode: Darker blue gradient for visibility */
    background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

[data-theme="dark"] .brand {
    /* Dark mode: Lighter blue for contrast on dark bg */
    background: linear-gradient(135deg, #60a5fa 0%, #93c5fd 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.brand-subtitle {
    font-size: 0.75rem;
    color: var(--neutral-600);
    font-weight: 400;
    margin-top: 0.125rem;
}

[data-theme="dark"] .brand-subtitle {
    color: var(--neutral-300);
}

.header-center {
    flex: 1;
    max-width: 500px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.theme-toggle {
    background: rgba(0, 0, 0, 0.1);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    font-size: 1.2rem;
}

[data-theme="dark"] .theme-toggle {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
}

.theme-toggle:hover {
    background: rgba(0, 0, 0, 0.15);
    transform: scale(1.1);
}

[data-theme="dark"] .theme-toggle:hover {
    background: rgba(255, 255, 255, 0.25);
}

.hamburger {
    display: none;
    flex-direction: column;
    gap: 5px;
    width: 40px;
    height: 40px;
    background: rgba(0, 0, 0, 0.1);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    padding: 8px;
    transition: all var(--transition);
}

[data-theme="dark"] .hamburger {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.hamburger .bar {
    width: 100%;
    height: 2px;
    background: var(--text-primary);
    border-radius: 2px;
    transition: all var(--transition);
}

.hamburger:hover {
    background: rgba(0, 0, 0, 0.15);
}

[data-theme="dark"] .hamburger:hover {
    background: rgba(255, 255, 255, 0.25);
}

.search-wrap {
    flex: 1;
    max-width: 400px;
    min-width: 200px;
    position: relative;
}

.search-input {
    width: 100%;
    padding: 0.625rem 2.5rem 0.625rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    font-size: 0.9375rem;
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: all var(--transition);
}

.search-input:focus {
    outline: none;
    border-color: var(--accent-500);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-top: 0.5rem;
    max-height: 300px;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    display: none;
}

.autocomplete-dropdown.show {
    display: block;
}

.autocomplete-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: background var(--transition);
    border-bottom: 1px solid var(--border-color);
}

.autocomplete-item:last-child {
    border-bottom: none;
}

.autocomplete-item:hover {
    background: var(--neutral-50);
}

.chip-button {
    background: var(--neutral-200);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 0.375rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

[data-theme="dark"] .chip-button {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.chip-button:hover {
    background: var(--neutral-300);
    transform: translateY(-1px);
}

[data-theme="dark"] .chip-button:hover {
    background: rgba(255, 255, 255, 0.25);
}

.filter-controls {
    display: flex;
    gap: 0.25rem;
}

.results-wrapper {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.results-label {
    font-weight: 500;
}

.results-badge {
    background: linear-gradient(135deg, var(--accent-600), var(--accent-500));
    color: white;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.25rem 0.75rem;
    min-width: 28px;
    text-align: center;
}

/* Container */
.container {
    display: flex;
    flex: 1;
    height: calc(100vh - 140px);
    min-height: 500px;
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
    gap: 1.5rem;
    padding: 1.5rem;
}

/* Sidebar */
.sidebar {
    width: 360px;
    background: var(--bg-primary);
    padding: 1.5rem;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    border-radius: 16px;
    transition: all 0.3s ease;
}

.sidebar::-webkit-scrollbar {
    width: 8px;
}

.sidebar::-webkit-scrollbar-track {
    background: var(--neutral-50);
    border-radius: 4px;
}

.sidebar::-webkit-scrollbar-thumb {
    background: var(--neutral-300);
    border-radius: 4px;
}

.sidebar.hidden {
    transform: translateX(-100%);
    opacity: 0;
    position: absolute;
    pointer-events: none;
}

.sidebar h2 {
    color: var(--primary-900);
    margin-bottom: 1rem;
    font-size: 1.125rem;
    font-weight: 700;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0.5rem;
}

[data-theme="dark"] .sidebar h2 {
    color: var(--primary-500);
}

.section {
    margin-bottom: 2rem;
}

/* Favorites Section */
.favorites-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.favorite-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem;
    background: var(--neutral-50);
    border-radius: 8px;
    cursor: pointer;
    transition: all var(--transition);
}

.favorite-item:hover {
    background: var(--neutral-100);
    transform: translateX(4px);
}

.remove-favorite {
    background: transparent;
    border: none;
    color: var(--danger-600);
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Filter Options */
.filter-options {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.filter-options label {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    transition: all var(--transition);
    font-weight: 500;
    color: var(--text-primary);
}

.filter-options label:hover {
    background: var(--neutral-50);
    transform: translateX(2px);
}

.filter-checkbox {
    margin-right: 0.75rem;
    cursor: pointer;
    width: 18px;
    height: 18px;
    accent-color: var(--accent-600);
}

/* Routing Controls */
.routing-controls {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.routing-select {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.9375rem;
    background: var(--bg-primary);
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition);
}

.routing-select:focus {
    outline: none;
    border-color: var(--accent-500);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.routing-button {
    width: 100%;
    padding: 0.75rem;
    background: linear-gradient(135deg, var(--accent-600), var(--accent-500));
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9375rem;
    font-weight: 600;
    transition: all var(--transition);
}

.routing-button:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.routing-row {
    display: flex;
    gap: 0.5rem;
}

.routing-row .routing-button {
    flex: 1;
}

/* Facility List */
#facilities-list {
    list-style: none;
    padding: 0;
}

#facilities-list li {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: all var(--transition);
    border-radius: 8px;
    margin-bottom: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

#facilities-list li:hover {
    background: var(--neutral-50);
    transform: translateX(4px);
}

.add-favorite {
    background: transparent;
    border: none;
    color: var(--neutral-400);
    cursor: pointer;
    font-size: 1.2rem;
    transition: all var(--transition);
}

.add-favorite:hover {
    color: var(--accent-500);
    transform: scale(1.2);
}

.add-favorite.active {
    color: var(--accent-500);
}

/* Map */
#map {
    flex: 1;
    height: 100%;
    min-height: 500px;
    background: var(--neutral-200);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}

.leaflet-container {
    height: 100%;
    width: 100%;
}

.map-controls {
    position: absolute;
    right: 16px;
    bottom: 16px;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    z-index: 1000;
}

.fab-button {
    background: var(--bg-primary);
    color: var(--primary-900);
    border: none;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    transition: all var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.fab-button:hover {
    background: var(--accent-600);
    color: white;
    transform: translateY(-2px);
}

/* Popup Styles */
.popup-content {
    width: 280px;
}

.popup-image {
    width: 100%;
    height: 160px;
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: 0.75rem;
}

.popup-image-placeholder {
    width: 100%;
    height: 160px;
    background: linear-gradient(135deg, var(--primary-700), var(--primary-500));
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 3rem;
    margin-bottom: 0.75rem;
}

.popup-header {
    font-weight: 700;
    color: var(--primary-900);
    font-size: 1.125rem;
    margin-bottom: 0.5rem;
}

.popup-category {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.25rem 0.625rem;
    background: var(--neutral-100);
    border-radius: 4px;
    display: inline-block;
    margin-bottom: 0.5rem;
}

.popup-description {
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 0.75rem;
}

.popup-actions {
    display: flex;
    gap: 0.5rem;
}

.popup-button {
    padding: 0.5rem 0.75rem;
    background: linear-gradient(135deg, var(--accent-600), var(--accent-500));
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8125rem;
    font-weight: 600;
    flex: 1;
    transition: all var(--transition);
}

.popup-button:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

/* Toast */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--primary-900);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 10000;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Footer */
footer {
    background: var(--header-light-gradient);
    color: var(--text-primary);
    padding: 1rem 1.5rem;
    text-align: center;
    font-size: 0.875rem;
}

[data-theme="dark"] footer {
    background: var(--header-dark-gradient);
    color: var(--text-primary);
}

/* Ensure header text doesn't inherit issues */
.site-header,
.header-main,
.header-left,
.header-center,
.header-right {
    color: var(--text-primary);
}

[data-theme="dark"] .site-header,
[data-theme="dark"] .header-main,
[data-theme="dark"] .header-left,
[data-theme="dark"] .header-center,
[data-theme="dark"] .header-right {
    color: var(--text-primary);
}

/* Responsive */
@media (max-width: 768px) {
    .hamburger {
        display: flex;
    }

    .header-main {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }
    
    .header-center {
        order: 3;
        max-width: none;
    }
    
    .header-right {
        order: 2;
        justify-content: flex-end;
    }

    .container {
        flex-direction: column;
        height: auto;
        padding: 1rem;
        gap: 1rem;
    }

    .sidebar {
        width: 100%;
        order: 2;
        max-height: 70vh;
    }

    .sidebar.hidden {
        display: none;
    }

    #map {
        height: 60vh;
        min-height: 400px;
        order: 1;
    }

    .search-wrap {
        width: 100%;
        max-width: 100%;
        order: 3;
        flex-basis: 100%;
    }

    .brand {
        font-size: 1.125rem;
    }
}
/* Mobile Sidebar Height Fix */
@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        order: 2;
        max-height: 85vh; /* Increased from 70vh for better visibility */
        overflow-y: auto; /* Ensure scrolling if content overflows */
    }

    .sidebar.hidden {
        display: none; /* Toggle visibility */
    }

    /* Optional: Adjust padding for more space */
    .sidebar {
        padding: 1rem; /* Slightly reduced from 1.5rem for tighter mobile fit */
    }

    /* Ensure container adjusts */
    .container {
        flex-direction: column;
        height: auto;
        padding: 0.5rem; /* Reduced outer padding on mobile */
        gap: 0.5rem;
    }

    #map {
        height: 50vh; /* Reduced map height to give more room to sidebar */
        min-height: 300px;
        order: 1;
        border-radius: 12px; /* Slightly smaller radius */
    }
}
/* Legend Styles */
.legend {
    background: var(--bg-primary);
    border-radius: 8px;
    padding: 0.75rem;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    font-size: 0.8125rem;
    line-height: 1.4;
    max-width: 150px;
    z-index: 1000;
}

.legend-title {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    text-align: center;
    font-size: 0.875rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
    color: var(--text-secondary);
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
}

.legend-color.academic {
    background-color: #0891b2;
}

.legend-color.residential {
    background-color: #16A34A;
}

.legend-color.service {
    background-color: #f59e0b;
}

[data-theme="dark"] .legend {
    background: var(--neutral-800);
    border-color: var(--border-color);
}

[data-theme="dark"] .legend-title {
    color: var(--text-primary);
}

[data-theme="dark"] .legend-item {
    color: var(--text-secondary);
}

/* Responsive Legend (smaller on mobile) */
@media (max-width: 768px) {
    .legend {
        max-width: 120px;
        padding: 0.5rem;
        font-size: 0.75rem;
    }
    
    .legend-title {
        font-size: 0.8125rem;
    }
}