body, html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    font-family: 'Helvetica Neue', Arial, sans-serif;
}

/* ── Main Map Area — wrapper for map canvas + all UI controllers ── */
#main-map-area {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

#map {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* Fallback color — bầu trời thực tế do MapLibre setSky() render trên canvas */
    background: #199EF3;
}

/* ── Synchronized Map (Right 1/2) — hidden by default ── */
#sync-map {
    position: absolute;
    top: 0;
    bottom: 0;
    right: 0;
    width: 50%;
    height: 100%;
    /* Fallback color — bầu trời thực tế do MapLibre setSky() render trên canvas */
    background: #199EF3;
    border-left: 2px solid rgba(148, 163, 184, 0.35);
    z-index: 0;
    /* Hidden by default (single mode) */
    display: none;
    opacity: 0;
    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Sync Mode: activated via body.sync-mode ── */
body.sync-mode #main-map-area {
    width: 50%;
}

body.sync-mode #sync-map {
    display: block;
    opacity: 1;
}

/* Keep MapLibre controls at original viewport positions in sync mode */
body.sync-mode #map .maplibregl-ctrl-bottom-right,
body.sync-mode #map .maplibregl-ctrl-top-right {
    position: fixed !important;
}

body.sync-mode #map .maplibregl-ctrl-top-left {
    position: fixed !important;
}

/* Hide all default MapLibre controls on sync map */
#sync-map .maplibregl-control-container {
    display: none !important;
}

/* --- Thanh điều khiển lớp dữ liệu (top-right, bên trái nút MapLibre) --- */
#grid-controls-bar {
    position: absolute;
    top: 10px;
    right: 100px; /* Chừa chỗ cho nút So sánh (sync-toggle-bar) bên phải */
    z-index: 1000;
    display: flex;
    flex-wrap: nowrap;
    justify-content: flex-end;
    align-items: center;
    gap: 6px;
    width: max-content;
    pointer-events: none;
    transition: right 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Nút So sánh (tách riêng, không bị ẩn khi sync mode) --- */
#sync-toggle-bar {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 1001;
    pointer-events: auto;
    transition: right 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Shift all controllers right when info sidebar (400px) is open */
/* body:has(.info-sidebar.open) #grid-controls-bar stays at top-right, no shift needed */

body:has(.info-sidebar.open) #top-bar {
    left: 400px;
}

body:has(.info-sidebar.open) #map .maplibregl-ctrl-top-left,
body:has(.info-sidebar.open) #map .maplibregl-ctrl-bottom-left {
    left: 400px !important;
    transition: left 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.bottom-panel-group {
    pointer-events: auto;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(14px);
    padding: 3px 8px;
    border-radius: 24px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(0,0,0,0.04);
    border: none;
    display: flex;
    align-items: center;
    gap: 2px;
}

/* --- School Controls --- */
#school-controls {
    display: flex;
    align-items: center;
    gap: 2px;
}

/* --- Modern Toggle Switch --- */
.toggle-switch {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 6px;
    background: transparent;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.toggle-switch:hover:not(:disabled) {
    background: rgba(0, 0, 0, 0.04);
}

.toggle-switch:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    filter: grayscale(80%);
}

.switch-track {
    position: relative;
    width: 26px;
    height: 14px;
    background-color: #cbd5e1;
    border-radius: 999px;
    transition: background-color 0.3s ease, border-color 0.3s ease;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.12);
    border: 1px solid #94a3b8;
    flex-shrink: 0;
}

.switch-thumb {
    position: absolute;
    top: 0px;
    left: 0px;
    width: 12px;
    height: 12px;
    background-color: #ffffff;
    border: 1px solid #94a3b8;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.toggle-switch.active .switch-track.track-teal {
    background-color: #14b8a6;
    border-color: #0d9488;
}

.toggle-switch.active .switch-track.track-amber {
    background-color: #f59e0b; /* amber-500 */
    border-color: #d97706;
}

.toggle-switch.active .switch-track.track-indigo {
    background-color: #6366f1; /* indigo-500 */
    border-color: #4f46e5;
}

.toggle-switch.active .switch-track.track-green {
    background-color: #22c55e; /* green-500 */
    border-color: #16a34a;
}

.toggle-switch.active .switch-track.track-blue {
    background-color: #3b82f6; /* blue-500 */
    border-color: #2563eb;
}

.toggle-switch.active .switch-track.track-yellow {
    background-color: #eab308; /* yellow-500 */
    border-color: #ca8a04;
}

.toggle-switch.active .switch-track.track-red {
    background-color: #ef4444; /* red-500 */
    border-color: #dc2626;
}

.toggle-switch.active .switch-track.track-purple {
    background-color: #a855f7; /* purple-500 */
    border-color: #9333ea;
}

.toggle-switch.active .switch-thumb {
    transform: translateX(12px);
    border-color: rgba(0,0,0,0.1);
}

.switch-label {
    font-size: 11px;
    font-weight: 600;
    color: #64748b;
    transition: color 0.3s ease;
    white-space: nowrap;
}

