/* ==========================================================================
   IRGC Propaganda Alignment Analyzer - Stylesheet
   Dark Theme (#1a1a2e), IRGC Green (#2d6a4f), Twitter Blue (#1da1f2)
   ========================================================================== */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg-primary: #1a1a2e;
  --bg-card: #16213e;
  --bg-card-hover: #1b284c;
  --bg-input: #0f172a;
  --border-color: rgba(255, 255, 255, 0.1);
  --border-focus: #1da1f2;
  --text-primary: #e0e0e0;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --twitter-blue: #1da1f2;
  --twitter-blue-dim: rgba(29, 161, 242, 0.12);
  --twitter-blue-border: rgba(29, 161, 242, 0.35);
  
  --irgc-green: #2d6a4f;
  --irgc-green-dim: rgba(45, 106, 79, 0.2);
  --irgc-green-light: #52b788;
  --irgc-green-border: rgba(82, 183, 136, 0.4);

  --score-zero: rgba(255, 255, 255, 0.04);
  --score-low: rgba(234, 179, 8, 0.4);
  --score-med: rgba(249, 115, 22, 0.65);
  --score-high: rgba(239, 68, 68, 0.85);

  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* --- Container & Layout --- */
.dashboard-wrapper {
  max-width: 1380px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

/* --- Header --- */
.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 24px;
  margin-bottom: 28px;
  border-bottom: 1px solid var(--border-color);
  flex-wrap: wrap;
  gap: 16px;
}

.header-left {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.back-link {
  color: var(--twitter-blue);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: opacity 0.2s;
  width: fit-content;
}

.back-link:hover {
  opacity: 0.8;
  text-decoration: underline;
}

.header-title-group h1 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: #ffffff;
}

.header-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
}

.header-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(45, 106, 79, 0.25);
  border: 1px solid var(--irgc-green-border);
  color: var(--irgc-green-light);
  padding: 6px 14px;
  border-radius: 9999px;
  font-size: 13px;
  font-weight: 600;
}

.badge-dot {
  width: 8px;
  height: 8px;
  background-color: #10b981;
  border-radius: 50%;
  box-shadow: 0 0 8px #10b981;
}

/* --- Cards --- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}

.card-header {
  padding: 16px 20px;
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-title h2 {
  font-size: 17px;
  font-weight: 600;
  color: #f1f5f9;
}

.card-icon {
  font-size: 18px;
}

.twitter-icon {
  color: var(--twitter-blue);
  font-weight: bold;
}

.card-body {
  padding: 20px;
}

.badge-tag {
  background: rgba(255, 255, 255, 0.07);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
}

/* --- Input Grid --- */
.inputs-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 28px;
}

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

.form-group {
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-row {
  display: flex;
  gap: 12px;
}

.flex-1 { flex: 1; }
.flex-2 { flex: 2; }

label {
  font-size: 13px;
  font-weight: 500;
  color: #cbd5e1;
}

input[type="text"],
input[type="password"],
input[type="number"],
textarea {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: #ffffff;
  padding: 9px 13px;
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
  width: 100%;
}

textarea {
  resize: vertical;
  min-height: 120px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.4;
}

input:focus, textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px rgba(29, 161, 242, 0.2);
}

.form-help {
  font-size: 11px;
  color: var(--text-muted);
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
}

.btn-primary {
  background: var(--twitter-blue);
  color: #ffffff;
  width: 100%;
}

.btn-primary:hover {
  background: #1a91da;
}

.btn-secondary {
  background: #334155;
  color: #ffffff;
}

.btn-secondary:hover {
  background: #475569;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
}

.btn-outline:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #ffffff;
}

.btn-text {
  background: none;
  border: none;
  color: var(--twitter-blue);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  padding: 0;
}

.btn-text:hover {
  text-decoration: underline;
}

.button-group {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

/* --- Status & Spinner --- */
.status-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(29, 161, 242, 0.1);
  border: 1px solid var(--twitter-blue-border);
  padding: 14px 20px;
  border-radius: 8px;
  margin-bottom: 28px;
}

