@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@300;400;600;700;800&family=Inter:wght@300;400;600;700&family=JetBrains+Mono:wght@300;400;700&display=swap');

:root {
  /* EDTECH Design System Palette */
  --edtech-bg: #0F1520;
  --edtech-panel: #1A2332;
  --edtech-border: #2A3A50;
  --edtech-border-hover: #3A5A80;
  --edtech-text: #E2E8F0;
  --edtech-text-muted: #94A3B8;
  --edtech-accent: #00E5FF; /* Cyber-Teal */
  --edtech-accent-hover: #00B8D9;
  
  --font-ui: 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

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

body {
  font-family: var(--font-ui);
  background: var(--edtech-bg);
  color: var(--edtech-text);
  height: 100vh;
  margin: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.app-header {
  background: var(--edtech-panel);
  padding: 0.8rem 1.2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--edtech-border);
  position: sticky;
  top: 0;
  z-index: 100;
  flex-shrink: 0;
}

.app-header h1 {
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.02em;
}

.controls { display: flex; gap: 0.6rem; align-items: center; }
.file-input { display: none; }

.btn {
  padding: 0.5rem 1rem;
  border-radius: 4px; /* Modern Sharp */
  font-weight: 600;
  font-size: 0.8rem;
  cursor: pointer;
  border: none;
  font-family: var(--font-ui);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.btn-primary {
  background: var(--edtech-accent);
  color: #000;
}

.btn-primary:hover {
  background: var(--edtech-accent-hover);
}

.btn-secondary {
  background: #3B82F6; /* Standard action */
  color: #fff;
}

.btn-secondary:disabled {
  background: #334155;
  color: #64748B;
  cursor: not-allowed;
}

.btn-toggle {
  background: var(--edtech-panel);
  color: var(--edtech-text-muted);
  border: 1px solid var(--edtech-border);
}

.btn-toggle:hover {
  background: var(--edtech-border);
  color: #fff;
}

.btn-toggle.active {
  background: var(--edtech-accent);
  color: #000;
  border-color: var(--edtech-accent);
}

.app-body {
  flex: 1;
  display: flex;
  overflow: hidden;
  height: calc(100vh - 54px); /* Viewport minus header height approximately */
}

/* LEFT PANEL (Settings) */
.settings-panel {
  width: 280px;
  flex-shrink: 0;
  min-height: 0; /* Critical for flex child scrolling */
  background: var(--edtech-panel);
  border-right: 1px solid var(--edtech-border);
  overflow-y: auto;
  overflow-x: hidden;
  transition: margin-left 0.3s ease;
}
.settings-panel.hidden { margin-left: -280px; }

.panel-inner { padding: 0.8rem; }
.panel-inner h2 {
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 0.8rem;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
}

details {
  margin-bottom: 0.5rem;
  background: var(--edtech-bg);
  border-radius: 4px;
  border: 1px solid var(--edtech-border);
}
details[open] { border-color: var(--edtech-border-hover); }

summary {
  padding: 0.5rem 0.6rem;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--edtech-text);
  user-select: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
summary svg {
  color: var(--edtech-primary);
}
summary:hover { color: #fff; }

.setting-group {
  padding: 0.4rem 0.6rem 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.setting-group label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  color: var(--edtech-text-muted);
  gap: 0.5rem;
}

.setting-group input[type="number"], .setting-group select, .setting-group input[type="text"] {
  font-family: var(--font-mono);
  background: var(--edtech-panel);
  border: 1px solid var(--edtech-border);
  border-radius: 3px;
  color: #fff;
  font-size: 0.75rem;
  padding: 0.35rem;
  transition: border-color 0.2s;
}
.setting-group input[type="number"]:focus, .setting-group select:focus, .setting-group input[type="text"]:focus {
  outline: none;
  border-color: var(--edtech-accent);
}
.setting-group input[type="number"] { width: 60px; text-align: center; }
.setting-group input[type="text"] { width: 70px; text-transform: uppercase; }
.setting-group select { flex: 1; }

.color-hex-group {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.setting-group input[type="color"] {
  width: 32px;
  height: 26px;
  border: 1px solid var(--edtech-border);
  border-radius: 3px;
  background: none;
  cursor: pointer;
  padding: 0;
}

.btn-apply {
  width: 100%;
  margin-top: 0.8rem;
  background: var(--edtech-border);
  color: #fff;
  padding: 0.6rem;
  border: 1px solid transparent;
}
.btn-apply:hover { background: var(--edtech-border-hover); }

.btn-reset {
  width: 100%;
  margin-top: 0.4rem;
  background: transparent;
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.3);
  padding: 0.5rem;
  font-size: 0.8rem;
}
.btn-reset:hover { background: rgba(239, 68, 68, 0.1); color: #f87171; }

.config-io { display: flex; gap: 0.4rem; margin-top: 0.6rem; }
.btn-io {
  flex: 1;
  text-align: center;
  background: var(--edtech-panel);
  color: var(--edtech-text-muted);
  border: 1px solid var(--edtech-border);
  padding: 0.45rem 0.5rem;
  font-size: 0.75rem;
  cursor: pointer;
}
.btn-io:hover { color: #fff; border-color: var(--edtech-text-muted); }

/* RIGHT PANEL (Canvas) */
.app-main {
  flex: 1;
  min-height: 0; /* Critical for flex child scrolling */
  overflow: auto;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  background: #090D14; /* Darker working area */
  background-image: radial-gradient(#1A2332 1px, transparent 1px);
  background-size: 20px 20px;
}
.app-main > .canvas-wrapper,
.app-main > .placeholder {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 2rem;
}

.canvas-wrapper {
  border-radius: 4px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
  overflow: visible;
  border: 1px solid var(--edtech-border);
  transition: transform 0.15s ease;
  transform-origin: top center;
  width: fit-content;
  max-width: 100%;
}

/* Remove wrapper styles when showing the placeholder drop-zone */
.canvas-wrapper:has(.placeholder) {
  border: none;
  box-shadow: none;
  background: transparent;
  width: auto;
}

.diagram-container {
  background: transparent; 
  display: inline-block;
  line-height: 0; /* Remove gap below inline SVG */
}

.placeholder {
  color: var(--edtech-text-muted);
  text-align: center;
  font-size: 1.05rem;
  line-height: 1.5;
  margin-top: 15vh;
  padding: 3rem 4rem;
  background: var(--edtech-panel);
  border: 2px dashed var(--edtech-border);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  max-width: 500px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}
.placeholder svg {
  color: var(--edtech-border-hover);
  margin-bottom: 0.5rem;
}
.placeholder span {
  font-size: 0.85rem;
  opacity: 0.7;
}

/* Scrollbars */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--edtech-bg); }
::-webkit-scrollbar-thumb { background: var(--edtech-border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover {
  background: var(--edtech-border-hover);
}

/* FOOTER */
.app-footer {
  position: fixed;
  bottom: 0;
  right: 0;
  padding: 0.5rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.7rem;
  color: var(--edtech-text-muted);
  opacity: 0.6;
  transition: opacity 0.2s;
  pointer-events: none; /* Let clicks pass through if needed */
  z-index: 50;
}
.app-footer:hover {
  opacity: 1;
}
.app-footer strong {
  color: var(--edtech-accent);
  font-weight: 700;
  letter-spacing: 0.05em;
}
.app-footer svg {
  color: var(--edtech-accent);
}

/* ========================================================================
   MODAL (INTERACTIVE NODE EDITOR)
   ======================================================================== */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(9, 13, 20, 0.85);
  backdrop-filter: blur(4px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  opacity: 1;
  transition: opacity 0.2s ease;
}
.modal-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.modal-content {
  background: var(--edtech-panel);
  border: 1px solid var(--edtech-border);
  border-radius: 6px;
  width: 400px;
  max-width: 90%;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
}

.modal-header {
  padding: 1rem 1.2rem;
  border-bottom: 1px solid var(--edtech-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-header h3 {
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.btn-close {
  background: none;
  border: none;
  color: var(--edtech-text-muted);
  cursor: pointer;
  padding: 0.2rem;
  display: flex;
}
.btn-close:hover { color: #fff; }

.modal-body {
  padding: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.form-group label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--edtech-text-muted);
}
.form-input {
  background: var(--edtech-bg);
  border: 1px solid var(--edtech-border);
  padding: 0.6rem;
  border-radius: 4px;
  color: #fff;
  font-family: var(--font-ui);
  font-size: 0.85rem;
  resize: vertical;
}
.form-input:focus {
  outline: none;
  border-color: var(--edtech-accent);
}

.color-picker-row {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  justify-content: space-between;
}
.color-swatches {
  display: flex;
  gap: 0.6rem;
}
.color-swatch {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.2s, border-color 0.2s;
}
.color-swatch:hover {
  transform: scale(1.1);
}
.color-swatch.active {
  border-color: #fff;
  box-shadow: 0 0 8px rgba(255,255,255,0.4);
}
.btn-small {
  padding: 0.4rem 0.8rem;
  font-size: 0.75rem;
  flex: 1;
}

/* ── RIGHT SIDEBAR EDITOR ── */
.editor-sidebar {
  width: 420px;
  flex-shrink: 0;
  min-height: 0;
  background: var(--edtech-panel);
  border-left: 1px solid var(--edtech-border);
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  transition: margin-right 0.3s ease;
}
.editor-sidebar.hidden {
  margin-right: -320px;
}
.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}
.sidebar-header h2 {
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0;
  display: flex;
  align-items: center;
}
.btn-close {
  background: none;
  border: none;
  color: var(--edtech-text-muted);
  cursor: pointer;
  padding: 0.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all 0.2s ease;
}
.btn-close:hover {
  color: #fff;
  background: var(--edtech-border);
}
.sidebar-body {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  flex: 1;
}
.sidebar-footer {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--edtech-border);
}
.sidebar-separator {
  border: 0;
  height: 1px;
  background: var(--edtech-border);
  margin: 0.5rem 0;
}

/* ── OUTLINE LIST STYLES ── */
.outline-body {
  padding: 0.4rem;
  padding-bottom: 2rem;
}
.structure-group {
  margin-bottom: 0.2rem;
}
.structure-group-title {
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--edtech-text-muted);
  font-weight: 700;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.structure-card {
  background: var(--edtech-bg);
  border: 1px solid var(--edtech-border);
  border-radius: 4px;
  padding: 0.2rem 0.3rem;
  margin-bottom: 0.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  transition: border-color 0.2s;
}
.structure-card:focus-within {
  border-color: var(--edtech-accent);
}
.structure-card.highlight-card {
  border-color: var(--edtech-accent);
  box-shadow: 0 0 12px rgba(0, 212, 255, 0.3);
  background: rgba(0, 212, 255, 0.08);
}
.structure-card input[type="text"],
.structure-card textarea,
.structure-card select {
  width: 100%;
  background: transparent;
  border: 1px solid transparent;
  color: #fff;
  font-family: var(--font-ui);
  padding: 0.1rem 0.2rem;
  border-radius: 3px;
  transition: background 0.2s, border-color 0.2s;
}
.structure-card input[type="text"] {
  font-weight: 600;
  font-size: 0.8rem;
}
.structure-card textarea {
  font-size: 0.75rem;
  color: var(--edtech-text-muted);
  resize: vertical;
  min-height: 28px;
  line-height: 1.4;
}
.structure-card input[type="text"]:focus,
.structure-card textarea:focus {
  outline: none;
  background: rgba(0,0,0,0.2);
  border-color: var(--edtech-border);
  color: #fff;
}
.structure-card select {
  font-size: 0.7rem;
  color: var(--edtech-text-muted);
  cursor: pointer;
  background: var(--edtech-panel);
  border: 1px solid var(--edtech-border);
  margin-top: 0.1rem;
}
.btn-icon {
  background: none;
  border: none;
  color: var(--edtech-text-muted);
  cursor: pointer;
  padding: 0.2rem;
  display: flex;
  align-items: center;
  transition: color 0.2s;
}
.btn-icon:hover { color: #fff; }
.btn-icon.danger:hover { color: #ef4444; }

/* ── FIELD ROW (title/subtitle + eye toggle) ── */
.field-row {
  display: flex;
  align-items: flex-start;
  gap: 0.15rem;
}
.field-row input,
.field-row textarea {
  flex: 1;
  min-width: 0;
}
.field-row .toggle-field-btn {
  flex-shrink: 0;
  margin-top: 0.15rem;
  opacity: 0.4;
  transition: opacity 0.2s;
}
.field-row .toggle-field-btn:hover {
  opacity: 1;
}
.field-row.field-hidden input,
.field-row.field-hidden textarea {
  text-decoration: line-through;
  opacity: 0.35;
}
.field-row.field-hidden .toggle-field-btn {
  opacity: 0.7;
  color: #ef4444;
}

/* ── COLLAPSIBLE CARD BODY ── */
.card-collapsible-body {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  overflow: hidden;
  max-height: 500px; /* large enough for any content */
  transition: max-height 0.25s ease, opacity 0.2s ease;
  opacity: 1;
}
.structure-card.is-collapsed .card-collapsible-body {
  max-height: 0;
  opacity: 0;
  margin: 0;
}
.card-collapse-btn svg {
  transition: transform 0.25s ease;
}
.structure-card.is-collapsed .card-collapse-btn svg {
  transform: rotate(-90deg);
}

.structure-children {
  margin-left: 0.4rem;
  padding-left: 0.4rem;
  border-left: 2px solid var(--edtech-border);
  margin-bottom: 0.2rem;
}
.structure-children .structure-card {
  background: rgba(0,0,0,0.1); /* Slightly darker for nested */
}

/* ── HIDDEN STATE MODIFIERS ── */
.structure-card.is-hidden {
  opacity: 0.4;
  border: 1px dashed var(--edtech-text-muted);
  background: transparent;
}
.structure-card.is-hidden input,
.structure-card.is-hidden textarea {
  text-decoration: line-through;
  color: var(--edtech-text-muted);
}
.structure-card.is-hidden .btn-icon.danger {
  color: var(--edtech-text); /* Revert from red when hidden to indicate toggle */
}

/* ── CANVAS TABS ── */
.canvas-tabs {
  display: flex;
  gap: 0;
  background: var(--edtech-panel);
  border-bottom: 1px solid var(--edtech-border);
  padding: 0 1rem;
  flex-shrink: 0;
  overflow-x: auto;
}
.hito-tabs {
  border-bottom: 2px solid var(--edtech-accent);
  background: linear-gradient(180deg, var(--edtech-panel) 0%, rgba(0,229,255,0.03) 100%);
}
.hito-tabs .tab-btn {
  font-size: 0.85rem;
  padding: 0.7rem 1.1rem;
}
.tab-btn {
  padding: 0.6rem 1rem;
  border: none;
  background: transparent;
  color: var(--edtech-text-muted);
  font-family: var(--font-ui);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
}
.tab-btn:hover {
  color: #fff;
  background: rgba(255,255,255,0.04);
}
.tab-btn.active {
  color: var(--edtech-accent);
  border-bottom-color: var(--edtech-accent);
  background: rgba(0, 229, 255, 0.06);
}

/* ── TAB REVIEW INDICATORS ── */
.tab-review-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  font-size: 0.6rem;
  font-weight: 800;
  margin-left: 4px;
  vertical-align: middle;
  line-height: 1;
}
.tab-review-dot.warn {
  background: rgba(245, 158, 11, 0.25);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.4);
  animation: review-pulse 2s ease-in-out infinite;
}
.tab-review-dot.ok {
  background: rgba(34, 197, 94, 0.2);
  color: #22c55e;
  border: 1px solid rgba(34, 197, 94, 0.3);
}
@keyframes review-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ── ZOOM CONTROLS ── */
.zoom-controls {
  position: fixed;
  bottom: 1.2rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--edtech-panel);
  border: 1px solid var(--edtech-border);
  border-radius: 6px;
  padding: 3px;
  z-index: 90;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}
.zoom-btn {
  background: none;
  border: none;
  color: var(--edtech-text-muted);
  cursor: pointer;
  padding: 0.35rem 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all 0.15s ease;
  font-family: var(--font-mono);
  font-size: 0.75rem;
}
.zoom-btn:hover {
  color: #fff;
  background: var(--edtech-border);
}
.zoom-btn.zoom-label {
  min-width: 48px;
  font-weight: 600;
  color: var(--edtech-text);
  cursor: pointer;
}

/* Header separator between button groups */
.header-separator {
  width: 1px;
  height: 24px;
  background: var(--edtech-border);
  flex-shrink: 0;
}