.toggle-switch.active .switch-track.track-teal + .switch-label { color: #0f766e; }
.toggle-switch.active .switch-track.track-amber + .switch-label { color: #b45309; }
.toggle-switch.active .switch-track.track-indigo + .switch-label { color: #4338ca; }
.toggle-switch.active .switch-track.track-green + .switch-label { color: #15803d; }
.toggle-switch.active .switch-track.track-blue + .switch-label { color: #1d4ed8; }
.toggle-switch.active .switch-track.track-yellow + .switch-label { color: #a16207; }
.toggle-switch.active .switch-track.track-red + .switch-label { color: #b91c1c; }
.toggle-switch.active .switch-track.track-purple + .switch-label { color: #7e22ce; }

.control-divider {
    width: 1px;
    height: 18px;
    background-color: #e2e8f0;
    margin: 0 2px;
}

/* --- Legend Panel --- */
#legend-container {
    position: absolute;
    bottom: 4rem;
    right: 1.5rem;
    z-index: var(--z-dropdown);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(226, 232, 240, 0.8);
    border-radius: 12px;
    padding: 1rem 1.25rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    width: 280px;
    font-size: 13px;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease, right 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: auto;
}
#legend-container .gradient { width: 100%; height: 10px; border-radius: 5px; border: 1px solid #ccc; margin-bottom: 4px; }
#legend-container .labels { display: flex; justify-content: space-between; font-weight: bold; font-size: 11px; margin-top: 5px; }

.hover-tooltip-popup { z-index: 1200 !important; pointer-events: none; }
.hover-tooltip-popup .maplibregl-popup-content { padding: 0; background: transparent; box-shadow: none; border-radius: 10px; overflow: visible; }
.hover-tooltip-popup .maplibregl-popup-tip { border-top-color: rgba(255, 255, 255, 0.97); }
.hover-tooltip-popup .maplibregl-popup-close-button { display: none; }

.maplibregl-popup-content { padding: 0; border-radius: 8px; overflow: hidden; box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06); }
.maplibregl-popup-close-button { font-size: 16px; color: #64748b; padding: 4px 8px; right: 4px; top: 4px; border-radius: 50%; transition: all 0.2s; }
.maplibregl-popup-close-button:hover { background-color: rgba(0,0,0,0.05); color: #1e293b; }

/* --- Professional Loader --- */
.loader-overlay { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: #ffffff; z-index: 999999; display: flex; justify-content: center; align-items: center; transition: opacity 0.5s ease, visibility 0.5s ease; }
.loader-content { display: flex; flex-direction: column; align-items: center; gap: 2.5rem; animation: loaderPopIn 0.6s cubic-bezier(0.16, 1, 0.3, 1); }
.loader-logo-wrapper { position: relative; display: flex; justify-content: center; align-items: center; }

.loader-logo {
    width: 140px;
    height: auto;
    filter: drop-shadow(0 10px 15px rgba(0, 0, 0, 0.1));
    animation: loaderFloat 3s ease-in-out infinite;
}

.loader-text {
    font-size: 0.9rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: #1e40af;
    background: linear-gradient(90deg, #1e3a8a, #3b82f6, #1e3a8a);
    background-size: 200% auto;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: textShimmer 2s linear infinite;
}

@keyframes rippleEffect {
    0% { transform: scale(0.8); opacity: 1; }
    100% { transform: scale(2.2); opacity: 0; }
}

@keyframes loaderFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

@keyframes loaderPopIn {
    0% { opacity: 0; transform: scale(0.95) translateY(15px); }
    100% { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes textShimmer {
    to { background-position: 200% center; }
}

/* --- Basemap Error Toast Notification --- */
#basemap-error-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    z-index: 10000;
    opacity: 0;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.4s ease;
    pointer-events: none;
}

#basemap-error-toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    pointer-events: auto;
}

.basemap-toast-content {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(15, 23, 42, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: #f8fafc;
    padding: 12px 18px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 500;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    white-space: nowrap;
}

.basemap-toast-content i { color: #fbbf24; font-size: 15px; }

#toast-switch-basemap {
    background: #3b82f6;
    color: white;
    border: none;
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}
#toast-switch-basemap:hover { background: #2563eb; }

#toast-dismiss {
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 18px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    transition: color 0.2s;
}
#toast-dismiss:hover { color: #f8fafc; }

/* --- ADDED FROM OLD PROJECT --- */
/* --- Thanh tìm kiếm ở trên --- */
#top-bar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1001;
    display: flex;
    gap: 0.5rem;
    justify-content: flex-start;
    align-items: center;
    padding: 10px 60px 0 10px; /* 10px top, 60px right (for map controls), 0 bottom, 10px left */
    pointer-events: none;
    transition: left 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}


#logo-container {
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.hcmedu-logo {
    height: 82px;
    display: block;
}

/* 3 nút tác vụ phía trên */
.top-action-btn {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(226, 232, 240, 0.8);
    color: #475569;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: auto;
}

.top-action-btn:hover {
    background: #ffffff;
    color: #3b82f6;
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(59, 130, 246, 0.15);
}

.top-action-btn.active {
    background: #3b82f6;
    color: #ffffff;
    border-color: #2563eb;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
}

.top-action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}


@media (max-width: 640px) {
    #top-bar {
        padding: 0.5rem;
    }

    .hcmedu-logo {
        height: 80px;
    }
}

#search-container {
    position: relative;
    width: 400px;
    flex-shrink: 0;
    pointer-events: auto;
}

@media (max-width: 640px) {
    #search-container {
        max-width: 85%;
    }

    #search-box {
        padding: 0.4rem 0.4rem;
        font-size: 0.7rem;
    }

    #SearchInput {
        font-size: 0.7rem;
    }

    #logo-container {
        margin-right: 0.5rem;
    }
}

#search-box {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(229, 231, 235, 0.7);
    border-radius: 12px;
    padding: 0.6rem 1rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08), 0 1px 3px rgba(0, 0, 0, 0.03);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0.6;
}

#search-box:hover,
#search-box:focus-within,
#search-box:has(#SearchInput:not(:placeholder-shown)) {
    opacity: 1;
}

#search-box:focus-within {
    background: rgba(255, 255, 255, 0.98);
    border-color: #3b82f6;
    box-shadow: 0 8px 30px rgba(59, 130, 246, 0.15), 0 0 0 3px rgba(59, 130, 246, 0.1);
    transform: translateY(-1px);
}

.search-icon {
    color: #64748b;
    font-size: 14px;
    transition: color 0.3s ease;
}

#search-box:focus-within .search-icon {
    color: #3b82f6;
}

#SearchInput {
    width: 100%;
    background: transparent;
    font-size: 0.85rem;
    font-weight: 500;
    color: #0f172a;
    outline: none;
    border: none;
    padding: 0;
}

#SearchInput::placeholder {
    color: #94a3b8;
    font-weight: 400;
}



#btn-search-clear {
    background: transparent;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    font-size: 1.1rem;
    padding: 0 4px;
    transition: color 0.2s;
    display: flex;
    align-items: center;
}
#btn-search-clear:hover { color: #ef4444; }
#btn-search-clear.hidden { display: none !important; }

/* Pulse Marker for Geocoding */
.geocode-marker-icon {
    position: relative;
    width: 20px;
    height: 20px;
}
.geocode-marker-dot {
    width: 14px;
    height: 14px;
    background-color: #ef4444;
    border: 2px solid white;
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
    z-index: 2;
}
.geocode-marker-pulse {
    width: 30px;
    height: 30px;
    background-color: rgba(239, 68, 68, 0.4);
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1;
    animation: geocode-pulse 1.5s ease-out infinite;
}
@keyframes geocode-pulse {
    0% { transform: translate(-50%, -50%) scale(0.5); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(1.5); opacity: 0; }
}

