/* ==========================================================================
   AI Update (views/ai-update.js, docs/design-v2/AiUpdate.dc.html) — prefix .au-
   Colours only through tokens (Nova 2 from v2.css, classic + dark from app.css): the area of a proposal on its left edge
   and badge – Dotácie green, Dane a odvody and Ceny brown, Legislatíva grey; amber (--warning-*) = a proposal that cannot
   be accepted; the accept button is --primary (white text ≥ 4.5 : 1 in dark mode too).
   Phone first: one column, nothing wider than the phone, ≥ 44 px targets on touch, long values wrap.
   ========================================================================== */

.au { gap: 12px; }
.au-head .v2-head-actions { align-self: center; }
.au-last { color: var(--text-2); font-size: 12.5px; line-height: 1.3; white-space: nowrap; }
.au-last[data-stale="true"] { color: var(--warning-text); font-weight: 600; }
.au-last[hidden] { display: none; }

.au-status[hidden], .au-messages[hidden], .au-avail[hidden], .au-controls[hidden] { display: none; }
.au-messages { display: flex; flex-direction: column; gap: 10px; }
.au-loading { display: flex; align-items: center; gap: 10px; padding: 12px 4px; color: var(--text-2); font-size: 14px; }
.au-state { margin: 0; }
.au-cause { margin-top: 6px; font-size: 12.5px; }
.au-cause summary { cursor: pointer; color: var(--text-2); }
.au-cause code { display: block; margin-top: 4px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 12px; }

/* ---- cards ---- */
.au-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg, 14px);
  background: var(--surface);
}
.au-card[hidden], .au-result[hidden] { display: none; }
.au-card-title { margin: 0; font-size: 16px; font-weight: 700; line-height: 1.3; }
.au-hint { margin: 0; color: var(--text-2); font-size: 12.5px; line-height: 1.45; overflow-wrap: anywhere; }
.au-hint[hidden] { display: none; }
.au-hint.is-warn { color: var(--warning-text); font-weight: 600; }
.au-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---- „Čo sa aktualizuje“ ---- */
.au-controls { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.au-scopes { display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.au-scope {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  min-height: 36px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.au-scope[hidden] { display: none; }
.au-check {
  flex: none;
  width: 22px;
  height: 22px;
  margin: 0;
  accent-color: var(--primary, var(--green));
  cursor: pointer;
}
.au-check:disabled { cursor: default; }
.au-check:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.au-scope-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; line-height: 1.35; }
.au-scope-label { overflow-wrap: anywhere; }
.au-scope-hint { color: var(--text-2); font-size: 12px; overflow-wrap: anywhere; }
.au-scope-hint[hidden] { display: none; }
.au-profile { padding-top: 8px; border-top: 1px solid var(--border); }
.au-profile .au-scope-label { font-weight: 600; }

.au-go {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 50px;
  border: 0;
  border-radius: 13px;
  background: var(--primary);
  color: var(--accent-contrast, #fff);
  font: inherit;
  font-size: 16px;
  font-weight: 700;
}
.au-go:hover:not(:disabled) { background: var(--primary-hover, var(--primary)); }
.au-go:disabled { opacity: 0.55; cursor: not-allowed; }
.au-go svg { flex: none; }

/* ---- running job ---- */
.au-progress { border-left: 4px solid var(--green); }
.au-prog-row { display: flex; align-items: flex-start; gap: 12px; }
.au-prog-spin { flex: none; margin-top: 2px; }
.au-prog-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.au-prog-title { font-weight: 600; line-height: 1.35; }
.au-prog-time { color: var(--text-2); font-size: 13px; font-variant-numeric: tabular-nums; }

/* ---- „Navrhované zmeny“ ---- */
.au-result { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.au-res-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 0 4px; }
.au-res-head .v2-group-head { margin: 0; }
.au-all {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--green);
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green-text);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.au-all[hidden] { display: none; }
.au-all:disabled { opacity: 0.55; cursor: progress; }
.au-all:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.au-res-meta { padding: 0 4px; }
.au-summary { display: flex; flex-direction: column; gap: 6px; padding: 0 4px; color: var(--text); font-size: 14px; line-height: 1.45; }
.au-summary p { margin: 0; overflow-wrap: anywhere; }
.au-summary[hidden] { display: none; }
.au-ro-note { padding: 0 4px; }
.au-list { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.au-empty { margin: 0; padding: 12px 14px; border: 1px dashed var(--border-strong); border-radius: 12px; color: var(--text-2); font-size: 14px; }
.au-empty[hidden], .au-dropped[hidden] { display: none; }
.au-dropped { padding: 0 4px; }

.au-prop {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--border-strong);
  border-radius: 12px;
  background: var(--surface);
}
.au-prop[data-tone="green"] { border-left-color: var(--green); }
.au-prop[data-tone="brown"] { border-left-color: var(--brown); }
.au-prop.is-decided { background: var(--surface-2); }
.au-prop.is-decided .au-change, .au-prop.is-decided .au-prop-reason, .au-prop.is-decided .au-prop-notes { opacity: 0.85; }
.au-prop-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.au-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--grey-soft);
  color: var(--grey-text);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
}
.au-prop[data-tone="green"] .au-badge { background: var(--green-soft); color: var(--green-text); }
.au-prop[data-tone="brown"] .au-badge { background: var(--brown-soft); color: var(--brown-text); }
.au-verified { flex: none; color: var(--text-2); font-size: 12px; white-space: nowrap; }
.au-prop-title { margin: 0; font-size: 15px; font-weight: 600; line-height: 1.35; overflow-wrap: anywhere; }
.au-prop-item { margin: -4px 0 0; color: var(--text-2); font-size: 12.5px; line-height: 1.35; overflow-wrap: anywhere; }

