/* === Gốc & font === */
.app-body {
    font-family: "Inter", system-ui, -apple-system, sans-serif;
    font-feature-settings: "tnum" 1, "lnum" 1;
    overflow: hidden;
    background: #eef2f6;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* === Bảng thông tin (Info Panel) === */
#info-panel {
    position: fixed;
    top: max(12px, env(safe-area-inset-top));
    right: max(12px, env(safe-area-inset-right));
    display: none;
    max-height: min(520px, calc(100dvh - 100px));
    overflow: hidden;
    background-color: rgba(255, 255, 255, 0.97);
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 16px;
    box-shadow: 0 10px 40px rgba(15, 23, 42, 0.12);
    pointer-events: none;
    z-index: 1001;
    width: min(400px, calc(100vw - 24px));
    font-size: 0.9rem;
    backdrop-filter: blur(8px);
    animation: info-in 0.2s ease-out;
}
@keyframes info-in {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
#info-panel h3 {
    font-size: 1.25rem;
    font-weight: 700;
    color: #1d4ed8;
    margin: 0 0 12px 0;
    padding-bottom: 8px;
    border-bottom: 2px solid #dbeafe;
}
#info-panel a {
    pointer-events: auto;
}
#info-panel .info-scroll {
    pointer-events: auto;
}
#info-panel .info-quy-mo {
    font-size: 0.85rem;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
}
#info-panel .info-meta-line {
    margin-top: -4px;
}

/* Địa chỉ hành chính (VietMap picker) */
.addr-custom-dropdown .addr-dropdown-input:not(:disabled) {
    cursor: pointer;
}

/* === Sidebar (panel trái) === */
.app-sidebar-panel {
    box-sizing: border-box;
}
.app-sidebar-scroll {
    scrollbar-gutter: stable;
    scrollbar-width: thin;
    scrollbar-color: rgba(100, 116, 139, 0.45) transparent;
}
.app-sidebar-scroll::-webkit-scrollbar {
    width: 6px;
}
.app-sidebar-scroll::-webkit-scrollbar-thumb {
    background: rgba(100, 116, 139, 0.35);
    border-radius: 999px;
}

.sidebar-card {
    border-radius: 14px;
    background: #fff;
    border: 1px solid rgba(226, 232, 240, 0.95);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    padding: 14px 14px 15px;
}
.sidebar-card--soft {
    background: linear-gradient(180deg, #fafbfc 0%, #f8fafc 100%);
    border-color: rgba(203, 213, 225, 0.85);
}

.sidebar-section-head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    padding-bottom: 2px;
    border-bottom: 1px solid rgba(241, 245, 249, 0.95);
}
.sidebar-details .sidebar-section-head {
    flex: 1;
    margin-bottom: 0;
    border-bottom: none;
    padding-bottom: 0;
}
.sidebar-section-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: rgba(241, 245, 249, 0.95);
    color: #475569;
    flex-shrink: 0;
}
.sidebar-section-title {
    margin: 0;
    font-size: 0.8125rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: #0f172a;
    text-transform: none;
}
.sidebar-section-desc {
    margin: 0;
    font-size: 0.6875rem;
    line-height: 1.45;
    color: #64748b;
}

.sidebar-footnote {
    margin: 0;
    font-size: 0.625rem;
    line-height: 1.4;
    color: #94a3b8;
}