/* Modern User Location Beacon */
.user-loc-wrapper {
    position: relative;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-loc-core {
    width: 18px;
    height: 18px;
    background: linear-gradient(135deg, #22d3ee, #0891b2);
    border: 2px solid white;
    border-radius: 50%;
    position: relative;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 3px 6px rgba(0,0,0,0.4);
}

.user-loc-pulse {
    position: absolute;
    width: 100%;
    height: 100%;
    background-color: rgba(6, 182, 212, 0.45);
    border-radius: 50%;
    z-index: 2;
    animation: user-loc-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.user-loc-radar {
    position: absolute;
    width: 150%;
    height: 150%;
    border-radius: 50%;
    border: 1px solid rgba(6, 182, 212, 0.6);
    z-index: 1;
    animation: user-loc-radar 3s linear infinite;
}

@keyframes user-loc-pulse {
    0% { transform: scale(1); opacity: 0.8; }
    50% { transform: scale(2.2); opacity: 0; }
    100% { transform: scale(2.2); opacity: 0; }
}

@keyframes user-loc-radar {
    0% { transform: scale(0.5); opacity: 0; }
    20% { opacity: 1; }
    80% { transform: scale(2.5); opacity: 0; }
    100% { opacity: 0; }
}

#search-results {
    display: none;
    position: absolute;
    top: calc(100% + 12px);
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(16px);
    border-radius: 12px;
    box-shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.15), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    max-height: 45vh;
    overflow-y: auto;
    border: 1px solid rgba(229, 231, 235, 0.8);
    z-index: 1000;
    padding: 0.4rem;
}

#search-results::-webkit-scrollbar {
    width: 6px;
}

#search-results::-webkit-scrollbar-track {
    background: transparent;
}

#search-results::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}

#search-results button.focused-search-result {
    background-color: #eff6ff;
    border-radius: 8px;
    outline: none;
    box-shadow: 0 0 0 2px #3b82f6 inset;
}

#search-results button:hover {
    background-color: #f8fafc;
    border-radius: 8px;
}

/* ══════════════════════════════════════════════
   TOP ACTION BUTTONS (Info, Routing, Projects)
   ══════════════════════════════════════════════ */
.top-action-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 2px solid #e2e8f0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    font-size: 1.15rem;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
    position: relative;
}

.top-action-btn:hover {
    transform: scale(1.08) translateY(-2px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.15);
    background: #ffffff;
}

/* Info Button */
.top-action-btn.btn-info {
    color: #3b82f6; /* Blue */
}
.top-action-btn.btn-info:hover {
    border-color: #3b82f6;
}

/* Routing Button */
.top-action-btn.btn-routing {
    color: #10b981; /* Emerald */
}
.top-action-btn.btn-routing:hover {
    border-color: #10b981;
}
.top-action-btn.btn-routing.active {
    background: linear-gradient(135deg, #10b981, #059669);
    color: #fff;
    border-color: #059669;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.3), 0 4px 12px rgba(16, 185, 129, 0.35);
    animation: routing-btn-pulse 2s ease-in-out infinite;
}

/* Projects Button */
.top-action-btn.btn-projects {
    color: #f59e0b; /* Amber */
}
.top-action-btn.btn-projects:hover {
    border-color: #f59e0b;
}

.top-action-btn.btn-projects i.school-icon {
    animation: pulseGlow 2.5s infinite alternate;
}

.top-action-btn.btn-projects i.plus-icon {
    position: absolute;
    top: 6px;
    right: 4px;
    font-size: 0.6rem;
    color: #ef4444;
    font-weight: 900;
    text-shadow: 1px 1px 0 #fff, -1px -1px 0 #fff, 1px -1px 0 #fff, -1px 1px 0 #fff;
}

@keyframes pulseGlow {
    from {
        filter: drop-shadow(0 0 1px rgba(245, 158, 11, 0.4));
        transform: scale(1);
    }
    to {
        filter: drop-shadow(0 0 4px rgba(245, 158, 11, 0.8));
        transform: scale(1.05);
    }
}
/* ══════════════════════════════════════════════
   ROUTING FEATURE STYLES
   ══════════════════════════════════════════════ */

/* Routing mode: crosshair cursor on map */
body.routing-mode #map {
    cursor: crosshair !important;
}

@keyframes routing-btn-pulse {
    0%, 100% { box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.3), 0 4px 12px rgba(16, 185, 129, 0.35); }
    50% { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0.15), 0 4px 16px rgba(16, 185, 129, 0.4); }
}

/* Routing Overlay */
.routing-overlay {
    position: fixed;
    inset: 0;
    background: transparent;
    z-index: 9990;
    display: none;
}

.routing-overlay.active {
    display: block;
}

/* Right Panel Container */
.right-panel-container {
    position: fixed;
    top: 80px;
    right: 60px;
    width: 340px;
    max-height: calc(100vh - 180px); /* Avoid overlapping grid-controls-bar */
    display: flex;
    flex-direction: column;
    gap: 16px;
    z-index: 9995;
    pointer-events: none; /* Let clicks pass through empty space */
    transition: right 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}


/* Routing Panel - Modern Minimalist Style */
.routing-panel {
    width: 100%;
    position: relative;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(16px);
    border: 1px solid rgba(226, 232, 240, 0.8);
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.08), 0 2px 10px rgba(0, 0, 0, 0.04);
    display: none;
    flex-direction: column;
    overflow: hidden;
    pointer-events: auto; /* Re-enable clicks */
    transform: translateX(20px);
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
    font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.routing-panel.active {
    display: flex;
    transform: translateX(0);
    opacity: 1;
}

.routing-panel-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 20px 16px;
    border-bottom: 1px solid rgba(226, 232, 240, 0.8);
    color: #1e293b;
    font-weight: 700;
    font-size: 1rem;
    background: rgba(255, 255, 255, 0.5);
}

.routing-panel-header i {
    color: #10b981; /* Emerald to match the button */
    font-size: 1.2rem;
}

.routing-panel-close {
    margin-left: auto;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    border: 1px solid rgba(226, 232, 240, 0.8);
    background: rgba(241, 245, 249, 0.6);
    color: #94a3b8;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s ease;
}

.routing-panel-close:hover {
    background: #fee2e2;
    color: #ef4444;
    border-color: #fca5a5;
}

.routing-panel-close i {
    color: inherit;
    font-size: inherit;
}

.routing-panel-hint {
    padding: 12px 20px;
    color: #64748b;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(248, 250, 252, 0.7);
    border-bottom: 1px solid rgba(226, 232, 240, 0.5);
}

.routing-panel-hint i {
    color: #3b82f6;
    animation: pulse-soft 2s infinite;
}

@keyframes pulse-soft {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(0.95); }
}

/* Routing Results */
.routing-results {
    flex: 1;
    overflow-y: auto;
    padding: 0;
    background: transparent;
}

