﻿html, body, #map {
    height: 100%;
    margin: 0;
    padding: 0;
}
body {
    user-select: none;
}

#layerSidebar {
    position: absolute;
    top: 0px;
    left: 0;
    width: 300px;
    height: calc(100% - 0px);
    background: #ffffffee;
    border-right: 2px solid #ddd;
    box-shadow: 4px 0 8px rgba(0,0,0,0.15);
    transition: all 0.35s ease;
    z-index: 9990;
    padding: 10px;
    display: flex;
    flex-direction: column;
}

    #layerSidebar.sidebar-collapsed {
        transform: translateX(-100%);
    }

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-weight: bold;
}

.sidebar-content {
    overflow-y: auto;
    flex: 1;
}


.floating-btn {
    position: absolute;
    top: 65px;
    left: 25px;
    z-index: 1000; /* giảm từ 10000 */
    background: #fff;
    border-radius: 50%;
    width: 42px;
    height: 42px;
    border: 1px solid #ccc;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
}


#layerSidebarUser {
    position: absolute;
    top: 0px;
    left: 0;
    width: 300px;
    height: calc(100% - 0px);
    background: #ffffffee;
    border-right: 2px solid #ddd;
    box-shadow: 4px 0 8px rgba(0,0,0,0.15);
    transition: all 0.35s ease;
    z-index: 9999;
    padding: 10px;
    display: flex;
    flex-direction: column;
}

    #layerSidebarUser.sidebarUser-collapsed {
        transform: translateX(-100%);
    }

.sidebarUser-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-weight: bold;
}

.sidebarUser-content {
    overflow-y: auto;
    flex: 1;
}


.floatingUser-btn {
    position: absolute;
    top: 18px;
    left: 25px;
    z-index: 1000;
    background: #fff;
    border-radius: 50%;
    width: 42px;
    height: 42px;
    border: 4px solid #ccc;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    overflow: hidden; /* rất quan trọng để avatar lấp đầy vòng tròn */
}

    /* Avatar lấp đầy nút */
    .floatingUser-btn img.user-avatar {
        width: 100%;
        height: 100%;
        object-fit: cover; /* giữ tỉ lệ, không méo */
        border-radius: 50%;
        display: block; /* loại bỏ inline spacing */
    }

    /* SVG icon lấp đầy nút */
    .floatingUser-btn svg.user-icon {
        width: 100%;
        height: 100%;
        display: block; /* loại bỏ inline spacing */
    }



.user-shifted {
    left: 315px !important; /* 300px sidebar width + 35px margin */
}

.floatingUser-btn {
    transition: left 0.35s ease; /* cho animation mượt */
}




.leaflet-marker-icon.selected-marker {
    transform: scale(1.2);
    filter: drop-shadow(0 0 6px blue);
    z-index: 9999 !important;
}


#ui-locker {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255,255,255,0.2);
    z-index: 99999; /* tăng lên */
    cursor: wait;
    display: none;
}

.leaflet-tooltip-pane {
    z-index: 9999;
}

.map-label .NameLabel {
    display: inline-block;
    transform: translateY(-50px); /* đẩy lên 10px */
    pointer-events: none; /* tránh label che marker */
}

/* Loại bỏ khung khi layer được focus */
.leaflet-interactive:focus,
.leaflet-interactive {
    outline: none !important;
    box-shadow: none !important;
}


#loading-indicator {
    position: fixed;
    left: 50%;
    bottom: 50%;
    transform: translateX(-50%);
    background: rgba(255,255,255,0.9);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
    display: none;
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
    z-index: 9999;
}

    #loading-indicator .spinner-border {
        width: 1rem;
        height: 1rem;
        border-width: 2px;
        margin-right: 5px;
    }