.app-main-tab--active {
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

/* Nhãn chương trong <select> (trắc nghiệm Địa 9) */
select.geo-quiz-lesson-select optgroup {
    font-weight: 600;
    font-size: 0.7rem;
    color: #334155;
}
select.geo-quiz-lesson-select option {
    font-weight: 400;
    padding: 0.25rem 0;
}

.geo-teach-tab--active {
    border-color: rgba(99, 102, 241, 0.55);
    box-shadow: 0 0 0 1px rgba(99, 102, 241, 0.2);
}

/* Tab Chuẩn bị / Làm bài (ngân hàng) */
.geo-quiz-bank-tab {
    background: #f8fafc;
    color: #64748b;
    border-color: #e2e8f0;
    transition: color 0.15s, background 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.geo-quiz-bank-tab:hover {
    color: #334155;
    background: #f1f5f9;
}
.geo-quiz-bank-tab--active {
    color: #3730a3;
    background: #fff;
    border-color: #e2e8f0 !important;
    border-bottom-color: #fff !important;
    box-shadow: 0 1px 0 #fff;
    font-weight: 700;
}

/* Trac nghiem: giao dien 2 cot + dieu huong nhanh */
.geo-quiz-main {
    box-shadow: 0 6px 24px rgba(15, 23, 42, 0.04);
    background: radial-gradient(1200px 320px at 20% -40%, rgba(99, 102, 241, 0.07), transparent 55%), #fff;
}
.geo-quiz-nav-btn {
    border: 1px solid #cbd5e1;
    background: #fff;
    color: #334155;
    border-radius: 8px;
    padding: 4px 0;
    font-size: 11px;
    font-weight: 600;
    line-height: 1;
}
.geo-quiz-nav-btn:hover {
    background: #f8fafc;
}
.geo-quiz-nav-btn--active {
    border-color: #4338ca;
    box-shadow: 0 0 0 1px rgba(67, 56, 202, 0.25);
}
.geo-quiz-nav-btn--ok {
    border-color: #10b981;
    background: #ecfdf5;
    color: #065f46;
}
.geo-quiz-nav-btn--bad {
    border-color: #f59e0b;
    background: #fffbeb;
    color: #92400e;
}

#geo-quiz-options label {
    border-width: 2px;
    border-color: #dbeafe;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    padding: 12px;
    font-size: 15px;
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
#geo-quiz-options label:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(30, 64, 175, 0.12);
}
#geo-quiz-options label.geo-quiz-option--ok {
    border-color: #10b981;
    background: linear-gradient(180deg, #f0fdf4 0%, #ecfdf5 100%);
}
#geo-quiz-options label.geo-quiz-option--bad {
    border-color: #f59e0b;
    background: linear-gradient(180deg, #fffbeb 0%, #fefce8 100%);
}
#geo-quiz-badge {
    padding: 6px 10px;
    border-radius: 10px;
}
.geo-quiz-mission,
.geo-quiz-reward {
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

#geo-quiz-print-holder {
    display: none;
}

@media print {
    body * {
        visibility: hidden !important;
    }
    #geo-quiz-print-holder {
        display: block !important;
    }
    #geo-quiz-print-sheet,
    #geo-quiz-print-sheet * {
        visibility: visible !important;
    }
    #geo-quiz-print-sheet {
        position: fixed;
        inset: 0;
        width: 100%;
        background: #fff;
        color: #111827;
        padding: 24px;
        font-family: "Inter", Arial, sans-serif;
    }
}

/* Minh họa 3D — công cụ dạy học biểu đồ */
.geo-3d-demo-wrap {
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}
.geo-3d-svg {
    display: block;
    max-width: 100%;
}
.geo-line-3d-inner {
    perspective: 520px;
    transform-style: preserve-3d;
}
.geo-line-3d-inner svg {
    transform: rotateX(14deg);
    transform-origin: 50% 100%;
    transition: transform 0.35s ease;
}

.sidebar-details-summary {
    padding: 0;
    margin: 0;
    list-style: none;
}
.sidebar-details[open] .sidebar-details-summary {
    margin-bottom: 0;
}

.sidebar-radio-group {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.sidebar-radio-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 10px;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background 0.12s ease, border-color 0.12s ease;
}
.sidebar-radio-row:hover {
    background: rgba(248, 250, 252, 0.95);
}
.sidebar-radio-row:has(.sidebar-radio-input:checked) {
    background: rgba(239, 246, 255, 0.85);
    border-color: rgba(147, 197, 253, 0.55);
}
.sidebar-radio-input {
    margin: 2px 0 0;
    width: 15px;
    height: 15px;
    flex-shrink: 0;
    accent-color: #2563eb;
    cursor: pointer;
}
.sidebar-radio-label {
    font-size: 0.8125rem;
    line-height: 1.35;
    color: #334155;
    cursor: pointer;
    padding-top: 1px;
}

.sidebar-check-grid {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.sidebar-check {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 10px;
    align-items: start;
    padding: 8px 10px;
    border-radius: 10px;
    cursor: pointer;
    border: 1px solid rgba(241, 245, 249, 0.9);
    background: rgba(255, 255, 255, 0.65);
    transition: background 0.12s ease, border-color 0.12s ease;
}
.sidebar-check:hover {
    background: #fff;
    border-color: rgba(226, 232, 240, 0.95);
}
.sidebar-check-input {
    margin: 2px 0 0;
    width: 15px;
    height: 15px;
    flex-shrink: 0;
    border-radius: 4px;
    accent-color: #0d9488;
    cursor: pointer;
}
.sidebar-check-text {
    font-size: 0.8125rem;
    line-height: 1.4;
    color: #334155;
    cursor: pointer;
    hyphens: auto;
    overflow-wrap: anywhere;
}

#address-picker-status.addr-panel-status--info {
    background: rgba(248, 250, 252, 0.98) !important;
    border-color: rgba(203, 213, 225, 0.95) !important;
    color: #475569 !important;
}

