/*
 * Component-level polish on top of theme.css's tokens. Bootstrap's compiled CSS bakes most
 * per-component colors in at build time (its Sass mixins set component-scoped variables like
 * --bs-btn-bg to a literal hex, not to var(--bs-primary)), so setting --bs-primary alone does
 * NOT reskin .btn-primary - each component below is overridden explicitly and deliberately,
 * the documented, supported way to reskin Bootstrap without a Sass rebuild.
 */

/* --- Icons (see TagHelpers/IconTagHelper.cs - <icon name="..."/>) --- */
.icon-svg {
    width: 1.1em;
    height: 1.1em;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.75;
    stroke-linecap: round;
    stroke-linejoin: round;
    vertical-align: -0.2em;
    flex-shrink: 0;
}

.icon-lg {
    width: 1.5em;
    height: 1.5em;
}

/* --- Buttons --- */
.btn {
    font-weight: 500;
    padding-block: 0.5rem;
}

.btn-primary {
    --bs-btn-bg: var(--brand);
    --bs-btn-border-color: var(--brand);
    --bs-btn-hover-bg: var(--brand-dark);
    --bs-btn-hover-border-color: var(--brand-dark);
    --bs-btn-active-bg: var(--brand-dark);
    --bs-btn-active-border-color: var(--brand-dark);
    --bs-btn-disabled-bg: var(--brand);
    --bs-btn-disabled-border-color: var(--brand);
    --bs-btn-focus-shadow-rgb: 15, 81, 50;
    box-shadow: var(--shadow-sm);
}

.btn-outline-primary {
    --bs-btn-color: var(--brand);
    --bs-btn-border-color: var(--brand);
    --bs-btn-hover-bg: var(--brand);
    --bs-btn-hover-border-color: var(--brand);
    --bs-btn-active-bg: var(--brand);
    --bs-btn-active-border-color: var(--brand);
}

.btn-link {
    --bs-btn-color: var(--text-muted);
}

.btn-sm {
    padding-block: 0.32rem;
}

/* --- Forms --- */
.form-label {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text);
    margin-bottom: 0.35rem;
}

.form-control,
.form-select {
    border-color: var(--border);
    padding-block: 0.55rem;
    background-color: var(--surface);
    color: var(--text);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 0.2rem var(--brand-tint-strong);
}

.form-control::placeholder {
    color: var(--text-muted);
    opacity: 0.7;
}

.form-check-input:checked {
    background-color: var(--brand);
    border-color: var(--brand);
}

.form-check-input:focus {
    box-shadow: 0 0 0 0.2rem var(--brand-tint-strong);
}

.form-text {
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* A form's natural home: a raised card rather than floating on the page background. */
.form-card {
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 1.75rem;
}

/* --- Cards / surfaces --- */
.card {
    border-color: var(--border);
    box-shadow: var(--shadow-sm);
}

.surface-card {
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

/* --- Tables --- */
.table {
    --bs-table-bg: var(--surface-raised);
    color: var(--text);
    vertical-align: middle;
}

.table > thead {
    background: var(--surface-alt);
}

.table > thead th {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    font-weight: 700;
    border-bottom-width: 1px;
    border-color: var(--border);
    white-space: nowrap;
}

.table > :not(caption) > * > * {
    border-bottom-color: var(--border);
}

.table-hover > tbody > tr:hover > * {
    background-color: var(--brand-tint);
}

/* --- Badges --- */
.badge {
    font-weight: 600;
    letter-spacing: 0.01em;
    padding: 0.4em 0.65em;
}

/* --- Theme toggle --- */
.theme-toggle-btn {
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.theme-toggle-btn:hover {
    background: var(--surface-alt);
}

.theme-toggle-btn .icon-moon {
    display: none;
}

[data-bs-theme="dark"] .theme-toggle-btn .icon-sun {
    display: none;
}

[data-bs-theme="dark"] .theme-toggle-btn .icon-moon {
    display: inline-flex;
}

/* --- Alerts get the same radius language --- */
.alert {
    border-radius: var(--radius);
}

/* --- Reporting dashboard: plain CSS bar chart (no charting library available offline - see
   ReportingController's doc comment) and the metric summary cards above it. --- */
.report-bar-track {
    background: var(--surface-alt);
    border-radius: 0.3rem;
    height: 0.5rem;
    overflow: hidden;
    min-width: 80px;
}

.report-bar-fill {
    background: var(--brand);
    height: 100%;
    border-radius: 0.3rem;
    transition: width 0.3s ease;
}

.report-stat-card {
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 1.1rem 1.25rem;
}

.report-stat-card .report-stat-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.2;
}

.report-stat-card .report-stat-label {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    font-weight: 600;
}

.report-view-tabs .btn-check:checked + .btn-outline-primary {
    color: #fff;
    background-color: var(--brand);
    border-color: var(--brand);
}

/* --- Dashboard: Ghana region map (Views/Home/Index.cshtml) - the map itself, its legend and its
   data-table fallback are all drawn by the vendored GhanaMap library
   (wwwroot/js/lib/ghana-map.js, injects its own <style id="ghana-map-styles"> the first time it
   runs) rather than by anything in this file. What's here just retunes that library's own CSS
   custom properties (--gh-*) to this app's theme tokens instead of its light/dark defaults, using
   the exact hook the library documents for this ([data-theme] on its root element, which it sets
   and updates itself) - scoped to #ghanaRegionMap so it can't leak onto any other GhanaMap
   instance a future page might add with different theming needs. --- */
#ghanaRegionMap {
    --gh-max-height: min(60vh, 480px);
}

#ghanaRegionMap[data-theme] {
    --gh-ink: var(--text);
    --gh-ink-2: var(--text-muted);
    --gh-ink-3: var(--text-muted);
    --gh-line: var(--border);
    --gh-focus: var(--brand);
}

#ghanaRegionMap[data-theme="light"] {
    --gh-surface: var(--surface);
    --gh-nodata: var(--surface-alt);
    --gh-stroke: var(--surface-raised);
}

#ghanaRegionMap[data-theme="dark"] {
    --gh-surface: var(--surface);
    --gh-nodata: var(--surface-alt);
    --gh-stroke: var(--surface-raised);
}

/* --- District drill-down modal (populated from #regionMapData via initRegionMap in site.js,
   opened on GhanaMap's onClick) - reuses .report-bar-track/.report-bar-fill for its mini bars. --- */
.district-list-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding-block: 0.35rem;
}

.district-list-row .district-label {
    flex: 0 0 auto;
    min-width: 9rem;
    font-size: 0.85rem;
    color: var(--text);
}

.district-list-row .district-count {
    flex: 0 0 auto;
    width: 2.75rem;
    text-align: right;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
}

.district-list-row .report-bar-track {
    flex: 1 1 auto;
}
