/* =========================
   ROOT & GLOBAL
========================= */
:root {
  --bg-main: #0b0f14;
  --bg-panel: rgba(20, 25, 35, 0.55);
  --bg-panel-solid: #141923;

  --accent-cyan: #3ef3d3;
  --accent-green: #38e8a8;
  --accent-yellow: #facc15;
  --accent-red: #ef4444;

  --text-primary: #e5e7eb;
  --text-secondary: #9ca3af;

  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-blur: blur(18px);

  --radius-lg: 18px;
  --radius-md: 14px;

  --transition: 0.35s ease;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Inter', sans-serif;
  background: radial-gradient(
      circle at 20% 20%,
      rgba(62, 243, 211, 0.08),
      transparent 40%
    ),
    radial-gradient(
      circle at 80% 80%,
      rgba(56, 232, 168, 0.06),
      transparent 40%
    ),
    var(--bg-main);
  color: var(--text-primary);
  min-height: 100vh;
}

/* =========================
   PAGE CONTAINER
========================= */
.ledger-container {
  padding: 32px;
  max-width: 1600px;
  margin: 0 auto;
}

/* =========================
   HEADER
========================= */
.ledger-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 28px;
}

.ledger-header h1 {
  margin: 0;
  font-size: 32px;
  font-weight: 600;
}

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

.header-right {
  display: flex;
  gap: 14px;
  align-items: center;
}

.status-indicator {
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
}

.status-indicator.ready {
  background: rgba(56, 232, 168, 0.15);
  color: var(--accent-green);
  border: 1px solid rgba(56, 232, 168, 0.35);
}

.status-indicator.conditional {
  background: rgba(250, 204, 21, 0.15);
  color: var(--accent-yellow);
  border: 1px solid rgba(250, 204, 21, 0.35);
}

.export-btn {
  background: linear-gradient(
    135deg,
    var(--accent-cyan),
    var(--accent-green)
  );
  color: #04110d;
  border: none;
  padding: 8px 16px;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.export-btn:hover {
  opacity: 0.85;
}

/* Guided Demo button (Phase 5) */
.guided-demo-btn {
  padding: 6px 12px;
  font-size: 13px;
  background: transparent;
  border: 1px solid var(--glass-border);
  color: var(--text-secondary);
  border-radius: 8px;
  cursor: pointer;
  transition: var(--transition);
}

.guided-demo-btn:hover {
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
}

/* Demo highlight (presentation only) */
.panel.demo-highlight {
  box-shadow: 0 0 0 2px var(--accent-cyan), 0 0 24px rgba(62, 243, 211, 0.2);
  transition: box-shadow 0.3s ease;
}

/* Inline explanation overlay */
.ledger-explanation {
  position: fixed;
  max-width: 320px;
  padding: 12px 14px;
  background: var(--bg-panel-solid);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  font-size: 13px;
  color: var(--text-primary);
  line-height: 1.5;
  z-index: 200;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.ledger-explanation .ledger-explanation-dismiss {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 24px;
  height: 24px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}

.ledger-explanation .ledger-explanation-dismiss:hover {
  color: var(--text-primary);
}

body.ledger-rtl .ledger-explanation .ledger-explanation-dismiss {
  right: auto;
  left: 8px;
}

/* =========================
   GRID LAYOUT
========================= */
.ledger-grid {
  display: grid;
  grid-template-columns: 40% 35% 25%;
  gap: 20px;
  margin-bottom: 24px;
}

/* =========================
   PANELS (GLASS)
========================= */
.panel {
  background: var(--bg-panel);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  position: relative;
}

.panel h2 {
  margin: 0 0 14px 0;
  font-size: 16px;
  font-weight: 500;
  color: var(--text-primary);
}

/* =========================
   CHART PLACEHOLDERS
========================= */
.chart-container {
  height: 260px;
  border-radius: var(--radius-md);
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.03),
    rgba(255, 255, 255, 0)
  );
  border: 1px dashed rgba(255, 255, 255, 0.08);
}

/* =========================
   LOADING & ERROR (non-blocking)
========================= */
.ledger-loading,
.ledger-error {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 120px;
  padding: 16px;
  font-size: 13px;
  color: var(--text-secondary);
  text-align: center;
}

.ledger-error {
  color: var(--accent-red);
}

/* =========================
   TIMELINE (JS-injected nodes)
========================= */
#decisionTimeline {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 8px 0;
}