.au-change { font-size: 13.5px; line-height: 1.45; overflow-wrap: anywhere; }
.au-before { color: var(--text-2); text-decoration: line-through; }
.au-before.is-plain { text-decoration: none; }
.au-after { color: var(--text); font-weight: 700; text-decoration: none; }
/* short values (one line „121,92 €/mes. → 129,60 €/mes.“): the number never parts from its unit – review UXR6-07 */
.au-change:not(.au-change--text):not(.au-change--new) > .au-before:not(.is-plain),
.au-change:not(.au-change--text):not(.au-change--new) > .au-after { white-space: nowrap; }
.au-arrow { color: var(--text-2); }
.au-change--text { display: flex; flex-direction: column; gap: 6px; }
.au-was, .au-will { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.au-k { color: var(--text-2); font-size: 11.5px; font-weight: 600; letter-spacing: 0.03em; text-transform: uppercase; }
.au-change--text .au-after { font-weight: 600; }
.au-change--new { display: flex; flex-direction: column; gap: 4px; }
.au-new-kind, .au-new-text, .au-new-meta { margin: 0; }
.au-new-meta { color: var(--text-2); font-size: 12.5px; }
.au-new-applies { margin: 0; color: var(--text); font-size: 13px; font-weight: 600; overflow-wrap: anywhere; }
/* a proposed text that adds a link / e-mail / phone (review SEC-5) */
.au-prop-warn {
  margin: 0;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--warning-soft);
  color: var(--warning-text);
  font-size: 13px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.au-prop-reason { margin: 0; color: var(--text); font-size: 13.5px; line-height: 1.45; overflow-wrap: anywhere; }
.au-prop-notes { margin: 0; color: var(--text-2); font-size: 12.5px; line-height: 1.45; overflow-wrap: anywhere; }
.au-prop-source { margin: 0; color: var(--text-2); font-size: 12.5px; line-height: 1.45; overflow-wrap: anywhere; }
.au-src { color: var(--link, var(--accent)); font-weight: 600; text-decoration: none; overflow-wrap: anywhere; }
.au-src:hover { text-decoration: underline; }
.au-prop-block {
  margin: 0;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--warning-soft);
  color: var(--warning-text);
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.4;
}
.au-prop-block[hidden], .au-prop-state[hidden], .au-prop-actions[hidden] { display: none; }
.au-prop-state { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-size: 12.5px; color: var(--text-2); }
.au-state-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--grey-soft);
  color: var(--grey-text);
  font-size: 12px;
  font-weight: 600;
}
.au-state-badge.is-good { background: var(--green-soft); color: var(--green-text); }
.au-state-badge.is-warn { background: var(--warning-soft); color: var(--warning-text); }
.au-prop-actions { display: flex; gap: 8px; }
.au-prop-actions .btn { flex: 1 1 0; min-width: 0; min-height: 40px; border-radius: 10px; font-size: 13.5px; font-weight: 600; }
.au-prop-actions .au-undo { flex: 0 0 auto; }

