/* ================================================================
   Diagram Theme — Enhanced Mermaid Visibility for Classroom Projection
   ================================================================
   - 18px+ fonts for classroom readability
   - High-contrast colors (dark backgrounds, bright nodes)
   - classDef-based reusable styles
   - 120% default zoom
   - Titles/badges on diagrams
   - fit-to-screen helper
   ================================================================ */

/* --------------------------------------------------
   Diagram Container (shared across all pages)
   -------------------------------------------------- */
.diagram-wrapper {
  position: relative;
  background: #0f172a;
  border: 2px solid #334155;
  border-radius: 16px;
  padding: 1.5rem;
  margin: 1.5rem 0;
  overflow: hidden;
  min-height: 300px;
}

.diagram-title {
  text-align: center;
  font-size: 1.3rem;
  font-weight: 800;
  color: #f8fafc;
  margin-bottom: 1rem;
  letter-spacing: 0.02em;
}

.diagram-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  background: #6366f1;
  color: #fff;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  z-index: 10;
  box-shadow: 0 2px 8px rgba(99,102,241,0.4);
}

.diagram-note {
  background: #1e293b;
  border-left: 4px solid #f59e0b;
  color: #fde68a;
  padding: 0.6rem 1rem;
  border-radius: 0 8px 8px 0;
  font-size: 0.85rem;
  margin-top: 1rem;
  line-height: 1.5;
}

.diagram-note strong {
  color: #f59e0b;
}

/* --------------------------------------------------
   Mermaid SVG — 18px+ fonts for classroom
   -------------------------------------------------- */
.diagram-wrapper .mermaid {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 220px;
  overflow: auto;
}

.diagram-wrapper svg {
  max-width: 100%;
  height: auto;
  zoom: 1.2;
  font-size: 18px;
}

/* Ensure all text inside diagrams uses large fonts */
.diagram-wrapper .mermaid text,
.diagram-wrapper .mermaid tspan,
.diagram-wrapper svg text,
.diagram-wrapper svg tspan {
  font-size: 18px !important;
  font-family: 'Segoe UI', Roboto, system-ui, sans-serif !important;
}

.diagram-wrapper .mermaid .nodeLabel,
.diagram-wrapper svg .nodeLabel {
  font-size: 18px !important;
}

.diagram-wrapper .mermaid .edgeLabel,
.diagram-wrapper svg .edgeLabel {
  font-size: 16px !important;
}

/* --------------------------------------------------
   Zoom Controls
   -------------------------------------------------- */
.diagram-controls {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  gap: 4px;
  z-index: 10;
}

.diagram-controls button {
  background: #1e293b;
  color: #e2e8f0;
  border: 1px solid #475569;
  border-radius: 8px;
  width: 32px;
  height: 32px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.diagram-controls button:hover {
  background: #334155;
}

.diagram-controls button:active {
  background: #475569;
}

/* --------------------------------------------------
   High-Contrast ClassDef Styles (Mermaid)
   --------------------------------------------------
   Use these in Mermaid classDef declarations:
   classDef decision fill:#6366f1,stroke:#818cf8,color:#fff,font-size:18px,font-weight:bold
   classDef process fill:#0ea5e9,stroke:#38bdf8,color:#fff,font-size:18px,font-weight:bold
   classDef success fill:#22c55e,stroke:#4ade80,color:#fff,font-size:18px,font-weight:bold
   classDef warning fill:#f59e0b,stroke:#fbbf24,color:#1e1b4b,font-size:18px,font-weight:bold
   classDef error fill:#ef4444,stroke:#f87171,color:#fff,font-size:18px,font-weight:bold
   classDef info fill:#8b5cf6,stroke:#a78bfa,color:#fff,font-size:18px,font-weight:bold
   classDef dark fill:#1e293b,stroke:#64748b,color:#f1f5f9,font-size:18px,font-weight:bold
   classDef highlight fill:#ec4899,stroke:#f472b6,color:#fff,font-size:18px,font-weight:bold
   -------------------------------------------------- */

/* --------------------------------------------------
   Diagram Color Scheme (Dark Theme for Classroom)
   -------------------------------------------------- */
.diagram-wrapper .mermaid .node rect,
.diagram-wrapper .mermaid .node circle,
.diagram-wrapper .mermaid .node polygon {
  stroke-width: 2px;
}

.diagram-wrapper .mermaid .edgePath .path {
  stroke: #94a3b8;
  stroke-width: 2px;
}

.diagram-wrapper .mermaid .edgePath .marker {
  fill: #94a3b8;
}

.diagram-wrapper .mermaid .cluster rect {
  fill: #1e293b;
  stroke: #475569;
  stroke-width: 2px;
}

/* --------------------------------------------------
   Responsive: Mobile fallback
   -------------------------------------------------- */
@media (max-width: 768px) {
  .diagram-wrapper {
    padding: 0.8rem;
    border-radius: 10px;
    min-height: 200px;
  }

  .diagram-wrapper svg {
    zoom: 1;
  }

  .diagram-title {
    font-size: 1.1rem;
  }

  .diagram-controls button {
    width: 28px;
    height: 28px;
    font-size: 0.85rem;
  }
}

/* --------------------------------------------------
   Print Styles (hide zoom controls, expand diagram)
   -------------------------------------------------- */
@media print {
  .diagram-controls { display: none !important; }
  .diagram-wrapper { border: 1px solid #ccc; padding: 1rem; break-inside: avoid; }
  .diagram-wrapper svg { zoom: 1; }
}
