/*
 * Parkeringsklagenævnet dashboard styles. Everything is scoped under
 * .pklage-dashboard so it can't bleed into the surrounding WordPress theme, and
 * uses CSS custom properties so a theme can re-skin it by overriding the vars.
 */
.pklage-dashboard {
    --pk-bg: #ffffff;
    --pk-fg: #1d2733;
    --pk-muted: #5d6b7a;
    --pk-line: #e3e8ee;
    --pk-card: #f7f9fb;
    --pk-accent: #1f6feb;
    --pk-radius: 10px;
    --pk-medhold: #2e7d32;
    --pk-ikke: #c62828;
    --pk-afvist: #f9a825;

    color: var(--pk-fg);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.45;
    container-type: inline-size;
}
.pklage-dashboard * { box-sizing: border-box; }

.pklage-loading, .pklage-error, .pklage-empty { color: var(--pk-muted); padding: 1rem 0; }
.pklage-error { color: var(--pk-ikke); }

/* Header */
.pklage-header h2 { margin: 0 0 .15rem; font-size: 1.5rem; }
.pklage-subtitle { margin: 0 0 1rem; color: var(--pk-muted); font-size: .95rem; }

/* KPI row */
.pklage-kpis {
    display: grid; grid-template-columns: repeat(5, 1fr);
    gap: .75rem; margin-bottom: 1.1rem;
}
.pklage-kpi {
    background: var(--pk-card); border: 1px solid var(--pk-line);
    border-radius: var(--pk-radius); padding: .85rem 1rem;
}
.pklage-kpi-value { font-size: 1.55rem; font-weight: 700; letter-spacing: -.01em; }
.pklage-kpi-label { color: var(--pk-muted); font-size: .82rem; margin-top: .1rem; }

/* Filters */
.pklage-filters {
    display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1.1rem;
}
.pklage-filter {
    appearance: none; -webkit-appearance: none;
    background: var(--pk-bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%235d6b7a'/%3E%3C/svg%3E") no-repeat right .7rem center;
    border: 1px solid var(--pk-line); border-radius: 8px;
    padding: .5rem 1.8rem .5rem .7rem; font-size: .9rem; color: var(--pk-fg);
    max-width: 100%; cursor: pointer;
}
.pklage-filter:focus { outline: 2px solid var(--pk-accent); outline-offset: 1px; }
.pklage-reset {
    background: none; border: 1px solid var(--pk-line); border-radius: 8px;
    padding: .5rem .9rem; font-size: .9rem; color: var(--pk-muted); cursor: pointer;
}
.pklage-reset:hover { color: var(--pk-fg); border-color: var(--pk-muted); }

/* Module grid. Each module mounts into a host cell (.pklage-mod); KPI/table/
 * members/calc span the full width, charts take one column, so an arbitrary
 * modules="…" order still flows (ADR 0005). */
.pklage-charts {
    display: grid; grid-template-columns: 1fr 2fr; gap: .9rem; margin-bottom: 1.3rem;
    align-items: start;
}
.pklage-span-full { grid-column: 1 / -1; }
/* Grid items must be allowed to shrink below their content's min-width, or the
 * nowrap tables / rendered canvases pin the 1fr tracks wider than a phone
 * screen and the whole dashboard overflows horizontally. */
.pklage-mod { min-width: 0; }
.pklage-mod > .pklage-kpis,
.pklage-mod > .pklage-table-wrap,
.pklage-mod > .pklage-calc-section,
.pklage-mod > .pklage-members { margin: 0; }
/* Standalone [pklage_modul]: the module fills its mount, no grid. */
.pklage-modul { display: block; }
/* Provenance caption under a scoped standalone module. */
.pklage-card-caption { margin: .55rem 0 0; color: var(--pk-muted); font-size: .8rem; }
.pklage-card {
    background: var(--pk-bg); border: 1px solid var(--pk-line);
    border-radius: var(--pk-radius); padding: .9rem 1rem 1rem;
}
.pklage-card h3 { margin: 0 0 .6rem; font-size: 1rem; }
.pklage-card-note { margin: -.35rem 0 .7rem; color: var(--pk-muted); font-size: .82rem; }
.pklage-canvas-wrap { position: relative; height: 240px; }
.pklage-card-tall .pklage-canvas-wrap { height: 320px; }
.pklage-card-wide { } /* spans the wide column by grid placement below */
.pklage-card-tall { grid-column: span 1; }
/* "Hvor vinder man?" guide spans the full grid width and is taller (11 sagstyper). */
.pklage-card-full { grid-column: 1 / -1; }
.pklage-card-guide .pklage-canvas-wrap { height: 360px; }

/* Table */
.pklage-table-note { color: var(--pk-muted); font-size: .85rem; margin-bottom: .4rem; }
.pklage-table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--pk-line); border-radius: var(--pk-radius); }
.pklage-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.pklage-table th, .pklage-table td {
    text-align: left; padding: .5rem .7rem; border-bottom: 1px solid var(--pk-line);
    white-space: nowrap;
}
.pklage-table th { background: var(--pk-card); font-weight: 600; position: sticky; top: 0; }
.pklage-table tbody tr:hover { background: var(--pk-card); }
.pklage-table .pklage-num { text-align: right; font-variant-numeric: tabular-nums; }
.pklage-table a { color: var(--pk-accent); text-decoration: none; }
.pklage-table a:hover { text-decoration: underline; }

