:root {
    --primary-color: #ef4444;
    --primary-hover: #ff3333;
    --bg-color: #0a0a0a;
    --card-bg: rgba(20, 20, 20, 0.7);
    --text-main: #ffffff;
    --text-muted: #a0aec0;
    --border-color: rgba(255, 255, 255, 0.1);
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.5);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.6), 0 2px 4px -1px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.6), 0 4px 6px -2px rgba(0, 0, 0, 0.4);
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-full: 9999px;
    --sidebar-width: 320px;
}

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

body {
    font-family: 'Poppins', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.app-container {
    display: flex;
    height: 90vh;
    min-height: 800px;
    width: 100%;
    margin-top: 80px; /* Space for the site navbar */
    position: relative;
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
}

/* Sidebar Styles */
.sidebar {
    width: var(--sidebar-width);
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 50;
    box-shadow: var(--shadow-lg);
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar.collapsed {
    margin-left: calc(var(--sidebar-width) * -1);
}

.sidebar-header {
    padding: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-toggle-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.25rem;
    cursor: pointer;
    transition: color 0.2s;
    margin-right: 8px;
}
.sidebar-toggle-btn:hover {
    color: var(--text-main);
}

.sidebar-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--primary-color);
}

.close-sidebar-btn {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-md);
    transition: background-color 0.2s, color 0.2s;
}

.close-sidebar-btn:hover {
    background-color: rgba(0, 0, 0, 0.05);
    color: var(--text-main);
}

.sidebar-content {
    padding: 24px;
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 32px;
}

/* Map Theme Switcher */
.map-theme-switcher {
    display: flex;
    gap: 8px;
    background: rgba(30, 30, 30, 0.8);
    padding: 6px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.theme-btn {
    flex: 1;
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    font-size: 0.8rem;
    padding: 8px 4px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    font-family: inherit;
    font-weight: 500;
}

.theme-btn i {
    font-size: 1.1rem;
}

.theme-btn:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
}

.theme-btn.active {
    background: rgba(239, 68, 68, 0.15);
    color: var(--primary-color);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

/* Search Bar */
.search-bar {
    position: relative;
    display: flex;
    align-items: center;
}

.search-bar i {
    position: absolute;
    left: 16px;
    color: var(--text-muted);
    font-size: 1.2rem;
}

.search-bar input {
    width: 100%;
    padding: 14px 16px 14px 48px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border-color);
    background: rgba(30, 30, 30, 0.8);
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.95rem;
    transition: all 0.2s;
    box-shadow: var(--shadow-sm);
}

.search-bar input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.25);
}

/* Search Suggestions */
.search-suggestions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: -16px; /* pull closer to search bar */
}
.search-suggestions.hidden {
    display: none;
}

/* Search Results */
.search-results {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 500px;
    overflow-y: auto;
    background: rgba(30, 30, 30, 0.5);
    border-radius: var(--radius-md);
    padding: 8px;
    border: 1px solid var(--border-color);
}

.search-results.hidden {
    display: none;
}

.search-result-item {
    padding: 12px;
    border-radius: var(--radius-md);
    background: rgba(40, 40, 40, 0.6);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem;
    color: var(--text-main);
}
.search-result-item:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.3);
}

/* Info Card */
.info-card {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.1), rgba(200, 30, 30, 0.05));
    border-radius: var(--radius-md);
    padding: 16px;
    display: flex;
    gap: 12px;
    align-items: flex-start;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.info-card i {
    color: var(--primary-color);
    font-size: 1.5rem;
}

.info-card p {
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--text-main);
}

/* Main Content Area */
.main-content {
    flex: 1;
    position: relative;
    display: flex;
    flex-direction: column;
}

/* Map Wrapper */
.map-wrapper {
    flex: 1;
    width: 100%;
    height: 100%;
    position: relative;
    z-index: 10;
}

/* Leaflet Overrides */
#map.theme-dark .leaflet-tile-pane {
    filter: invert(100%) hue-rotate(180deg) brightness(95%) contrast(90%);
}

.leaflet-popup-content-wrapper {
    background: rgba(20, 20, 20, 0.9);
    color: white;
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-md);
}
.leaflet-popup-tip {
    background: rgba(20, 20, 20, 0.9);
}
.leaflet-popup-content h3 {
    margin: 0 0 8px 0;
    color: var(--primary-color);
    font-family: 'Poppins', sans-serif;
    font-size: 1rem;
}
.leaflet-container a.leaflet-popup-close-button {
    color: white;
}

.directions-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--primary-color);
    color: white !important;
    text-decoration: none;
    padding: 8px 16px;
    border-radius: var(--radius-full);
    font-size: 0.85rem;
    font-weight: 600;
    transition: background 0.2s, transform 0.2s;
    box-shadow: var(--shadow-md);
}
.directions-btn:hover {
    background: var(--primary-hover);
    transform: scale(1.05);
}

/* Desktop Reopen Button */
.reopen-sidebar-btn {
    position: absolute;
    top: 24px;
    left: 24px;
    z-index: 400;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    color: var(--text-main);
    transition: all 0.2s;
}
.reopen-sidebar-btn:hover {
    background: rgba(40, 40, 40, 0.8);
    transform: scale(1.05);
}
.reopen-sidebar-btn.hidden {
    display: none;
}

/* Scroll Handle (Left Slidebar) */
.scroll-handle {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 100px;
    background: rgba(20, 20, 20, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-left: none;
    border-radius: 0 12px 12px 0;
    z-index: 400;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    cursor: pointer;
    box-shadow: 2px 0 8px rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    transition: all 0.2s;
}
.scroll-handle:hover {
    color: var(--text-main);
    background: rgba(40, 40, 40, 0.9);
    width: 28px;
}
.scroll-handle i {
    font-size: 0.85rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .app-container {
        height: calc(100vh - 70px); /* Fill exact screen minus mobile navbar */
        min-height: unset; /* Remove the 800px constraint on mobile */
        margin-top: 70px;
    }

    .sidebar {
        position: fixed;
        top: 70px; /* Below navbar */
        left: 0;
        height: calc(100vh - 70px);
        width: 100%; /* Take full width on mobile */
        max-width: 100%;
        transform: translateX(-100%);
        margin-left: 0 !important; /* Override collapsed margin */
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .close-sidebar-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        background: rgba(255, 255, 255, 0.05);
        border: 1px solid rgba(255, 255, 255, 0.1);
    }

    .map-mobile-toggle {
        display: flex !important;
    }
    
    .reopen-sidebar-btn {
        display: none !important; /* Ensure desktop reopen button never shows on mobile */
    }

    .sidebar-toggle-btn {
        display: none !important; /* Hide desktop toggle button inside header on mobile */
    }
}
