/* ============================================================
   research-enhanced.css
   Shared styles for enhanced research page sections.
   All classes prefixed with "re-" to avoid collisions with
   existing .research-* classes.
   Uses CSS variables from /css/styles.css.
   ============================================================ */

/* ── Protocol Snapshot ── */
.re-snapshot {
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  margin-bottom: var(--space-6);
}

.re-snapshot-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: var(--space-5);
  gap: var(--space-4);
}

.re-snapshot-title {
  flex: 1;
}

.re-snapshot-title h2 {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--color-text-primary);
  margin-bottom: var(--space-2);
}

.re-snapshot-oneliner {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  line-height: var(--leading-relaxed);
}

.re-snapshot-badges {
  display: flex;
  gap: var(--space-2);
  flex-shrink: 0;
}

.re-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.re-badge-signal.buy { background: #dcfce7; color: #166534; }
.re-badge-signal.hold { background: #fef3c7; color: #92400e; }
.re-badge-signal.sell { background: #fef2f2; color: #991b1b; }

.re-badge-conviction { background: #dbeafe; color: #1e40af; }
.re-badge-risk.low { background: #dcfce7; color: #166534; }
.re-badge-risk.medium { background: #fef3c7; color: #92400e; }
.re-badge-risk.high { background: #fef2f2; color: #991b1b; }

.re-metrics-strip {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: var(--space-3);
}

.re-metric-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-4);
  text-align: center;
}

.re-metric-value {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--color-text-primary);
  margin-bottom: 2px;
}

.re-metric-label {
  font-size: 11px;
  color: var(--color-text-tertiary);
}

.re-metric-trend {
  display: inline-block;
  font-size: 10px;
  margin-left: 4px;
}

.re-metric-trend.up { color: var(--color-success); }
.re-metric-trend.down { color: var(--color-danger); }
.re-metric-trend.stable { color: var(--color-text-tertiary); }

/* ── Condensed Thesis ── */
.re-thesis {
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  margin-bottom: var(--space-6);
}

.re-thesis-header {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-5);
}

.re-thesis-pillars {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-5);
}

.re-thesis-pillar {
  position: relative;
  padding-left: var(--space-4);
  border-left: 3px solid var(--color-border);
}

.re-thesis-pillar:nth-child(1) { border-left-color: var(--color-success); }
.re-thesis-pillar:nth-child(2) { border-left-color: var(--color-accent); }
.re-thesis-pillar:nth-child(3) { border-left-color: var(--color-warning); }

.re-thesis-pillar-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-2);
}

.re-thesis-pillar:nth-child(1) .re-thesis-pillar-label { color: var(--color-success); }
.re-thesis-pillar:nth-child(2) .re-thesis-pillar-label { color: var(--color-accent); }
.re-thesis-pillar:nth-child(3) .re-thesis-pillar-label { color: var(--color-warning); }

.re-thesis-pillar-content {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  line-height: var(--leading-relaxed);
}

/* ── Level Toggle Buttons ── */
.re-level-toggle {
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-4) var(--space-6);
  margin-bottom: var(--space-6);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.2s;
  width: 100%;
  text-align: left;
  font-family: inherit;
}

.re-level-toggle:hover {
  border-color: var(--color-accent);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.re-level-toggle-text {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--color-text-primary);
}

.re-level-toggle-hint {
  font-size: var(--text-xs);
  color: var(--color-text-tertiary);
  margin-top: 2px;
}

.re-level-toggle-icon {
  font-size: 20px;
  color: var(--color-text-tertiary);
  transition: transform 0.3s ease;
  font-weight: 300;
}

.re-level-toggle.expanded .re-level-toggle-icon {
  transform: rotate(45deg);
}

/* ── Expandable Sections ── */
.re-expandable {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s ease;
}

.re-expandable.re-expanded {
  max-height: none;
  overflow: visible;
}

/* ── Flywheel Visual ── */
.re-flywheel {
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  margin-bottom: var(--space-6);
}

.re-flywheel-title {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-4);
  text-align: center;
}

.re-flywheel-svg-container {
  display: flex;
  justify-content: center;
}

.re-flywheel-svg {
  max-width: 520px;
  width: 100%;
}

.re-flywheel-node {
  cursor: default;
  transition: filter 0.2s;
}

.re-flywheel-node:hover {
  filter: brightness(1.05);
}

.re-flywheel-node:hover .re-flywheel-node-detail {
  opacity: 1;
}

.re-flywheel-node-detail {
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}

/* ── Health Dashboard ── */
.re-health {
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  margin-bottom: var(--space-6);
}

.re-health-title {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-5);
}

.re-health-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-4);
}

.re-health-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  border-left: 4px solid var(--color-border);
}

.re-health-card.grade-a  { border-left-color: var(--color-success); }
.re-health-card.grade-b  { border-left-color: var(--color-accent); }
.re-health-card.grade-c  { border-left-color: var(--color-warning); }
.re-health-card.grade-d  { border-left-color: var(--color-danger); }

.re-health-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-3);
}