.timeline-node {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: rgba(20, 25, 35, 0.6);
  border: 1px solid var(--glass-border);
  cursor: pointer;
  transition: var(--transition);
}

.timeline-node:hover {
  border-color: rgba(62, 243, 211, 0.3);
  background: rgba(62, 243, 211, 0.06);
}

.timeline-node .node-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.timeline-node.green .node-dot {
  background: var(--accent-green);
  box-shadow: 0 0 10px rgba(56, 232, 168, 0.4);
}

.timeline-node.yellow .node-dot {
  background: var(--accent-yellow);
  box-shadow: 0 0 10px rgba(250, 204, 21, 0.4);
}

.timeline-node.red .node-dot {
  background: var(--accent-red);
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.4);
}

.timeline-node .node-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}

/* =========================
   INTENT VS OUTCOME
========================= */
.intent-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.intent-card {
  background: rgba(20, 25, 35, 0.75);
  border-radius: var(--radius-md);
  padding: 14px;
  border: 1px solid var(--glass-border);
}

.intent-card h3 {
  margin-top: 0;
  font-size: 14px;
  margin-bottom: 10px;
}

.intent-card ul {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 13px;
  color: var(--text-secondary);
}

.intent-card li {
  margin-bottom: 6px;
}

.alignment-indicator {
  margin-top: 14px;
  padding: 8px;
  text-align: center;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
}

.alignment-indicator.aligned {
  background: rgba(56, 232, 168, 0.12);
  color: var(--accent-green);
}

/* =========================
   AUDIT READINESS
========================= */
.audit-panel {
  display: flex;
  gap: 24px;
  align-items: center;
}

.audit-meter {
  display: flex;
  gap: 20px;
  align-items: center;
}

.meter-circle {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: conic-gradient(
    var(--accent-green) 0deg,
    var(--accent-green) 331deg,
    rgba(255, 255, 255, 0.08) 331deg
  );
  display: flex;
  align-items: center;
  justify-content: center;
}

.meter-value {
  font-size: 22px;
  font-weight: 600;
}

.meter-details ul {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 13px;
  color: var(--text-secondary);
}

.meter-details li {
  margin-bottom: 6px;
}

/* =========================
   MODAL
========================= */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 12, 0.75);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: var(--bg-panel-solid);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 520px;
  max-width: calc(100vw - 32px);
  border: 1px solid var(--glass-border);
  position: relative;
}

.modal-content h2 {
  margin: 0 0 16px 0;
  font-size: 18px;
  font-weight: 600;
}

.close-modal {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 20px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.close-modal:hover {
  color: var(--text-primary);
}

/* Reason graph preview (JS-injected) */
.reason-graph-preview {
  margin-top: 12px;
  padding: 16px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: var(--radius-md);
  border: 1px solid var(--glass-border);
}

.graph-node {
  padding: 10px 14px;
  font-size: 13px;
  color: var(--text-secondary);
  background: rgba(20, 25, 35, 0.8);
  border-radius: 8px;
  border: 1px solid var(--glass-border);
  margin-bottom: 8px;
}

.graph-node.highlight {
  color: var(--accent-green);
  border-color: rgba(56, 232, 168, 0.35);
  background: rgba(56, 232, 168, 0.08);
}

.graph-arrow {
  text-align: center;
  font-size: 16px;
  color: var(--accent-cyan);
  margin: 4px 0;
}

/* Reason Graph 3D container (no change to existing IDs/classes) */
#reason-graph-3d-container {
  width: 100%;
  height: 280px;
  position: relative;
  background: rgba(0, 0, 0, 0.3);
  border-radius: var(--radius-md);
  overflow: hidden;
}

#reason-graph-3d-container canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* =========================
   RESPONSIVE
========================= */
@media (max-width: 1200px) {
  .ledger-grid {
    grid-template-columns: 1fr;
  }

  .audit-panel {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 768px) {
  .ledger-container {
    padding: 16px;
  }

  .ledger-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }

  .ledger-header h1 {
    font-size: 24px;
  }

  .header-right {
    width: 100%;
    flex-wrap: wrap;
  }

  .intent-cards {
    grid-template-columns: 1fr;
  }

  .chart-container {
    height: 220px;
  }

  .audit-meter {
    flex-direction: column;
    align-items: flex-start;
  }
}
