/* ==========================================================================
   Porovnanie scenárov (views/compare.js) — every class is prefixed .cmp-
   Scenario identity colours arrive as the custom property --cmp-color, set from
   charts.js seriesColor(slot) on elements carrying data-cmp-slot (re-painted on themechange).
   ========================================================================== */

.cmp-view {
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
}
.cmp-view > .page-header { margin-bottom: 0; }

.cmp-notices { display: flex; flex-direction: column; gap: 8px; min-width: 0; }

/* Colour marks (identity only — text never uses the series colour) */
.cmp-swatch {
  display: inline-block;
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--cmp-color, transparent);
  box-shadow: inset 0 0 0 1.5px var(--cmp-color, var(--border-strong));
}
.cmp-swatch--lg { width: 14px; height: 14px; border-radius: 4px; }

/* ---------------------------------------------------------------- picker */

.cmp-picker {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 20px;
}
.cmp-picker.is-prominent {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow-sm);
}
.cmp-picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 12px;
  min-width: 0;
}
.cmp-picker-heading {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 10px;
  min-width: 0;
}
.cmp-picker-title { margin: 0; font-size: 16px; font-weight: 650; }
.cmp-picker-count { font-size: 13px; color: var(--text-2); }

.cmp-selected { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }
.cmp-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 100%;
  min-height: 32px;
  padding: 0 4px 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 550;
}
.cmp-chip-name { min-width: 0; max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmp-chip-base {
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--link);
  font-size: 11.5px;
  font-weight: 600;
}
.cmp-chip-remove {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
}
.cmp-chip-remove:hover { background: var(--surface-3); color: var(--text); }
.cmp-chip-remove:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.cmp-chips-empty { margin: 0; font-size: 13px; color: var(--text-2); }

.cmp-picker-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  min-width: 0;
}
.cmp-intro {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--accent-soft);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}
.cmp-intro > .icon { flex: none; margin-top: 1px; color: var(--accent); }
.cmp-intro-text { min-width: 0; }
.cmp-intro p { margin: 0; max-width: 820px; }
.cmp-intro .cmp-intro-title { margin-bottom: 2px; font-weight: 650; }

.cmp-picker-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; min-width: 0; }
.cmp-search { position: relative; flex: 1 1 260px; max-width: 420px; min-width: 0; }
.cmp-search > .icon {
  position: absolute;
  top: 50%;
  left: 10px;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}
.cmp-search > .input { width: 100%; padding-left: 32px; }
.cmp-limit-hint { margin: 0; font-size: 13px; color: var(--text-2); }
.cmp-limit-hint.is-warning { color: var(--warning-text); font-weight: 550; }

.cmp-list { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.cmp-group { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.cmp-group-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 8px;
  margin: 0;
  font-size: 13.5px;
  font-weight: 650;
  color: var(--text);
}
.cmp-group-icon {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--link);
}
.cmp-group-title { min-width: 0; overflow-wrap: anywhere; }
.cmp-group-meta { font-size: 12.5px; font-weight: 500; color: var(--text-2); }
.cmp-group-empty,
.cmp-no-results {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 13px;
  color: var(--text-2);
}

