/* ── Dashboard Styles ──────────────────────────────────────────────
   Simulation controls strip, network graph area, event feed,
   COBOL viewer panel, node detail popup.
   ────────────────────────────────────────────────────────────────── */

/* ── Controls Strip ──────────────────────────────────────────────── */
.controls {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-3) var(--sp-4);
  flex-wrap: wrap;
}

.controls__group {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.controls__divider {
  width: 1px;
  height: 24px;
  background: var(--glass-border);
}

.controls__day {
  font-family: var(--font-mono);
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--text-accent);
  min-width: 80px;
}

/* ── Network Graph Container ─────────────────────────────────────── */
.network-graph {
  position: relative;
  display: flex;
  flex-direction: column;
}

.network-graph__svg-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-4);
  min-height: 0;
}

.network-graph svg {
  width: 100%;
  height: 100%;
  max-height: 500px;
}

/* ── SVG Node Styles ─────────────────────────────────────────────── */
.node-group { cursor: pointer; }
.node-group:hover .node-ring { filter: brightness(1.3); }

.node-label {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  fill: var(--text-secondary);
  text-anchor: middle;
}

.node-sublabel {
  font-family: var(--font-sans);
  font-size: 10px;
  fill: var(--text-muted);
  text-anchor: middle;
}

.spoke-line {
  stroke: rgba(255, 255, 255, 0.06);
  stroke-width: 1;
}

/* ── Edge Flash Animation ────────────────────────────────────────── */
.edge-flash {
  stroke-width: 2;
  fill: none;
  stroke-dasharray: 8 4;
  animation: edgeDash 600ms linear;
  opacity: 0;
}

@keyframes edgeDash {
  0%   { opacity: 0.8; stroke-dashoffset: 48; }
  100% { opacity: 0;   stroke-dashoffset: 0; }
}

/* ── Node Pulse ──────────────────────────────────────────────────── */
.node-pulse {
  animation: nodePulse 500ms ease-out;
}

@keyframes nodePulse {
  0%   { r: 38; opacity: 0.6; }
  100% { r: 56; opacity: 0; }
}

/* ── Transaction Log ────────────────────────────────────────────── */
.event-feed {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* ── Narrative Banner ────────────────────────────────────────────── */
.dashboard-grid__narrative {
  padding: var(--sp-2) var(--sp-4);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  border-left: 3px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.02);
  border-radius: var(--radius-sm);
  transition: all 300ms ease;
}

.dashboard-grid__narrative--warning {
  border-left-color: var(--warning);
  color: var(--warning);
  background: rgba(245, 158, 11, 0.06);
}

.dashboard-grid__narrative--danger {
  border-left-color: var(--danger);
  color: var(--danger);
  background: rgba(239, 68, 68, 0.06);
}

.dashboard-grid__narrative--success {
  border-left-color: var(--success);
  color: var(--success);
  background: rgba(34, 197, 94, 0.06);
}

/* ── Controls Action + Hint ─────────────────────────────────────── */
.controls__action {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 2px var(--sp-1);
}

.controls__action .btn {
  justify-content: center;
}

.controls__action .controls__hint {
  flex-basis: 100%;
  text-align: center;
}

.controls__hint {
  font-size: var(--text-2xs);
  color: var(--text-muted);
  white-space: nowrap;
}

/* ── COBOL Live Ticker ──────────────────────────────────────────── */
.cobol-ticker {
  flex: 1 1 0;
  min-height: 200px;
  display: flex;
  flex-direction: column;
}

.cobol-ticker__header {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-4);
  border-bottom: 1px solid var(--glass-border);
}

.cobol-ticker__file {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--text-accent);
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 2px;
  cursor: pointer;
  transition: color var(--transition-fast);
}

.cobol-ticker__file:hover {
  color: #93c5fd;
}

.cobol-term {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-2) var(--sp-3);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  line-height: 1.5;
  white-space: pre;
  tab-size: 4;
  min-height: 0;
}

.cobol-term__entry {
  border-left: 2px solid rgba(255, 255, 255, 0.06);
  padding-left: var(--sp-2);
  margin-bottom: var(--sp-1);
}

.cobol-term__header {
  color: var(--text-accent);
  font-size: var(--text-2xs);
  font-weight: 600;
  white-space: nowrap;
}

.cobol-term__code {
  color: var(--text-secondary);
  font-size: var(--text-xs);
  line-height: 1.4;
}

/* ── COBOL Full-File Modal ──────────────────────────────────────── */
.popup--wide {
  max-width: 900px;
  width: 90vw;
}

.cobol-modal__source {
  max-height: 60vh;
  overflow: auto;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  line-height: 1.6;
  white-space: pre;
  tab-size: 4;
}