.map-label {
    pointer-events: none;
    position: absolute;
    transform: translate(-50%, -50%); /* canh giữa theo tọa độ */
    white-space: nowrap;
    text-align: center;
    font-family: "Segoe UI", Roboto, Arial, sans-serif;
    font-weight: 200;
    color: #fff;
}

    .map-label .label-wrap {
        transform-origin: center center;
        transition: all 0.25s ease-out;
    }

    .map-label .label-text {
        background: rgba(0, 0, 0, 0.2);
        padding: 4px 10px;
        border-radius: 8px;
        border: 1px solid rgba(255, 255, 255, 0.2);
        box-shadow: 0 2px 6px rgba(0,0,0,0.3);
        backdrop-filter: blur(3px);
        font-size: 8px;
    }

.map-label-xa {
    pointer-events: none;
    position: absolute;
    transform: translate(-50%, -50%); /* canh giữa theo tọa độ */
    white-space: nowrap;
    text-align: center;
    font-family: "Segoe UI", Roboto, Arial, sans-serif;
    font-weight: 200;
    color: #fff;
}

    .map-label-xa .label-wrap-xa {
        transform-origin: center center;
        transition: all 0.25s ease-out;
    }

    .map-label-xa .label-text-xa {
        background: rgba(0, 0, 0, 0.2);
        padding: 4px 8px;
        border-radius: 5px;
        border: 1px solid rgba(255, 255, 255, 0.2);
        box-shadow: 0 2px 6px rgba(0,0,0,0.3);
        backdrop-filter: blur(3px);
        font-size: 10px;
    }


/* Hover để mở danh sách layer */
/* ========================================================================== */																											   🎨 Nút toggle hiển thị lớp bản đồ
.leaflet-control .area-control {
    z-index: 9999 !important;
    margin-top: 60px !important; /* đẩy xuống dưới control layer mặc định */
    position: relative;
}



/* Khi chưa hover thì ẩn danh sách lớp */
.leaflet-control-layers:not(:hover) .leaflet-control-layers-list {
    display: none;
}

/* Hover để hiện danh sách */
.leaflet-control-layers:hover .leaflet-control-layers-list {
    display: block;
}

/* Tùy chỉnh nút toggle */
.leaflet-control-layers-toggle {
    width: 34px;
    height: 34px;
    background-color: #fff;
    background-image: url('/lib/leaflet/images/layers.png');
    background-repeat: no-repeat;
    background-position: center;
    background-size: 20px 20px;
    border-radius: 6px;
    box-shadow: 0 1px 5px rgba(0,0,0,0.4);
}


.leaflet-control-layers label svg {
    vertical-align: middle;
    margin-right: 4px;
    transform: translateY(-1px);
}

/* ===========================
																												   🎨 Hover Dropdown cho Area Control
																												   =========================== */
.leaflet-control.area-control {
    position: absolute;
    z-index: 500;
    right: 0px;
    top: 266px;
    border: 2px solid rgba(0, 0, 0, 0.2);
    border-radius: 5px;
}

.leaflet-top.leaflet-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}




.leaflet-control.toggle-fill-control {
    position: absolute;
    z-index: 600;
    right: 0px;
    top: 160px;
    border: 2px solid rgba(0, 0, 0, 0.2);
    border-radius: 5px;
}

.toggle-fill-control .toggle-fill-btn {
    width: 44px;
    height: 44px;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
    cursor: pointer;
}

.leaflet-control.toggle-goworld-control {
    position: absolute;
    z-index: 600;
    right: 0px;
    top: 60px;
    border: 2px solid rgba(0, 0, 0, 0.2);
    border-radius: 5px;
}

.toggle-goworld-control .toggle-goworld-btn {
    width: 44px;
    height: 44px;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
    cursor: pointer;
}

.leaflet-control.toggle-govnm-control {
    position: absolute;
    z-index: 600;
    right: 0px;
    top: 110px;
    border: 2px solid rgba(0, 0, 0, 0.2);
    border-radius: 5px;
}

.toggle-govnm-control .toggle-govnm-btn {
    width: 44px;
    height: 44px;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
    cursor: pointer;
}

.leaflet-control.backmap-control {
    position: absolute;
    z-index: 500;
    right: 0px;
    top: 210px;
    border: 2px solid rgba(0, 0, 0, 0.2);
    border-radius: 5px;
}

