/* === 1. NỀN TẢNG (BASE) & RESET === */
* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden; /* Loại bỏ viền cuộn toàn trang */
}

body {
  display: flex;
  flex-direction: row;
  background: #7b0000;
  font-family: Arial, Helvetica, sans-serif;
}




/* Các đường vẽ bên trong roadsPane phải nhận chuột */
.leaflet-roadsPane-pane path {
    pointer-events: auto !important;
    cursor: pointer;
}
.ubnd-marker-icon {
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 50%;
    border: 1px solid #da251d;
    filter: drop-shadow(0 2px 3px rgba(0,0,0,0.4));
    transition: transform 0.2s;
}

.ubnd-marker-icon i:hover {
    transform: scale(1.3);
    background: #ffcc00 !important;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 50%;
    border: 1px solid #ffcc00;
    filter: drop-shadow(0 2px 3px rgba(0,0,0,0.4));
    transition: transform 0.2s;
}

/*Khi người dùng di chuột qua các ô lưới, chúng ta nên có hiệu ứng để họ biết ô đó có thể click được.*/
.leaflet-interactive {
    cursor: pointer;
    transition: fill-opacity 0.2s;
}

.leaflet-interactive:hover {
    fill-opacity: 0;
    stroke: #e90947  !important;
    stroke-width: 2px !important;
}
/*End Khi người dùng di chuột qua các ô lưới, chúng ta nên có hiệu ứng để họ biết ô đó có thể click được.*/
/* Hiệu ứng nhấp nháy cho xã nguy hiểm cấp 4-5 */
.warning-blink {
    animation: blink-animation 1s steps(5, start) infinite;
    -webkit-animation: blink-animation 1s steps(5, start) infinite;
}
.leaflet-interactive {
    transition: opacity 0.3s ease-in-out;
}
@keyframes vibrate {
    0% { transform: translate(0); }
    20% { transform: translate(-2px, 2px); }
    40% { transform: translate(-2px, -2px); }
    60% { transform: translate(2px, 2px); }
    80% { transform: translate(2px, -2px); }
    100% { transform: translate(0); }
}
@keyframes blinker {
    50% { fill-opacity: 0.3; }
}

/* Hiệu ứng rung icon trụ sở */
@keyframes blink-animation {
    to { visibility: hidden; }
}

/* Hiệu ứng rung icon cảnh báo */
.warning-vibrate {
    display: inline-block;
    animation: vibrate 0.3s linear infinite;
}

@keyframes shake {
    10%, 90% { transform: translate3d(-1px, 0, 0); }
    20%, 80% { transform: translate3d(2px, 0, 0); }
    30%, 50%, 70% { transform: translate3d(-2px, 0, 0); }
    40%, 60% { transform: translate3d(2px, 0, 0); }
}

.popup-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    background: #f8f9fa;
    border-bottom: 2px solid #da251d;
    border-radius: 12px 12px 0 0;
    position: sticky; /* Giữ tiêu đề luôn ở trên khi cuộn nội dung */
    top: 0;
    z-index: 100;
}