/* ── COBOL Syntax Highlighting ───────────────────────────────────── */
.cobol-kw   { color: #c084fc; font-weight: 600; }     /* Keywords — purple */
.cobol-div  { color: #22d3ee; font-weight: 700; }     /* Divisions — cyan */
.cobol-str  { color: #4ade80; }                        /* Strings — green */
.cobol-num  { color: #fb923c; }                        /* Numbers — orange */
.cobol-cmt  { color: #64748b; font-style: italic; }   /* Comments — gray */
.cobol-para { color: #e2e8f0; font-weight: 600; }     /* Paragraph names */

.cobol-highlight {
  background: rgba(59, 130, 246, 0.12);
  border-left: 3px solid var(--bank-a);
  margin-left: -3px;
  display: block;
}

/* ── Node Detail Popup ───────────────────────────────────────────── */
.node-detail__header {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.node-detail__color {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.node-detail__name {
  font-family: var(--font-mono);
  font-size: var(--text-lg);
  font-weight: 600;
}

/* ── Node Ring (unified health + identity) ─────────────────────── */
.node-ring {
  transition: stroke 400ms ease, filter 400ms ease;
}

.node-ring--valid {
  filter: url(#glow-health-valid);
}

.node-ring--broken {
  filter: url(#glow-health-broken);
}

/* ── Event Feed — Structured Grid Items ─────────────────────────── */
.feed__item {
  display: grid;
  grid-template-columns: 28px 32px 1fr auto;
  gap: var(--sp-2);
  align-items: center;
  padding: var(--sp-1) var(--sp-3);
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  animation: feedSlideIn 200ms ease-out;
}

@keyframes feedSlideIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.feed__item--deposit    { border-left: 5px solid #22c55e; background: rgba(34, 197, 94, 0.04); }
.feed__item--withdraw   { border-left: 5px solid #ef4444; background: rgba(239, 68, 68, 0.04); }
.feed__item--transfer   { border-left: 5px solid #3b82f6; background: rgba(59, 130, 246, 0.04); }
.feed__item--settlement { border-left: 5px solid #a855f7; background: rgba(168, 85, 247, 0.04); }
.feed__item--scenario   { border-left: 5px solid #f59e0b; background: rgba(245, 158, 11, 0.06); }
.feed__item--error      { border-left: 5px solid #ef4444; background: rgba(239, 68, 68, 0.06); }
.feed__item--default    { border-left: 5px solid var(--glass-border); }

.feed__day {
  font-size: var(--text-2xs);
  color: var(--text-muted);
  text-align: center;
}

.feed__type {
  font-size: var(--text-2xs);
  font-weight: 700;
  text-align: center;
  padding: 2px 5px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.06);
  letter-spacing: 0.04em;
}

.feed__type--deposit    { color: #22c55e; }
.feed__type--withdraw   { color: #ef4444; }
.feed__type--transfer   { color: #3b82f6; }
.feed__type--settlement { color: #a855f7; }
.feed__type--scenario   { color: #f59e0b; }
.feed__type--error      { color: #ef4444; }
.feed__type--default    { color: var(--text-muted); }

.feed__details {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-secondary);
}

.feed__status { font-weight: 600; }
.feed__status--ok   { color: #22c55e; }
.feed__status--fail { color: #ef4444; }

.node-detail__chain {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-top: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-family: var(--font-mono);
}

/* ── Feed Split (Outgoing / Incoming) ──────────────────────────── */
.feed-split {
  display: grid;
  grid-template-columns: 1fr 1px 1fr;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.feed-split__panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.feed-split__label {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-1) var(--sp-3);
  font-family: var(--font-mono);
  font-size: var(--text-2xs);
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--glass-border);
}

.feed-split__icon {
  font-size: 0.75rem;
}

.feed-split__icon--out { color: #ef4444; }
.feed-split__icon--in  { color: #22c55e; }

.feed-split__list {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.feed-split__divider {
  background: var(--glass-border);
}

/* Scenario banners span both columns */
.feed__item--scenario-banner {
  grid-column: 1 / -1;
}

/* ── Ring Pulse Animation (Integrity Check) ──────────────────── */
@keyframes ringPulse {
  0%   { opacity: 0.8; }
  50%  { opacity: 0.3; }
  100% { opacity: 0.8; }
}

.node-ring--checking {
  animation: ringPulse 600ms ease-in-out infinite;
}

/* ── System Events Panel ─────────────────────────────────────── */
.feed-system {
  max-height: 120px;
  overflow-y: auto;
  border-bottom: 1px solid var(--glass-border);
}

.feed-system__label {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-1) var(--sp-3);
  font-family: var(--font-mono);
  font-size: var(--text-2xs);
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--glass-border);
}

.feed-system__icon {
  font-size: 0.75rem;
  color: #f59e0b;
}

/* (old .cobol-ticker__entry styles removed — replaced by viewport + log) */

@media (max-width: 1200px) {
  .feed-split {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 1px 1fr;
  }
  .feed-split__divider {
    height: 1px;
    width: 100%;
  }
}
