/* Session Replay Viewer — content building blocks: dashboard cards, "Needs attention", KPI tiles with
   progress bars, tables with mini bars and legends, widget action menus, empty widget states. Reads the
   --kt-* tokens from app.css. Values (paddings, radii, type sizes, bar heights) follow the KidsTime web
   dashboard (dashboard-box / DashboardCard / "Grupy dziś" / "Wymaga uwagi"). Loaded after viewer.css, so
   the few overrides of earlier rules live here on purpose. */

/* ── content column: centred, KidsTime width. Pages with wide tables opt out with
      <PageHeader Wide="true"> (or any element carrying .kt-page-wide). ───────────────────────────── */
.kt-main { max-width: none; margin: 0; }
/* A diagnostics tool: data pages (stacks, tables, lists, dashboards, charts) fill the window, left-aligned,
   with 24–32px gutters. Only form pages (settings) keep a narrow reading column: <PageHeader Narrow="true">. */
.kt-main:has(.kt-page-narrow) { max-width: 920px; }
@media (min-width: 1600px) { .kt-main { padding-left: 32px; padding-right: 32px; } .kt-topbar { padding-left: 32px; padding-right: 32px; } }

/* ── page header additions: action tile next to the title, icon subtitle, context chips ─────────── */
.kt-title-action {
    width: 36px; height: 36px; flex: none; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center;
    background: var(--kt-surface); border: 1px solid var(--kt-border); color: var(--kt-action-text); font-size: 14px;
    text-decoration: none; cursor: pointer; box-shadow: var(--kt-row-shadow);
}
.kt-title-action:hover { background: var(--kt-surface-hover); border-color: var(--kt-border-strong); color: var(--kt-action-text); }
.kt-subtitle > i:first-child { color: var(--kt-action-text); margin-right: 8px; }
.kt-page-header .kt-ctx-chips { flex: 1 0 100%; margin-top: 4px; }

/* Context chips ("Moduły placówki"): a secondary label followed by small chips — the active ones raised
   on the surface, the inactive ones flat, struck through and secondary. Toggle chips are buttons. */
.kt-ctx-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 0; }
.kt-ctx-label { font-size: 12px; color: var(--kt-muted); }
.kt-ctx-chip {
    display: inline-flex; align-items: center; gap: 6px; min-height: 28px; padding: 4px 10px; border: 0; border-radius: 8px;
    font: 600 12px "Poppins", sans-serif; background: var(--kt-surface); color: var(--kt-ink); box-shadow: var(--kt-card-shadow);
    text-decoration: none; white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis;
}
button.kt-ctx-chip, a.kt-ctx-chip { cursor: pointer; }
button.kt-ctx-chip:hover, a.kt-ctx-chip:hover { background: var(--kt-surface-hover); color: var(--kt-ink); }
.kt-ctx-chip.off { background: transparent; box-shadow: none; color: var(--kt-muted); text-decoration: line-through; font-weight: 500; }
.kt-ctx-sep { width: 1px; height: 16px; background: var(--kt-border-strong); margin: 0 4px; }

/* ── panel: the dashboard card (white, 1px outline, 16px radius, light shadow, 24px padding) ─────── */
.kt-panel {
    display: flex; flex-direction: column; gap: 16px; min-width: 0; padding: 24px; margin-bottom: 20px;
    background: var(--kt-surface); border: 1px solid var(--kt-border); border-radius: var(--kt-radius-lg); box-shadow: var(--kt-card-shadow);
}
.kt-panel--red { border-left: 4px solid var(--kt-red); }
.kt-panel--flush { margin-bottom: 0; height: 100%; }
.kt-panel-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0; }
.kt-panel-icon { color: var(--kt-action-text); font-size: 18px; flex: none; }
.kt-panel--red .kt-panel-icon { color: var(--kt-red-text); }
.kt-panel-icon.ok { color: var(--kt-green-text); }
.kt-panel-title { margin: 0; font-size: 20px; line-height: 1.3; font-weight: 600; color: var(--kt-ink); min-width: 0; overflow-wrap: anywhere; }
.kt-panel-count { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 8px; font-size: 12px; font-weight: 600; background: var(--kt-grey-bg); color: var(--kt-grey-ink); }
.kt-panel-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.kt-panel-link { font-size: 12px; font-weight: 600; color: var(--kt-action-text); text-decoration: underline; text-underline-offset: 3px; white-space: nowrap; cursor: pointer; background: none; border: 0; padding: 4px 0; }
.kt-panel-link:hover { color: var(--kt-action-text); text-decoration-thickness: 2px; }
.kt-panel-note { font-size: 12px; color: var(--kt-muted); }
.kt-panel-foot { display: flex; justify-content: flex-end; }