.routing-results::-webkit-scrollbar {
    width: 6px;
}

.routing-results::-webkit-scrollbar-thumb {
    background: rgba(203, 213, 225, 0.8);
    border-radius: 4px;
}

.routing-results::-webkit-scrollbar-track {
    background: transparent;
}

/* Segment block */
.routing-segment {
    border-bottom: 1px solid rgba(226, 232, 240, 0.5);
}

.routing-segment-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: rgba(241, 245, 249, 0.5);
    color: #334155;
    font-size: 0.8rem;
    font-weight: 600;
}

.routing-segment-header .seg-label {
    display: flex;
    align-items: center;
    gap: 8px;
}

.routing-segment-header .seg-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.routing-segment-dist {
    color: #3b82f6;
    font-weight: 700;
    font-size: 0.8rem;
}

/* Route summary - main roads as chips */
.routing-summary {
    padding: 10px 16px 12px;
}

.routing-summary-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.routing-summary-label i {
    color: #3b82f6;
    font-size: 0.75rem;
}

.routing-main-roads {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.routing-road-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    padding: 4px 10px 4px 12px;
    transition: background 0.15s, border-color 0.15s;
}

.routing-road-chip:hover {
    background: #e0f2fe;
    border-color: #bae6fd;
}

.road-chip-name {
    font-size: 0.78rem;
    font-weight: 600;
    color: #334155;
    white-space: nowrap;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.road-chip-dist {
    font-size: 0.65rem;
    font-weight: 700;
    color: #3b82f6;
    background: rgba(59, 130, 246, 0.1);
    padding: 1px 6px;
    border-radius: 10px;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.routing-road-arrow {
    color: #cbd5e1;
    font-size: 0.55rem;
    flex-shrink: 0;
}

.routing-other-roads {
    margin-top: 6px;
    font-size: 0.7rem;
    color: #94a3b8;
    font-style: italic;
}

/* Total summary – prominent */
.routing-total {
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(135deg, #f0fdf4, #ecfdf5);
    border-top: 1px solid rgba(16, 185, 129, 0.15);
}

.routing-total-label {
    color: #475569;
    font-weight: 600;
    font-size: 0.82rem;
    display: flex;
    align-items: center;
}

.routing-total-label i {
    color: #10b981;
    margin-right: 8px;
    font-size: 1rem;
}

.routing-total-value {
    color: #065f46;
    font-weight: 800;
    font-size: 1.1rem;
    font-variant-numeric: tabular-nums;
}

/* Actions */
.routing-panel-actions {
    padding: 14px 20px;
    background: #ffffff;
    border-top: 1px solid #e2e8f0;
}

.btn-routing-clear {
    width: 100%;
    padding: 10px;
    border-radius: 10px;
    border: 1px solid rgba(239, 68, 68, 0.2);
    background: rgba(239, 68, 68, 0.05);
    color: #ef4444;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-routing-clear:hover {
    background: #ef4444;
    color: #ffffff;
    border-color: #ef4444;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.2);
}

/* ── Routing Schools Along Route ── */
.routing-schools-section {
    margin: 12px 16px 4px;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    overflow: hidden;
}

.routing-schools-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: linear-gradient(135deg, #fef3c7, #fffbeb);
    border-bottom: 1px solid #fde68a;
}

.routing-schools-header .rs-icon {
    width: 28px;
    height: 28px;
    background: linear-gradient(135deg, #f59e0b, #f97316);
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(245, 158, 11, 0.35);
}

.routing-schools-header .rs-icon i {
    color: #fff;
    font-size: 12px;
}

.routing-schools-header .rs-title {
    font-size: 12.5px;
    font-weight: 700;
    color: #92400e;
    flex: 1;
}

.routing-schools-header .rs-count {
    font-size: 11px;
    color: #b45309;
    background: rgba(245, 158, 11, 0.15);
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: 999px;
    padding: 1px 8px;
    font-weight: 600;
    white-space: nowrap;
}

.routing-schools-header .rs-toggle-btn {
    margin-left: auto;
    flex-shrink: 0;
    width: 26px;
    height: 26px;
    border-radius: 7px;
    border: 1px solid rgba(245, 158, 11, 0.3);
    background: rgba(255, 255, 255, 0.6);
    color: #b45309;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 11px;
    transition: background 0.15s, color 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.routing-schools-header .rs-toggle-btn:hover {
    background: rgba(245, 158, 11, 0.15);
    border-color: #f59e0b;
    box-shadow: 0 2px 6px rgba(245, 158, 11, 0.2);
}

.routing-schools-header .rs-toggle-btn.active {
    background: linear-gradient(135deg, #f59e0b, #f97316);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 2px 6px rgba(245, 158, 11, 0.35);
}

.routing-schools-list {
    max-height: 196px;
    overflow-y: auto;
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.routing-schools-list::-webkit-scrollbar {
    width: 4px;
}

.routing-schools-list::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 2px;
}

.routing-school-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 10px;
    border-radius: 8px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, transform 0.1s, box-shadow 0.15s;
    text-decoration: none;
}

.routing-school-item:hover {
    background: #eff6ff;
    border-color: #bfdbfe;
    transform: translateX(2px);
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.1);
}

.routing-school-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 0 2px rgba(255,255,255,0.8), 0 0 0 3px currentColor;
}

.routing-school-info {
    flex: 1;
    min-width: 0;
}

.routing-school-name {
    font-size: 12px;
    font-weight: 600;
    color: #1e293b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.routing-school-cap {
    font-size: 10px;
    color: #64748b;
    margin-top: 1px;
    line-height: 1;
}

.routing-school-dist {
    font-size: 10.5px;
    font-weight: 600;
    color: #94a3b8;
    flex-shrink: 0;
    white-space: nowrap;
    background: #f1f5f9;
    border-radius: 6px;
    padding: 2px 7px;
}

/* Routing Markers (numbered pins) */
.routing-marker {
    width: 32px;
    height: 32px;
    border-radius: 50% 50% 50% 0;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    border: 2.5px solid #fff;
    box-shadow: 0 3px 10px rgba(0,0,0,0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 800;
    font-size: 13px;
    transform: rotate(-45deg);
    transform-origin: center center;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.routing-marker span {
    transform: rotate(45deg);
}

.routing-marker:hover {
    transform: rotate(-45deg) scale(1.15);
    box-shadow: 0 4px 14px rgba(59, 130, 246, 0.5);
}

.routing-marker.waypoint-0 {
    background: linear-gradient(135deg, #22c55e, #16a34a);
}

.routing-marker.waypoint-2 {
    background: linear-gradient(135deg, #ef4444, #dc2626);
}

/* Loading state for routing */
.routing-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 24px;
    color: #94a3b8;
    font-size: 0.85rem;
}

.routing-loading i {
    color: #60a5fa;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Animated route line */
@keyframes dash-flow {
    to { stroke-dashoffset: -20; }
}

/* Responsive */
@media (max-width: 768px) {
    .right-panel-container {
        top: auto;
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        max-height: 50vh;
    }

    .routing-panel {
        border-radius: 16px 16px 0 0;
        transform: translateY(20px);
    }

    .routing-panel.active {
        transform: translateY(0);
    }
}

/* Custom premium style for routing engine & vehicle tabs */
.routing-options-container {
    padding: 14px 20px;
    border-bottom: 1px solid rgba(226, 232, 240, 0.8);
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: rgba(248, 250, 252, 0.5);
}

.routing-engine-tabs {
    display: flex;
    background: #e2e8f0;
    padding: 3px;
    border-radius: 12px;
    gap: 2px;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.06);
}

.routing-engine-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 12px;
    border: none;
    background: transparent;
    border-radius: 9px;
    color: #475569;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.routing-engine-btn:hover {
    color: #0f172a;
}

.routing-engine-btn.active {
    background: #ffffff;
    color: #10b981;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.06), 0 2px 4px rgba(0, 0, 0, 0.04);
}

.routing-engine-btn i {
    font-size: 0.95rem;
    transition: transform 0.2s ease;
}

.routing-engine-btn.active i {
    transform: scale(1.1);
    color: #10b981;
}

.routing-costing-buttons {
    display: flex;
    gap: 8px;
    transition: all 0.3s ease;
}

.routing-costing-buttons.hidden {
    display: none !important;
}

.routing-costing-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 4px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    color: #64748b;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.routing-costing-btn:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
    color: #334155;
}

.routing-costing-btn.active {
    background: #ecfdf5;
    border-color: #34d399;
    color: #047857;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.1);
}

.routing-costing-btn i {
    font-size: 1.1rem;
    transition: transform 0.2s ease;
}

.routing-costing-btn.active i {
    transform: scale(1.15);
}

/* ══════════════════════════════════════════════
   3D SCHOOL COLUMN HOVER TOOLTIP (Custom DOM)
   ══════════════════════════════════════════════ */
.school-3d-tooltip-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.school-3d-tip-card {
    background: rgba(15, 23, 42, 0.88);
    backdrop-filter: blur(16px) saturate(1.8);
    border: 1px solid rgba(148, 163, 184, 0.15);
    border-radius: 10px;
    padding: 7px 14px;
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.3),
        0 0 0 1px rgba(255, 255, 255, 0.04),
        inset 0 1px 0 rgba(255, 255, 255, 0.06);
    text-align: center;
    white-space: nowrap;
    animation: school-tip-appear 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.school-3d-tip-name {
    font-size: 12.5px;
    font-weight: 700;
    color: #f1f5f9;
    letter-spacing: 0.01em;
    line-height: 1.3;
}

.school-3d-tip-meta {
    font-size: 11px;
    font-weight: 600;
    color: #38bdf8;
    margin-top: 2px;
    font-variant-numeric: tabular-nums;
}

@keyframes school-tip-appear {
    from {
        opacity: 0;
        transform: translateY(4px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}
/* ================================================================
   GIS Tools Panel -- Modern Floating Panel
   ================================================================ */

.gis-left-panel {
    display: flex;
    align-items: flex-end;
    position: relative;
}

/* ── FAB Button ── */
.gis-fab {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    border: none;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    color: #e2e8f0;
    font-size: 17px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2), 0 0 0 1px rgba(255,255,255,0.06);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    z-index: 1;
}

.gis-fab:hover {
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    color: #38bdf8;
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(56,189,248,0.15), 0 0 0 1px rgba(56,189,248,0.2);
}

.gis-fab:active { transform: translateY(0); }

.gis-fab i { transition: transform 0.3s ease; }
.gis-fab:hover i { transform: rotate(-12deg) scale(1.1); }

/* ── Panel ── */
.gis-panel {
    position: absolute;
    left: 0;
    bottom: calc(100% + 10px);
    width: 280px;
    background: rgba(255,255,255,0.96);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(226,232,240,0.6);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.12), 0 0 0 1px rgba(0,0,0,0.02);
    z-index: 9999;
    overflow: hidden;
    animation: gis-panel-in 0.25s cubic-bezier(0.16,1,0.3,1);
}

.gis-panel.hidden { display: none !important; }

@keyframes gis-panel-in {
    from { opacity: 0; transform: translateY(12px) scale(0.96); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Header */
.gis-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px 12px;
    border-bottom: 1px solid rgba(226,232,240,0.7);
}

.gis-panel-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 700;
    color: #0f172a;
}

.gis-panel-title i { color: #3b82f6; font-size: 14px; }

.gis-panel-close {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    border: none;
    background: rgba(241,245,249,0.8);
    color: #94a3b8;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition: all 0.15s ease;
}

.gis-panel-close:hover { background: #e2e8f0; color: #475569; }

/* Body */
.gis-panel-body {
    padding: 8px 0;
    max-height: 420px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(148,163,184,0.3) transparent;
}

/* Group */
.gis-group + .gis-group {
    border-top: 1px solid rgba(226,232,240,0.5);
    margin-top: 4px;
    padding-top: 4px;
}

.gis-group-label {
    font-size: 10px;
    font-weight: 700;
    color: #94a3b8;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 8px 16px 4px;
}

/* Item row */
.gis-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 16px;
    border: none;
    background: none;
    cursor: pointer;
    font-family: inherit;
    font-size: 13px;
    color: #334155;
    transition: all 0.15s ease;
    text-align: left;
    position: relative;
}

.gis-item:hover:not(:disabled) { background: rgba(241,245,249,0.8); }
.gis-item:active:not(:disabled) { background: rgba(226,232,240,0.8); }
.gis-item:disabled { opacity: 0.4; cursor: not-allowed; }
.gis-item:disabled .gis-item-icon { filter: grayscale(100%); }

/* Icon */
.gis-item-icon {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    color: #fff;
    background: var(--icon-bg);
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
    transition: transform 0.2s ease;
}

.gis-item:hover:not(:disabled) .gis-item-icon { transform: scale(1.08); }

.gis-item-text { font-weight: 500; flex: 1; }

/* Badge */
.gis-item-badge {
    font-size: 9px;
    font-weight: 800;
    color: #16a34a;
    background: rgba(22,163,74,0.1);
    padding: 2px 7px;
    border-radius: 6px;
    letter-spacing: 0.06em;
}

/* Active */
.gis-item.gis-item-active,
.gis-item.gis-tool-active {
    background: rgba(59,130,246,0.06);
}

.gis-item.gis-item-active .gis-item-text,
.gis-item.gis-tool-active .gis-item-text {
    color: #1d4ed8;
    font-weight: 600;
}

/* Danger */
.gis-item.gis-item-danger:hover:not(:disabled) { background: rgba(239,68,68,0.06); }
.gis-item.gis-item-danger:hover .gis-item-text { color: #dc2626; }

/* Footer */
.gis-panel-footer {
    padding: 8px 16px;
    border-top: 1px solid rgba(226,232,240,0.5);
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(248,250,252,0.8);
}

.gis-panel-footer i { color: #94a3b8; font-size: 10px; }
.gis-panel-footer span { font-size: 11px; color: #94a3b8; }

.gis-panel-footer kbd {
    background: #e2e8f0;
    border-radius: 4px;
    padding: 1px 5px;
    color: #475569;
    font-size: 10px;
    font-family: inherit;
}

/* Compat: old class for JS toggling */
.gis-tool-active { background: rgba(59,130,246,0.06); }

.gis-icon-btn.gis-tool-active .gis-icon-wrap {
    box-shadow: 0 0 14px rgba(6,182,212,0.45), 0 3px 10px rgba(0,0,0,0.3);
}

/* Popup ket qua do khoang cach */
.measure-result-popup .maplibregl-popup-content {
    background: rgba(10,17,32,0.94);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(6,182,212,0.3);
    border-radius: 12px;
    color: #e2e8f0;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    padding: 4px 12px;
    font-size: 13px;
    font-weight: 700;
}
.measure-result-popup .maplibregl-popup-tip {
    border-top-color: rgba(10,17,32,0.94);
}

/* ══════════════════════════════════════════════
   SYNC MODE — DUAL CONTROLLER BOTTOM BAR
   ══════════════════════════════════════════════ */

/* Sync dual-controller: hidden by default, shown in sync mode */
#sync-controls {
    display: none !important;
}

body.sync-mode #sync-controls {
    display: flex !important;
    align-items: center;
}

/* Hide main-map grid controls in sync mode (sync-controls replaces them) */
body.sync-mode #grid-controls-bar {
    display: none !important;
}

/* ── Sync Legend (left side, for sync map) ── */
#sync-legend-container {
    position: absolute;
    bottom: 5.5rem;
    left: 1.5rem;
    z-index: var(--z-dropdown);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(226, 232, 240, 0.8);
    border-radius: 12px;
    padding: 1rem 1.25rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    width: 280px;
    font-size: 13px;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: auto;
}

#sync-legend-container .gradient {
    width: 100%;
    height: 10px;
    border-radius: 5px;
    border: 1px solid #ccc;
    margin-bottom: 4px;
}

#sync-legend-container .labels {
    display: flex;
    justify-content: space-between;
    font-weight: bold;
    font-size: 11px;
    margin-top: 5px;
}

/* In sync mode, move main legend to right half only */
body.sync-mode #legend-container {
    right: calc(1.5rem);
}

/* Responsive: stack vertically on narrow screens */
@media (max-width: 900px) {
    #sync-controls {
        flex-direction: column !important;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
   COORDINATE TOOLS — Dialog, Markers, Popup, Hint
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Go-To Dialog ── */
.coord-dialog {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.coord-dialog-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(4px);
}

.coord-dialog-content {
    position: relative;
    width: 360px;
    max-width: 90vw;
    background: white;
    border-radius: 16px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    overflow: hidden;
    animation: coordDialogIn 0.25s ease-out;
}

@keyframes coordDialogIn {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.coord-dialog-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 20px;
    background: linear-gradient(135deg, #0f766e, #14b8a6);
    color: white;
    font-size: 15px;
    font-weight: 700;
}

.coord-dialog-header i:first-child {
    font-size: 18px;
}

.coord-dialog-close {
    margin-left: auto;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.15);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s ease;
}

.coord-dialog-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.coord-dialog-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.coord-input-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.coord-input-group label {
    font-size: 12px;
    font-weight: 600;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.coord-input-group input {
    padding: 10px 14px;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    font-size: 15px;
    font-family: 'SF Mono', 'Cascadia Code', 'Fira Code', monospace;
    color: #1e293b;
    background: #f8fafc;
    transition: all 0.2s ease;
    outline: none;
}

.coord-input-group input:focus {
    border-color: #14b8a6;
    box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.15);
    background: white;
}

.coord-input-group input.coord-input-error {
    border-color: #ef4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
    animation: coordShake 0.4s ease;
}

@keyframes coordShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-6px); }
    75% { transform: translateX(6px); }
}

