/* ── In-chat report visualisatie (wr-*) ───────────────────────
 * Gebruikt binnen chat bubble. MarketOS palette (synced with core.css :root).
 */

.wr-msg .bubble.wr-bubble {
  max-width: 100%;
  background: #fff;
  border: 1px solid #F3F4F6;
  padding: 20px 22px;
}

.wr-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 16px;
  margin-bottom: 18px;
  border-bottom: 2px solid #2563EB;
}

.wr-title {
  font-size: 16px;
  font-weight: 600;
  color: #111827;
  line-height: 1.2;
}

.wr-subtitle {
  font-size: 12px;
  color: #9CA3AF;
  margin-top: 3px;
}

.wr-section {
  margin-bottom: 22px;
}

.wr-section:last-child {
  margin-bottom: 0;
}

.wr-section-title {
  font-size: 11px;
  font-weight: 600;
  color: #111827;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 12px;
}

/* ── KPI Grid ───────────────────────────────────────────── */
.wr-kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

@media (max-width: 900px) {
  .wr-kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

.wr-kpi {
  background: #F3F4F6;
  border: 1px solid #E5E7EB;
  border-radius: 10px;
  padding: 12px 14px;
}

.wr-kpi-label {
  font-size: 10px;
  font-weight: 500;
  color: #9CA3AF;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.wr-kpi-value {
  font-size: 20px;
  font-weight: 600;
  color: #2563EB;
  line-height: 1.1;
  margin-bottom: 4px;
}

.wr-kpi-delta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 500;
}