/* ── "Needs attention" rows: category tag · title + description · Show › ─────────────────────────── */
.kt-attn { display: flex; flex-direction: column; }
.kt-attn-row { display: grid; grid-template-columns: 76px minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--kt-border); }
.kt-attn-row:first-child { border-top: 0; padding-top: 0; }
.kt-attn-row:last-child { padding-bottom: 0; }
.kt-attn-tag { justify-self: start; padding: 4px 8px; border-radius: 8px; font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; background: var(--kt-grey-bg); color: var(--kt-grey-ink); white-space: nowrap; }
.kt-attn-tag.red { background: var(--kt-red-bg); color: var(--kt-red-text); }
.kt-attn-tag.yellow { background: var(--kt-yellow-bg); color: var(--kt-yellow-ink); }
.kt-attn-title { font-size: 14px; font-weight: 600; color: var(--kt-ink); overflow-wrap: anywhere; }
.kt-attn-desc { font-size: 12px; color: var(--kt-muted); overflow-wrap: anywhere; }
.kt-attn-ok { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--kt-muted); }
.kt-attn-ok i { color: var(--kt-green-text); font-size: 16px; }
@media (min-width: 1000px) {
    .kt-attn--wide { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 32px; }
    .kt-attn--wide .kt-attn-row:nth-child(2) { border-top: 0; padding-top: 0; }
    .kt-attn--wide .kt-attn-row:nth-last-child(2):nth-child(odd) { padding-bottom: 0; }
}

/* ── KPI tile: secondary label, 2rem semibold value with a quiet suffix, 8px bar, detail line ───── */
.kt-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; margin-bottom: 20px; }
.kt-kpi {
    display: flex; flex-direction: column; gap: 12px; min-width: 0; padding: 24px; text-decoration: none;
    background: var(--kt-surface); border: 1px solid var(--kt-border); border-radius: var(--kt-radius-lg); box-shadow: var(--kt-card-shadow);
    transition: box-shadow .2s ease, border-color .2s ease;
}
a.kt-kpi:hover, .kt-kpi.clickable:hover { box-shadow: var(--kt-shadow-hover); border-color: var(--kt-border-strong); }
.kt-kpi.clickable { cursor: pointer; }
.kt-kpi-label { font-size: 12px; color: var(--kt-muted); }
.kt-kpi-value-row { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; min-width: 0; }
.kt-kpi-value { font-size: 2rem; line-height: 1.15; font-weight: 600; color: var(--kt-ink); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.kt-kpi-value.bad { color: var(--kt-red-text); }
.kt-kpi-value.good { color: var(--kt-green-text); }
.kt-kpi-suffix { font-size: 1rem; color: var(--kt-muted); }
.kt-kpi-tag { margin-left: auto; align-self: center; }
.kt-kpi-detail { font-size: 12px; color: var(--kt-muted); }

/* ── bars: stacked segments on a neutral track; 8px in KPI tiles, 5px in table cells ─────────────── */
.kt-bar { display: flex; height: 8px; border-radius: 8px; overflow: hidden; background: var(--kt-grey-bg); gap: 0; min-width: 40px; }
.kt-bar.thin { height: 5px; }
.kt-bar > span { display: block; height: 100%; min-width: 0; }
.kt-bar > span + span { box-shadow: -2px 0 0 var(--kt-surface); }
.kt-tone-good { background: var(--kt-green); }
.kt-tone-info { background: var(--kt-blue); }
.kt-tone-bad { background: var(--kt-red); }
.kt-tone-warn { background: var(--kt-yellow); }
.kt-tone-muted { background: var(--kt-icon-muted); }
.kt-tone-purple { background: var(--kt-purple); }
.kt-cell-bar { min-width: 96px; }
.kt-cell-bar .kt-cell-value { font-weight: 600; color: var(--kt-ink); font-variant-numeric: tabular-nums; }
.kt-cell-bar .kt-bar { margin-top: 4px; }
.kt-cell-bar .kt-cell-note { margin-top: 4px; font-size: 12px; color: var(--kt-muted); }

.kt-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12px; color: var(--kt-muted); }
.kt-legend > span { display: inline-flex; align-items: center; gap: 6px; }
.kt-legend i { width: 9px; height: 9px; border-radius: 50%; flex: none; }

