/*
 * Feedback Dashboard — dashboard-specific components.
 *
 * The base look-and-feel (WEG brand tokens, Roboto, buttons, cards, table,
 * tags, tabs, topbar, modal, light/dark themes) comes from weg-theme.css — a
 * faithful port of the @weg-react-ui design system. This file only adds the
 * pieces the design system does not ship as ready-made classes: KPI tiles,
 * horizontal bar charts, the sentiment split bar and the connection status
 * dot. Everything is built strictly on the semantic tokens (var(--color-*),
 * var(--spacing-*), var(--radius-*)) so both themes work automatically.
 */

/* ---------- Page scaffolding ---------- */
/* weg-theme.css paints the body with --color-background (near-white), the same
 * token .weg-card uses — so on a full-width layout (no dark sidebar) the cards
 * blend into the page. Put the page on the gray --color-surface instead so the
 * white cards read as elevated, matching the WEG dashboard intent. */
body {
  background: var(--color-surface);
}

.layout {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: var(--spacing-8) var(--spacing-6);
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--spacing-4);
  margin-bottom: var(--spacing-6);
  flex-wrap: wrap;
}

.page-head h1 {
  margin: 0;
  font-size: var(--text-2xl);
  font-weight: var(--font-bold);
  letter-spacing: -0.01em;
}

.page-head p {
  margin: var(--spacing-1) 0 0;
  color: var(--color-neutral-muted);
  font-size: var(--text-sm);
}

.filters {
  display: flex;
  align-items: flex-end;
  gap: var(--spacing-3);
}

.filters .weg-select {
  min-width: 180px;
}

.view[hidden] {
  display: none;
}

/* ---------- Topbar brand + status ---------- */
.brand {
  display: flex;
  align-items: center;
  gap: var(--spacing-3);
}

.brand__title {
  font-size: var(--text-md);
  font-weight: var(--font-semibold);
  line-height: 1.2;
}

.brand__subtitle {
  font-size: var(--text-xs);
  opacity: 0.85;
  font-weight: var(--font-normal);
}

.topbar__status {
  display: flex;
  align-items: center;
  gap: var(--spacing-2);
  font-size: var(--text-xs);
  opacity: 0.95;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--color-warning-solid);
}

.dot--ok {
  background: var(--color-positive-solid);
}

.dot--off {
  background: var(--color-negative-solid);
}

/* ---------- KPI tiles ---------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--spacing-4);
  margin-bottom: var(--spacing-6);
}

.kpi {
  padding: var(--spacing-5);
}

.kpi__label {
  font-size: var(--text-xs);
  color: var(--color-neutral-muted);
  font-weight: var(--font-semibold);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.kpi__value {
  font-size: var(--text-3xl);
  font-weight: var(--font-bold);
  margin-top: var(--spacing-2);
  line-height: 1.1;
}

.kpi__hint {
  font-size: var(--text-xs);
  color: var(--color-neutral-muted);
  margin-top: var(--spacing-1);
}

.kpi__accent {
  height: 4px;
  border-radius: var(--radius-full);
  margin-top: var(--spacing-4);
  background: var(--color-primary-solid);
}

.kpi--success .kpi__accent {
  background: var(--color-positive-solid);
}
.kpi--success .kpi__value {
  color: var(--color-positive);
}
.kpi--danger .kpi__accent {
  background: var(--color-negative-solid);
}
.kpi--danger .kpi__value {
  color: var(--color-negative);
}
.kpi--rating .kpi__accent {
  background: var(--color-warning-solid);
}

/* ---------- Two-column card grid ---------- */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--spacing-4);
  margin-bottom: var(--spacing-6);
}

.card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--spacing-4) var(--spacing-6);
  border-bottom: 1px solid var(--color-border);
}

.card__head h2 {
  margin: 0;
  font-size: var(--text-md);
  font-weight: var(--font-semibold);
}

.card__head span {
  font-size: var(--text-xs);
  color: var(--color-neutral-muted);
}

