/*
 * components-traffic.css — traffic & history: auto-comparison panel,
 * history tab, trend chart, history diff, subnet grouping,
 * trusted-traffic bar, service candidate export.
 */

/* ─────────────────────────────────────────────────────────────────────────────
   Traffic Comparison (baseline diff in History tab)
───────────────────────────────────────────────────────────────────────────── */
/* ── Auto-comparison panel (Before/After tab) ────────────────────────────── */
.acp-header {
  display: flex; align-items: baseline; gap: .75rem; flex-wrap: wrap;
  margin-bottom: .65rem;
}
.acp-title {
  font-size: 14px; font-weight: 700; color: var(--text);
}
.acp-sub {
  font-size: 12px; color: var(--muted);
}
.acp-verdict {
  font-size: 13px; padding: .55rem .85rem; border-radius: 6px;
  background: var(--surface2); border: 1px solid var(--border);
  margin-bottom: .85rem; line-height: 1.4;
}
.tc-section-note {
  font-size: 11px; color: var(--muted); margin: 0 0 .45rem; font-style: italic;
}

.traffic-comparison {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 8px;
  margin-bottom: 1.25rem;
  padding: .85rem 1rem;
}
.tc-header {
  display: flex; align-items: baseline; gap: .75rem;
  margin-bottom: .85rem;
}
.tc-label {
  font-size: 13px; font-weight: 600; color: var(--text);
}
.tc-sub   { font-size: 12px; color: var(--muted); }

/* Volume delta bar */
.tc-volume-bar {
  display: flex; gap: 1.5rem; flex-wrap: wrap;
  padding: .55rem .75rem;
  background: var(--surface2);
  border-radius: 6px;
  margin-bottom: .85rem;
}
.tc-vol-stat {
  display: flex; align-items: center; gap: .4rem;
  font-size: 12px;
}
.tc-vol-label { color: var(--muted); }
.tc-vol-cur   { font-weight: 600; color: var(--text); font-family: var(--font-mono); }
.tc-vol-base  { color: var(--muted); font-size: 11px; font-family: var(--font-mono); }
.tc-vol-badge {
  padding: 1px 6px; border-radius: 10px; font-size: 11px;
  font-weight: 600; font-family: var(--font-mono);
}
.tc-vol-up   { background: rgba(239,154,154,.18); color: var(--block); }
.tc-vol-down { background: rgba(56,217,169,.15);  color: var(--allow); }
.tc-vol-flat { background: rgba(136,146,164,.12); color: var(--muted); }

/* Sections */
.tc-none { font-size: 13px; color: var(--muted); margin: 0; }
.tc-section { margin-bottom: .85rem; }
.tc-section:last-child { margin-bottom: 0; }
.tc-section-label {
  font-size: 12px; font-weight: 600;
  margin-bottom: .35rem; color: var(--text2);
}
.tc-count { color: var(--muted); font-weight: 400; }

/* Individual items */
.tc-item {
  font-size: 12px;
  padding: .3rem .6rem;
  margin-bottom: 3px;
  border-radius: 4px;
  background: var(--surface2);
  display: flex; align-items: baseline;
  gap: .5rem; flex-wrap: wrap;
  font-family: var(--font-mono);
  word-break: break-all;
}
.tc-delta    { font-weight: 600; color: var(--text); white-space: nowrap; }
.tc-up       { color: var(--block); }
.tc-prev     { color: var(--muted); font-size: 11px; white-space: nowrap; }
.tc-ua       { font-family: var(--font-sans, inherit); font-size: 11px;
               color: var(--muted); word-break: break-all; flex: 1; }

/* ─────────────────────────────────────────────────────────────────────────────
   History tab
───────────────────────────────────────────────────────────────────────────── */
.history-tab-panel { animation: fadeUp .2s ease; }
.history-site-title { font-size: 15px; font-weight: 600; margin-bottom: 1rem; }
.history-empty, .history-no-diff { font-size: 13px; color: var(--muted); padding: .5rem 0; }

.history-diff-header {
  font-size: 12px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .06em; color: var(--muted); margin-bottom: .75rem;
}
.history-diff-group { margin-bottom: 1rem; }
.diff-group-label   { font-size: 13px; font-weight: 600; margin-bottom: .4rem; }
.diff-item          {
  font-size: 13px; padding: .35rem .75rem;
  margin-bottom: 3px; border-radius: 4px;
  background: var(--surface2);
}
.diff-escalated .diff-item { border-left: 3px solid var(--block); }
.diff-new       .diff-item { border-left: 3px solid var(--accent); }
.diff-fixed     .diff-item { border-left: 3px solid var(--allow); color: var(--muted); }
.diff-unchanged .diff-item { border-left: 3px solid var(--border2); color: var(--muted); }