/* Board-member section */
.pklage-members { margin-top: 1.8rem; }
.pklage-members h2 { margin: 0 0 .15rem; font-size: 1.5rem; }
.pklage-members-table { margin-top: 1rem; }
.pklage-legend {
    display: flex; flex-wrap: wrap; gap: .35rem 1.1rem;
    margin: .1rem 0 .9rem; font-size: .82rem; color: var(--pk-muted);
}
.pklage-legend-item { display: inline-flex; align-items: center; gap: .4rem; }
.pklage-legend-swatch { width: .72rem; height: .72rem; border-radius: 2px; }
.pklage-aff-dot {
    display: inline-block; width: .6rem; height: .6rem; border-radius: 50%;
    vertical-align: middle; margin-right: .1rem;
}

.pklage-outcome { font-weight: 600; }
.pklage-outcome-medhold { color: var(--pk-medhold); }
.pklage-outcome-ikke_medhold { color: var(--pk-ikke); }
.pklage-outcome-afvist { color: var(--pk-afvist); }

/* Small "delvis" badge on a scanned-source (partial) row's date cell. */
.pklage-partial-flag {
    display: inline-block; margin-left: .4rem; padding: 0 .35rem;
    font-size: .7rem; font-weight: 600; line-height: 1.4;
    color: var(--pk-muted); background: rgba(0, 0, 0, .06);
    border-radius: .25rem; vertical-align: middle; cursor: help;
}

/* ---------------------------------------------------------------------------
 * Annual-report modules (reports.json): the datagrundlag caveat note, the
 * benchmark chart (reuses .pklage-card-guide), and the Sagstragten funnel.
 * ------------------------------------------------------------------------- */
/* "Om datagrundlaget" callout — a soft-tinted card so the correctness caveat
 * reads as a framing note, not just another chart. */
.pklage-note {
    background: var(--pk-card);
    border-left: 3px solid var(--pk-accent);
}
.pklage-note p { margin: 0 0 .6rem; font-size: .92rem; }
.pklage-note p:last-child { margin-bottom: 0; }
.pklage-note-foot { color: var(--pk-muted); font-size: .85rem; }

/* Sagstragten — a year picker beside the heading, then one block per funnel
 * stage: a label + count, a segmented bar (segments sized by their own stage's
 * percentages), and a legend spelling out each segment's share and count. */
