/* sentiment.css — BEM-namespaced styles for sentiment dashboard */

/* === Loading placeholder === */
.loading-placeholder { text-align: center; color: var(--text-muted); padding: 16px; }

/* === Score-legend === */
.score-legend {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-bottom: 12px;
  padding: 10px 14px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
}
.score-legend__label {
  color: var(--text-muted);
  font-weight: 600;
  white-space: nowrap;
}
.score-legend__bar-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.score-legend__gradient {
  width: 120px;
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(to right, #ef4444, #f59e0b 45%, #22c55e);
}
.score-legend__tags {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.score-legend__bars-note {
  margin-left: auto;
  color: var(--text-dim);
  font-size: 0.72rem;
  white-space: nowrap;
}
@media (max-width: 600px) {
  .score-legend {
    gap: 6px 10px;
    padding: 8px 10px;
    font-size: 0.74rem;
  }
  .score-legend__gradient { width: 80px; }
  .score-legend__bars-note { display: none; }
}

/* === Table styles === */
#sources-table th {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  padding: 12px 14px;
  border-bottom: 2px solid var(--border-medium);
  font-family: var(--font-display);
}
#sources-table td {
  padding: 8px 14px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
  font-size: 0.84rem;
  color: var(--text-primary);
}
#sources-table tr:hover td,
#team-table tr:hover td,
#driver-table tr:hover td {
  background: var(--bg-hover);
}

/* Entity table cells (replaces inline styles in JS) */
#team-table td,
#driver-table td {
  padding: 8px 14px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}
#team-table td.entity-count,
#driver-table td.entity-count {
  text-align: right;
  font-family: var(--font-data);
  font-size: 0.82rem;
  color: var(--text-primary);
}
#team-table td.entity-nodata,
#driver-table td.entity-nodata {
  color: var(--text-dim);
}

/* === Source group rows === */
.src-group-row td {
  background: var(--bg-elevated) !important;
  padding: 10px 14px !important;
  border-bottom: 2px solid var(--border-medium) !important;
}
.src-group-label {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.src-group-count {
  font-family: var(--font-data);
  font-size: 0.7rem;
  font-weight: 400;
  color: var(--text-muted);
  margin-left: 10px;
}

/* === Data type badge === */
.data-type-badge {
  font-size: 0.72rem;
  margin-left: 6px;
  opacity: 0.85;
  cursor: default;
}

/* === Source badges === */
.src-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: var(--radius-xs);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  font-family: var(--font-display);
}
.src-badge-yt { background: rgba(255,68,68,0.12); color: #ff4444; border: 1px solid rgba(255,68,68,0.2); }
.src-badge-rss { background: var(--f1-green-dim); color: var(--f1-green); border: 1px solid rgba(0,210,106,0.2); }
.src-badge-pod { background: rgba(155,89,255,0.10); color: var(--f1-purple); border: 1px solid rgba(155,89,255,0.2); }
.src-badge-bsky { background: var(--f1-cyan-dim); color: var(--f1-cyan); border: 1px solid rgba(0,212,255,0.15); }
.src-badge-reddit { background: rgba(255,69,0,0.12); color: #ff6b35; border: 1px solid rgba(255,69,0,0.2); }
.src-badge-team { background: var(--f1-orange-dim); color: var(--f1-orange); border: 1px solid rgba(255,135,0,0.2); }
.src-badge-team-bsky { background: rgba(0,133,255,0.12); color: #0085ff; border: 1px solid rgba(0,133,255,0.2); }
.src-badge-other { background: rgba(150,150,150,0.10); color: var(--text-muted); border: 1px solid var(--border-subtle); }

/* === Team sources matrix === */
.ts-cell { text-align: center; padding: 10px 14px; }
.ts-active { font-weight: 600; font-size: 0.85rem; white-space: nowrap; }
.ts-none { color: var(--text-dim); font-size: 0.8rem; }
.ts-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.78rem;
  font-weight: 600;
  background: rgba(255,255,255,0.05);
  margin: 2px;
}
#team-sources-table th {
  font-size: 0.82rem;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-subtle);
  padding: 10px 14px;
}
#team-sources-table th.ts-center { text-align: center; }
#team-sources-table th.ts-wide { width: 25%; }
#team-sources-table td { border-bottom: 1px solid var(--border-subtle); padding: 10px 14px; }
#team-sources-table .src-name { white-space: nowrap; word-break: normal; }