.history-comparison { margin-bottom: 1.5rem; }
.history-scan-list  { display: flex; flex-direction: column; gap: 4px; }
.history-scan-row   {
  display: flex; align-items: center; gap: .75rem;
  padding: .5rem .75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
}
.history-scan-date   { color: var(--muted); min-width: 100px; }
.history-scan-label  { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-scan-issues { color: var(--muted); font-family: var(--font-mono); font-size: 12px; }
.history-rename-btn {
  background: none; border: none; color: var(--muted);
  cursor: pointer; font-size: 14px; line-height: 1;
  padding: 2px 5px; border-radius: 3px; flex-shrink: 0;
  transition: color .15s, background .15s;
}
.history-rename-btn:hover { color: var(--accent); background: var(--surface2); }
.history-delete-btn  {
  background: none; border: none; color: var(--muted);
  cursor: pointer; padding: 2px 6px; border-radius: 3px; font-size: 12px;
  flex-shrink: 0;
}
.history-delete-btn:hover { color: var(--block); background: rgba(239,154,154,.1); }

/* Risk chip (used in save banner + history rows) */
.risk-chip {
  padding: 2px 8px; border-radius: 10px; font-size: 11px;
  font-weight: 600; flex-shrink: 0;
}
/* Scoped to chips only — prevents tinting the whole risk-score-wrap */
.risk-chip.risk-low      { background: rgba(56,217,169,.15);  color: var(--allow); }
.risk-chip.risk-medium   { background: rgba(255,183,77,.15);  color: var(--challenge); }
.risk-chip.risk-high     { background: rgba(239,154,154,.15); color: var(--block); }
.risk-chip.risk-critical { background: rgba(239,154,154,.25); color: var(--block); }

/* Score number + label colour matches severity */
.risk-low      .risk-score-main span,
.risk-low      .risk-score-main strong { color: var(--allow); }
.risk-medium   .risk-score-main span,
.risk-medium   .risk-score-main strong { color: var(--challenge); }
.risk-high     .risk-score-main span,
.risk-high     .risk-score-main strong { color: var(--block); }
.risk-critical .risk-score-main span,
.risk-critical .risk-score-main strong { color: var(--block); }

@media (max-width: 640px) {
  .save-scan-banner { flex-direction: column; align-items: flex-start; }
  .history-scan-row { flex-wrap: wrap; }
  .login-modal      { padding: 1.5rem; }
  .user-pill        { max-width: 120px; }
}

/* ─────────────────────────────────────────────────────────────────────────────
   History — trend chart
───────────────────────────────────────────────────────────────────────────── */
.history-trend {
  margin-bottom: 1.5rem;
  padding: 1rem 1rem .75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.history-trend-header {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: .85rem;
}

.history-section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
}

.trend-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
}
.trend-badge--worse  { background: rgba(239,154,154,.18); color: var(--block); }
.trend-badge--better { background: rgba(56,217,169,.15);  color: var(--allow); }
.trend-badge--stable { background: var(--surface2);       color: var(--muted); }

.trend-chart {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 72px;
}

.trend-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 0;
  cursor: default;
}

.trend-bar-wrap {
  width: 100%;
  height: 48px;
  display: flex;
  align-items: flex-end;
}

.trend-bar {
  width: 100%;
  border-radius: 3px 3px 0 0;
  transition: opacity .15s;
  min-height: 3px;
}
.trend-bar:hover { opacity: .75; }

/* Risk-level colours for bars */
.risk-bar-low      { background: var(--allow); }
.risk-bar-medium   { background: var(--challenge); }
.risk-bar-high     { background: var(--block); }
.risk-bar-critical { background: #ef5350; }

/* Current (unsaved) scan bar — outlined style */
.trend-bar--current {
  opacity: .55;
  outline: 2px dashed currentColor;
  outline-offset: -2px;
}

.trend-col-label {
  font-size: 9px;
  color: var(--muted);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  line-height: 1.2;
}

.trend-now-label {
  display: block;
  font-weight: 700;
  color: var(--accent);
  font-size: 9px;
}

/* ─────────────────────────────────────────────────────────────────────────────
   History — issue comparison diff (multi-scan labels)
───────────────────────────────────────────────────────────────────────────── */
.diff-group-count { font-weight: 400; opacity: .7; }

.diff-count {
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--muted);
  margin-left: .25rem;
}