/* === 5. THANH CUỘN (SCROLLBAR) === */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: #f3f3f3; border-radius: 10px; }
::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #d4a94f 0%, #c0943c 100%);
  border-radius: 10px; border: 2px solid #f3f3f3;
}
::-webkit-scrollbar-corner { background: #f3f3f3; }
* { scrollbar-color: #d4a94f #f3f3f3; scrollbar-width: thin; }

/* Tùy chỉnh nút chọn lớp bản đồ */
.leaflet-control-layers-toggle {
    background-image: none !important; /* Bỏ biểu tượng bị lỗi 404 */
    background-color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

/* Thêm chữ hoặc biểu tượng thay thế bằng mã hiệu */
.leaflet-control-layers-toggle::after {
    content: "🗺️"; /* Biểu tượng bản đồ */
    font-size: 18px;
}

.leaflet-control-layers {
    z-index: 1000 !important; /* Luôn nằm trên cùng */
    border: 2px solid #da251d !important; /* Viền đỏ theo tông màu chủ đạo */
}


@keyframes pulse-red {
    0% { box-shadow: 0 0 0 0 rgba(218, 37, 29, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(218, 37, 29, 0); }
    100% { box-shadow: 0 0 0 0 rgba(218, 37, 29, 0); }
}


@keyframes subtle-pulse {
    0% { opacity: 1; }
    50% { opacity: 0.7; }
    100% { opacity: 1; }
}
/*End Ghim trông đẹp hơn và không bị nhảy dòng khi thêm chữ "(Đã ghim)",*/



/* === 2. BẢN ĐỒ (MAP) === */
/* Hiệu ứng phóng to mượt mà dựa trên mức zoom của bản đồ */
.dynamic-cam-icon {
    width: 100%;
    height: 100%;
    transition: transform 0.2s ease-out;
}

/* Khi bản đồ ở mức zoom sâu (từ 16 trở lên), icon sẽ tự phóng to 1.5 - 2 lần */
.leaflet-zoom-16 .dynamic-cam-icon { transform: scale(1.5); }
.leaflet-zoom-17 .dynamic-cam-icon { transform: scale(1.8); }
.leaflet-zoom-18 .dynamic-cam-icon { transform: scale(2.2); }
.leaflet-zoom-19 .dynamic-cam-icon { transform: scale(2.5); }

/* Hiệu ứng trống đồng quay */
/*
#map::before {
  content: "";
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: 190vmin; height: 190vmin;
  background: url("../img/trongdong.png") no-repeat center / contain;
  opacity: 0.2;
  pointer-events: none;
  animation: spin 80s linear infinite;
  z-index: 0;
}
*/

@keyframes spin {
  from { transform: translate(-50%, -50%) rotate(0deg); }
  to { transform: translate(-50%, -50%) rotate(360deg); }
}



/* === 4. THÀNH PHẦN GIAO DIỆN (UI COMPONENTS) === */
/* Văn bản & Liên kết */
a.trichdan { color: #fff; font-size: 8px; text-decoration: none; }
.thangtv_chuyentrang { text-align: center; color: #fff; text-transform: uppercase; }
p.thangtv_0976961169 {
    margin: 0px  !important;
    font-size: 10px;
    color: #ffee00;
    padding: 10px 10%;
}
.header-content { font-size: 14px; }

/* Tiện ích */
.color-swatch {
  display: inline-block;
  width: 14px; height: 14px;
  border: 1px solid #666; border-radius: 3px;
  margin-right: 6px; vertical-align: middle;
}

.btn-export {
  margin-left: 8px; padding: 6px 12px;
  border: 1px solid #666; border-radius: 6px;
  cursor: pointer; background: #fafafa;
}
.btn-export:hover { background: #eee; }

.ftmp { border-bottom: 1px dashed #f00; margin-top: 12px; }
.read-more { cursor: pointer; text-decoration: underline; }

/* Thông báo (Alert Box) */
#alert-box {
  position: fixed;
  top: 12px; left: 50%;
  transform: translateX(-50%);
  background: #ffefef; color: #8a0000;
  border: 1px solid #e3a3a3; border-radius: 8px;
  padding: 10px 14px;
  z-index: 2000;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
  max-width: min(92vw, 720px);
  display: none;
  animation: alertFade 0.25s ease;
}
@keyframes alertFade {
  from { opacity: 0; transform: translate(-50%, -6px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* Toolbox */
.toolbox-content {
  display: none; opacity: 0;
  transform: translateY(-5px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.toolbox-content.open { display: flex; opacity: 1; transform: translateY(0); }



/* BEGIN Bộ lọc thông minh trang chủ */
/* --- Khung hiển thị bộ lọc nổi --- */
.filter-float {
    display: none; 
    position: fixed;
    /* Đặt vị trí mặc định ở giữa màn hình bên phải để tránh Sidebar trái */
    top: 50%;
    left: 60%; 
    transform: translate(-50%, -50%);
    
    width: 350px;
    background: #ffffff;
    border: 2px solid #28a745;
    border-radius: 10px;
    box-shadow: 0 15px 35px rgba(0,0,0,0.5); /* Đổ bóng đậm để nổi bật */
    
    /* QUAN TRỌNG: Phải cao hơn Sidebar (3200) và các thành phần khác */
    z-index: 9999 !important; 
    
    font-family: sans-serif;
    overflow: hidden;
}

.filter-float.show {
    display: block !important;
}

/* --- Header của bộ lọc (Vùng có thể kéo thả) --- */
.filter-float__header {
    background: #f8f9fa;
    padding: 10px 15px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid #eee;
    cursor: move; /* Biểu tượng bàn tay khi di chuyển */
}
/* Sử dụng ID để tăng độ ưu tiên (Specificity) */
#filter-floating.filter-float {
    position: fixed !important;
    transform: none !important; /* Tuyệt đối không dùng translate khi đã kéo thả */
    display: none;
    z-index: 99999 !important;
}

#filter-floating.filter-float.show {
    display: block !important;
}

/* Sửa lỗi nhãn bị module khác ghi đè */
#filter-floating .filter-row label {
    width: 100% !important;
    display: block !important;
    font-weight: 600 !important;
    margin-bottom: 5px !important;
    color: #333 !important;
}
.filter-float__header strong {
    font-size: 16px;
    color: #333;
}
.filter-float.is-dragging {
    transform: none !important; /* Vô hiệu hóa căn giữa khi đang kéo */
    margin: 0 !important;
    transition: none !important; /* Tắt hiệu ứng mượt để bám sát chuột */
}
.filter-float__close {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #999;
    transition: color 0.2s;
}

.filter-float__close:hover {
    color: #da251d;
}

/* --- Thân bộ lọc (Các dòng nhập liệu) --- */
.filter-float__body {
    padding: 15px;
}

.filter-row {
    display: flex;
    align-items: center;
    padding: 10px 15px;
    gap: 10px;
}
.filter-row label {
    width: 100%;
    font-weight: 600;
    font-size: 13px;
    margin-bottom: 5px;
    display: block;
}

.filter-row input[type="number"] {
    flex: 1;
    padding: 5px 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 13px;
    width: 80px;
}

.filter-row span {
    margin: 0 8px;
    color: #666;
}

/* Tùy chỉnh checkbox loại hình */
.filter-row label input[type="checkbox"] {
    margin-right: 5px;
    cursor: pointer;
}

.filter-row label:has(input[type="checkbox"]) {
    width: auto;
    margin-right: 15px;
    font-weight: normal;
    cursor: pointer;
}

/* --- Footer (Nút bấm và Bộ đếm) --- */
.filter-float__footer {
    padding: 10px 15px;
    background: #f8f9fa;
    border-top: 1px solid #eee;
    display: flex;
    align-items: center;
    gap: 10px;
}

.filter-float__footer button {
    padding: 5px 12px;
    border: 1px solid #666;
    background: #fff;
    cursor: pointer;
    font-size: 13px;
    border-radius: 3px;
}

.filter-float__footer button:hover {
    background: #eee;
}

#applyFilterBtn {
    border-color: #28a745;
    color: #28a745;
}

#applyFilterBtn:hover {
    background: #28a745;
    color: #fff;
}

#filterCountDisplay {
    font-size: 11px;
    color: #666;
    margin-left: auto; /* Đẩy sang bên phải */
}

/* --- Responsive cho Mobile --- */
@media (max-width: 480px) {
    .filter-float {
        width: 90%;
    }
}
/* End Bộ lọc thông minh trang chủ */



/*Form xem chi tiết ngoài site Tiêu đề Popup có thể kéo được*/
#sidebar.collapsed {
    left: -320px; /* Hoặc độ rộng sidebar của bạn */
    transition: left 0.3s ease;
}


/* Tùy chỉnh icon đóng mới cho đồng bộ với giao diện */
.btn-close-custom,.btn-zoom-custom {
    background: none;
    border: none;
    color: #666;
    font-size: 18px;
    cursor: pointer;
    padding: 2px 5px;
    transition: color 0.2s;
}
.btn-close-custom{
    margin-right: 15px;
}
.btn-close-custom:hover {
    color: #da251d; /* Đổi sang màu đỏ khi di chuột vào */
}
.btn-zoom-custom:hover {
    color: #da251d !important; /* Đổi sang màu đỏ khi di chuột vào */
}

.toggle-btn {
    padding: 8px 12px; /* Tăng diện tích chạm */
    margin: 4px 0;
    display: inline-block;
    color: #da251d;
    font-weight: bold;
    text-decoration: underline;
    cursor: pointer;
}


/* Style cho nút Xem thêm/Rút gọn */
.toggle-btn {
    color: #0056b3;
    text-decoration: none;
    font-weight: bold;
    font-size: 0.85em;
    cursor: pointer;
    display: inline-block;
    margin-top: 4px;
}

.toggle-btn:hover {
    color: #da251d;
    text-decoration: underline;
}

/* Đảm bảo ảnh không ngăn cản sự kiện click vào nút hoặc vùng chứa */
.map-layer-btn img, #openChartBtn img {
    pointer-events: none;
}


@keyframes slideDown {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
}

.less-btn {
    color: #da251d; /* Màu đỏ cho nút rút gọn để dễ phân biệt */
    margin-top: 8px;
}
.truncate-wrapper {
    position: relative;
    z-index: 10;
    max-height: none !important; /* Cho phép nội dung mở rộng tự nhiên */
    overflow: visible !important;
}

.content-full {
    word-break: break-word; /* Đảm bảo văn bản dài (danh sách bản) không bị tràn ngang */
    
}



/*<-- Thanh tiêu đề trên .province-summary -->*/
/* 1. CẤU HÌNH CƠ BẢN */
.province-summary-bar {
    position: fixed;
    top: 0; /* Luôn giữ ở đỉnh */
    left: 50%;
    transform: translateX(-50%); /* Chỉ căn giữa theo chiều ngang */
    z-index: 3100;
    width: 95%;
    max-width: 1000px;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform;
}

.toggle-control {
    text-align: center;
    background: #da251d;
    width: 68px;
    border-radius: 0 0 5px 5px;
    margin: 0 auto;
    color: #fff;
    height: 30px;
    padding: 5px;
}

/* 2. TRẠNG THÁI ẨN (MINIMIZED) - SỬA TẠI ĐÂY */
/* Thay vì đổi top: -110px, ta đẩy nó lên theo trục Y */
.province-summary-bar.minimized {
    /* Đẩy ngược lên 100% chiều cao của chính nó, trừ lại 1 khoảng nhỏ cho nút bấm */
    /* Nếu đồng chí có nút handle cao 25px, ta trừ lại tầm 30px */
    transform: translateX(-50%) translateY(calc(-100% + 30px));
}

/* 3. NỘI DUNG BÊN TRONG (Gộp chung cho gọn) */
.summary-content {
    background: #da251d;
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    border-radius: 0 0 12px 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

/* 4. ĐIỀU CHỈNH CHO MOBILE (Tránh nhảy dòng làm mất góc) */
@media (max-width: 767.98px) {
    .province-summary-bar {
        width: 100%; /* Mobile nên tràn viền để tránh lộ khe hở góc */
    }
    .summary-content {
        padding: 8px 12px;
        flex-wrap: wrap; /* Cho phép xuống dòng nếu chữ quá dài */
        justify-content: center;
        gap: 4px 10px;
    }
    .summary-item {
        font-size: 11px;
        white-space: nowrap; /* Giữ chữ trên 1 dòng để chiều cao ổn định */
    }
    .summary-center h1 {
        font-size: 15px;
        width: 100%;
        text-align: center;
        margin-bottom: 2px;
    }
}

/*<-- End thanh tiêu đề trên .province-summary -->*/


/* Responsive: Xử lý cho màn hình điện thoại nhỏ */
@media (max-width: 575.9999999px) {
   
   

    /* Giảm kích thước chữ trên mobile để dễ nhìn hơn */
    .tenxa {
        font-size: 14px !important;
    }
    
    .popup-body-content {
        font-size: 13px;
    }
}

/* Tối ưu vùng chạm cho mobile */
@media (max-width: 767px) {
 

    /* Tối ưu kích thước chữ để không bị vỡ hàng */
    .tenxa {
        font-size: 14px !important;
    }
    .toggle-btn {
        display: inline-block;
        padding: 10px 5px; /* Tăng diện tích chạm */
        min-width: 80px;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }
    .leaflet-popup {
        bottom: 50px !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
    }
}

/* Class hỗ trợ phóng to Popup */
#commune-detail-window.is-maximized {
    z-index: 99999 !important; /* Đảm bảo nổi lên trên tất cả */
    max-width: none !important;
    transition: all 0.3s ease;
}

#commune-detail-window.is-maximized .custom-window__body {
    /* Khi phóng to, phần nội dung được phép cao hết cỡ màn hình */
    max-height: calc(100vh - 70px) !important;
    height: 100% !important;
}

/* Ẩn tính năng kéo thả khi đang phóng to để tránh lỗi giao diện */
#commune-detail-window.is-maximized .custom-window__header {
    cursor: default !important;
}
/*END Form xem chi tiết ngoài site Tiêu đề Popup có thể kéo được*/
/*END Sytle Popup thông tin xã*/


/*BEGIN POPUP TÊN ĐƯỜNG*/
/* === HIỆU ỨNG ĐIỂM ĐẦU VÀ ĐIỂM CUỐI ĐƯỜNG === */

/* === HIỆU ỨNG ĐIỂM ĐẦU VÀ ĐIỂM CUỐI ĐƯỜNG === */

/* Icon marker nhảy nhẹ (Bounce) */
.endpoint-marker i {
    filter: drop-shadow(0 2px 5px rgba(0,0,0,0.4));
    animation: marker-bounce 2s infinite ease-in-out;
    display: block;
}

@keyframes marker-bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

/* Vòng tròn lan tỏa (Ripple) - Đồng bộ màu với Icon */
.endpoint-marker::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 10px;
    height: 10px;
    border: 3px solid currentColor;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    animation: marker-ripple 1.5s infinite ease-out;
    pointer-events: none;
    z-index: -1;
}

@keyframes marker-ripple {
    0% {
        width: 10px;
        height: 10px;
        opacity: 1;
    }
    100% {
        width: 60px;
        height: 60px;
        opacity: 0;
    }
}

/* Tên nhãn (Label) của đường */
.road-label-marker {
    transition: opacity 0.3s;
}

/* Ẩn nhãn đường khi zoom xa */
.leaflet-zoom-hide-labels .road-label-marker {
    display: none !important;
}

/* Layer popup cho việc kéo thả Pixel */
.leaflet-popup {
    transition: none !important; 
    z-index: 10001 !important; /* Đảm bảo cao hơn endpoint-marker */
}

.road-info-popup {
    cursor: grab;
    user-select: none;
}

.road-info-popup:active {
    cursor: grabbing;
}
/* Nhưng phải cho phép các nút bấm nhận sự kiện click */
.road-info-popup button, 
.road-info-popup a,
.leaflet-popup-close-button {
    pointer-events: auto !important;
    cursor: pointer;
}
/* Đảm bảo nội dung bên trong không chặn sự kiện kéo của container */
.road-info-popup table, 
.road-info-popup div {
    pointer-events: none; 
}
.endpoint-marker {
    z-index: 1000 !important;
}
/* Đảm bảo nhãn chữ ĐẦU/CUỐI nằm đúng vị trí trên Icon */
/* Đảm bảo Marker nhãn chữ luôn nằm trên cùng */
.marker-label {
    position: absolute;
    top: -25px;
    left: 50%;
    transform: translateX(-50%);
    color: white;
    font-size: 9px;
    font-weight: bold;
    padding: 2px 5px;
    border-radius: 3px;
    white-space: nowrap;
    z-index: 1001;
}
/* Class đánh dấu trạng thái đang kéo (được thêm bằng JS ở trên) */
.custom-window.is-dragging, .road-info-popup.is-dragging {
    opacity: 0.85;
    transition: none !important;
    cursor: grabbing !important;
}
/* Hiệu ứng nhấp nháy lan tỏa chuẩn tâm cho điểm ghim */
.road-endpoint-pulse {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%); /* Luôn ở giữa ghim */
    pointer-events: none;
    z-index: -1;
}

.pulse-start { 
    background: rgba(40, 167, 69, 0.7); 
    animation: marker-pulse-animation 1.5s infinite ease-out; 
}

.pulse-end { 
    background: rgba(218, 37, 29, 0.7); 
    animation: marker-pulse-animation 1.5s infinite ease-out; 
}

@keyframes marker-pulse-animation {
    0% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(4); opacity: 0; }
}

/* Đảm bảo Marker nhãn chữ không chặn click */
.marker-label {
    position: absolute;
    top: -25px;
    left: 50%;
    transform: translateX(-50%);
    color: white;
    font-size: 9px;
    font-weight: bold;
    padding: 2px 5px;
    border-radius: 3px;
    white-space: nowrap;
    z-index: 10;
    pointer-events: none;
}
/*END POPUP TÊN ĐƯỜNG*/
