/* MovieClipper UI kit · components/data.css
   ----------------------------------------------------------------------------
   Данные: контейнеры, KPI, метрики, стат-бар, score-ring, график, тренды,
   кампании, список задач. Значения из components.css (97–110, 381–430, 702–767,
   865–968) и controlroom.css (.kpi 262–314, .cr-top 378–422, .cr-trends
   425–470, .cr-camps 472–512).
*/

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--sp-4);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.card-title {
  font-family: var(--font-display);
  font-size: var(--type-md);
  font-weight: 700;
  margin: 0 0 var(--sp-3);
}

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-2);
  flex-wrap: wrap;
}

.card-actions {
  display: flex;
  gap: var(--sp-2);
  flex-wrap: wrap;
  margin-top: var(--sp-3);
}

.overline {
  display: block;
  font-size: var(--type-xs);
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}

.tag {
  display: inline-flex;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--accent);
  font-size: var(--type-xs);
  font-weight: 700;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.tag-quiet {
  background: var(--surface-2);
  color: var(--muted);
}

/* ---- Сетки ---------------------------------------------------------------- */

.kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--sp-3);
  margin: var(--sp-5) 0;
}

.split-2-1 {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: var(--sp-4);
}

.split-1-1 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-4);
  margin-top: var(--sp-4);
}

@media (max-width: 860px) {
  .split-2-1,
  .split-1-1 { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
}

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

.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: var(--sp-3);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.kpi:hover {
  border-color: color-mix(in srgb, var(--accent) 40%, var(--line));
}

.kpi .label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.kpi .kval {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
  margin-top: var(--sp-1);
}

.kpi .kdelta {
  margin-top: var(--sp-1);
  color: var(--muted);
  font-size: var(--type-xs);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.kpi .up { color: var(--ok); }
.kpi .down { color: var(--err); }

@media (max-width: 420px) {
  .kpi .kval { font-size: var(--type-md); }
}

/* ---- Метрика и полоса статусов ------------------------------------------- */

.metric { display: flex; flex-direction: column; gap: 2px; }

.metric-value {
  font-family: var(--font-display);
  font-size: var(--type-xl);
  font-weight: 800;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}

.metric-label { color: var(--muted); font-size: var(--type-sm); }

.statbar {
  display: flex;
  height: 10px;
  border-radius: var(--radius-pill);
  overflow: hidden;
  background: color-mix(in srgb, var(--line) 70%, transparent);
}

.statbar .bar { display: block; height: 100%; }

.bar-queued    { background: var(--status-queued); }
.bar-running   { background: var(--status-running); }
.bar-done      { background: var(--status-done); }
.bar-failed    { background: var(--status-failed); }
.bar-cancelled { background: var(--status-cancelled); opacity: 0.55; }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
  margin-top: var(--sp-2);
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  color: var(--muted);
  font-size: var(--type-xs);
  font-variant-numeric: tabular-nums;
}

.legend i {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  display: block;
}

/* ---- Скор ------------------------------------------------------------------ */

.score-ring {
  --ring: 52px;
  position: relative;
  width: var(--ring);
  height: var(--ring);
  flex: none;
}

.score-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }

.score-ring .ring-track {
  fill: none;
  stroke: color-mix(in srgb, var(--line) 70%, transparent);
  stroke-width: 5;
}

.score-ring .ring-fill {
  fill: none;
  stroke: var(--accent);
  stroke-width: 6;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.6s ease;
}

.score-ring .ring-num {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: var(--type-sm);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.score-bar {
  --w: 0%;
  flex: 1 1 auto;
  min-width: 90px;
  height: 6px;
  border-radius: var(--radius-pill);
  background: color-mix(in srgb, var(--line) 70%, transparent);
  overflow: hidden;
}

.score-bar .fill {
  display: block;
  height: 100%;
  width: var(--w);
  border-radius: inherit;
  background: var(--accent);
  transition: width 0.6s ease;
}

/* ---- График ---------------------------------------------------------------- */

.chart {
  min-height: 220px;
  margin-top: var(--sp-1);
}

.chart svg { width: 100%; height: auto; display: block; }

.chart-foot {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
  margin-top: var(--sp-3);
  color: var(--muted);
  font-size: var(--type-xs);
  font-variant-numeric: tabular-nums;
}

/* ---- Лучший клип ----------------------------------------------------------- */

.best {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
}

.best-body { display: flex; flex-direction: column; gap: var(--sp-1); min-width: 0; }

.best-source {
  color: var(--muted);
  font-size: var(--type-xs);
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.best-hook {
  font-size: var(--type-sm);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.best-meta {
  color: var(--muted);
  font-size: var(--type-xs);
  font-variant-numeric: tabular-nums;
}

/* ---- Тренды ---------------------------------------------------------------- */

.trends {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

.trend {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  min-width: 0;
  max-width: 100%;
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--surface);
  transition: border-color var(--transition), background var(--transition);
}

.trend:hover {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  background: var(--surface-2);
}

.trend-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--type-sm);
  font-weight: 700;
}

.trend-n {
  flex: none;
  color: var(--muted);
  font-size: var(--type-xs);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ---- Кампании -------------------------------------------------------------- */

.camps { display: flex; flex-direction: column; gap: var(--sp-3); }

.camp {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding: var(--sp-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.camp-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
}

.camp-name {
  min-width: 0;
  font-size: var(--type-sm);
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.camp-meta {
  color: var(--muted);
  font-size: var(--type-xs);
  font-variant-numeric: tabular-nums;
}

.camp-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  flex-wrap: wrap;
}

/* ---- Список задач ----------------------------------------------------------- */

.jobs { display: flex; flex-direction: column; }

.job {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding: var(--sp-3) 0;
  border-bottom: 1px solid var(--line);
}

.job:last-child { border-bottom: 0; padding-bottom: 0; }

.job-head {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
}

.job-title {
  font-size: var(--type-sm);
  font-weight: 700;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.job-meta {
  font-family: var(--font-mono);
  font-size: var(--type-xs);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.job-stage {
  color: var(--muted);
  font-size: var(--type-xs);
}

.job-foot {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-wrap: wrap;
}

.job-foot .progress { flex: 1 1 160px; min-width: 120px; }

.job-err {
  color: color-mix(in srgb, var(--status-failed) 70%, var(--text));
  font-size: var(--type-xs);
}

.filter-bar {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-wrap: wrap;
  margin-bottom: var(--sp-3);
}

.note {
  color: var(--muted);
  font-size: var(--type-sm);
  padding: var(--sp-2) 0;
}

/* ---- Появление ------------------------------------------------------------- */

.rise > * { animation: kit-rise 300ms cubic-bezier(0.2, 0.7, 0.3, 1) both; }
.rise > :nth-child(2)  { animation-delay: 30ms; }
.rise > :nth-child(3)  { animation-delay: 60ms; }
.rise > :nth-child(4)  { animation-delay: 90ms; }
.rise > :nth-child(5)  { animation-delay: 120ms; }
.rise > :nth-child(6)  { animation-delay: 150ms; }
.rise > :nth-child(n+7) { animation-delay: 180ms; }

.tabpanel.active { animation: kit-panel-in 240ms ease both; }

@keyframes kit-panel-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}