@media (max-width: 767px) {
    .app-sidebar-panel:not(.hidden) {
        border-radius: 0 16px 16px 0;
        box-shadow: 12px 0 40px rgba(15, 23, 42, 0.12);
    }
}

/* === Bản đồ (Map Container) === */
#map-container.map-viewport {
    position: relative;
    width: 100%;
    flex: 1 1 0;
    min-height: 0;
    /* Không bo tròn + không overflow:hidden để mép bản đồ không bị cắt bởi viền */
}
#map-container svg {
    display: block;
    width: 100%;
    height: 100%;
    cursor: grab;
    vertical-align: top;
    /* Trình duyệt không “cuộn trang” / gesture khi pinch — tránh đấu với D3 zoom */
    touch-action: none;
}
#map-container svg:active {
    cursor: grabbing;
}

/* Một transform cho toàn lớp → GPU, giảm jank khi zoom/pan */
.map-zoom-root {
    will-change: transform;
}
.map-zoom-root.is-panning path.province {
    shape-rendering: optimizeSpeed;
}

/* Khi đang kéo/zoom: chỉ giảm độ “mịn” đường path láng giềng/thế giới — KHÔNG ẩn lớp (tránh mất các nước xung quanh). */
#map-container .map-zoom-root.is-panning .map-region-context-layer path {
    shape-rendering: optimizeSpeed;
}

/* Nhãn: giảm vẽ/fade bằng CSS thay vì set opacity từng frame trong JS */
#map-container .map-labels-layer {
    transition: opacity 0.16s ease-out;
}
#map-container .map-zoom-root.is-panning .map-labels-layer {
    opacity: 0.38;
    transition: none;
    pointer-events: none;
}

/* Nền các nước khác (toàn cầu, mờ) */
#map-container path.world-country {
    fill: #e8eaef;
    stroke: #d1d5dc;
    stroke-width: 0.22;
    stroke-linejoin: round;
    opacity: 0.48;
    shape-rendering: geometricPrecision;
}

/* Halo láng giềng — xám, lấp khe với ranh VN */
#map-container g.neighbor-halo-layer path.neighbor-halo {
    fill: none;
    pointer-events: none;
    stroke: #d0d5dd;
    stroke-width: 2.2;
    stroke-linejoin: round;
    stroke-linecap: round;
    shape-rendering: geometricPrecision;
    opacity: 0.86;
}

/* Lớp nhấn đường biên giới quốc tế với VN */
#map-container g.vn-intl-border-layer path.vn-intl-border {
    fill: none;
    stroke: #0f172a;
    stroke-width: 1.25;
    stroke-dasharray: 5 3;
    opacity: 0.8;
    vector-effect: non-scaling-stroke;
    shape-rendering: geometricPrecision;
}

/* Láng giềng — tô màu phân biệt theo quốc gia */
#map-container g.neighbor-admin0 path.neighbor-country {
    shape-rendering: geometricPrecision;
    paint-order: stroke fill;
    stroke-linejoin: round;
    stroke-linecap: round;
    stroke-width: 1.05;
    opacity: 0.98;
    fill: #dbe3ef;
    stroke: #63738a;
    cursor: pointer;
}
#map-container g.neighbor-admin0 path.neighbor-CHN {
    fill: #f6d6d8;
    stroke: #b4232f;
}
#map-container g.neighbor-admin0 path.neighbor-LAO {
    fill: #ffe7bf;
    stroke: #c97b00;
}
#map-container g.neighbor-admin0 path.neighbor-KHM {
    fill: #e0dbff;
    stroke: #5b43b4;
}
#map-container g.neighbor-admin0 path.neighbor-THA {
    fill: #d7f0ff;
    stroke: #1372b8;
}
#map-container g.neighbor-admin0 path.neighbor-MMR {
    fill: #fbe4c6;
    stroke: #b7791f;
}
#map-container g.neighbor-admin0 path.neighbor-MYS {
    fill: #d3f3e2;
    stroke: #188a5d;
}
#map-container g.neighbor-admin0 path.neighbor-PHL {
    fill: #ffe1f3;
    stroke: #b83280;
}
#map-container g.neighbor-admin0 path.neighbor-IDN {
    fill: #fde8d0;
    stroke: #c26a00;
}
#map-container g.neighbor-admin0 path.neighbor-BRN {
    fill: #ece8ff;
    stroke: #5e4bb2;
}
#map-container g.neighbor-admin0 path.neighbor-SGP {
    fill: #ffd7d7;
    stroke: #b83232;
}
#map-container g.neighbor-admin0 path.neighbor-TLS {
    fill: #fff4cc;
    stroke: #b38a00;
}
#map-container g.neighbor-admin0 path.neighbor-country:not(.neighbor-CHN):not(.neighbor-LAO):not(.neighbor-KHM) {
    fill: #d7dde7;
    stroke: #718096;
}