.coord-hint {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #0f766e;
}

.coord-hint code {
    background: rgba(20, 184, 166, 0.15);
    padding: 1px 5px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 11px;
}


.coord-dialog-footer {
    display: flex;
    gap: 10px;
    padding: 16px 20px;
    border-top: 1px solid #f1f5f9;
    background: #fafbfc;
}

.coord-btn-secondary {
    flex: 1;
    padding: 10px;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    background: white;
    color: #64748b;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.coord-btn-secondary:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
}

.coord-btn-primary {
    flex: 1.5;
    padding: 10px;
    border: none;
    border-radius: 10px;
    background: linear-gradient(135deg, #0f766e, #14b8a6);
    color: white;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(20, 184, 166, 0.3);
}

.coord-btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(20, 184, 166, 0.4);
}

/* ── Go-To Marker ── */
.goto-marker-el {
    position: relative;
    width: 40px;
    height: 40px;
}

.goto-marker-pin {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%) translateY(-100%);
    width: 36px;
    height: 42px;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    animation: gotoMarkerBounce 0.6s ease-out;
}

.goto-marker-pin i {
    font-size: 38px;
    color: #ef4444;
    filter: drop-shadow(0 3px 6px rgba(239, 68, 68, 0.4));
}

@keyframes gotoMarkerBounce {
    0% { transform: translateX(-50%) translateY(-200%); }
    60% { transform: translateX(-50%) translateY(-95%); }
    80% { transform: translateX(-50%) translateY(-105%); }
    100% { transform: translateX(-50%) translateY(-100%); }
}