.cmp-options {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
  gap: 8px;
  min-width: 0;
}
.cmp-option {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  min-height: 52px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  transition: background-color 0.12s, border-color 0.12s;
}
.cmp-option:hover { background: var(--surface-2); border-color: var(--border-strong); }
.cmp-option:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus-ring); }
.cmp-option.is-checked { border-color: var(--accent); background: var(--accent-soft); }
.cmp-option.is-disabled { cursor: not-allowed; opacity: 0.55; }
.cmp-option.is-disabled:hover { background: var(--surface); border-color: var(--border); }
.cmp-option-input {
  flex: none;
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--primary);
  cursor: inherit;
}
.cmp-option-input:focus-visible { outline: none; }
.cmp-option-text { display: flex; flex: 1 1 auto; flex-direction: column; gap: 1px; min-width: 0; }
.cmp-option-name {
  overflow: hidden;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cmp-option-meta {
  overflow: hidden;
  font-size: 12.5px;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cmp-option-lock { display: inline-flex; flex: none; color: var(--muted); }

/* ---------------------------------------------------------------- comparison area */

.cmp-main { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.cmp-stage:empty { display: none; }
.cmp-analysis {
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
  transition: opacity 0.2s ease;
}
.cmp-analysis.is-updating { opacity: 0.6; }

/* Scenario header cards */
.cmp-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr));
  gap: 12px;
  min-width: 0;
}
.cmp-scard {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  padding: 18px 16px 14px;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.cmp-scard::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 4px;
  background: var(--cmp-color, var(--border-strong));
}
.cmp-scard.is-base { border-color: var(--border-strong); }
.cmp-scard-head { display: flex; align-items: flex-start; gap: 10px; min-width: 0; }
.cmp-scard-head > .cmp-swatch { margin-top: 3px; }
.cmp-scard-titles { flex: 1 1 auto; min-width: 0; }
.cmp-scard-title { margin: 0; font-size: 15px; font-weight: 650; line-height: 1.35; overflow-wrap: anywhere; }
.cmp-scard-title a { color: var(--text); text-decoration: none; }
.cmp-scard-title a:hover { color: var(--link); text-decoration: underline; }
.cmp-scard-owner {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin: 4px 0 0;
  font-size: 12.5px;
  color: var(--text-2);
}
.cmp-scard-owner > .icon { color: var(--muted); }
.cmp-scard-private { color: var(--text-2); }
.cmp-scard-menu { flex: none; margin: -4px -6px 0 0; }
.cmp-scard-badges { display: flex; flex-wrap: wrap; gap: 6px; }
.cmp-scard-facts {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 4px 12px;
  margin: 0;
  font-size: 13px;
}
.cmp-scard-facts dt { color: var(--text-2); }
.cmp-scard-facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.cmp-scard-alias { margin: 0; font-size: 12px; color: var(--text-2); }
.cmp-scard-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; padding-top: 2px; }
.cmp-scard.is-loading { min-height: 170px; }
.cmp-scard.is-loading .skeleton-line:nth-of-type(2) { width: 70%; }
.cmp-scard.is-loading .skeleton-line:nth-of-type(3) { width: 55%; }
.cmp-scard .error-state { margin: 0; }

.cmp-align-list { display: flex; flex-direction: column; gap: 4px; margin: 4px 0 0; padding-left: 18px; }