.backmap-control .backmap-btn {
    width: 44px;
    height: 44px;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
    cursor: pointer;
}


/* Giữ nút area-btn cùng kích thước với layer-control */
.area-control .area-btn {
    width: 44px;
    height: 44px;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
    cursor: pointer;
}

/* Dropdown */
.area-dropdown {
    position: absolute;
    top: 0; /* chỉnh thấp hơn để vừa layer-control */
    right: 0;
    min-width: 250px;
    max-height: 60vh;
    overflow-y: auto;
    background: white;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    padding: 6px 0;
    opacity: 0;
    transform: translateY(-6px);
    pointer-events: none;
    transition: all 0.2s ease;
}

.leaflet-control.area-control {
    margin-top: 4px; /* hoặc 6px tùy bạn muốn cao/thấp */
}

/* Hover để hiện dropdown */
.area-control:hover .area-dropdown {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

/* Hover để hiện dropdown */
.area-control:hover .area-dropdown {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}


.leaflet-right .leaflet-control {
    margin-right: 0px;
}

/* Canh cụm nút zoom + custom ở giữa bên phải */
.leaflet-bottom.leaflet-right {
    bottom: 0px !important;
    z-index: 800;
}

.leaflet-right {
    right: 10px !important;
}

.leaflet-bar {
    margin-bottom: 8px;
}

.leaflet-control-attribution {
    display: none !important;
}

.leaflet-bar.custom-btn {
    background: white;
    box-shadow: 0 1px 4px rgba(0,0,0,0.4);
    border-radius: 4px;
    overflow: hidden;
}

    .leaflet-bar.custom-btn a {
        display: block;
        text-align: center;
        line-height: 28px;
        font-size: 18px;
        color: #333;
        text-decoration: none;
        width: 30px;
        height: 30px;
    }

        .leaflet-bar.custom-btn a:hover {
            background-color: #f4f4f4;
        }

.leaflet-control-area {
    position: absolute;
    top: 70px;
    right: 27px;
    z-index: 900;
    background: transparent;
    font-family: system-ui, sans-serif;
}

    .leaflet-control-area .area-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        background: #fff;
        border-radius: 4px;
        box-shadow: 0 1px 4px rgba(0,0,0,0.4);
        width: 44px;
        height: 44px;
        right: 25px;
        cursor: pointer;
        user-select: none;
        font-size: 16px;
        color: #333;
        line-height: 1;
        transition: background-color 0.2s ease, box-shadow 0.2s ease;
        border: 1px solid rgba(0,0,0,0.15);
    }

        .leaflet-control-area .area-btn:hover {
            background-color: #f4f4f4;
            box-shadow: 0 1px 6px rgba(0,0,0,0.45);
        }

    .leaflet-control-area .area-dropdown {
        position: absolute;
        top: 0;
        right: 0;
        background: #fff;
        border-radius: 4px;
        min-width: 220px;
        max-height: calc(100vh - 140px);
        overflow-y: auto;
        box-shadow: 0 1px 6px rgba(0,0,0,0.25);
        border: 1px solid rgba(0,0,0,0.08);
        padding: 6px 0;
        display: none;
        transform-origin: top right;
        animation: fadeSlideDown 180ms ease;
    }

        .leaflet-control-area .area-dropdown.show {
            display: block;
        }

    .leaflet-control-area .area-option {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 6px 10px;
        font-size: 14px;
        color: #222;
        cursor: pointer;
        white-space: normal;
        line-height: 1.3;
    }

        .leaflet-control-area .area-option:hover {
            background: #f4f4f4;
        }

        .leaflet-control-area .area-option input[type="radio"] {
            flex-shrink: 0;
            width: 14px;
            height: 14px;
            accent-color: #007bff;
            margin: 0;
        }

.area-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    font-size: 14px;
    color: #222;
    cursor: pointer;
    white-space: normal;
    line-height: 1.3;
    transition: background-color 0.2s ease;
}

    .area-option:hover {
        background: #f4f4f4;
    }

    .area-option .arrow-icon {
        color: #007bff;
        font-size: 13px;
        transition: transform 0.2s ease;
    }

    .area-option:hover .arrow-icon {
        transform: translateX(3px);
    }