/* ── data table inside a card ("Grupy dziś"): tinted two-line header, avatar + name first column ── */
.kt-data-wrap { overflow-x: auto; min-width: 0; }
.kt-data { width: 100%; border-collapse: collapse; font-size: 13px; color: var(--kt-ink); }
.kt-data th {
    text-align: left; vertical-align: bottom; padding: 10px 12px; font-size: 12px; font-weight: 600; color: var(--kt-muted);
    background: color-mix(in srgb, var(--kt-grey-bg) 60%, transparent); border-bottom: 1px solid var(--kt-border); white-space: nowrap;
}
.kt-data th:first-child { border-radius: 8px 0 0 0; }
.kt-data th:last-child { border-radius: 0 8px 0 0; }
.kt-data th small, .kt-data th .sub { display: block; font-size: 12px; font-weight: 400; color: var(--kt-muted); }
.kt-data td { padding: 10px 12px; border-bottom: 1px solid var(--kt-border); vertical-align: middle; }
.kt-data tbody tr:last-child td { border-bottom: 0; }
.kt-data tbody tr.clickable { cursor: pointer; }
.kt-data tbody tr.clickable:hover td, .kt-data.hover tbody tr:hover td { background: var(--kt-surface-hover); }
.kt-data .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.kt-data .bad { color: var(--kt-red-text); font-weight: 600; }
.kt-data .muted { color: var(--kt-muted); }
.kt-who { display: flex; align-items: center; gap: 10px; min-width: 132px; }
.kt-who-avatar {
    width: 32px; height: 32px; border-radius: 50%; flex: none; display: inline-flex; align-items: center; justify-content: center;
    background: var(--kt-tonal); color: var(--kt-ink); font-size: 13px; font-weight: 600;
}
.kt-who-avatar.blue { background: var(--kt-blue-bg); color: var(--kt-blue-ink); }
.kt-who-avatar.green { background: var(--kt-green-bg); color: var(--kt-green-text); }
.kt-who-avatar.purple { background: var(--kt-purple-bg); color: var(--kt-purple-ink); }
.kt-who-avatar.yellow { background: var(--kt-yellow-bg); color: var(--kt-yellow-ink); }
.kt-who-name { font-weight: 600; color: var(--kt-ink); overflow-wrap: break-word; min-width: 0; }
.kt-who-sub { font-size: 12px; color: var(--kt-muted); }