.wr-kpi-delta.up { color: #059669; }
.wr-kpi-delta.down { color: #DC2626; }
.wr-kpi-delta.neutral { color: #9CA3AF; }

/* ── Charts ─────────────────────────────────────────────── */
.wr-chart-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

@media (max-width: 900px) {
  .wr-chart-grid { grid-template-columns: 1fr; }
}

.wr-chart-card {
  background: #fff;
  border: 1px solid #E5E7EB;
  border-radius: 10px;
  padding: 14px 16px;
}

.wr-chart-wide {
  grid-column: 1 / -1;
}

.wr-chart-title {
  font-size: 12px;
  font-weight: 600;
  color: #2563EB;
  margin-bottom: 10px;
}

.wr-chart-wrap {
  position: relative;
  height: 280px;
}

.wr-chart-wrap-small {
  height: 200px;
}

/* ── Movers Table ──────────────────────────────────────── */
.wr-movers-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 900px) {
  .wr-movers-grid { grid-template-columns: 1fr; }
}

.wr-movers-heading {
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 8px;
}

.wr-positive { color: #059669; }
.wr-negative { color: #DC2626; }

.wr-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.wr-table td {
  padding: 8px 6px;
  border-bottom: 1px solid #F3F4F6;
  vertical-align: top;
}

.wr-table tr:last-child td {
  border-bottom: none;
}

.wr-td-main {
  width: 60%;
}

.wr-kw {
  font-weight: 500;
  color: #111827;
  word-break: break-word;
}

.wr-kw-sub {
  font-size: 11px;
  color: #9CA3AF;
  margin-top: 2px;
}

.wr-td-num {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* ── Anomalies ──────────────────────────────────────────── */
.wr-anomaly {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid #F3F4F6;
  font-size: 12px;
}

.wr-anomaly:last-child { border-bottom: none; }

.wr-badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 11px;
  font-size: 10px;
  font-weight: 600;
  flex-shrink: 0;
}

.wr-badge-urgent { background: #FEE2E2; color: #DC2626; }
.wr-badge-attention { background: #FEF3C7; color: #D97706; }
.wr-badge-info { background: #CFFAFE; color: #0891B2; }
.wr-badge-positive { background: #D1FAE5; color: #059669; }

.wr-anomaly-text {
  flex: 1;
  color: #6B7280;
}

.wr-anomaly-delta {
  font-weight: 600;
  color: #111827;
  font-variant-numeric: tabular-nums;
}

.wr-empty {
  color: #9CA3AF;
  font-size: 12px;
  font-style: italic;
  padding: 8px 0;
}

/* ══════════════════════════════════════════════════════════
   Template: SCORECARD (audits)
   ══════════════════════════════════════════════════════════ */

.wr-sc-top {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 24px;
  align-items: center;
}

@media (max-width: 700px) {
  .wr-sc-top { grid-template-columns: 1fr; }
}

.wr-sc-overall-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 8px;
}

/* Score ring — conic-gradient voor radial progress */
.wr-sc-score-ring {
  --score: 0;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: conic-gradient(
    var(--ring-color, #2563EB) calc(var(--score) * 1%),
    #F3F4F6 0
  );
  position: relative;
}

.wr-sc-score-ring::before {
  content: '';
  position: absolute;
  inset: 10px;
  background: #fff;
  border-radius: 50%;
  z-index: 0;
}

.wr-sc-ring-good { --ring-color: #059669; }
.wr-sc-ring-warn { --ring-color: #D97706; }
.wr-sc-ring-fail { --ring-color: #DC2626; }

.wr-sc-score-value {
  position: relative;
  z-index: 1;
  font-size: 36px;
  font-weight: 600;
  color: #111827;
  line-height: 1;
}

.wr-sc-score-max {
  position: relative;
  z-index: 1;
  font-size: 11px;
  color: #9CA3AF;
  margin-top: 2px;
}

.wr-sc-score-meta {
  text-align: center;
}

.wr-sc-score-label {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.wr-sc-label-good { color: #059669; }
.wr-sc-label-warn { color: #D97706; }
.wr-sc-label-fail { color: #DC2626; }

.wr-sc-score-sub {
  font-size: 11px;
  color: #9CA3AF;
  margin-top: 2px;
}

.wr-sc-radar-wrap {
  background: #fff;
  border: 1px solid #E5E7EB;
  border-radius: 10px;
  padding: 14px 16px;
}

.wr-sc-radar-wrap .wr-chart-wrap {
  height: 220px;
}

/* Module score cards */
.wr-sc-modules {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
}

.wr-sc-module {
  background: #fff;
  border: 1px solid #E5E7EB;
  border-radius: 10px;
  padding: 12px 14px;
}

.wr-sc-module-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}

.wr-sc-module-name {
  font-size: 12px;
  font-weight: 500;
  color: #111827;
}

.wr-sc-module-score {
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.wr-sc-module-bar {
  width: 100%;
  height: 6px;
  background: #F3F4F6;
  border-radius: 3px;
  overflow: hidden;
}

.wr-sc-module-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s ease;
}

/* Stats row */
.wr-sc-stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}

.wr-sc-stat {
  background: #F7F8FA;
  border: 1px solid #E5E7EB;
  border-radius: 8px;
  padding: 10px 12px;
}

.wr-sc-stat-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #9CA3AF;
  font-weight: 500;
  margin-bottom: 4px;
}

.wr-sc-stat-value {
  font-size: 18px;
  font-weight: 600;
  color: #111827;
  line-height: 1;
}

/* Diagnostics */
.wr-sc-diag-filter {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.wr-sc-filter-btn {
  padding: 6px 12px;
  border: 1px solid #E5E7EB;
  background: #fff;
  border-radius: 16px;
  font-family: inherit;
  font-size: 11px;
  font-weight: 500;
  color: #6B7280;
  cursor: pointer;
  transition: all 0.15s;
}

.wr-sc-filter-btn:hover {
  border-color: #2563EB;
  color: #2563EB;
}

.wr-sc-filter-btn.active {
  background: #2563EB;
  border-color: #2563EB;
  color: #fff;
}

.wr-sc-diag-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.wr-sc-diag {
  background: #fff;
  border: 1px solid #E5E7EB;
  border-left: 3px solid #9CA3AF;
  border-radius: 8px;
  padding: 12px 14px;
}

.wr-sc-diag:has(.wr-badge-urgent)    { border-left-color: #DC2626; }
.wr-sc-diag:has(.wr-badge-attention) { border-left-color: #D97706; }
.wr-sc-diag:has(.wr-badge-info)      { border-left-color: #0891B2; }

.wr-sc-diag-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.wr-sc-diag-module {
  font-size: 10px;
  color: #9CA3AF;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 500;
}

.wr-sc-diag-check {
  font-size: 13px;
  color: #111827;
  font-weight: 500;
}

.wr-sc-diag-finding {
  font-size: 12px;
  color: #6B7280;
  margin-bottom: 6px;
  line-height: 1.5;
}

.wr-sc-diag-rec {
  font-size: 12px;
  color: #111827;
  padding: 8px 10px;
  background: #F3F4F6;
  border-radius: 6px;
  line-height: 1.5;
}

.wr-sc-diag-rec strong {
  color: #2563EB;
}

/* ══════════════════════════════════════════════════════════
   Template: DATALIST (search-term-analyzer, etc.)
   ══════════════════════════════════════════════════════════ */

.wr-dl-section {
  background: #fff;
  border: 1px solid #E5E7EB;
  border-radius: 10px;
  padding: 16px 18px;
  margin-bottom: 14px;
  border-left: 4px solid #9CA3AF;
}

.wr-dl-section:last-child { margin-bottom: 0; }

.wr-dl-tone-negative { border-left-color: #DC2626; }
.wr-dl-tone-positive { border-left-color: #059669; }
.wr-dl-tone-neutral  { border-left-color: #9CA3AF; }

.wr-dl-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}

.wr-dl-title {
  font-size: 14px;
  font-weight: 600;
  color: #111827;
  line-height: 1.2;
}

.wr-dl-desc {
  font-size: 12px;
  color: #9CA3AF;
  margin-top: 3px;
  line-height: 1.4;
}

.wr-dl-count {
  display: inline-block;
  padding: 3px 10px;
  background: #F3F4F6;
  color: #6B7280;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}

.wr-dl-tone-negative .wr-dl-count { background: #FEE2E2; color: #DC2626; }
.wr-dl-tone-positive .wr-dl-count { background: #D1FAE5; color: #059669; }

.wr-dl-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.wr-dl-filter {
  flex: 1;
  min-width: 180px;
  max-width: 280px;
  padding: 7px 12px;
  border: 1px solid #E5E7EB;
  border-radius: 6px;
  font-family: inherit;
  font-size: 12px;
  color: #6B7280;
  background: #fff;
  transition: border 0.15s;
}

.wr-dl-copy-group {
  display: flex;
  align-items: stretch;
  gap: 0;
  margin-left: auto;
}

.wr-dl-match-select {
  padding: 7px 24px 7px 10px;
  border: 1px solid #E5E7EB;
  border-right: none;
  border-radius: 6px 0 0 6px;
  font-family: inherit;
  font-size: 12px;
  color: #6B7280;
  background: #fff url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%23434343' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>") no-repeat right 8px center;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}

.wr-dl-match-select:focus {
  outline: none;
  border-color: #2563EB;
}

.wr-dl-copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: 1px solid #2563EB;
  border-radius: 0 6px 6px 0;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  color: #fff;
  background: #2563EB;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border 0.15s;
}

.wr-dl-copy-btn:hover {
  background: #1D4ED8;
  border-color: #1D4ED8;
}

.wr-dl-copy-btn.wr-dl-copy-success {
  background: #059669;
  border-color: #059669;
}

.wr-dl-copy-btn.wr-dl-copy-error {
  background: #DC2626;
  border-color: #DC2626;
}

.wr-dl-filter:focus {
  outline: none;
  border-color: #2563EB;
}

.wr-dl-table-wrap {
  max-height: 420px;
  overflow-y: auto;
  border: 1px solid #F3F4F6;
  border-radius: 8px;
}

.wr-dl-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.wr-dl-table thead {
  position: sticky;
  top: 0;
  background: #F3F4F6;
  z-index: 1;
}

.wr-dl-th {
  padding: 8px 10px;
  text-align: left;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #2563EB;
  border-bottom: 1px solid #DBEAFE;
  white-space: nowrap;
}

.wr-dl-th-num,
.wr-dl-th-eur,
.wr-dl-th-pct { text-align: right; }
.wr-dl-th-badge,
.wr-dl-th-pill { text-align: center; }

.wr-dl-td {
  padding: 8px 10px;
  border-bottom: 1px solid #F3F4F6;
  color: #6B7280;
  vertical-align: middle;
}

.wr-dl-table tr:last-child .wr-dl-td {
  border-bottom: none;
}

.wr-dl-table tbody tr:hover {
  background: #FAFBFC;
}

.wr-dl-td-num {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  color: #111827;
}

.wr-dl-td-badge,
.wr-dl-td-pill {
  text-align: center;
  white-space: nowrap;
}

.wr-dl-td-empty {
  text-align: center;
}

.wr-dl-muted {
  color: #E5E7EB;
}

.wr-dl-pill {
  display: inline-block;
  padding: 3px 10px;
  background: #F3F4F6;
  color: #6B7280;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 500;
}

/* ══════════════════════════════════════════════════════════
   Error bubble — shown when viz.json is malformed or template throws
   ══════════════════════════════════════════════════════════ */

.wr-bubble-error {
  border-color: #FEE2E2 !important;
  background: #FEF6F6;
}

.wr-bubble-error .wr-header {
  border-bottom-color: #DC2626;
}

.wr-bubble-error .wr-title {
  color: #DC2626;
}

.wr-error-list {
  margin: 0 0 12px;
  padding-left: 18px;
  color: #6B7280;
  font-size: 12px;
  line-height: 1.6;
}

.wr-error-list li {
  margin-bottom: 3px;
  font-family: var(--font-mono, ui-monospace, monospace);
}

.wr-error-hint {
  font-size: 11px;
  color: #9CA3AF;
  padding: 8px 10px;
  background: #fff;
  border: 1px dashed #E5E7EB;
  border-radius: 6px;
}

.wr-error-hint code {
  background: #F3F4F6;
  padding: 1px 5px;
  border-radius: 3px;
  font-family: var(--font-mono, ui-monospace, monospace);
  color: #111827;
}