@keyframes fadeSlideDown {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.polygon-label div {
    text-align: center;
    font-weight: bold;
    text-shadow: 1px 1px 2px #fff;
    pointer-events: none;
}

.geo-popup h4 {
    margin: 0 0 6px;
    font-size: 15px;
    color: #2b4c7e;
    border-bottom: 1px solid #ddd;
    padding-bottom: 4px;
}

.geo-popup table {
    border-collapse: collapse;
}

.geo-popup td {
    padding: 2px 4px;
    vertical-align: top;
}

.geo-context-menu {
    user-select: none;
}

.leaflet-popup-pane {
    z-index: 9999;
}

.area-option.parent {
    font-weight: 700;
    color: #003366;
    border-bottom: 1px solid #ddd;
    padding: 5px 6px;
}

.area-option.child {
    margin-left: 20px;
    color: #333;
    padding: 3px 6px;
}


/* CSS mặc định cho desktop & portrait mobile */
.leaflet-bar.custom-btn {
    position: absolute; /* mặc định leaflet control là absolute */
    bottom: 70px; /* khoảng cách từ đáy */
    right: 0px; /* khoảng cách từ bên phải */
    display: flex;
    flex-direction: column; /* xếp dọc mặc định */
    gap: 5px;
    z-index: 9999;
}

@media only screen and (max-width: 932px) {
    #layerSidebar {
        position: absolute;
        top: 0px;
        left: 0;
        width: 250px;
        height: calc(100% - 0px);
        background: #ffffffee;
        border-right: 2px solid #ddd;
        box-shadow: 4px 0 8px rgba(0,0,0,0.15);
        transition: all 0.35s ease;
        z-index: 9990;
        padding: 10px;
        display: flex;
        flex-direction: column;
    }

        #layerSidebar.sidebar-collapsed {
            transform: translateX(-100%);
        }

    .user-shifted {
        left: 260px !important; /* 300px sidebar width + 35px margin */
    }

}


@media only screen and (max-width: 932px) and (orientation: landscape) {

    .leaflet-control.area-control {
        position: absolute;
        z-index: 700;
        right: 150px;
        border: 2px solid rgba(0, 0, 0, 0.2);
        border-radius: 5px;
        top: 16px;
    }

    .area-dropdown {
        position: absolute;
        top: 0; /* chỉnh thấp hơn để vừa layer-control */
        right: 0;
        min-width: 250px;
        max-height: 75vh;
        overflow-y: auto;
        background: white;
        border-radius: 6px;
        box-shadow: 0 2px 8px rgba(0,0,0,0.2);
        padding: 6px 0;
        opacity: 0;
        transform: translateY(-6px);
        pointer-events: none;
        transition: all 0.2s ease;
    }

    .leaflet-top.leaflet-right {
        display: flex;
        flex-direction: column;
        align-items: flex-end;
        gap: 6px; /* khoảng cách giữa các nút */
    }

    .leaflet-control.toggle-fill-control {
        position: absolute;
        z-index: 500;
        right: 100px;
        border: 2px solid rgba(0, 0, 0, 0.2);
        border-radius: 5px;
        top: 10px;
    }

    .toggle-fill-control .toggle-fill-btn {
        width: 44px;
        height: 44px;
        background: white;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 6px;
        box-shadow: 0 1px 4px rgba(0,0,0,0.3);
        cursor: pointer;
    }



    .leaflet-control.backmap-control {
        position: absolute;
        z-index: 500;
        right: 50px;
        border: 2px solid rgba(0, 0, 0, 0.2);
        border-radius: 5px;
        top: 10px;
    }

    .backmap-control .backmap-btn {
        width: 44px;
        height: 44px;
        background: white;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 6px;
        box-shadow: 0 1px 4px rgba(0,0,0,0.3);
        cursor: pointer;
    }

    .leaflet-bottom.leaflet-right {
        bottom: 0 !important;
        z-index: 500;
    }
}
