/* === 1. LAYOUT & SIDEBAR STATE === */
:root { 
    --red-flag: #da251d; 
    --dark-red: #b31d17; 
    --yellow-star: #ffff00; 
    --sidebar-w: 280px; 
}

/* Đồng nhất trạng thái bản đồ */
body {
    margin: 0;
    padding: 0;
    overflow: hidden;
    display: block !important;
}

#map {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 1;
}

/* 1. Khung Sidebar mặc định (Fixed để nổi lên trên bản đồ) */
#sidebar {
    position: fixed !important; /* Cưỡng bách vị trí */
    top: 0;
    bottom: 0;
    left: -100% !important; /* Đảm bảo ẩn hoàn toàn khi không có class show */
    width: 280px;
    background: linear-gradient(180deg, #da251d 0%, #b31d17 100%) !important;
    z-index: 99999 !important; /* Đẩy lên trên cả bản đồ và các nút khác */
    display: flex !important; /* Luôn là flex để chứa nội dung bên trong */
    flex-direction: column;
    transition: left 0.3s ease-in-out;
    box-shadow: 5px 0 15px rgba(0,0,0,0.3);
}

/* Class mở Sidebar */
#sidebar.show {
    left: 0 !important;
}

/* 2. Tay nắm điều khiển (Sidebar Handle) */
#sidebarHandle {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    width: 30px;
    height: 60px;
    background: var(--red-flag);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 5001 !important;
    border-radius: 0 8px 8px 0;
    transition: left 0.3s ease;
    box-shadow: 2px 0 5px rgba(0,0,0,0.2);
}

/* 3. Lớp phủ mờ (Overlay) */
#sidebarOverlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 4999;
    display: none;
    backdrop-filter: blur(3px);
}

#sidebar.show ~ #sidebarOverlay {
    display: block;
}

/* 4. Thành phần bên trong Sidebar */
.sidebar-header {
    padding: 20px 15px 10px;
    text-align: center;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    color: #fc0;
}
.sidebar-footer {
    color: #fc0;
    font-size: 10px;
    text-align: center;
}
.sidebar-header h1 { font-size: 20px; margin: 0; font-weight: bold; }

.sidebar-search { padding: 10px; }
.search-wrapper { display: flex; gap: 5px; }
#search {
    flex: 1;
    padding: 8px 12px;
    border-radius: 5px;
    border: none;
}

.sidebar-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

#list-xa {
    margin: 0;
    padding: 0;
    list-style: none;
}

#list-xa li {
    padding: 12px 15px;
    border-radius: 6px;
    margin-bottom: 5px;
    color: #ff0;
    cursor: pointer;
    background: rgba(255,255,255,0.05);
    transition: 0.2s;
}

#list-xa li:hover { background: rgba(255,255,255,0.2); }
#list-xa li.active { background: white; color: #da251d; font-weight: bold; }

/* === 5. CẤU HÌNH DESKTOP (>= 768px) === */
@media (min-width: 768px) {
    /* Mặc định trên Desktop là HIỆN */
    body:not(.sidebar-hidden) #sidebar {
        left: 0;
        z-index: 9999999 !important;
    }
    body:not(.sidebar-hidden) #sidebarHandle {
        left: var(--sidebar-w);
    }
    /* Khi người dùng chủ động ẩn Sidebar */
    body.sidebar-hidden #sidebar {
        left: calc(-1 * var(--sidebar-w));
    }
    body.sidebar-hidden #sidebarHandle {
        left: 0;
    }
    #sidebarHandle{left:0 !important;bottom:86px}
}

/* === 6. CẤU HÌNH MOBILE (< 768px) === */
@media (max-width: 767.98px) {
    #sidebar {
        width: 60vw !important;
        left: -85vw !important;
    }
    #sidebar.show {
        left: 0 !important;
        z-index: 9999999 !important;
    }

    .sidebar-header h1 { font-size: 18px; }
}

/* === 7. CÁC THÀNH PHẦN PHỤ TRỢ (Tooltip, Button) === */
.custom-focus-tooltip {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
}

.btn-focus-detail {
    background: #da251d;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 25px;
    font-size: 13px;
    font-weight: bold;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

/* Filter System */
.filter-float {
    position: fixed;
    bottom: 16px;
    left: 16px;
    width: min(380px, 92vw);
    background: #fff;
    border: 6px solid #057111;
    border-radius: 10px;
    z-index: 3800;
    display: none;
}
.filter-float.show { display: block; }