.diff-level-change {
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--block);
  margin-left: .25rem;
}

/* Chronic — persistent red-orange strip */
.diff-chronic .diff-item {
  border-left: 3px solid #ff7043;
  background: rgba(255,112,67,.07);
}
.diff-chronic .diff-group-label { color: #ff7043; }

/* Recurring — purple */
.diff-recurring .diff-item {
  border-left: 3px solid #ab47bc;
  background: rgba(171,71,188,.07);
}
.diff-recurring .diff-group-label { color: #ab47bc; }

@media (max-width: 480px) {
  .trend-chart { height: 56px; gap: 2px; }
  .trend-bar-wrap { height: 36px; }
  .trend-col-label { font-size: 8px; }
}

/* ── Subnet section ───────────────────────────────────────────────────────── */
.subnet-section-title {
  font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); margin: 1.25rem 0 .5rem; padding-top: 1rem;
  border-top: 1px solid var(--border);
}
.subnet-section-sub {
  font-size: 11px; font-weight: 400; text-transform: none; letter-spacing: 0;
  color: var(--muted); margin-left: .5rem;
}
.subnet-row {
  display: flex; align-items: center; gap: .6rem; padding: .45rem 0;
  border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.subnet-row:last-of-type { border-bottom: none; }
.subnet-label {
  font-family: var(--font-mono); font-size: 13px; font-weight: 600;
  flex-shrink: 0; min-width: 130px;
}
.subnet-meta { font-size: 12px; color: var(--muted); flex: 1; min-width: 140px; }
.subnet-tag-ctrl { display: flex; gap: 4px; align-items: center; flex-shrink: 0; }
.subnet-tag-select {
  background: var(--surface2); border: 1px solid var(--border2); color: var(--text);
  border-radius: 5px; font-size: 12px; padding: 3px 6px; cursor: pointer;
}
.subnet-tag-all-btn {
  padding: 3px 10px; font-size: 11px; font-weight: 600; border-radius: 5px;
  background: var(--surface2); border: 1px solid var(--border2); color: var(--text);
  cursor: pointer; white-space: nowrap; transition: background .15s;
}
.subnet-tag-all-btn:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.subnet-expand-btn {
  background: none; border: none; color: var(--muted); cursor: pointer;
  font-size: 14px; padding: 2px 6px; border-radius: 4px; flex-shrink: 0;
  transition: background .15s, color .15s;
}
.subnet-expand-btn:hover { background: var(--surface2); color: var(--text); }
.subnet-ips-drawer { display: none; padding: .25rem 0 .5rem .75rem; }
.subnet-ips-drawer.open { display: block; }

/* ── Trusted Traffic bar ─────────────────────────────────────────────────── */
#trusted-traffic-bar {
  background: rgba(79, 156, 249, 0.07);
  border: 1px solid rgba(79, 156, 249, 0.25);
  border-radius: 10px;
  padding: .75rem 1rem;
  margin-bottom: 1.25rem;
  font-size: 13px;
}
.trusted-bar-main {
  display: flex; align-items: flex-start; gap: .6rem;
}
.trusted-bar-icon { font-size: 15px; flex-shrink: 0; margin-top: 1px; }
.trusted-bar-chips {
  display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .55rem;
}
.trusted-profile-chip {
  display: inline-flex; align-items: center; gap: .35rem;
  background: rgba(79, 156, 249, 0.12); border: 1px solid rgba(79, 156, 249, 0.2);
  border-radius: 6px; padding: 2px 8px; font-size: 11px; font-weight: 600;
  color: var(--accent);
}
.trusted-profile-chip span { font-weight: 400; color: var(--muted); }

/* ── Service Candidate Export ─────────────────────────────────────────────── */
.candidate-list { display: flex; flex-direction: column; gap: .5rem; }
.candidate-row {
  padding: .55rem .75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}
.candidate-ua {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: .3rem;
  word-break: break-all;
}
.candidate-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .5rem;
  font-size: 12px;
}
.candidate-paths { display: flex; flex-wrap: wrap; gap: .3rem; }
.candidate-path {
  background: var(--surface2);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 11px;
  color: var(--muted);
}
