﻿/* Bản đồ Giá nông sản - layout map + panel theo mockup */
body.page-bando-standalone form#form_bando {
    height: 100%;
    margin: 0;
}
.page-bando-standalone .bando-standalone-main {
    padding: 0;
    height: 100%;
    max-height: 100%;
    overflow: hidden;
    position: relative;
}

.bgns-app {
    --bgns-green: #1B6B2A;
    --bgns-green-dark: #145221;
    --bgns-green-soft: #E8F5E9;
    --bgns-panel-w: min(500px, 92vw);
    position: fixed;
    top: max(env(safe-area-inset-top, 0px), 0px);
    right: max(env(safe-area-inset-right, 0px), 0px);
    bottom: max(env(safe-area-inset-bottom, 0px), 0px);
    left: max(env(safe-area-inset-left, 0px), 0px);
    z-index: 2;
    width: auto;
    height: auto;
    display: flex;
    background: #f4f7f4;
}

.bgns-map-wrap {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
    height: 100%;
}

#bgnsMap {
    width: 100%;
    height: 100%;
    z-index: 1;
    background: #eef5ee;
}

.bgns-top-left {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 500;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.bgns-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid rgba(27, 107, 42, 0.25);
    background: #fff;
    color: var(--bgns-green-dark);
    border-radius: 999px;
    padding: 0.4rem 0.85rem;
    font-size: 0.85rem;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    cursor: pointer;
}

.bgns-chip:hover { background: var(--bgns-green-soft); }
.bgns-chip-link { text-decoration: none; }

.bgns-layer-pop {
    position: absolute;
    top: 56px;
    left: 12px;
    z-index: 510;
    width: min(280px, calc(100% - 24px));
    background: #fff;
    border-radius: 12px;
    padding: 12px 14px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14);
    border: 1px solid #e0e0e0;
    display: none;
}

.bgns-layer-pop.is-open {
    display: block;
}

.bgns-layer-title {
    font-weight: 700;
    color: var(--bgns-green-dark);
    margin-bottom: 8px;
    font-size: 0.92rem;
}

.bgns-label {
    display: block;
    font-size: 0.75rem;
    color: #666;
    margin-bottom: 4px;
}

.bgns-legend {
    position: absolute;
    left: 12px;
    bottom: 28px;
    z-index: 500;
    background: rgba(255, 255, 255, 0.96);
    border-radius: 10px;
    padding: 10px 12px;
    min-width: 180px;
    max-width: min(280px, calc(100% - 24px));
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
    font-size: 0.78rem;
}

.bgns-legend-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
}

.bgns-legend-title {
    font-weight: 800;
    color: var(--bgns-green-dark);
    margin-bottom: 0;
    letter-spacing: 0.02em;
    font-size: 0.8rem;
    line-height: 1.3;
    flex: 1 1 auto;
    min-width: 0;
}

.bgns-legend-toggle {
    flex: 0 0 auto;
    width: 28px;
    height: 28px;
    margin: -4px -4px 0 0;
    padding: 0;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--bgns-green-dark);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    line-height: 1;
}

.bgns-legend-toggle:hover {
    background: var(--bgns-green-soft);
}

.bgns-legend-toggle i {
    font-size: 1rem;
}

.bgns-legend-content {
    margin-top: 8px;
}

.bgns-legend.is-collapsed .bgns-legend-content {
    display: none;
}

.bgns-legend.is-collapsed {
    padding: 8px 10px;
    min-width: 0;
}

.bgns-legend-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 4px 0;
    padding: 2px 4px;
    border-radius: 4px;
    transition: background 0.15s ease;
}

.bgns-legend-row.is-active {
    background: #E8F5E9;
    outline: 1px solid #A5D6A7;
    font-weight: 700;
}

.bgns-swatch {
    width: 18px;
    height: 12px;
    border-radius: 2px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    flex: 0 0 auto;
}

.bgns-legend-select {
    margin-top: 8px;
    padding: 8px;
    border-radius: 8px;
    background: #F1F8E9;
    border: 1px solid #C5E1A5;
    font-size: 0.75rem;
    line-height: 1.35;
    color: #1B5E20;
}

.bgns-legend-select strong {
    display: block;
    font-size: 0.82rem;
    margin-bottom: 2px;
    color: #0D4A1A;
}

.bgns-legend-marker {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed #ddd;
    color: #444;
}

.bgns-source {
    position: absolute;
    right: 8px;
    bottom: 4px;
    z-index: 450;
    font-size: 0.58rem;
    color: #333;
    text-align: right;
    line-height: 1.35;
    max-width: 55%;
    pointer-events: none;
}
.bgns-source .src-main { font-style: italic; }
.bgns-source .src-attr { opacity: .88; font-size: 0.52rem; }
#bgnsMap .leaflet-control-attribution {
    display: none !important;
}

.bgns-marker-badge {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--bgns-icon-bg, #1B6B2A);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    font-size: 0.72rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.bgns-marker-badge i {
    color: #fff;
    line-height: 1;
}

.bgns-marker-badge .bgns-emoji {
    font-style: normal;
    line-height: 1;
    font-size: 0.95em;
    color: inherit;
}

.bgns-marker-badge-lg {
    width: 32px;
    height: 32px;
    font-size: 1rem;
}

.bgns-marker-icon {
    background: transparent !important;
    border: none !important;
}