.pklage-flow-title { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; margin-bottom: .6rem; }
.pklage-flow-title .pklage-filter { margin-left: auto; }
.pklage-flow { display: flex; flex-direction: column; gap: 1rem; }
.pklage-flow-stage { }
.pklage-flow-head {
    display: flex; justify-content: space-between; align-items: baseline;
    gap: .6rem; margin-bottom: .35rem;
}
.pklage-flow-label { font-weight: 600; font-size: .95rem; }
.pklage-flow-n { color: var(--pk-muted); font-size: .9rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pklage-flow-bar {
    display: flex; height: 1.4rem; border-radius: 6px; overflow: hidden;
    background: var(--pk-line);
}
.pklage-flow-seg { height: 100%; min-width: 2px; }
.pklage-flow-legend {
    display: flex; flex-wrap: wrap; gap: .3rem 1.1rem;
    margin-top: .4rem; font-size: .82rem; color: var(--pk-muted);
}
.pklage-flow-legend-item { display: inline-flex; align-items: center; gap: .4rem; }
.pklage-flow-swatch { width: .72rem; height: .72rem; border-radius: 2px; flex: none; }
.pklage-flow-foot { margin: .4rem 0 0; color: var(--pk-muted); font-size: .82rem; font-style: italic; }

/* ---------------------------------------------------------------------------
 * "Kan det betale sig at klage?" calculator (calculator.js). Lives both as a
 * card inside the dashboard (.pklage-calc-section) and as a standalone shortcode
 * whose root carries .pklage-dashboard so these vars + the base font resolve.
 * ------------------------------------------------------------------------- */
.pklage-calc-section { margin-top: 1.8rem; }
.pklage-calc {
    background: var(--pk-bg); border: 1px solid var(--pk-line);
    border-radius: var(--pk-radius); padding: 1.1rem 1.2rem 1.2rem;
}
.pklage-calc h3 { margin: 0 0 .4rem; font-size: 1.15rem; }
.pklage-calc .pklage-card-note { margin: 0 0 1rem; }

/* The three input chips (afgift / tid / gebyr). */
.pklage-calc-basis {
    display: grid; grid-template-columns: repeat(3, 1fr);
    gap: .75rem; margin-bottom: 1.4rem;
}
.pklage-calc-chip {
    background: var(--pk-card); border: 1px solid var(--pk-line);
    border-radius: 8px; padding: .7rem .85rem;
}
.pklage-calc-chip-value { font-size: 1.25rem; font-weight: 700; letter-spacing: -.01em; }
.pklage-calc-chip-label { color: var(--pk-muted); font-size: .8rem; margin-top: .1rem; }

/* Slider row + live readout. */
.pklage-calc-control { display: flex; align-items: center; gap: .8rem; }
.pklage-calc-rate-label { color: var(--pk-muted); font-size: .9rem; min-width: 6.5rem; }
.pklage-calc-slider { flex: 1; accent-color: var(--pk-accent); cursor: pointer; }
.pklage-calc-rate-out {
    font-size: 1.05rem; font-weight: 700; min-width: 3.2rem; text-align: right;
    font-variant-numeric: tabular-nums;
}

/* Tick marks on the slider track, positioned by % along the track. Marks only;
 * the labelled list is the preset chips below (avoids label collisions). */
.pklage-calc-ticks { position: relative; height: .55rem; margin: .1rem .35rem .9rem; }
.pklage-calc-tick { position: absolute; transform: translateX(-50%); }
.pklage-calc-tick-mark {
    display: block; width: 2px; height: .5rem; border-radius: 1px;
    background: var(--pk-accent); opacity: .5; cursor: help;
}

/* Preset chips. */
.pklage-calc-presets {
    display: flex; flex-wrap: wrap; align-items: center; gap: .45rem;
    margin: 0 0 1.4rem;
}
.pklage-calc-presets-label { color: var(--pk-muted); font-size: .85rem; margin-right: .15rem; }
.pklage-calc-preset {
    background: none; border: 1px solid var(--pk-line); border-radius: 999px;
    padding: .3rem .7rem; font-size: .82rem; color: var(--pk-fg); cursor: pointer;
    font-variant-numeric: tabular-nums;
}
.pklage-calc-preset:hover { border-color: var(--pk-accent); color: var(--pk-accent); }

/* Result. */
.pklage-calc-result-head {
    display: flex; align-items: baseline; flex-wrap: wrap; gap: .15rem .6rem;
    margin-bottom: .9rem;
}
.pklage-calc-result-label { color: var(--pk-muted); font-size: .9rem; }
.pklage-calc-gain { font-size: 1.8rem; font-weight: 700; letter-spacing: -.01em; }

.pklage-calc-check {
    display: flex; align-items: center; gap: .6rem;
    padding: .55rem .7rem; border-radius: 8px; margin-bottom: .45rem;
    background: var(--pk-card); color: var(--pk-muted);
}
.pklage-calc-check.is-ok {
    background: rgba(46, 125, 50, .1); color: var(--pk-medhold);
}
.pklage-calc-check-icon { font-weight: 700; width: 1.1rem; text-align: center; }
.pklage-calc-check-label { flex: 1; font-size: .92rem; }
.pklage-calc-check-detail { font-size: .85rem; font-weight: 600; font-variant-numeric: tabular-nums; }

.pklage-calc-foot { color: var(--pk-muted); font-size: .8rem; margin: .9rem 0 0; }
.pklage-calc-foot-dim { font-size: .76rem; margin-top: .35rem; opacity: .85; }

/* Responsive: collapse to one column on narrow containers. */
@container (max-width: 720px) {
    .pklage-kpis { grid-template-columns: repeat(2, 1fr); }
    .pklage-charts { grid-template-columns: 1fr; }
    .pklage-calc-basis { grid-template-columns: 1fr; }
}

/* Phone-width containers: tighten paddings/typography and make the controls
 * finger-sized. Chart internals (label wrapping, per-bar heights, tick fonts)
 * are handled in dashboard.js, which watches the same ~breakpoint. */
@container (max-width: 520px) {
    .pklage-header h2 { font-size: 1.25rem; }
    .pklage-kpis { gap: .5rem; }
    .pklage-kpi { padding: .6rem .75rem; }
    .pklage-kpi-value { font-size: 1.25rem; }
    .pklage-kpi-label { font-size: .76rem; }

    /* Two selects per row, full-width, long option labels ellipsised. */
    .pklage-filters { display: grid; grid-template-columns: 1fr 1fr; gap: .45rem; }
    .pklage-filter {
        width: 100%; padding-right: 1.7rem;
        overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
    }
    .pklage-reset { width: 100%; }

    .pklage-card { padding: .75rem .8rem .9rem; }
    .pklage-card h3 { font-size: .95rem; }
    .pklage-table { font-size: .82rem; }
    .pklage-table th, .pklage-table td { padding: .45rem .55rem; }
    .pklage-members h2 { font-size: 1.25rem; }

    /* Calculator: slider gets its own full-width row under the label/readout. */
    .pklage-calc { padding: .9rem .85rem 1rem; }
    .pklage-calc-control { flex-wrap: wrap; gap: .35rem .8rem; }
    .pklage-calc-rate-label { min-width: 0; }
    .pklage-calc-rate-out { margin-left: auto; }
    .pklage-calc-slider { flex: 1 1 100%; order: 3; min-height: 1.8rem; }
    .pklage-calc-gain { font-size: 1.5rem; }
}
