:root {
    --primary: #2c3e50;
    --accent: #4a90e2;
    --success: #2ecc71;
    --danger: #e74c3c;
    --warning: #f39c12;
    --bg-light: #FAF7F2;
    /* Standard Cream Color */
    --text-main: #2c3e50;
    --text-muted: #666;
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.3);
    --sidebar-header-bg: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    --shadow-soft: 0 8px 32px 0 rgba(31, 38, 135, 0.15);
}

.admin-only {
    display: none !important;
}

body.edit-mode-active .admin-only {
    display: flex !important;
}

/* Specific override for non-flex admin elements */
body.edit-mode-active button.admin-only,
body.edit-mode-active div.admin-only {
    display: block !important;
}

body {
    display: flex;
    height: 100vh;
    overflow: hidden;
    color: var(--text-main);
    background-color: var(--bg-light);
}

#sidebar {
    width: 360px;
    height: 100%;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-right: 1px solid var(--glass-border);
    box-shadow: var(--shadow-soft);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: width 0.3s ease;
}

#sidebar-header {
    background: var(--sidebar-header-bg);
    color: white;
    padding: 25px 20px;
    text-align: left;
    position: relative;
    flex-shrink: 0;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

#lang-switch {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-bottom: 15px;
}

#sidebar-header h1 {
    margin: 0;
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

#sidebar-header p {
    margin: 5px 0 0;
    font-size: 0.95rem;
    opacity: 0.85;
    font-weight: 300;
}

/* Lang Buttons */
.lang-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 4px 10px;
    font-size: 1.2rem;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.lang-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
}

.lang-btn.active {
    background: white;
    color: var(--primary);
    border-color: white;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}


/* Filter Container */
#filter-container,
#route-filter-container {
    padding: 10px 15px;
    background: rgba(0, 0, 0, 0.02);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: row;
    /* Ensure row */
    flex-wrap: wrap;
    align-content: flex-start;
    /* Prevent vertical stretching */
    gap: 8px;
    flex-shrink: 0;
}

#filter-container::-webkit-scrollbar,
#route-filter-container::-webkit-scrollbar {
    height: 0px;
}

.filter-btn,
.route-filter-btn {
    background: white;
    border: 1px solid rgba(0, 0, 0, 0.08);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.03);
    flex: 0 0 auto;
}

.filter-btn:hover,
.route-filter-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.06);
}

.filter-btn.active,
.route-filter-btn.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

/* RIGHT SIDEBAR */
#sidebar-right {
    width: 300px;
    /* Slightly narrower than left */
    height: 100%;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-left: 1px solid var(--glass-border);
    box-shadow: -8px 0 32px 0 rgba(31, 38, 135, 0.15);
    /* Shadow on left */
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: width 0.3s ease;
}

#sidebar-right-header {
    background: var(--sidebar-header-bg);
    /* Use same header bg */
    color: white;
    padding: 15px;
}

#sidebar-right-header h2 {
    margin: 0 0 10px 0;
    font-size: 1.2rem;
}

/* POI List */
#poi-list {
    list-style: none;
    padding: 0;
    margin: 0;
    flex: 1.5;
    /* Takes 60% of available space relative to routes */
    overflow-y: auto;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.poi-item {
    padding: 10px 15px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.03);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 12px;
}

.poi-item:hover {
    background-color: rgba(74, 144, 226, 0.05);
}

.poi-item.active {
    background-color: rgba(74, 144, 226, 0.1);
    border-left: 4px solid var(--accent);
}

.poi-icon {
    font-size: 1.2rem;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
    flex-shrink: 0;
}

.poi-info h3 {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-main);
    line-height: 1.2;
}

.poi-info p {
    margin: 2px 0 0;
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.2;
}

.poi-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 4px;
    padding: 2px 8px;
    /* Very compact */
    background-color: rgba(255, 255, 255, 0.05);
    color: #bdc3c7 !important;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    text-decoration: none;
    font-size: 0.7rem;
    transition: all 0.3s ease;
}

.poi-link:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: white !important;
}

/* Routes Section */
#routes-section {
    border-top: 1px solid rgba(255, 255, 255, 0.5);
    padding: 0;
    background: rgba(0, 0, 0, 0.02);
    display: flex;
    flex-direction: column;
    flex: 1;
    /* Takes remaining space */
    overflow: hidden;
    /* Contains the scrollable list */
    min-height: 150px;
    /* Prevent collapse */
}

