/**
 * Giao diện Phân hệ Bản đồ số Thống kê TP Hải Phòng
 * Phong cách: Civic Design System (Inter, Slate, Deep Blue)
 */

.bando-module-wrapper {
    font-family: 'Be Vietnam Pro', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: #1E293B;
    margin-bottom: 30px;
}

/* 1. Header Phân khu Bản đồ số */
.bando-page-header {
    margin-bottom: 20px;
    position: relative;
    padding-left: 20px;
}

.bando-header-accent-bar {
    position: absolute;
    left: 0;
    top: 4px;
    bottom: 4px;
    width: 5px;
    background: linear-gradient(180deg, var(--hp-blue-primary, #0079B6) 0%, var(--hp-blue-primary, #0079B6) 100%);
    border-radius: 4px;
}

.bando-kicker {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--hp-blue-link, #005781);
    margin-bottom: 4px;
}

.bando-page-title {
    font-size: 24px;
    font-weight: 800;
    color: #0F172A;
    line-height: 1.25;
    margin: 0 0 8px 0;
}

.bando-page-sapo {
    font-size: 14px;
    line-height: 1.6;
    color: #475569;
    margin: 0;
    max-width: 1050px;
}

/* 2. Khung Viewport Bản đồ số */
.bando-viewport-card {
    position: relative;
    height: 750px;
    border-radius: 12px;
    border: 1px solid #CBD5E1;
    box-shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.08), 0 8px 10px -6px rgba(15, 23, 42, 0.04);
    overflow: hidden;
    background: #F8FAFC;
}

.bando-viewport-card:fullscreen,
.bando-viewport-card:-webkit-full-screen {
    height: 100vh !important;
    width: 100vw !important;
    border-radius: 0;
    border: none;
}

/* 3. Thanh công cụ điều khiển nổi (Floating Control Bar) */
.bando-control-bar {
    position: absolute;
    top: 14px;
    left: 14px;
    right: 14px;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    background: #FFFFFF;
    border: 1px solid #CBD5E1;
    border-radius: 10px;
    padding: 10px 16px;
    box-shadow: 0 4px 16px rgba(15, 23, 42, 0.08);
}

.bando-ctrl-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

.bando-ctrl-item label {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--hp-blue-link, #005781);
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 6px;
}

.bando-select-wrap {
    flex: 1 1 320px;
}

.bando-select {
    height: 38px;
    border-radius: 8px;
    border: 1.5px solid #CBD5E1;
    font-size: 13.5px;
    font-weight: 600;
    color: #0F172A;
    background-color: #FFFFFF;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    cursor: pointer;
    transition: all 0.2s ease;
}

.bando-select:focus {
    border-color: var(--hp-blue-primary, #0079B6);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
    outline: none;
}

.bando-search-wrap {
    flex: 1 1 260px;
}

.bando-input-group {
    position: relative;
    width: 100%;
    display: flex;
    align-items: center;
}

.bando-search-input {
    height: 38px;
    border-radius: 8px;
    border: 1.5px solid #CBD5E1;
    font-size: 13px;
    padding-right: 30px;
    color: #0F172A;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.bando-search-input:focus {
    border-color: var(--hp-blue-primary, #0079B6);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
    outline: none;
}

.bando-btn-clear {
    position: absolute;
    right: 8px;
    background: transparent;
    border: none;
    font-size: 18px;
    line-height: 1;
    color: #94A3B8;
    cursor: pointer;
    padding: 2px 6px;
}

.bando-btn-clear:hover {
    color: #0F172A;
}

.bando-action-buttons {
    display: flex;
    gap: 8px;
}

.bando-btn-tool {
    height: 38px;
    padding: 0 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    color: #1E293B;
    background: #F1F5F9;
    border: 1px solid #CBD5E1;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
    cursor: pointer;
}

.bando-btn-tool:hover {
    background: #E2E8F0;
    color: #0F172A;
    border-color: #94A3B8;
}

/* 4. Canvas Leaflet */
.bando-map-canvas {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
    background: #EBF3F9;
}

/* ==========================================================================
   Khử răng cưa & Tối ưu hóa Vector SVG - 100% Solid & Zero-Flicker (Khử chớp hình)
   ========================================================================== */
.bando-map-canvas svg {
    shape-rendering: geometricPrecision;
    text-rendering: geometricPrecision;
}

.bando-map-canvas svg path {
    shape-rendering: geometricPrecision;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: fill-opacity 0.15s ease, stroke 0.15s ease;
}

/* ==========================================================================
   HIỆU ỨNG HIỆN ĐẠI: SPOTLIGHT FOCUS MODE & RADAR PULSE BEACON (MƯỢT MÀ 60FPS)
   ========================================================================== */

/* 1. Spotlight Mode: Dịu màu tự nhiên các đơn vị khác, tập trung ánh sáng vào đơn vị được chọn */
.bando-map-canvas.has-selection svg path:not(.is-selected-polygon) {
    fill-opacity: 0.3 !important;
    stroke: rgba(255, 255, 255, 0.45) !important;
    stroke-width: 0.8px !important;
    cursor: pointer;
}

.bando-map-canvas.has-selection svg path:not(.is-selected-polygon):hover {
    fill-opacity: 0.75 !important;
    stroke: #0F172A !important;
    stroke-width: 1.8px !important;
}

/* 2. Polygon được chọn: Đường viền Cyber Blue sắc sảo, dứt khoát, không dùng filter gây chớp */
.bando-map-canvas svg path.is-selected-polygon {
    stroke: var(--hp-blue-highlight, #0091D8) !important;
    stroke-width: 3.5px !important;
    stroke-linejoin: round !important;
    stroke-linecap: round !important;
    fill-opacity: 0.96 !important;
    cursor: pointer;
}

/* 3. Sóng Radar Pulse & Huy hiệu định vị tâm địa phương (Centroid Beacon) */
.bando-beacon-icon-wrap {
    background: transparent !important;
    border: none !important;
}

.bando-centroid-beacon {
    position: relative;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    will-change: transform;
}

.beacon-core-dot {
    width: 10px;
    height: 10px;
    background: var(--hp-blue-primary, #0079B6);
    border: 2px solid #FFFFFF;
    border-radius: 50%;
    box-shadow: 0 0 8px rgba(14, 165, 233, 0.9);
    z-index: 2;
}

.beacon-pulse-ring {
    position: absolute;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid var(--hp-blue-primary, #0079B6);
    animation: beacon-ripple 2s cubic-bezier(0, 0.2, 0.8, 1) infinite;
    z-index: 1;
    will-change: transform, opacity;
}

.beacon-pulse-ring:nth-child(2) {
    animation-delay: 0.7s;
}

@keyframes beacon-ripple {
    0% {
        transform: scale(0.2);
        opacity: 0.9;
    }
    100% {
        transform: scale(2.6);
        opacity: 0;
    }
}

.beacon-name-tag {
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    background: #0F172A;
    color: #F8FAFC;
    font-size: 11.5px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 20px;
    white-space: nowrap;
    border: 1px solid #38BDF8;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
    display: flex;
    align-items: center;
    gap: 4px;
    letter-spacing: 0.02em;
    pointer-events: none;
    animation: beacon-badge-pop 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.beacon-name-tag::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: #0F172A transparent transparent transparent;
}

@keyframes beacon-badge-pop {
    0% {
        opacity: 0;
        transform: translateX(-50%) translateY(6px) scale(0.85);
    }
    100% {
        opacity: 1;
        transform: translateX(-50%) translateY(0) scale(1);
    }
}

/* 4. Hiệu ứng các thẻ KPI trượt thác nước (Staggered Cascade) trong Drawer */
.bando-kpi-card {
    background: #FFFFFF;
    border: 1px solid #E2E8F0;
    border-radius: 8px;
    padding: 12px 14px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
    opacity: 0;
    animation: kpiCascadeIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes kpiCascadeIn {
    0% {
        opacity: 0;
        transform: translateY(12px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==========================================================================
   Singleton Floating Tooltip mượt mà (Khử hiện tượng giật giật & tạo quá nhiều popup)
   ========================================================================== */
.bando-floating-tooltip {
    position: absolute;
    z-index: 1000;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transform: translate(-50%, -100%) translateY(-14px) scale(0.96);
    transition: opacity 0.15s ease, transform 0.15s ease;
    background: #0F172A;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: #FFFFFF;
    padding: 8px 12px;
    box-shadow: 0 10px 25px -4px rgba(15, 23, 42, 0.45), 0 4px 6px -2px rgba(15, 23, 42, 0.25);
    white-space: nowrap;
    will-change: transform, opacity;
}

.bando-floating-tooltip.is-active {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -100%) translateY(-10px) scale(1);
}

.bando-floating-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: #0F172A transparent transparent transparent;
}

.tooltip-unit-title {
    font-size: 13.5px;
    font-weight: 700;
    color: #60A5FA;
    margin-bottom: 2px;
}

.tooltip-unit-type {
    font-size: 11px;
    color: #94A3B8;
    text-transform: capitalize;
    margin-bottom: 4px;
}

.tooltip-unit-metric {
    font-size: 14px;
    font-weight: 800;
    color: #F8FAFC;
    border-top: 1px dashed rgba(255, 255, 255, 0.2);
    padding-top: 4px;
    margin-top: 4px;
}

/* 5. Chú giải phân lớp chuyên đề (Dynamic Legend) */
.bando-legend-panel {
    position: absolute;
    bottom: 24px;
    left: 20px;
    z-index: 998;
    background: #FFFFFF;
    border: 1px solid #CBD5E1;
    border-radius: 10px;
    padding: 12px 14px;
    box-shadow: 0 4px 16px rgba(15, 23, 42, 0.1);
    min-width: 220px;
    max-width: 280px;
}

.bando-legend-header {
    border-bottom: 1px solid #F1F5F9;
    padding-bottom: 6px;
    margin-bottom: 8px;
}

.bando-legend-badge {
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    color: #64748B;
    letter-spacing: 0.05em;
    display: flex;
    align-items: center;
    gap: 4px;
}

.bando-legend-title {
    font-size: 13.5px;
    font-weight: 700;
    color: #0F172A;
    margin-top: 2px;
}

.bando-legend-classes {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.legend-class-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.legend-swatch {
    width: 24px;
    height: 14px;
    border-radius: 3px;
    border: 1px solid rgba(0, 0, 0, 0.15);
    flex-shrink: 0;
}

.legend-label {
    font-size: 12px;
    color: #334155;
    font-weight: 500;
    line-height: 1.3;
}

/* 6. Slide-in Profile Drawer */
.bando-profile-drawer {
    position: absolute;
    top: 72px;
    right: -450px;
    width: 430px;
    height: calc(100% - 72px);
    z-index: 999;
    background: #FFFFFF;
    box-shadow: -6px 4px 24px rgba(15, 23, 42, 0.12);
    border-left: 1px solid #E2E8F0;
    border-top: 1px solid #E2E8F0;
    border-top-left-radius: 12px;
    transition: right 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
}

.bando-profile-drawer.is-open {
    right: 0;
}

.bando-drawer-header {
    padding: 16px 20px;
    background: #F8FAFC;
    border-bottom: 1px solid #E2E8F0;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.bando-drawer-title-group {
    flex: 1;
}

.bando-unit-badge {
    display: inline-block;
    padding: 3px 8px;
    background: #DBEAFE;
    color: var(--hp-blue-link, #005781);
    font-size: 11px;
    font-weight: 700;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
}

.bando-drawer-unit-name {
    font-size: 19px;
    font-weight: 800;
    color: #0F172A;
    margin: 0;
    line-height: 1.25;
}

.bando-drawer-close-btn {
    background: #EDF2F7;
    border: 1px solid #CBD5E1;
    color: #64748B;
    font-size: 22px;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    cursor: pointer;
    transition: all 0.2s;
    padding: 0;
}

.bando-drawer-close-btn:hover {
    background: #E2E8F0;
    color: #0F172A;
}

.bando-drawer-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.bando-drawer-section {
    margin-bottom: 24px;
}

.bando-section-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--hp-blue-link, #005781);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin: 0 0 12px 0;
    display: flex;
    align-items: center;
    gap: 6px;
    padding-bottom: 6px;
    border-bottom: 2px solid #E2E8F0;
}

.bando-section-header-flex {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    border-bottom: 2px solid #E2E8F0;
    padding-bottom: 6px;
}

.bando-section-header-flex .bando-section-title {
    margin: 0;
    border-bottom: none;
    padding-bottom: 0;
}

.bando-year-tag {
    font-size: 11px;
    font-weight: 700;
    padding: 2px 7px;
    background: #E2E8F0;
    color: #334155;
    border-radius: 4px;
}

.bando-meta-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.bando-meta-item {
    background: #F8FAFC;
    padding: 10px 12px;
    border-radius: 6px;
    border-left: 3px solid var(--hp-blue-highlight, #0091D8);
    font-size: 13px;
}

.meta-label {
    display: block;
    font-size: 11.5px;
    font-weight: 600;
    color: #64748B;
    margin-bottom: 2px;
}

.meta-value {
    font-size: 13.5px;
    font-weight: 700;
    color: #0F172A;
}

/* Lưới Thẻ Chỉ tiêu KPI trong Drawer */
.bando-kpi-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

/* bando-kpi-card moved to modern effects */

.bando-kpi-card:hover {
    box-shadow: 0 4px 10px rgba(15, 23, 42, 0.08);
    border-color: #CBD5E1;
}

.bando-kpi-card.is-active-metric {
    border-color: var(--hp-blue-primary, #0079B6);
    background: #EFF6FF;
}

.kpi-title {
    font-size: 12px;
    font-weight: 600;
    color: #475569;
    line-height: 1.35;
    margin-bottom: 6px;
}

.kpi-value {
    font-size: 16px;
    font-weight: 800;
    color: #0F172A;
    line-height: 1.2;
}

.kpi-unit {
    font-size: 11px;
    font-weight: 500;
    color: #64748B;
    margin-left: 3px;
}

/* 7. Loading Overlay */
.bando-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.92);
    z-index: 1002;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s ease;
}

.bando-loading-overlay.is-hidden {
    opacity: 0;
    visibility: hidden !important;
    display: none !important;
    pointer-events: none;
}

.bando-spinner-box {
    text-align: center;
    background: #FFFFFF;
    padding: 24px 32px;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    border: 1px solid #E2E8F0;
}

.bando-spinner {
    width: 42px;
    height: 42px;
    margin: 0 auto 12px auto;
    border: 3.5px solid #E2E8F0;
    border-top-color: var(--hp-blue-primary, #0079B6);
    border-radius: 50%;
    animation: bando-spin 0.8s linear infinite;
}

@keyframes bando-spin {
    to { transform: rotate(360deg); }
}

.bando-loading-text {
    font-size: 13.5px;
    font-weight: 600;
    color: #1E293B;
}

/* 8. Mobile & Responsive Styles */
@media (max-width: 991px) {
    .bando-viewport-card {
        height: 650px;
    }
    .bando-profile-drawer {
        width: 360px;
        right: -380px;
    }
}

@media (max-width: 767px) {
    .bando-control-bar {
        flex-direction: column;
        align-items: stretch;
    }
    .bando-select-wrap,
    .bando-search-wrap {
        flex: 1 1 100%;
    }
    .bando-profile-drawer {
        width: 100%;
        right: -100%;
    }
    .bando-kpi-grid {
        grid-template-columns: 1fr;
    }
    .bando-legend-panel {
        bottom: 10px;
        left: 10px;
        max-width: 200px;
        font-size: 11px;
    }
}