.au-fold { min-width: 0; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.au-fold[hidden] { display: none; }
.au-fold > summary {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 0 14px;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}
/* a disclosure chevron (display: flex drops the marker in WebKit – review UXR6-09; as analysis.css .an-glossary) */
.au-fold > summary::-webkit-details-marker { display: none; }
.au-fold > summary::after {
  content: "";
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  margin-left: auto;
  border-right: 2px solid var(--text-2);
  border-bottom: 2px solid var(--text-2);
  transform: rotate(45deg) translateY(-2px);
  transition: transform 0.15s;
}
.au-fold[open] > summary::after { transform: rotate(-135deg) translateX(-2px); }
.au-fold > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 12px; }
.au-fold > .au-list, .au-fold > .au-sets, .au-fold > .au-jobs-list, .au-fold > .au-conf-list { padding: 0 10px 10px; }
.au-conf-list { display: flex; flex-direction: column; gap: 6px; margin: 0; list-style: none; }
.au-conf { display: flex; flex-direction: column; gap: 1px; padding: 6px 4px; border-top: 1px solid var(--border); font-size: 13px; }
.au-conf:first-child { border-top: 0; }
.au-conf-label { overflow-wrap: anywhere; }
.au-conf-meta { color: var(--text-2); font-size: 12px; }

/* ---- history ---- */
.au-history .au-fold { border-radius: 10px; }
.au-sets { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.au-set {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
}
.au-set[data-state="rolledback"] { background: var(--surface-2); }
.au-set-body { display: flex; flex: 1 1 auto; flex-direction: column; gap: 2px; min-width: 0; }
.au-set-title { font-size: 14px; font-weight: 600; line-height: 1.35; overflow-wrap: anywhere; }
.au-set-detail { color: var(--text-2); font-size: 12.5px; line-height: 1.4; overflow-wrap: anywhere; }
.au-set-state { color: var(--text-2); font-size: 12.5px; }
.au-set[data-state="partial"] .au-set-state { color: var(--warning-text); }
.au-set[data-state="superseded"] .au-set-state { color: var(--warning-text); font-weight: 600; }
.au-set-value { white-space: nowrap; font-weight: 600; }
.au-rollback { flex: none; min-height: 40px; }
.au-jobs-list { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.au-job {
  display: flex;
  flex-direction: column;
  gap: 1px;
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  text-align: left;
}
button.au-job { cursor: pointer; }
button.au-job:hover { border-color: var(--border-strong); }
button.au-job:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.au-job[aria-current="true"] { border-color: var(--green); background: var(--green-tint, var(--surface)); }
.au-job-title { font-size: 13.5px; font-weight: 600; overflow-wrap: anywhere; }
.au-job-status { color: var(--text-2); font-size: 12.5px; }
.au-job[data-status="error"] .au-job-status { color: var(--critical-text); }

.au-disclaimer { margin: 0; padding: 0 4px; color: var(--text-2); font-size: 12px; line-height: 1.45; }

/* ---- Domov: „Údaje overené pred N dňami“ / „N zmien čaká na schválenie“ (views/domov.js .dm-aiu; the inside is
   domov.css .dm-alert-*; this file is loaded by views/ai-update.js ensureStyles() before the card shows) ---- */
.dm-aiu {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-width: 0;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg, 14px);
  background: var(--surface);
}
.dm-aiu[hidden] { display: none; }
.dm-aiu .dm-alert-icon, .dm-aiu .dm-alert-title { color: var(--text); }
.dm-aiu[data-tone="warning"] { background: var(--warning-soft); }
.dm-aiu[data-tone="warning"] .dm-alert-icon, .dm-aiu[data-tone="warning"] .dm-alert-title { color: var(--warning-text); }
@supports (color: color-mix(in srgb, red 50%, blue)) {
  .dm-aiu[data-tone="warning"] { border-color: color-mix(in srgb, var(--warning) 38%, var(--warning-soft)); }
}

/* ---- touch: ≥ 44 px targets ---- */
@media (pointer: coarse) {
  .au-scope { min-height: 44px; }
  .au-all, .au-prop-actions .btn, .au-rollback, .au-stop, .au-state .btn, .au-resume { min-height: 44px; }
  /* the source link stays inline in its sentence; padding widens the tap area without moving the lines */
  .au-src { padding: 12px 0; margin: -12px 0; }
}

/* ---- narrow phones: the set's button under its text ---- */
@media (max-width: 380px) {
  .au-set { flex-wrap: wrap; }
  .au-rollback { width: 100%; }
}

@media print {
  .au-start, .au-progress, .au-prop-actions, .au-all, .au-rollback { display: none !important; }
  .au-fold { border: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .au-fold > summary::after { transition: none; }
}