/* Ranh tỉnh/bang láng giềng */
#map-container g.neighbor-admin1 path.neighbor-admin1 {
    shape-rendering: geometricPrecision;
    stroke-linejoin: round;
    stroke-linecap: round;
    paint-order: stroke fill;
    stroke-width: 0.52;
    opacity: 1;
    fill: rgba(255, 255, 255, 0.1);
    stroke: #6b7280;
    cursor: pointer;
}

#map-container .neighbor-country-label .neighbor-label-bg {
    fill: rgba(255, 255, 255, 0.88);
    stroke: rgba(15, 23, 42, 0.22);
    stroke-width: 0.7;
}
#map-container .neighbor-country-label .neighbor-name {
    font-size: 11px;
    font-weight: 800;
    fill: #0b1324;
    paint-order: stroke fill;
    stroke: rgba(255, 255, 255, 0.98);
    stroke-width: 2.7px;
}

#map-container .neighbor-country-label .neighbor-capital {
    font-size: 9.5px;
    font-weight: 600;
    fill: #1e293b;
    paint-order: stroke fill;
    stroke: rgba(255, 255, 255, 0.92);
    stroke-width: 2px;
}

#map-neighbor-legend .legend-swatch {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    border: 1px solid rgba(15, 23, 42, 0.25);
}
#map-neighbor-legend .legend-swatch-chn { background: #f6d6d8; border-color: #b4232f; }
#map-neighbor-legend .legend-swatch-lao { background: #ffe7bf; border-color: #c97b00; }
#map-neighbor-legend .legend-swatch-khm { background: #e0dbff; border-color: #5b43b4; }
#map-neighbor-legend .legend-border-sample {
    width: 18px;
    height: 0;
    border-top: 2px dashed #0f172a;
    opacity: 0.85;
}

#map-container .map-provinces-layer {
    filter: drop-shadow(0 2px 5px rgba(12, 65, 22, 0.42));
}

#map-container path.province {
    fill: url(#vn-province-gradient);
    stroke: rgba(255, 255, 255, 0.97);
    stroke-width: 0.72;
    stroke-linejoin: round;
    stroke-linecap: round;
    paint-order: stroke fill;
    cursor: pointer;
    shape-rendering: geometricPrecision;
}
#map-container path.province:hover {
    filter: brightness(0.93);
}
#map-container path.province.selected {
    fill: #2563eb !important;
    stroke: #f8fafc;
    stroke-width: 0.62;
    filter: none;
}
/* Tô màu AI highlight — mỗi tỉnh màu riêng biệt, nổi bật trên nền xanh lá */
#map-container path.province.ai-hl-1 {
    fill: #ef4444 !important;        /* đỏ tươi — tỉnh thứ 1 */
    stroke: #fff;
    stroke-width: 1;
    filter: drop-shadow(0 0 5px rgba(239,68,68,0.7));
}
#map-container path.province.ai-hl-2 {
    fill: #f59e0b !important;        /* vàng hổ phách — tỉnh thứ 2 */
    stroke: #fff;
    stroke-width: 1;
    filter: drop-shadow(0 0 5px rgba(245,158,11,0.7));
}
#map-container path.province.ai-hl-3 {
    fill: #8b5cf6 !important;        /* tím — tỉnh thứ 3 */
    stroke: #fff;
    stroke-width: 1;
    filter: drop-shadow(0 0 5px rgba(139,92,246,0.7));
}
#map-container path.province.ai-hl-4 {
    fill: #ec4899 !important;        /* hồng — tỉnh thứ 4 */
    stroke: #fff;
    stroke-width: 1;
    filter: drop-shadow(0 0 5px rgba(236,72,153,0.6));
}
#map-container path.province.ai-hl-5 {
    fill: #06b6d4 !important;        /* cyan — tỉnh thứ 5+ */
    stroke: #fff;
    stroke-width: 1;
    filter: drop-shadow(0 0 5px rgba(6,182,212,0.6));
}