.goto-marker-pulse {
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 16px;
    height: 16px;
    transform: translateX(-50%);
    border-radius: 50%;
    background: rgba(239, 68, 68, 0.3);
    animation: gotoMarkerPulse 2s ease-out infinite;
}

@keyframes gotoMarkerPulse {
    0% { transform: translateX(-50%) scale(1); opacity: 0.6; }
    100% { transform: translateX(-50%) scale(3); opacity: 0; }
}

/* ── Pick Marker ── */
.pick-marker-el {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: #f59e0b;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
    animation: pickMarkerPop 0.3s ease-out;
}

@keyframes pickMarkerPop {
    from { transform: scale(0); }
    to { transform: scale(1); }
}

/* ── Coordinate Popup ── */
.coord-popup .maplibregl-popup-content {
    padding: 0 !important;
    border-radius: 12px !important;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15) !important;
}

.coord-popup-content {
    min-width: 180px;
}

.coord-popup-title {
    padding: 8px 14px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    font-size: 12px;
    font-weight: 700;
    color: #475569;
    display: flex;
    align-items: center;
    gap: 6px;
}

.coord-popup-title i {
    color: #14b8a6;
}

.coord-popup-coords {
    padding: 10px 14px;
    font-size: 13px;
    color: #334155;
    line-height: 1.8;
}