/* ── dashboard widgets ──────────────────────────────────────────────────────────────────────────── */
/* Rows no longer stretch every card to the tallest neighbour (that left white holes in short widgets). */
.kt-widget-grid.mud-grid { align-items: flex-start; }
.kt-widget-grid .widget-tile { height: auto; }
.mud-paper.kt-widget, .kt-widget {
    display: flex; flex-direction: column; gap: 12px; padding: 20px 24px 24px; min-width: 0; height: auto;
    border-radius: var(--kt-radius-lg);
}
.kt-widget-head { display: flex; align-items: center; gap: 10px; min-height: 32px; min-width: 0; }
.kt-widget-icon { color: var(--kt-action-text); font-size: 16px; flex: none; width: 20px; text-align: center; }
.kt-widget-title { margin: 0; flex: 1 1 auto; min-width: 0; font-size: 16px; line-height: 1.3; font-weight: 600; color: var(--kt-ink); overflow-wrap: anywhere; }
.kt-widget--kpi { gap: 8px; }
.kt-widget--kpi .kt-widget-title { font-size: 12px; font-weight: 400; color: var(--kt-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kt-widget--kpi .kt-widget-icon { display: none; }
.kt-widget--kpi .kt-widget-head { min-height: 24px; }
/* Actions live in a quiet ⋯ menu; no red tiles on the card itself. */
.kt-widget-menu { margin: -4px -8px -4px auto; flex: none; }
.kt-widget-menu .mud-button-root.mud-icon-button.mud-icon-button-size-small:not(.mud-button-filled) { background: transparent; color: var(--kt-muted); border-radius: 50%; }
.kt-widget-menu .mud-button-root.mud-icon-button.mud-icon-button-size-small:not(.mud-button-filled):hover { background: var(--kt-tonal); color: var(--kt-ink); }
.mud-popover .mud-list-item.kt-menu-danger, .mud-popover .mud-list-item.kt-menu-danger .mud-list-item-icon, .mud-popover .mud-list-item.kt-menu-danger .mud-typography { color: var(--kt-red-text) !important; }
.kt-widget-grip { color: var(--kt-icon-muted); font-size: 13px; cursor: grab; flex: none; }
/* Customize mode ("Dostosuj pulpit"): dashed outline around each tile, grip + ⋯ in the header. */
.kt-widget-grid.is-customizing .widget-tile { border: 2px dashed var(--kt-border-strong); border-radius: 18px; padding: 6px; }
.kt-widget-grid.is-customizing .widget-tile:hover { border-color: var(--kt-yellow-dark); }
.kt-widget-grid.is-customizing .widget-tile.widget-dragover { outline: 0; border-color: var(--kt-focus); background: var(--kt-blue-bg); }
.kt-customize-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 16px; margin-bottom: 20px; border-radius: var(--kt-radius-md); background: var(--kt-yellow-bg); color: var(--kt-yellow-ink); font-size: 13px; font-weight: 500; }
.kt-customize-bar .grow { flex: 1 1 200px; }

/* Widget empty / error state: an icon in a tonal circle and one secondary line — never a white hole. */
.kt-widget-empty { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 12px 8px 4px; text-align: center; font-size: 13px; color: var(--kt-muted); }
.kt-widget-empty > i { width: 44px; height: 44px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--kt-tonal); color: var(--kt-ink); font-size: 16px; }
.kt-widget-empty.error > i { background: var(--kt-red-bg); color: var(--kt-red-text); }
.kt-widget-skel { display: flex; flex-direction: column; gap: 10px; padding: 4px 0; }
.kt-widget-skel .kt-skel { height: 14px; }

/* Three-up counts (Issues by status): number + label columns, a stacked bar and its legend. */
.kt-counts { display: grid; grid-template-columns: repeat(auto-fit, minmax(84px, 1fr)); gap: 12px; }
.kt-count b { display: block; font-size: 1.75rem; line-height: 1.2; font-weight: 600; color: var(--kt-ink); font-variant-numeric: tabular-nums; }
.kt-count span { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--kt-muted); }
.kt-count span i { width: 9px; height: 9px; border-radius: 50%; }

/* Inline stat strip at the top of a panel (Network): value over label. */
.kt-statline { display: flex; flex-wrap: wrap; gap: 12px 28px; }
.kt-statline > div { min-width: 0; }
.kt-statline b { display: block; font-size: 1.25rem; line-height: 1.25; font-weight: 600; color: var(--kt-ink); font-variant-numeric: tabular-nums; }
.kt-statline b.bad { color: var(--kt-red-text); }
.kt-statline span { font-size: 12px; color: var(--kt-muted); }
.kt-subhead { margin: 4px 0 0; font-size: 14px; font-weight: 600; color: var(--kt-ink); }