/* Thủ đô Hà Nội — sao vàng; TP.HCM — chấm tròn (không phải thủ đô) */
#map-container .vn-capital-markers .vn-capital-star {
    paint-order: stroke fill;
    pointer-events: none;
    stroke-linejoin: round;
    filter: drop-shadow(0 0.6px 1px rgba(15, 23, 42, 0.28));
}
#map-container .vn-capital-star-hanoi {
    fill: #facc15;
    stroke: #713f12;
    stroke-width: 1.05px;
}
#map-container .vn-capital-markers .vn-major-city-dot {
    paint-order: stroke fill;
    pointer-events: none;
    filter: drop-shadow(0 0.5px 1px rgba(15, 23, 42, 0.22));
}
#map-container .vn-major-city-dot-hcmc {
    fill: #60a5fa;
    stroke: #1e3a8a;
    stroke-width: 1.1px;
}

#map-container.measuring svg {
    cursor: crosshair;
}

.map-spinner {
    animation: map-spin 0.75s linear infinite;
}
@keyframes map-spin {
    to {
        transform: rotate(360deg);
    }
}

/* Các nhãn trên bản đồ */
.province-label {
    font-size: 7px;
    font-weight: 600;
    fill: #1e293b;
    text-anchor: middle;
    dominant-baseline: middle;
    pointer-events: none;
    paint-order: stroke;
    stroke: #ffffff;
    stroke-width: 0.45px;
    stroke-linejoin: round;
}
.island-label {
    font-style: italic;
    font-size: 8px;
    fill: #1e3a8a;
    stroke-width: 0.65px;
}
.sea-label {
    font-style: italic;
    font-size: 16px;
    font-weight: 600;
    fill: #1e3a8a;
    text-anchor: middle;
    pointer-events: none;
    paint-order: stroke;
    stroke: #ffffff;
    stroke-width: 1px;
}

/* Điểm đo — không dùng non-scaling để trùng hệ tọa độ projection */
#map-container circle.measure-point {
    vector-effect: none;
}

/* === Chat Box (Right Panel) === */
#chat-container {
    width: 100%;
    height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
#chat-messages {
    flex-grow: 1;
    min-height: 0;
    padding: 12px 14px;
    overflow-y: auto;
    scroll-behavior: smooth;
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
    display: flex;
    flex-direction: column;
}
.chat-message {
    margin-bottom: 10px;
    padding: 10px 14px;
    border-radius: 16px;
    max-width: 85%;
    line-height: 1.45;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}
.user-message {
    background-color: #dbeafe;
    align-self: flex-end;
    margin-left: auto;
    border: 1px solid #bfdbfe;
}
.ai-message {
    background-color: #ffffff;
    align-self: flex-start;
    border: 1px solid #e2e8f0;
}
.ai-message table {
    min-width: 90%;
    border-collapse: collapse;
    margin: 8px 0;
    background-color: white;
}
.ai-message th, .ai-message td {
    border: 1px solid #d1d5db;
    padding: 4px 6px;
    font-size: 0.9em;
    text-align: left;
}
.ai-message th {
    background-color: #f3f4f6;
}
.ai-message .chart-container {
    width: 100%;
    min-height: 150px;
    background-color: white;
    border-radius: 8px;
    padding: 8px;
    margin-top: 8px;
    border: 1px solid #e5e7eb;
}
.chart-bar {
    fill: #60a5fa;
}
.chart-text {
    font-size: 10px;
    fill: #374151;
}

.typing-indicator span {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #9ca3af;
    margin: 0 2px;
    animation: typing-blink 1.4s infinite both;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing-blink {
    0% { opacity: 0.2; }
    20% { opacity: 1; }
    100% { opacity: 0.2; }
}

/* Chế độ đơn giản: giảm đổ bóng SVG, ranh mảnh hơn */
body.map-mode-simple #map-container .map-provinces-layer {
    filter: drop-shadow(0 1px 2px rgba(12, 65, 22, 0.22));
}
body.map-mode-simple #map-container path.province {
    stroke-width: 0.48;
}