.coord-popup-label {
    font-weight: 600;
    color: #64748b;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.coord-popup-coords code {
    background: #f1f5f9;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'SF Mono', 'Cascadia Code', monospace;
    font-size: 13px;
    font-weight: 600;
    color: #0f766e;
}

.coord-popup-copy {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 8px;
    border: none;
    border-top: 1px solid #e2e8f0;
    background: #f8fafc;
    color: #3b82f6;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.coord-popup-copy:hover {
    background: #eff6ff;
    color: #2563eb;
}

/* ── Pick Mode Hint Toast ── */
.coord-pick-hint {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    padding: 10px 20px;
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(8px);
    color: white;
    font-size: 13px;
    font-weight: 600;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 5000;
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.coord-pick-hint.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.coord-pick-hint i {
    color: #f59e0b;
    font-size: 16px;
}

.coord-pick-hint kbd {
    padding: 2px 8px;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    font-family: inherit;
    font-size: 11px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   INFO SIDEBAR — Google Maps-style left panel
   ═══════════════════════════════════════════════════════════════════════════ */

.info-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 400px;
    height: 100vh;
    background: #fff;
    box-shadow: 2px 0 16px rgba(0, 0, 0, 0.1);
    z-index: 3000;
    display: flex;
    flex-direction: column;
    transform: translateX(-100%);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.info-sidebar.open {
    transform: translateX(0);
}

.info-sidebar-search-slot {
    flex-shrink: 0;
    padding: 10px 10px 0;
    background: white;
}

.info-sidebar-search-slot:empty {
    display: none;
}

#search-container.in-sidebar {
    position: relative !important;
    top: auto !important;
    left: auto !important;
    transform: none !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0;
}

#search-container.in-sidebar #search-box {
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
    opacity: 1;
    background: rgba(255, 255, 255, 0.98);
}

.info-sidebar-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.info-sidebar-content::-webkit-scrollbar { width: 5px; }
.info-sidebar-content::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.3);
    border-radius: 4px;
}

.info-sidebar-body { padding: 0; }

.info-sidebar-collapse {
    position: absolute;
    top: 50%;
    right: -18px;
    transform: translateY(-50%) translateX(8px);
    width: 18px;
    height: 56px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(226, 232, 240, 0.5);
    border-left: none;
    border-radius: 0 12px 12px 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
    font-size: 10px;
    z-index: 10;
    opacity: 0;
    pointer-events: none;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 4px 0 16px rgba(0, 0, 0, 0.06);
}

.info-sidebar.open .info-sidebar-collapse {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(-50%) translateX(0);
}

.info-sidebar-collapse:hover {
    width: 24px;
    right: -24px;
    background: #ffffff;
    color: #3b82f6;
    box-shadow: 4px 0 20px rgba(59, 130, 246, 0.12);
}

.info-sidebar-collapse i {
    transition: transform 0.2s ease;
}

.info-sidebar-collapse:hover i {
    transform: translateX(-1px);
}