#routes-section h2,
#routes-section h3 {
    padding: 12px 20px;
    font-size: 1rem;
    font-weight: 700;
    color: white;
    margin: 0;
    background: var(--accent);
    /* More visible background */
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
    /* Header stays fixed */
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

#routes-list {
    list-style: none;
    padding: 0;
    margin: 0;
    overflow-y: auto;
    flex-grow: 1;
    /* Fills the rest of the section */
}

.route-item {
    padding: 12px 15px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: background 0.2s;
}

.route-item:hover {
    background: rgba(0, 0, 0, 0.03);
}

.route-item.active {
    background: rgba(46, 204, 113, 0.1);
    border-left: 4px solid var(--success);
}

.route-info h3 {
    padding: 0;
    margin: 0;
    font-size: 0.85rem;
    color: var(--text-main);
}

.route-info p {
    margin: 2px 0 0 0;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.route-actions {
    display: none;
}

.route-item:hover .route-actions {
    display: block;
}

.btn-delete-route {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    padding: 5px;
    border-radius: 5px;
    transition: background 0.2s;
}

.btn-delete-route:hover {
    background: rgba(231, 76, 60, 0.1);
}

.btn-download-route {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    padding: 5px;
    border-radius: 5px;
    transition: background 0.2s;
}

.btn-download-route:hover {
    background: rgba(46, 204, 113, 0.1);
}

/* Actions Panel (Imported Route) */
#route-info-panel {
    display: none;
    padding: 15px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    margin-top: 15px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.action-btn {
    background: var(--accent);
    border: none;
    color: white;
    padding: 6px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 500;
    transition: all 0.2s;
}

.action-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* Map Styling */
#map {
    flex-grow: 1;
    height: 100%;
}

.leaflet-popup-content-wrapper {
    border-radius: 15px;
    padding: 0;
    overflow: hidden;
    box-shadow: var(--shadow-soft);
}

.leaflet-popup-content {
    margin: 0;
    width: 220px !important;
    /* Smaller width */
}

.popup-img {
    width: 100%;
    height: 110px;
    /* Smaller height */
    object-fit: cover;
}

.popup-inner {
    padding: 10px 12px;
    /* reduced padding */
}

.popup-inner b {
    display: block;
    font-size: 0.95rem;
    /* slightly smaller title */
    margin-bottom: 3px;
    line-height: 1.2;
}

.popup-inner span {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: block;
    margin-bottom: 6px;
    line-height: 1.3;
}

/* Modal Styling */
.modal-content {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(15px);
    padding: 30px;
    border-radius: 24px;
    box-shadow: var(--shadow-soft);
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    body {
        flex-direction: column;
        /* Stack vertically */
    }

    #sidebar,
    #sidebar-right {
        width: 100%;
        height: auto;
        flex: none;
        /* Do not grow/shrink */
    }

    #sidebar {
        order: 2;
        /* Put left sidebar below map */
        height: 40vh;
    }

    #sidebar-right {
        order: 3;
        /* Put right sidebar at very bottom */
        height: 30vh;
    }

    #map {
        height: 30vh;
        /* Map on top/middle */
        order: 1;
        flex-grow: 1;
    }
}

/* Improve Leaflet Popup Close Button Visibility */
.leaflet-popup-close-button {
    width: 32px !important;
    height: 32px !important;
    font: 22px/32px Tahoma, Verdana, sans-serif !important;
    color: #333 !important;
    background: #ffffff !important;
    border: 2px solid rgba(0, 0, 0, 0.1) !important;
    border-radius: 50%;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4) !important;
    top: 10px !important;
    right: 10px !important;
    display: flex;
    /* Centering */
    align-items: center;
    justify-content: center;
    text-decoration: none !important;
    transition: all 0.2s ease;
    z-index: 1000;
}

.leaflet-popup-close-button:hover {
    background: #f0f0f0 !important;
    color: #000 !important;
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5) !important;
}

/* Ensure it stays on top of images */
.leaflet-popup-content-wrapper {
    overflow: hidden;
    /* Ensure rounded corners clip content */
}