/* Mobile team sources */
.team-sources-list__item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-subtle);
}
.team-sources-list__name { font-weight: 600; font-size: 0.9rem; white-space: nowrap; word-break: normal; }
.team-sources-list__icons { display: flex; gap: 4px; flex-wrap: wrap; }

@media (max-width: 480px) {
  #team-sources-table { display: none; }
  .team-sources-list { display: block !important; }
}

/* === Score bar === */
.score-bar { display: inline-flex; align-items: center; gap: 8px; width: 100%; }
.score-bar-track {
  flex: 1;
  max-width: 100px;
  height: 8px;
  background: var(--bg-elevated);
  border-radius: var(--radius-xs);
  overflow: hidden;
}
.score-bar-fill { height: 100%; border-radius: var(--radius-xs); transition: width 0.3s ease; }
.score-bar-label {
  font-family: var(--font-data);
  font-size: 0.78rem;
  font-weight: 600;
  min-width: 44px;
  text-align: right;
}

/* === Language pill === */
.lang-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-xs);
  font-size: 0.68rem;
  font-weight: 700;
  font-family: var(--font-data);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  letter-spacing: 0.04em;
}

/* === Sort headers (scoped to tables) === */
#sources-table .sort-header,
#team-table .sort-header,
#driver-table .sort-header {
  cursor: pointer;
  user-select: none;
  padding: 12px 14px !important;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  border-bottom: 2px solid var(--border-medium);
  transition: color 0.15s;
}
#sources-table .sort-header:hover,
#team-table .sort-header:hover,
#driver-table .sort-header:hover { color: var(--text-bright); }
#sources-table .sort-header.active,
#team-table .sort-header.active,
#driver-table .sort-header.active { color: var(--f1-cyan); }

.sort-arrow { font-size: 0.6rem; margin-left: 4px; opacity: 0.3; }
.sort-header.active .sort-arrow { opacity: 1; }

/* === Source name/count/date === */
.src-name { font-weight: 600; color: var(--text-bright); }
.src-count {
  font-family: var(--font-data);
  font-size: 0.82rem;
  text-align: right;
  color: var(--text-primary);
}
.src-date {
  font-family: var(--font-data);
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: right;
}

/* === Mobile hero card === */
.sentiment-hero {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  margin-bottom: var(--space-4);
  text-align: center;
}
.sentiment-hero__score {
  font-family: var(--font-data);
  font-size: 3rem;
  font-weight: 700;
  line-height: 1;
}
.sentiment-hero__sparkline {
  height: 40px;
  margin: var(--space-3) auto;
  max-width: 200px;
}
.sentiment-hero__sparkline svg {
  width: 100%;
  height: 100%;
}
.sentiment-hero__split {
  margin-top: var(--space-3);
}
.sentiment-hero__bar {
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(to right, #22c55e var(--positive, 50%), #ef4444 var(--positive, 50%));
  margin-bottom: var(--space-2);
}
.sentiment-hero__label {
  font-size: var(--fs-small);
  color: var(--text-secondary);
}

/* === Mobile source/entity list === */
.source-list, .entity-list {
  padding: var(--space-2) 0;
}
.source-list__item, .entity-list__item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  min-height: 44px;
}
.source-list__name, .entity-list__name {
  flex: 1;
  font-weight: 600;
  color: var(--text-bright);
  font-size: var(--fs-small);
}
.source-list__count, .entity-list__count {
  font-family: var(--font-data);
  font-size: var(--fs-xs);
  color: var(--text-secondary);
  min-width: 40px;
  text-align: right;
}
.source-list__bar, .entity-list__bar {
  width: 60px;
}

/* === Card header h2 reset === */
.card-header h2 {
  font-size: inherit;
  font-weight: inherit;
  margin: 0;
  line-height: inherit;
}

/* === Responsive toggle === */
@media (max-width: 768px) {
  .sentiment-hero { display: block !important; }
  .source-list, .entity-list { display: block !important; }
  /* Hide desktop stat cards row on mobile */
  #sentiment-stats { display: none; }
  /* Hide desktop tables in sources/entity cards */
  #sources-table { display: none; }
  #team-table, #driver-table { display: none; }
  /* Hide sources chart on mobile (too dense) */
  #sources-chart { display: none; }
}
@media (min-width: 769px) {
  .sentiment-hero { display: none !important; }
  .source-list, .entity-list { display: none !important; }
}