/* Highlight marker */
.sidebar-highlight-marker {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--marker-color, #3b82f6);
    border: 3px solid white;
    box-shadow: 0 0 0 2px var(--marker-color, #3b82f6), 0 2px 8px rgba(0,0,0,0.3);
    position: relative;
}

.sidebar-highlight-marker::after {
    content: '';
    position: absolute;
    top: -8px; left: -8px;
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--marker-color, #3b82f6);
    opacity: 0.2;
    animation: sb-pulse 2s ease-out infinite;
}

@keyframes sb-pulse {
    0% { transform: scale(0.8); opacity: 0.3; }
    70% { transform: scale(2); opacity: 0; }
    100% { transform: scale(2); opacity: 0; }
}

/* ── Sidebar Card Styles ──────────────────────────────────────────────── */

.sb-card { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; font-size: 14px; }

.sb-card-header {
    padding: 20px 20px 16px;
    border-bottom: 1px solid #f1f5f9;
}

.sb-card-header-color {
    border-left: 4px solid var(--sb-color, #3b82f6);
    padding-left: 14px;
}

.sb-card-badges { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }

.sb-badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 2px 10px; border-radius: 99px;
    font-size: 11px; font-weight: 700; white-space: nowrap;
}

.sb-badge-primary { color: white; background: var(--sb-color, #3b82f6); }
.sb-badge-outline { color: #475569; background: #f1f5f9; border: 1px solid #e2e8f0; }
.sb-badge-star { color: #b45309; background: #fffbeb; border: 1px solid #fde68a; }

.sb-card-title { font-size: 20px; font-weight: 700; color: #0f172a; line-height: 1.3; margin: 0; }
.sb-card-subtitle { font-size: 12px; color: #94a3b8; margin-top: 2px; }

.sb-section { padding: 14px 20px; border-bottom: 1px solid #f1f5f9; }
.sb-section:last-child { border-bottom: none; }

.sb-info-row {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 5px 0; font-size: 13px; color: #334155; line-height: 1.5;
}

.sb-info-row i {
    color: #94a3b8; font-size: 12px; margin-top: 3px;
    width: 16px; text-align: center; flex-shrink: 0;
}

.sb-contact-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 0; }

.sb-chip {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 5px 12px; border-radius: 8px;
    font-size: 12px; font-weight: 500; text-decoration: none;
    transition: all 0.15s; cursor: pointer; border: 1px solid;
}

.sb-chip-blue { color: #2563eb; background: #eff6ff; border-color: #bfdbfe; }
.sb-chip-blue:hover { background: #dbeafe; border-color: #93c5fd; }
.sb-chip-green { color: #059669; background: #ecfdf5; border-color: #a7f3d0; }
.sb-chip-green:hover { background: #d1fae5; }

.sb-stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; padding: 4px 0; }
.sb-stats-grid-2 { grid-template-columns: 1fr 1fr; }

.sb-stat {
    background: #f8fafc; border: 1px solid #e2e8f0;
    border-radius: 10px; padding: 10px 6px; text-align: center;
}

.sb-stat-value { font-size: 16px; font-weight: 700; color: #0f172a; line-height: 1.2; }
.sb-stat-label {
    font-size: 9px; font-weight: 600; color: #94a3b8;
    text-transform: uppercase; letter-spacing: 0.5px; margin-top: 4px;
}

.sb-actions { display: flex; gap: 8px; padding: 4px 0; }

.sb-action-btn {
    flex: 1; display: flex; align-items: center; justify-content: center;
    gap: 6px; padding: 10px 8px; border-radius: 10px;
    font-size: 12px; font-weight: 600; cursor: pointer;
    transition: all 0.15s; border: 1.5px solid; text-decoration: none;
}

.sb-action-btn-blue { color: #2563eb; background: #eff6ff; border-color: #bfdbfe; }
.sb-action-btn-blue:hover { background: #dbeafe; transform: translateY(-1px); }
.sb-action-btn-orange { color: #ea580c; background: #fff7ed; border-color: #fed7aa; }
.sb-action-btn-orange:hover { background: #ffedd5; transform: translateY(-1px); }
.sb-action-btn-red { color: #dc2626; background: #fef2f2; border-color: #fecaca; }
.sb-action-btn-red:hover { background: #fee2e2; transform: translateY(-1px); }
.sb-action-btn-slate { color: #64748b; background: #f8fafc; border-color: #e2e8f0; }

.sb-note {
    display: flex; align-items: flex-start; gap: 8px;
    font-size: 12.5px; color: #64748b; line-height: 1.6; font-style: italic;
}
.sb-note i { color: #94a3b8; font-size: 12px; margin-top: 3px; flex-shrink: 0; }

.sb-loading {
    display: flex; align-items: center; justify-content: center;
    gap: 10px; padding: 40px 20px; color: #64748b; font-size: 13px;
}

@media (max-width: 480px) {
    .info-sidebar { width: 100vw; }
    .info-sidebar-collapse { display: none; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   NEW SCHOOL PROJECT — Edit Side Panel (Google Maps style, docked left)
   ═══════════════════════════════════════════════════════════════════════════ */

.nsp-edit-panel {
    position: fixed;
    top: 0;
    left: 0;
    width: 380px;
    height: 100vh;
    background: #ffffff;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.12);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    transform: translateX(-100%);
    opacity: 0;
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.25s ease;
}

.nsp-edit-panel.visible {
    transform: translateX(0);
    opacity: 1;
}

/* Header */
.nsp-edit-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: linear-gradient(135deg, #1e3a5f, #2563eb);
    color: white;
    flex-shrink: 0;
}

.nsp-edit-header-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 15px;
    font-weight: 700;
}

.nsp-edit-header-title i {
    font-size: 17px;
    opacity: 0.9;
}

.nsp-edit-close {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.25);
    background: rgba(255,255,255,0.12);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
    flex-shrink: 0;
}

.nsp-edit-close:hover {
    background: rgba(255,255,255,0.25);
    transform: scale(1.05);
}

/* Body — scrollable */
.nsp-edit-body {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

.nsp-edit-body::-webkit-scrollbar {
    width: 4px;
}
.nsp-edit-body::-webkit-scrollbar-thumb {
    background: rgba(148,163,184,0.3);
    border-radius: 4px;
}

/* Sections */
.nsp-edit-section {
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    border-bottom: 1px solid #f1f5f9;
}

.nsp-edit-section:last-child {
    border-bottom: none;
}

.nsp-edit-section-title {
    font-size: 12px;
    font-weight: 700;
    color: #1e40af;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 2px;
}

.nsp-edit-section-title i {
    font-size: 13px;
    opacity: 0.8;
}

/* Form rows */
.nsp-edit-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nsp-edit-row label {
    font-size: 11px;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.nsp-edit-row input,
.nsp-edit-row select,
.nsp-edit-row textarea {
    padding: 9px 12px;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    font-size: 13px;
    color: #1e293b;
    background: #f8fafc;
    outline: none;
    transition: all 0.2s;
    font-family: inherit;
}

.nsp-edit-row input:focus,
.nsp-edit-row select:focus,
.nsp-edit-row textarea:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
    background: white;
}

.nsp-edit-row textarea {
    resize: vertical;
    min-height: 44px;
}

.nsp-edit-row-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

/* Live coordinate display */
.nsp-edit-coord-live {
    display: flex;
    gap: 12px;
}

.nsp-coord-pair {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: 8px;
}

.nsp-coord-label {
    font-size: 10px;
    font-weight: 700;
    color: #0369a1;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.nsp-coord-pair code {
    font-family: 'SF Mono', 'Cascadia Code', 'Fira Code', monospace;
    font-size: 13px;
    font-weight: 600;
    color: #0c4a6e;
    background: transparent;
}

/* Coordinate hint */
.nsp-edit-coord-hint {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    font-size: 12px;
    color: #991b1b;
    font-weight: 500;
    line-height: 1.5;
}

.nsp-edit-coord-hint i {
    font-size: 14px;
    color: #dc2626;
    flex-shrink: 0;
}

.nsp-marker-badge {
    font-weight: 700;
    white-space: nowrap;
}

/* Footer */
.nsp-edit-footer {
    display: flex;
    gap: 10px;
    padding: 16px 20px;
    border-top: 1px solid #e2e8f0;
    background: #f8fafc;
    flex-shrink: 0;
}

.nsp-btn-cancel {
    flex: 1;
    padding: 10px;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    background: white;
    color: #64748b;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.nsp-btn-cancel:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
}

.nsp-btn-save {
    flex: 1.5;
    padding: 10px;
    border: none;
    border-radius: 10px;
    background: linear-gradient(135deg, #1e40af, #3b82f6);
    color: white;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(59,130,246,0.25);
}

.nsp-btn-save:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(59,130,246,0.35);
}

.nsp-btn-save:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

/* Responsive: narrow screens */
@media (max-width: 480px) {
    .nsp-edit-panel {
        width: 100vw;
    }
}