/* Quick summary ("kto vychádza najlepšie") */
.cmp-highlights {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr));
  gap: 12px;
}
.cmp-hl {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.cmp-hl-label { font-size: 12.5px; font-weight: 550; color: var(--text-2); }
.cmp-hl-hint { font-weight: 450; }
.cmp-hl-winners { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cmp-hl-winner { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 14.5px; font-weight: 650; color: var(--text); }
.cmp-hl-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmp-hl-value { font-size: 13px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.cmp-hl-none { font-size: 14px; color: var(--text-2); }

/* ---------------------------------------------------------------- KPI table */

.cmp-table th.cmp-kpi-label,
.cmp-table th.cmp-th-label {
  min-width: 180px;
  max-width: 280px;
  white-space: normal;
}
.cmp-table th.cmp-kpi-label { font-weight: 550; color: var(--text); vertical-align: top; }
.cmp-kpi-name { overflow-wrap: anywhere; }
.cmp-kpi-sub { display: block; margin-top: 1px; font-size: 12px; font-weight: 450; color: var(--text-2); }
.cmp-table tr.is-sub .cmp-kpi-name { padding-left: 14px; color: var(--text-2); font-weight: 500; }
.cmp-table td { min-width: 132px; vertical-align: top; }
.cmp-table thead th.cmp-th-scn {
  min-width: 132px;
  max-width: 220px;
  vertical-align: bottom;
  white-space: normal;
}
.cmp-th-inner { display: flex; align-items: center; justify-content: flex-end; gap: 6px; min-width: 0; }
.cmp-th-name {
  display: -webkit-box;
  overflow: hidden;
  color: var(--text);
  font-size: 13px;
  font-weight: 650;
  text-align: right;
  overflow-wrap: anywhere;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.cmp-th-sub { display: block; margin-top: 2px; font-size: 11.5px; font-weight: 500; color: var(--text-2); }

.cmp-table tr.cmp-group-row > th,
.cmp-table tr.cmp-group-row > td {
  padding-top: 12px;
  padding-bottom: 6px;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.cmp-table tbody tr.cmp-group-row:hover > td,
.cmp-table tbody tr.cmp-group-row:hover > th { background: var(--surface-2); }

.cmp-val { font-weight: 600; color: var(--text); }
.cmp-val.is-empty { font-weight: 500; color: var(--text-2); }
.cmp-note { margin-top: 1px; font-size: 12px; color: var(--text-2); }
.cmp-best {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 3px;
  color: var(--good-text);
  font-size: 12px;
  font-weight: 650;
}
.cmp-best > .icon { color: var(--good); }
.cmp-diff { margin-top: 2px; font-size: 12px; color: var(--text-2); }
.cmp-table td.is-best { background: var(--good-soft); }

.cmp-hint {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  margin: -3px 0 -3px 2px;
  padding: 0;
  vertical-align: middle;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: help;
}
.cmp-hint:hover { background: var(--accent-soft); color: var(--link); }
.cmp-hint:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; color: var(--link); }

/* Glossary (card footer of the KPI table) */
.cmp-glossary > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}
.cmp-glossary > summary::-webkit-details-marker { display: none; }
.cmp-glossary > summary::after {
  content: "";
  width: 7px;
  height: 7px;
  margin-left: 2px;
  border-right: 1.8px solid var(--text-2);
  border-bottom: 1.8px solid var(--text-2);
  transform: rotate(45deg) translateY(-2px);
  transition: transform 0.15s ease;
}
.cmp-glossary[open] > summary::after { transform: rotate(-135deg) translateY(-1px); }
.cmp-glossary > summary > .icon { flex: none; color: var(--accent); }
.cmp-glossary > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
.cmp-glossary-list {
  display: grid;
  grid-template-columns: minmax(170px, 250px) minmax(0, 1fr);
  gap: 10px 24px;
  margin: 14px 0 4px;
  font-size: 13.5px;
  line-height: 1.5;
}
.cmp-glossary-list dt { font-weight: 650; color: var(--text); outline: none; border-radius: 4px; }
.cmp-glossary-list dd { margin: 0; max-width: 78ch; color: var(--text-2); border-radius: 4px; }
.cmp-glossary-list .is-flash { background: var(--accent-soft); box-shadow: 0 0 0 4px var(--accent-soft); }

/* ---------------------------------------------------------------- chart sections */

.cmp-charts { display: flex; flex-direction: column; gap: 28px; min-width: 0; }
.cmp-section { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.cmp-section-title { margin: 0; font-size: 18px; font-weight: 650; }
.cmp-section-text { margin: 2px 0 0; color: var(--text-2); font-size: 13.5px; }
.cmp-chart-note { margin: 0; color: var(--text-2); font-size: 12.5px; line-height: 1.45; }

/* ---------------------------------------------------------------- responsive */

@media (max-width: 640px) {
  .cmp-view { gap: 16px; }
  .cmp-picker { padding: 14px 16px; }
  .cmp-chip-name { max-width: 170px; }
  .cmp-search { max-width: none; flex-basis: 100%; }
  .cmp-table th.cmp-kpi-label,
  .cmp-table th.cmp-th-label { min-width: 140px; max-width: 170px; }
  .cmp-table td,
  .cmp-table thead th.cmp-th-scn { min-width: 116px; }
  .cmp-glossary-list { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .cmp-glossary-list dd { margin-bottom: 10px; }
  .cmp-charts { gap: 22px; }
  .cmp-section-title { font-size: 16.5px; }
}

@media (prefers-reduced-motion: reduce) {
  .cmp-analysis,
  .cmp-option,
  .cmp-glossary > summary::after { transition: none; }
}

@media print {
  .cmp-picker,
  .cmp-notices,
  .cmp-scard-actions,
  .cmp-scard-menu,
  .cmp-hint { display: none !important; }
  .cmp-analysis.is-updating { opacity: 1; }
  .cmp-glossary-list { display: grid; }
  .cmp-scard,
  .cmp-hl { break-inside: avoid; page-break-inside: avoid; }
}