.spinner {
  width: 22px;
  height: 22px;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--twitter-blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.status-text {
  font-size: 14px;
  font-weight: 500;
  color: #38bdf8;
}

.hidden {
  display: none !important;
}

/* --- Results Section --- */
.results-section {
  display: flex;
  flex-direction: column;
  gap: 28px;
  animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* --- Stats Grid --- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

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

@media (max-width: 500px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: #ffffff;
}

.stat-value.highlight {
  color: #f97316;
}

.text-ellipsis {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 18px;
}

.stat-sub {
  font-size: 12px;
  color: var(--text-muted);
}

/* --- Visual Cards --- */
.visual-card {
  margin-bottom: 0;
}

/* --- Heatmap --- */
.heatmap-legend {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.legend-label {
  font-size: 12px;
  color: var(--text-secondary);
}

.legend-chip {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 4px;
  font-weight: 600;
}

.c-zero { background: var(--score-zero); color: var(--text-muted); border: 1px solid rgba(255, 255, 255, 0.08); }
.c-low { background: var(--score-low); color: #fef08a; }
.c-med { background: var(--score-med); color: #fed7aa; }
.c-high { background: var(--score-high); color: #fee2e2; }

.heatmap-card-body {
  padding: 10px 20px 24px;
}

.heatmap-scroll-container {
  overflow-x: auto;
  padding-top: 130px; /* Space for rotated headers */
  padding-bottom: 12px;
  position: relative;
}

.heatmap-table {
  border-collapse: separate;
  border-spacing: 5px;
  width: auto;
}

.heatmap-table th, .heatmap-table td {
  text-align: center;
}

.heatmap-table th.author-corner {
  min-width: 140px;
  text-align: left;
  padding-left: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.heatmap-table th.narrative-header {
  height: 0;
  position: relative;
  vertical-align: bottom;
  padding: 0;
  width: 50px;
  min-width: 50px;
}

.heatmap-table th.narrative-header > div {
  transform: rotate(-45deg);
  transform-origin: bottom left;
  position: absolute;
  bottom: 12px;
  left: 24px;
  width: 150px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: #cbd5e1;
  white-space: nowrap;
}

.heatmap-table td.author-label {
  text-align: left;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 4px;
  white-space: nowrap;
}

.heatmap-table td.heatmap-cell {
  width: 48px;
  height: 38px;
  font-size: 11px;
  font-family: var(--font-mono);
  font-weight: 600;
  border-radius: 4px;
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.15s ease;
  user-select: none;
}

.heatmap-table td.heatmap-cell:hover {
  transform: scale(1.18);
  z-index: 10;
  filter: brightness(1.2);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
}

/* --- Narrative Breakdown --- */
.breakdown-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.breakdown-item {
  display: flex;
  align-items: center;
  gap: 14px;
}

.breakdown-label {
  width: 220px;
  font-size: 13px;
  font-weight: 500;
  color: #cbd5e1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.breakdown-bar-bg {
  flex: 1;
  height: 12px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 6px;
  overflow: hidden;
}

.breakdown-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #2d6a4f, #f97316);
  border-radius: 6px;
  transition: width 0.5s ease-out;
}

.breakdown-count {
  width: 40px;
  text-align: right;
  font-size: 13px;
  font-weight: 600;
  color: #ffffff;
  font-family: var(--font-mono);
}

/* --- Side-by-Side Match Cards --- */
.matches-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.match-card {
  background: #111a33;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  transition: border-color 0.2s ease;
}

.match-card:hover {
  border-color: rgba(255, 255, 255, 0.2);
}

.match-meta-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.match-author-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.author-handle {
  color: var(--twitter-blue);
  font-weight: 600;
  font-size: 14px;
}

.match-date {
  color: var(--text-muted);
  font-size: 12px;
}

.match-header-badges {
  display: flex;
  align-items: center;
  gap: 8px;
}

.narrative-badge {
  background: rgba(45, 106, 79, 0.3);
  color: #80ed99;
  border: 1px solid rgba(82, 183, 136, 0.4);
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 9999px;
}

.score-badge {
  background: rgba(249, 115, 22, 0.2);
  color: #fdba74;
  border: 1px solid rgba(249, 115, 22, 0.4);
  font-size: 12px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 9999px;
  font-family: var(--font-mono);
}

/* Side-by-Side Columns */
.match-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 800px) {
  .match-columns {
    grid-template-columns: 1fr;
  }
}

.column-box {
  border-radius: 6px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tweet-box {
  background: var(--twitter-blue-dim);
  border: 1px solid var(--twitter-blue-border);
}

.irgc-box {
  background: var(--irgc-green-dim);
  border: 1px solid var(--irgc-green-border);
}

.box-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.tweet-box .box-title {
  color: var(--twitter-blue);
}

.irgc-box .box-title {
  color: var(--irgc-green-light);
}

.box-text {
  font-size: 14px;
  line-height: 1.5;
  color: #f1f5f9;
}

/* Keyword Highlighting */
.kw-highlight {
  background-color: rgba(245, 158, 11, 0.35);
  color: #fef08a;
  padding: 1px 4px;
  border-radius: 3px;
  font-weight: 600;
  border-bottom: 2px solid #f59e0b;
}

/* Match Footer & Score Bar */
.match-footer {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.matched-keywords-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.matched-kw-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

.kw-chip {
  background: rgba(255, 255, 255, 0.08);
  color: #fde047;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 4px;
  font-weight: 500;
}

.score-bar-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
}

.score-bar-bg {
  flex: 1;
  height: 8px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 4px;
  overflow: hidden;
}

.score-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #eab308, #ef4444);
  border-radius: 4px;
}

.score-bar-text {
  font-size: 12px;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  white-space: nowrap;
}

.empty-matches-msg {
  text-align: center;
  padding: 30px;
  color: var(--text-muted);
  font-style: italic;
}

/* Grok Forensic Analysis Card Elements */
.grok-btn {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #ffffff;
  border: none;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.grok-btn:hover {
  transform: translateY(-1px);
  opacity: 0.95;
}

.grok-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.grok-verdict-box {
  margin-top: 14px;
  padding: 14px 16px;
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: 8px;
  animation: fadeIn 0.25s ease-out;
}

.grok-verdict-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  flex-wrap: wrap;
  gap: 8px;
}

.grok-verdict-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: #34d399;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.grok-meta-pills {
  display: flex;
  align-items: center;
  gap: 6px;
}

.grok-class-pill {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.4);
}

.grok-technique-pill {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
  background: rgba(245, 158, 11, 0.2);
  color: #fcd34d;
  border: 1px solid rgba(245, 158, 11, 0.4);
}

.grok-score-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(16, 185, 129, 0.25);
  color: #6ee7b7;
  border: 1px solid rgba(16, 185, 129, 0.5);
}

.grok-analysis-text {
  font-size: 13px;
  line-height: 1.55;
  color: #e2e8f0;
}

/* Quick handle chips */
.handle-chips-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  flex-wrap: wrap;
}

.handle-chip {
  background: rgba(29, 161, 242, 0.12);
  border: 1px solid rgba(29, 161, 242, 0.3);
  color: #38bdf8;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.handle-chip:hover {
  background: rgba(29, 161, 242, 0.25);
  border-color: #38bdf8;
}