/* Biểu đồ xuất — phong cách sách giáo khoa; chữ nét rõ khi zoom/màn hình */
#chart-builder-viz svg.chart-svg-sgk {
    font-family: Times New Roman, Times, "DejaVu Serif", serif;
    shape-rendering: geometricPrecision;
}
#chart-builder-viz svg.chart-svg-sgk text {
    text-rendering: geometricPrecision;
}
#chart-builder-viz svg.chart-svg-sgk .domain {
    stroke: #0f172a;
}
#chart-builder-viz svg.chart-svg-sgk .tick line {
    stroke: #0f172a;
}

/* === Chú thích trên bản đồ (overlay) === */
#map-legend-overlay .map-legend-items .legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    line-height: 1.25;
}
#map-legend-overlay .legend-color {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    border: 1px solid rgba(15, 23, 42, 0.12);
    flex-shrink: 0;
}

/* Thước tỉ lệ */
#map-container .map-scale-bar__track {
    box-sizing: border-box;
}

#chat-input:disabled, #chat-send:disabled {
    background-color: #f3f4f6;
    cursor: not-allowed;
    opacity: 0.7;
}

#map-error-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(248, 250, 252, 0.94);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 20px;
    z-index: 100;
    backdrop-filter: blur(4px);
}

#search-suggestions .suggestion-item {
    padding: 10px 14px;
    cursor: pointer;
    font-size: 0.875rem;
}
#search-suggestions .suggestion-item:hover {
    background-color: #f1f5f9;
}

#map-tools button.active {
    background-color: #dbeafe;
    color: #1d4ed8;
}

/* Nút gợi ý chat (Tailwind class trong JS) — bo tròn đồng bộ */
#chat-suggestions button {
    border-radius: 9999px;
}

/* ── Calc tool cards ── */
.calc-card-head {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 12px;
}
.calc-card-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    font-size: 16px;
    flex-shrink: 0;
}
.calc-card-title {
    font-size: 12px;
    font-weight: 600;
    color: #1e293b;
    line-height: 1.3;
}
.calc-card-formula {
    font-size: 10.5px;
    color: #64748b;
    font-family: 'Georgia', serif;
    margin-top: 1px;
}
.calc-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
}
.calc-input {
    flex: 1;
    min-width: 100px;
    padding: 7px 10px;
    font-size: 12px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #f8fafc;
    color: #1e293b;
    transition: border-color 0.15s;
}
.calc-input:focus {
    outline: none;
    border-color: #6366f1;
    background: #fff;
}
.calc-btn {
    padding: 7px 14px;
    font-size: 11px;
    font-weight: 600;
    background: #4f46e5;
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s;
}
.calc-btn:hover { background: #4338ca; }
.calc-out {
    margin-top: 6px;
    min-height: 2rem;
    font-size: 11.5px;
    color: #334155;
    line-height: 1.55;
    padding: 6px 10px;
    background: #f1f5f9;
    border-radius: 8px;
}
.calc-out:empty { display: none; }

/* ── Info panel close button ── */
.info-close-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    color: #64748b;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.12s, color 0.12s;
    z-index: 10;
    pointer-events: auto;
}
.info-close-btn:hover {
    background: #fee2e2;
    color: #ef4444;
    border-color: #fca5a5;
}
/* .info-close-btn is absolute inside #info-panel (which is already position:fixed — no extra rule needed) */