.card__body {
  padding: var(--spacing-6);
}

/* ---------- Horizontal bar charts ---------- */
.bars {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-4);
}

.bar-row {
  display: grid;
  grid-template-columns: 140px 1fr 48px;
  align-items: center;
  gap: var(--spacing-3);
}

.bar-row__label {
  font-size: var(--text-sm);
  color: var(--color-foreground);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bar-track {
  height: 22px;
  background: var(--color-surface-2);
  border-radius: var(--radius);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: var(--color-primary-solid);
  border-radius: var(--radius);
  width: 0;
  transition: width 0.5s var(--ease);
}

.bar-row__value {
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  text-align: right;
  color: var(--color-neutral-muted);
}

/* ---------- Sentiment split bar ---------- */
.split {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-5);
}

.split__bar {
  display: flex;
  height: 28px;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--color-surface-2);
}

.split__pos {
  background: var(--color-positive-solid);
  transition: width 0.5s var(--ease);
}
.split__neg {
  background: var(--color-negative-solid);
  transition: width 0.5s var(--ease);
}

.split__legend {
  display: flex;
  justify-content: space-between;
  gap: var(--spacing-4);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: var(--spacing-2);
  font-size: var(--text-sm);
}

.legend-item .swatch {
  width: 12px;
  height: 12px;
  border-radius: var(--radius-sm);
}
.swatch--pos {
  background: var(--color-positive-solid);
}
.swatch--neg {
  background: var(--color-negative-solid);
}
.swatch--neutral {
  background: var(--color-neutral-muted);
}

.legend-item strong {
  font-weight: var(--font-bold);
}

/* ---------- Data table cells ---------- */
.table-wrap {
  overflow-x: auto;
}

.card > .table-wrap .weg-table {
  border-left: none;
  border-right: none;
}

.cell-question {
  max-width: 320px;
}

.cell-text {
  max-width: 280px;
}

.cell-muted {
  color: var(--color-neutral-muted);
}

.rating-stars {
  color: var(--color-warning-strong);
  letter-spacing: 1px;
  white-space: nowrap;
}

.rating-empty {
  color: var(--color-border);
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-1);
}

/* ---------- Empty / loading states ---------- */
.muted-center {
  text-align: center;
  color: var(--color-neutral-muted);
  padding: var(--spacing-8);
  font-size: var(--text-sm);
}

/* ---------- Token gate (auth) ---------- */
.gate {
  position: fixed;
  inset: 0;
  background: var(--color-surface-overlay);
  backdrop-filter: blur(2px);
  display: grid;
  place-items: center;
  z-index: 100;
  padding: var(--spacing-4);
}

.gate[hidden] {
  display: none;
}

.gate__panel {
  width: 100%;
  max-width: 440px;
  padding: var(--spacing-8);
}

.gate__panel h2 {
  margin: 0 0 var(--spacing-2);
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
}

.gate__panel p {
  margin: 0 0 var(--spacing-5);
  color: var(--color-neutral-muted);
  font-size: var(--text-sm);
}

.gate__panel .weg-input {
  margin-bottom: var(--spacing-4);
}

.gate__error {
  color: var(--color-negative);
  font-size: var(--text-sm);
  margin-bottom: var(--spacing-3);
  min-height: 18px;
}

.gate__hint {
  margin-top: var(--spacing-4);
  font-size: var(--text-xs);
  color: var(--color-neutral-muted);
}

.gate__hint code {
  font-family: var(--font-mono);
  background: var(--color-surface-2);
  padding: 2px 6px;
  border-radius: var(--radius);
  font-size: var(--text-xs);
}

.full-btn {
  width: 100%;
}

/* ---------- Responsive ---------- */
@media (max-width: 980px) {
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .grid-2 {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .layout {
    padding: var(--spacing-4);
  }
  .kpi-grid {
    grid-template-columns: 1fr;
  }
  .bar-row {
    grid-template-columns: 100px 1fr 40px;
  }
}
