/* public/teach.css */

/* ── Layout ─────────────────────────────────────────────────────────────── */
.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--surface-border);
  background: rgba(20, 26, 26, 0.9);
  backdrop-filter: blur(8px);
  flex-shrink: 0;
  gap: 12px;
  z-index: 10;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.workspace {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
.sidebar {
  width: 280px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--surface-border);
  background: rgba(20, 26, 26, 0.6);
  overflow: hidden;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--surface-border);
  flex-shrink: 0;
}

.sidebar-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.tree {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.tree-node {
  position: relative;
}

.tree-node-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  cursor: pointer;
  border-radius: 0;
  transition: background 0.15s;
  user-select: none;
}

.tree-node-row:hover {
  background: var(--accent-soft);
}

.tree-node-row.selected {
  background: rgba(92, 158, 161, 0.2);
  border-left: 2px solid var(--accent);
}

.tree-node-row.drag-over {
  background: rgba(92, 158, 161, 0.35);
}

.tree-indent {
  flex-shrink: 0;
}

.tree-arrow {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--muted);
  transition: transform 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tree-arrow.open {
  transform: rotate(90deg);
}

.tree-arrow.leaf {
  opacity: 0;
  pointer-events: none;
}

.tree-node-name {
  flex: 1;
  font-size: 13.5px;
  font-weight: 400;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tree-node-depth-0 > .tree-node-row .tree-node-name {
  font-weight: 600;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
}

.tree-node-depth-1 > .tree-node-row .tree-node-name {
  font-weight: 500;
}

.tree-edit-actions {
  display: none;
  gap: 4px;
  flex-shrink: 0;
}

.edit-mode .tree-edit-actions {
  display: flex;
}

.drag-handle {
  cursor: grab;
  color: var(--muted);
  opacity: 0.5;
  flex-shrink: 0;
  display: none;
}

.edit-mode .drag-handle {
  display: flex;
  align-items: center;
}

.tree-children {
  /* children are shown/hidden via JS adding/removing class */
}

.tree-children.collapsed {
  display: none;
}

.tree-mat-list {
  padding: 2px 0 4px;
}

.tree-mat-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px 4px 32px;
  cursor: pointer;
  font-size: 12.5px;
  color: var(--muted);
  transition: background 0.12s;
}

.tree-mat-item:hover {
  background: var(--accent-soft);
  color: var(--text);
}

/* ── Stage (right panel) ─────────────────────────────────────────────────── */
.stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: rgba(20, 25, 25, 0.4);
}

.stage-header {
  padding: 16px 24px 12px;
  border-bottom: 1px solid var(--surface-border);
  flex-shrink: 0;
}

.stage-breadcrumb {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  margin-bottom: 4px;
}

.stage-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}

.stage-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

/* ── Material cards ──────────────────────────────────────────────────────── */
.materials-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.mat-card {
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: 12px;
  padding: 16px 14px 12px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
}

.mat-card:hover {
  border-color: var(--surface-border-strong);
  background: var(--surface-strong);
}

.mat-card.drag-over {
  border-color: var(--accent);
}

.mat-icon {
  font-size: 28px;
  line-height: 1;
}

.mat-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  word-break: break-word;
  flex: 1;
}

.mat-meta {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.mat-actions {
  display: none;
  gap: 6px;
  position: absolute;
  top: 8px;
  right: 8px;
}

.edit-mode .mat-actions {
  display: flex;
}

/* ── Upload zone ─────────────────────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--surface-border-strong);
  border-radius: 12px;
  padding: 32px 24px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.upload-zone:hover,
.upload-zone.dragover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--text);
}

.upload-zone input[type="file"] {
  display: none;
}

.upload-zone-icon {
  font-size: 32px;
  margin-bottom: 8px;
}

/* ── Empty state ─────────────────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--muted);
  gap: 8px;
  text-align: center;
}

.empty-state[hidden] {
  display: none;
}

.empty-state-icon {
  font-size: 48px;
  opacity: 0.4;
}

.empty-state-text {
  font-size: 14px;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 8px;
  border: 1px solid var(--surface-border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.18);
}

.btn.primary {
  background: rgba(92, 158, 161, 0.22);
  border-color: var(--surface-border-strong);
  color: var(--accent);
}

.btn.primary:hover {
  background: rgba(92, 158, 161, 0.35);
}

.btn.danger {
  background: rgba(201, 122, 122, 0.12);
  border-color: rgba(201, 122, 122, 0.3);
  color: var(--danger);
}

.btn.danger:hover {
  background: rgba(201, 122, 122, 0.22);
}

.btn.icon-btn {
  padding: 5px;
  width: 28px;
  height: 28px;
  border-radius: 6px;
}

.btn.active {
  background: rgba(92, 158, 161, 0.25);
  border-color: var(--accent);
  color: var(--accent);
}

/* ── Add node inline form ────────────────────────────────────────────────── */
.inline-add {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
}

.inline-add[hidden] {
  display: none;
}

.inline-add input {
  flex: 1;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--surface-border-strong);
  border-radius: 6px;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  padding: 4px 8px;
  outline: none;
}

.inline-add input:focus {
  border-color: var(--accent);
}

/* ── Toast ───────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-strong);
  border: 1px solid var(--surface-border);
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 13px;
  color: var(--muted);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 1000;
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
}

/* ── Login overlay (same pattern as admin.html) ──────────────────────────── */
#loginView {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-1);
  z-index: 999;
}

#loginView[hidden] {
  display: none;
}

#appView[hidden] {
  display: none;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: 16px;
  padding: 32px;
  width: min(360px, 90vw);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.login-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  text-align: center;
}

.login-sub {
  font-size: 13px;
  color: var(--muted);
  text-align: center;
}

.qr-wrap {
  display: flex;
  justify-content: center;
  padding: 8px 0;
}

.qr-wrap canvas,
.qr-wrap img {
  border-radius: 8px;
}

.qr-status {
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}

.login-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.login-divider::before,
.login-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--surface-border);
}

.pw-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.pw-form input {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--surface-border);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 13.5px;
  padding: 9px 12px;
  outline: none;
  width: 100%;
}

.pw-form input:focus {
  border-color: var(--accent);
}

/* ── Modal ───────────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: 14px;
  padding: 24px;
  width: min(340px, 90vw);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.modal input {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--surface-border);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 13.5px;
  padding: 9px 12px;
  outline: none;
  width: 100%;
}

.modal input:focus {
  border-color: var(--accent);
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* ── Scrollbars ──────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 3px; }