/* Generic tables of the other panels inside a widget pick up the same header type. */
.kt-widget .mud-simple-table table thead th { background: color-mix(in srgb, var(--kt-grey-bg) 60%, transparent); padding-top: 8px; padding-bottom: 8px; }
.kt-widget .mud-simple-table table thead th:first-child { border-radius: 8px 0 0 0; }
.kt-widget .mud-simple-table table thead th:last-child { border-radius: 0 8px 0 0; }

/* ── row list inside a panel (apps, dashboards): avatar tile · title + meta · values · Open › ─────── */
.kt-rowlist { display: flex; flex-direction: column; }
.kt-rowlist-item {
    display: flex; align-items: center; gap: 14px; padding: 12px 8px; margin: 0 -8px; border-radius: var(--kt-radius-md); border: 0; background: transparent;
    text-align: left; text-decoration: none; color: var(--kt-ink); cursor: pointer; font: inherit; min-width: 0; width: calc(100% + 16px);
}
.kt-rowlist-item + .kt-rowlist-item { box-shadow: 0 -1px 0 var(--kt-border); }
.kt-rowlist-item:hover { background: var(--kt-surface-hover); color: var(--kt-ink); }
.kt-rowlist-icon { width: 40px; height: 40px; border-radius: 12px; flex: none; display: inline-flex; align-items: center; justify-content: center; background: var(--kt-blue-bg); color: var(--kt-blue-ink); font-size: 16px; }
.kt-rowlist-main { flex: 1 1 auto; min-width: 0; }
.kt-rowlist-title { font-size: 15px; font-weight: 600; overflow-wrap: anywhere; }
.kt-rowlist-meta { font-size: 12px; color: var(--kt-muted); }
.kt-rowlist-chev { color: var(--kt-action-text); font-size: 12px; font-weight: 600; white-space: nowrap; }

/* Two-column dashboard layout (main 8 / side 4), one column below 1100px. */
.kt-cols { display: flex; flex-direction: column; gap: 0; }
@media (min-width: 1100px) {
    .kt-cols { flex-direction: row; align-items: flex-start; gap: 20px; }
    .kt-cols > .main { flex: 1 1 0; min-width: 0; }
    .kt-cols > .side { flex: 0 0 clamp(320px, 30%, 400px); min-width: 0; }
}

/* Confirm dialog (ConfirmDialog.razor): centred title, text, Cancel + one filled action. */
.kt-confirm .mud-dialog-title { padding: 24px 24px 0; text-align: center; }
.kt-confirm .mud-dialog-content { text-align: center; color: var(--kt-muted); font-size: 14px; }
.kt-confirm .mud-dialog-actions { justify-content: center; padding-bottom: 24px; }
.kt-confirm .mud-dialog-actions .mud-button-root { min-width: 120px; }

@media (max-width: 767.98px) {
    .kt-panel { padding: 16px; margin-bottom: 16px; }
    .kt-panel-title { font-size: 18px; }
    .kt-kpis { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
    .kt-kpi { padding: 16px; gap: 8px; }
    .kt-kpi-value { font-size: 1.6rem; }
    .mud-paper.kt-widget, .kt-widget { padding: 16px; }
    .kt-attn-row { grid-template-columns: minmax(0, 1fr) auto; }
    .kt-attn-tag { grid-column: 1 / -1; }
    .kt-data th, .kt-data td { padding: 8px 10px; }
    .kt-rowlist-chev span { display: none; }
}

/* Filter bar toggle at the end of the context chips. */
.kt-ctx-edit { display: inline-flex; align-items: center; gap: 6px; min-height: 28px; padding: 4px 12px; border: 0; border-radius: 999px; background: var(--kt-tonal); color: var(--kt-ink); font: 600 12px "Poppins", sans-serif; cursor: pointer; margin-left: 4px; }
.kt-ctx-edit:hover { background: var(--kt-tonal-pressed); }
