/* =========================================================
   sares-dashboard.css — styling for the analytical dashboard pages.

   Consumed by Pages/Dashboard/*.razor and Shared/Dashboard/*.razor.
   Reads tokens from sares-tokens.css. Pairs with dash-charts.js
   (chart canvas sizing) and dash-map.js (map card layout).
   ========================================================= */

/* ── Page shell + typography ── */
body {
    background: var(--sares-bg);
    color: var(--sares-ink);
    font-family: var(--font-body);
}

h1,
h2,
h3,
.dash-display {
    font-family: var(--font-display);
}

.dash-surface-card {
    background: var(--sares-surface);
    border: 1px solid var(--sares-line);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.dash-page {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.dash-grid-row {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 1rem;
    align-items: stretch;
}

.dash-span-6 {
    grid-column: span 6;
    min-width: 0;
}

.dash-span-12 {
    grid-column: span 12;
    min-width: 0;
}

.dash-section-label {
    color: var(--sares-muted);
    font-size: 0.69rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.dash-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: var(--sares-green-soft);
    color: var(--sares-green-deep);
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.375rem 0.75rem;
}

.dash-tooltip {
    font-family: Inter, system-ui, Arial, sans-serif;
    font-size: 13px;
    padding: 6px 10px;
}

/* ── Error banner ── */
.dash-error-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    background: var(--sares-green-soft);
    border: 1px solid var(--sares-line);
    border-radius: var(--radius-md);
    color: var(--sares-green-deep);
    padding: 0.875rem 1rem;
}

    .dash-error-banner button {
        background: var(--sares-surface);
        border: 1px solid var(--sares-line);
        border-radius: 999px;
        color: var(--sares-green-deep);
        cursor: pointer;
        font: inherit;
        font-weight: 600;
        padding: 0.45rem 0.9rem;
    }

/* ── Indicator strip (header, country filter, scope, tablist) ── */
.dash-indicator-strip {
    padding: 0.75rem;
}

.dash-indicator-strip__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.dash-indicator-strip__title {
    color: var(--sares-green-deep);
    font-family: var(--font-display);
    font-size: 0.95rem;
    font-weight: 600;
    margin-top: 0.15rem;
}

.dash-indicator-strip__controls {
    display: flex;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: flex-end;
}

.dash-country-filter {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 220px;
}

.dash-country-filter__label {
    color: var(--sares-muted);
    font-size: 0.72rem;
    font-weight: 600;
}

.dash-country-filter .rz-dropdown {
    width: 100%;
    border-color: var(--sares-line);
    border-radius: 999px;
    box-shadow: none;
}

.dash-country-filter .rz-dropdown-label,
.dash-country-filter .rz-dropdown-trigger {
    color: var(--sares-ink-2);
}

.dash-scope-banner {
    color: var(--sares-muted);
    font-size: 0.75rem;
    padding-bottom: 0.5rem;
}

.dash-tablist {
    display: inline-flex;
    align-items: center;
    background: var(--sares-surface);
    border: 1px solid var(--sares-line);
    border-radius: 999px;
    padding: 0.125rem;
}

.dash-tab {
    background: transparent;
    border: none;
    border-radius: 999px;
    color: var(--sares-ink-2);
    cursor: pointer;
    font: inherit;
    font-size: 0.74rem;
    font-weight: 700;
    padding: 0.5rem 0.9rem;
}

    .dash-tab.is-active {
        background: var(--sares-surface);
        box-shadow: var(--shadow-sm);
        color: var(--sares-green-deep);
    }

.dash-clear-button {
    background: var(--sares-surface);
    border: 1px solid var(--sares-line);
    border-radius: 999px;
    color: var(--sares-muted);
    cursor: pointer;
    font: inherit;
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0.5rem 0.9rem;
}

/* ── Indicator tiles grid ── */
.dash-tiles-grid {
    display: grid;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    gap: 0.5rem;
}

.dash-indicator-tile {
    background: var(--sares-surface);
    border: 1px solid var(--sares-line);
    border-radius: var(--radius-md);
    color: inherit;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-width: 0;
    padding: 0.7rem 0.75rem;
    position: relative;
    text-align: left;
}

button.dash-indicator-tile {
    cursor: pointer;
    font: inherit;
}

.dash-indicator-tile--interactive:hover {
    border-color: var(--sares-green);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.dash-indicator-tile--selected {
    background: var(--sares-green-soft);
    border-color: var(--sares-green);
    box-shadow: inset 0 0 0 2px var(--sares-green);
}

    .dash-indicator-tile--selected::after {
        background: var(--sares-sun);
        border-radius: 0 0 2px 2px;
        content: "";
        height: 2px;
        left: 0.75rem;
        position: absolute;
        right: 0.75rem;
        top: 0;
    }

.dash-indicator-tile--pending {
    opacity: 0.5;
}

.dash-indicator-tile__top {
    align-items: center;
    display: flex;
    gap: 0.5rem;
    justify-content: space-between;
}

.dash-indicator-tile__badge {
    background: var(--sares-green-soft);
    border-radius: 999px;
    color: var(--sares-green-deep);
    font-size: 0.72rem;
    font-weight: 700;
    padding: 0.25rem 0.55rem;
    white-space: nowrap;
    flex-shrink: 0;
}

.dash-indicator-tile--joint .dash-indicator-tile__badge {
    background: var(--sares-mist);
}

.dash-indicator-tile--joint .dash-indicator-tile__value {
    color: var(--sares-muted);
}

.dash-indicator-tile__value {
    color: var(--sares-ink-2);
    font-size: 0.74rem;
    font-weight: 700;
    text-align: right;
    min-width: 0;
    overflow-wrap: break-word;
    word-break: normal;
}

.dash-indicator-tile__name {
    color: var(--sares-ink);
    font-size: 0.84rem;
    font-weight: 600;
    line-height: 1.25;
    min-height: 2.1rem;
    overflow: hidden;
}

.dash-indicator-tile__meta,
.dash-indicator-tile__subtitle {
    color: var(--sares-muted);
    font-size: 0.72rem;
}

.dash-indicator-tile__bar-track {
    background: var(--sares-line);
    border-radius: 999px;
    height: 0.375rem;
    overflow: hidden;
}

.dash-indicator-tile__bar-fill {
    background: var(--sares-green);
    border-radius: inherit;
    height: 100%;
}

.dash-indicator-tile--joint .dash-indicator-tile__bar-fill {
    background: var(--sares-sky);
}

/* ── Chart / map / beneficiaries cards ── */
.dash-chart-card,
.dash-map-card,
.dash-benef-card {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    height: 100%;
    padding: 1rem;
}

.dash-chart-header,
.dash-map-header,
.dash-benef-header {
    align-items: flex-start;
    display: flex;
    gap: 0.75rem;
    justify-content: space-between;
}

.dash-chart-title,
.dash-map-title,
.dash-benef-title {
    color: var(--sares-ink);
    font-size: 1rem;
    font-weight: 600;
}

.dash-chart-region {
    flex: 1;
    min-height: 240px;
}

.dash-chart-footer {
    display: grid;
    gap: 0.75rem;
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.dash-chart-footer--joint {
    grid-template-columns: minmax(0, 1fr);
}

.dash-chart-stat {
    background: var(--sares-surface);
    border: 1px solid var(--sares-line);
    border-radius: var(--radius-md);
    padding: 0.75rem;
    text-align: center;
}

.dash-chart-stat--primary {
    background: var(--sares-green-soft);
}

.dash-chart-stat__label {
    color: var(--sares-muted);
    font-size: 0.72rem;
}

.dash-chart-stat__value {
    color: var(--sares-green-deep);
    font-size: 1.15rem;
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    margin-top: 0.25rem;
}

/* ── KPI column ── */
.dash-kpi-column {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 0.75rem;
    height: 100%;
}

.dash-kpi-card {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 0.5rem;
    justify-content: center;
    padding: 1rem;
}

.dash-kpi-label {
    color: var(--sares-muted);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.dash-kpi-value {
    color: var(--sares-green-deep);
    font-size: 1.9rem;
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    line-height: 1.1;
}

.dash-kpi-subtitle {
    color: var(--sares-muted);
    font-size: 0.76rem;
}

.dash-kpi-bar-track {
    background: var(--sares-line);
    border-radius: 999px;
    height: 0.375rem;
    overflow: hidden;
}

.dash-kpi-bar-fill {
    background: var(--dash-progress-color, var(--sares-green));
    border-radius: inherit;
    height: 100%;
    transform: scaleX(var(--dash-progress, 0));
    transform-origin: left center;
    width: 100%;
}

/* ── Map card frame + legend + Leaflet skin ── */
.dash-map-frame {
    border-radius: var(--radius-md);
    height: 320px;
    overflow: hidden;
    position: relative;
}

.dash-map-canvas {
    height: 100%;
    width: 100%;
}

.dash-map-empty {
    align-items: center;
    background: rgba(247,249,245,0.88);
    color: var(--sares-muted);
    display: flex;
    inset: 0;
    justify-content: center;
    padding: 1.25rem;
    position: absolute;
    text-align: center;
}

    .dash-map-empty .dash-skeleton--map {
        width: 100%;
    }

.dash-inline-legend {
    color: var(--sares-muted);
    display: inline-flex;
    gap: 0.75rem;
    font-size: 0.75rem;
}

    .dash-inline-legend span {
        align-items: center;
        display: inline-flex;
        gap: 0.35rem;
    }

    .dash-inline-legend i {
        border-radius: 999px;
        display: inline-block;
        height: 0.65rem;
        width: 0.65rem;
    }

.dash-inline-legend__male {
    background: var(--dv-male);
}

.dash-inline-legend__female {
    background: var(--dv-female);
}

.dash-benef-region {
    flex: 1;
    min-height: 320px;
}

.dash-benef-summary {
    color: var(--sares-muted);
    font-size: 0.76rem;
    text-align: center;
}

/* ── Skeleton loaders + scroll affordances ── */
.dash-skeleton {
    animation: dash-pulse 1.2s ease-in-out infinite;
    background: var(--sares-line);
    border-radius: var(--radius-sm);
}

.dash-skeleton--line {
    height: 0.85rem;
}

.dash-skeleton--title {
    height: 1.1rem;
    width: 10rem;
}

.dash-skeleton--card {
    height: 7rem;
}

.dash-skeleton--chart {
    height: 280px;
}

.dash-skeleton--map {
    height: 320px;
}

.dash-scroll::-webkit-scrollbar {
    height: 0.5rem;
    width: 0.5rem;
}

.dash-scroll::-webkit-scrollbar-thumb {
    background: var(--sares-line);
    border-radius: 999px;
}

.leaflet-container {
    background: var(--sares-mist);
    font-family: var(--font-body);
}

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
    background: var(--sares-surface);
    color: var(--sares-ink);
}

/* ── Animations + responsive breakpoints ── */
@keyframes dash-pulse {
    0% {
        opacity: 0.65;
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: 0.65;
    }
}

@media (max-width: 1279px) {
    .dash-tiles-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@media (max-width: 1024px) {
    .dash-grid-row {
        grid-template-columns: 1fr;
    }

    .dash-span-6 {
        grid-column: auto;
    }

    .dash-indicator-strip__header {
        flex-direction: column;
    }
}

@media (max-width: 768px) {
    .dash-tiles-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .dash-country-filter {
        min-width: 100%;
    }
}

@media (max-width: 480px) {
    .dash-tiles-grid {
        grid-template-columns: 1fr;
    }
}