.re-health-card-label {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.re-health-grade {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
  font-weight: 700;
}

.re-health-card.grade-a .re-health-grade { background: #dcfce7; color: #166534; }
.re-health-card.grade-b .re-health-grade { background: #dbeafe; color: #1e40af; }
.re-health-card.grade-c .re-health-grade { background: #fef3c7; color: #92400e; }
.re-health-card.grade-d .re-health-grade { background: #fef2f2; color: #991b1b; }

.re-health-headline {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text-primary);
  margin-bottom: var(--space-2);
}

.re-health-details {
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  line-height: var(--leading-relaxed);
}

.re-health-trend {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: var(--radius-full);
  margin-top: var(--space-2);
  text-transform: uppercase;
}

.re-health-trend.improving { background: #dcfce7; color: #166534; }
.re-health-trend.stable    { background: #f3f4f6; color: #6b7280; }
.re-health-trend.watch     { background: #fef3c7; color: #92400e; }
.re-health-trend.declining { background: #fef2f2; color: #991b1b; }

/* ── Break Conditions ── */
.re-breaks {
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  margin-bottom: var(--space-6);
}

.re-breaks-title {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-5);
}

.re-break-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
  padding: var(--space-4) 0;
  border-bottom: 1px solid var(--color-border-light);
}

.re-break-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.re-break-severity {
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.re-break-severity.critical { background: #fef2f2; color: #991b1b; }
.re-break-severity.high     { background: #fef3c7; color: #92400e; }
.re-break-severity.medium   { background: #dbeafe; color: #1e40af; }

.re-break-content {
  flex: 1;
}

.re-break-condition {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-primary);
  margin-bottom: 4px;
}

.re-break-meta {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: 12px;
  color: var(--color-text-tertiary);
}

.re-break-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 600;
}

.re-break-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.re-break-status.healthy .re-break-status-dot  { background: var(--color-success); }
.re-break-status.watch .re-break-status-dot    { background: var(--color-warning); }
.re-break-status.breached .re-break-status-dot { background: var(--color-danger); }

/* ── Competitive Positioning ── */
.re-competitive {
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  margin-bottom: var(--space-6);
}

.re-competitive-title {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-4);
}

.re-competitive-table {
  width: 100%;
  border-collapse: collapse;
}

.re-competitive-table th,
.re-competitive-table td {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  border-bottom: 1px solid var(--color-border-light);
  font-size: var(--text-sm);
}

.re-competitive-table th {
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--color-surface);
}

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

.re-competitive-table tr.re-highlight td {
  background: #eff6ff;
  font-weight: 500;
}

/* ── Scenario Tabs ── */
.re-scenarios {
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  margin-bottom: var(--space-6);
}

.re-scenarios-title {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-4);
}

.re-scenario-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: var(--space-5);
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: 3px;
}

.re-scenario-tab {
  flex: 1;
  padding: var(--space-2) var(--space-4);
  text-align: center;
  font-size: var(--text-sm);
  font-weight: 600;
  border: none;
  background: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  color: var(--color-text-secondary);
  transition: all 0.15s;
}

.re-scenario-tab:hover {
  color: var(--color-text-primary);
}

.re-scenario-tab.active {
  background: var(--color-white);
  color: var(--color-text-primary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.re-scenario-tab[data-tab="bear"].active { color: var(--color-danger); }
.re-scenario-tab[data-tab="base"].active { color: var(--color-accent); }
.re-scenario-tab[data-tab="bull"].active { color: var(--color-success); }

.re-scenario-panel {
  display: none;
}

.re-scenario-panel.active {
  display: block;
}

.re-scenario-probability {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text-tertiary);
  text-transform: uppercase;
  margin-bottom: var(--space-3);
}

.re-scenario-conditions {
  margin-bottom: var(--space-4);
}

.re-scenario-conditions-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-2);
}

.re-scenario-conditions ul {
  margin: 0;
  padding-left: var(--space-5);
}

.re-scenario-conditions li {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-2);
  line-height: var(--leading-relaxed);
}

.re-scenario-outcome {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
}

.re-scenario-outcome-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-2);
}

.re-scenario-outcome p {
  font-size: var(--text-sm);
  color: var(--color-text-primary);
  line-height: var(--leading-relaxed);
  margin: 0;
}

/* ── Sidebar nav additions ── */
.re-sidebar-divider {
  height: 1px;
  background: var(--color-border-light);
  margin: var(--space-3) var(--space-3);
}

.re-sidebar-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--color-text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: var(--space-1) var(--space-3);
}

/* ── Responsive ── */
@media (max-width: 1024px) {
  .re-metrics-strip {
    grid-template-columns: repeat(3, 1fr);
  }

  .re-thesis-pillars {
    grid-template-columns: 1fr;
  }

  .re-health-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .re-metrics-strip {
    grid-template-columns: repeat(2, 1fr);
  }

  .re-snapshot-header {
    flex-direction: column;
  }

  .re-snapshot-badges {
    flex-wrap: wrap;
  }

  .re-break-item {
    flex-direction: column;
    gap: var(--space-2);
  }

  .re-competitive-table {
    font-size: 12px;
  }

  .re-competitive-table th,
  .re-competitive-table td {
    padding: var(--space-2);
  }
}