.bgns-marker-icon .bgns-marker-badge {
    width: 26px;
    height: 26px;
    font-size: 0.85rem;
}

.bgns-panel {
    width: var(--bgns-panel-w);
    max-width: 100%;
    height: 100%;
    background: #fff;
    border-left: 1px solid #e5e5e5;
    display: flex;
    flex-direction: column;
    z-index: 520;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.06);
}

.bgns-panel[hidden] { display: none !important; }

.bgns-panel-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
    padding: 14px 14px 10px;
    border-bottom: 1px solid #eee;
}

.bgns-panel-head-main {
    display: flex;
    gap: 10px;
    align-items: center;
    min-width: 0;
}

.bgns-panel-title {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 800;
    color: #222;
    line-height: 1.2;
}

.bgns-panel-meta {
    font-size: 0.78rem;
    color: #777;
    margin-top: 2px;
}

.bgns-close {
    border: none;
    background: transparent;
    color: #666;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
}

.bgns-close:hover { background: #f0f0f0; }

.bgns-panel-body {
    flex: 1 1 auto;
    overflow: auto;
    padding: 12px 14px 8px;
    min-height: 0;
}

.bgns-card {
    background: #fff;
    border: 1px solid #eef0ee;
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 12px;
}

.bgns-card-title {
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    color: var(--bgns-green);
    margin-bottom: 10px;
}

.bgns-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.bgns-stat-label {
    font-size: 0.7rem;
    color: #777;
    margin-bottom: 4px;
}

.bgns-stat-val {
    font-size: 1.05rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.bgns-stat-avg, .bgns-stat-hi { color: var(--bgns-green); }
.bgns-stat-lo { color: #C62828; }

.bgns-chart-wrap {
    position: relative;
    width: 100%;
    height: 168px;
    background: linear-gradient(180deg, #f7fbf7 0%, #fff 100%);
    border-radius: 8px;
    overflow: visible;
    padding: 4px 2px 0;
    box-sizing: border-box;
}

#bgnsChart { width: 100%; height: 100%; display: block; }

.bgns-chart-dot.is-hover {
    fill: #E8F5E9;
    stroke-width: 2.5;
}

.bgns-chart-tip {
    position: absolute;
    z-index: 5;
    transform: translate(-50%, calc(-100% - 10px));
    background: #1B5E20;
    color: #fff;
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1.2;
    padding: 0.28rem 0.5rem;
    border-radius: 6px;
    white-space: nowrap;
    pointer-events: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
}

.bgns-chart-tip::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 100%;
    margin-left: -5px;
    border: 5px solid transparent;
    border-top-color: #1B5E20;
}

.bgns-chart-tip[hidden] {
    display: none !important;
}

.bgns-range-btns {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}

.bgns-range-btns button {
    border: 1px solid #c8e6c9;
    background: #fff;
    color: var(--bgns-green-dark);
    border-radius: 999px;
    padding: 0.25rem 0.55rem;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    flex: 0 0 auto;
}

.bgns-range-btns button.active,
.bgns-range-btns button:hover {
    background: var(--bgns-green);
    border-color: var(--bgns-green);
    color: #fff;
}

@media (min-width: 992px) {
    .bgns-app {
        --bgns-panel-w: min(520px, 40vw);
    }

    .bgns-range-btns {
        flex-wrap: nowrap;
        gap: 5px;
    }

    .bgns-range-btns button {
        padding: 0.28rem 0.5rem;
        font-size: 0.72rem;
    }
}

.bgns-info-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.bgns-info-list li {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 8px 0;
    border-bottom: 1px solid #f1f1f1;
    font-size: 0.86rem;
}

.bgns-info-list li:last-child { border-bottom: none; }
.bgns-info-list i {
    color: var(--bgns-green);
    margin-top: 2px;
}
.bgns-info-list span {
    display: block;
    font-size: 0.72rem;
    color: #888;
}
.bgns-info-list strong {
    font-weight: 600;
    color: #222;
}

.bgns-panel-foot {
    padding: 10px 14px 14px;
    border-top: 1px solid #eee;
}

.bgns-btn-outline {
    width: 100%;
    border: 1.5px solid var(--bgns-green);
    background: #fff;
    color: var(--bgns-green-dark);
    border-radius: 10px;
    padding: 0.65rem 0.75rem;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
}

.bgns-btn-outline:hover {
    background: var(--bgns-green-soft);
}

.bgns-empty {
    position: absolute;
    inset: 0;
    z-index: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(244, 247, 244, 0.92);
    padding: 20px;
}

.bgns-empty[hidden] { display: none !important; }

.bgns-empty-card {
    max-width: 420px;
    background: #fff;
    border-radius: 14px;
    padding: 22px 24px;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.1);
}

.bgns-empty-card h3 {
    margin: 0 0 8px;
    color: var(--bgns-green-dark);
    font-size: 1.1rem;
}

.bgns-empty-card p {
    margin: 0;
    color: #555;
    font-size: 0.9rem;
    line-height: 1.45;
}

@media (max-width: 767.98px) {
    .bgns-app { flex-direction: column; }
    .bgns-map-wrap { height: 48vh; flex: none; }
    .bgns-panel {
        width: 100%;
        height: 52vh;
        border-left: none;
        border-top: 1px solid #e5e5e5;
    }
    .bgns-legend { bottom: 12px; font-size: 0.72rem; min-width: 150px; }
}