/* Nexus AI message wrap — flex child that carries alignment */
.chat-message-wrap {
    position: relative;
    display: flex;
    flex-direction: column;
}
.chat-message-wrap:has(.user-message) {
    align-self: flex-end;
    align-items: flex-end;
    max-width: 88%;
}
.chat-message-wrap:has(.ai-message) {
    align-self: flex-start;
    align-items: flex-start;
    max-width: 96%;
}
/* Remove alignment from inner element (now on wrapper) */
.user-message { align-self: unset; margin-left: unset; }
.ai-message   { align-self: unset; }
.nexus-msg-close {
    display: none;
    position: absolute;
    top: 4px; right: 4px;
    width: 20px; height: 20px;
    border-radius: 50%;
    background: rgba(226,232,240,0.85);
    border: none;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    color: #64748b;
    align-items: center;
    justify-content: center;
    transition: background 0.12s, color 0.12s;
}
.chat-message-wrap:hover .nexus-msg-close { display: flex; }
.nexus-msg-close:hover { background: #fee2e2; color: #ef4444; }

/* ── Chart builder v3 ── */
.chart-type-card {
    min-width: 0;
    transition: border-color 0.15s, background-color 0.15s, color 0.15s, box-shadow 0.15s, transform 0.1s;
    user-select: none;
}
.chart-type-card:hover {
    box-shadow: 0 0 0 2px rgba(99,102,241,0.3);
    transform: translateY(-1px);
}
.chart-type-card--active {
    box-shadow: 0 0 0 2.5px rgba(99,102,241,0.5), 0 2px 8px rgba(99,102,241,0.15);
}

/* ── Chart input table ── */
.chart-input-table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
}
.chart-input-table input {
    transition: border-color 0.15s, box-shadow 0.15s;
}
.chart-input-table input:focus {
    box-shadow: 0 0 0 2px rgba(99,102,241,0.2);
}
.chart-input-table tbody tr:last-child {
    border-bottom: none;
}
.chart-remove-row {
    font-size: 13px;
    line-height: 1;
    cursor: pointer;
    background: none;
    border: none;
    padding: 2px 4px;
    border-radius: 4px;
}
.chart-remove-row:hover {
    background: #fee2e2;
}


/* Tooltip trên biểu đồ */
#chart-builder-viz title {
    display: none;
}
#chart-builder-viz rect:hover,
#chart-builder-viz path:hover {
    filter: brightness(1.08);
}

/* ── Nexus AI Welcome Card ── */
.nexus-welcome {
    padding: 0;
    font-size: 12px;
    line-height: 1.6;
}
.nexus-welcome-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid #e0e7ff;
}
.nexus-avatar {
    width: 36px;
    height: 36px;
    border-radius: 12px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    font-size: 16px;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(99,102,241,0.35);
}
.nexus-name {
    font-size: 13px;
    font-weight: 700;
    color: #1e293b;
    line-height: 1.2;
}
.nexus-tagline {
    font-size: 10px;
    color: #6366f1;
    font-weight: 500;
    margin-top: 1px;
}
.nexus-intro {
    color: #334155;
    margin-bottom: 10px;
    font-size: 11.5px;
}
.nexus-feat-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 5px;
    margin-bottom: 10px;
}
@media (max-width: 340px) {
    .nexus-feat-list { grid-template-columns: 1fr; }
}
.nexus-feat {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 5px 7px;
    font-size: 11px;
    color: #475569;
    line-height: 1.45;
}
.nexus-feat strong {
    color: #1e293b;
    font-weight: 600;
}
.nexus-feat-ic {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    margin-top: 1px;
    color: #6366f1;
    display: flex;
    align-items: center;
    justify-content: center;
}
.nexus-ic {
    width: 14px;
    height: 14px;
    display: inline-block;
    vertical-align: middle;
}
.nexus-cta {
    font-size: 11.5px;
    color: #6366f1;
    font-weight: 600;
    text-align: center;
    padding: 6px 0 2px;
    border-top: 1px solid #e0e7ff;
    margin-top: 4px;
}

/* ── Modal Feature Icons ── */
.modal-feat-ic {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    margin-top: 1px;
    color: #6366f1;
}
.modal-feat-ic svg {
    width: 13px;
    height: 13px;
}

/* ── Nexus AI Fallback Grid ── */
.nexus-fallback { font-size: 11.5px; }
.nexus-fallback-title { font-weight: 600; color: #334155; margin-bottom: 8px; }
.nexus-fallback-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 5px;
    margin-bottom: 8px;
}
.nexus-fb-row {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 7px;
    padding: 5px 6px;
    font-size: 11px;
    color: #475569;
    line-height: 1.4;
}
.nexus-fb-row strong { color: #1e293b; font-weight: 600; display: block; }
.nexus-fb-ex { color: #64748b; font-style: normal; font-size: 10px; }
.nexus-fb-ref {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 10.5px;
    color: #6366f1;
    padding-top: 6px;
    border-top: 1px solid #e0e7ff;
    font-style: italic;
}

/* ── SVG icon trong AI messages ── */
.ai-icon-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 2px;
}
.ai-icon-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 6px;
    background: #ede9fe;
    color: #7c3aed;
    flex-shrink: 0;
}
.ai-icon-badge svg {
    width: 12px;
    height: 12px;
}
