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

body {
  font-family: 'Nunito', sans-serif;
  font-size: 15px;
  background: #f5f7fa;
  color: #1a1a2e;
  min-height: 100vh;
}

/* ── Header ─────────────────────────────────────────────────────── */
.admin-header {
  display: flex;
  align-items: center;
  gap: 16px;
  background: #1a1a2e;
  color: #fff;
  padding: 0 24px;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.admin-logo  {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #25ae7c;
  text-decoration: none;
  font-weight: 700;
  font-size: 14px;
}
.admin-logo img {
  display: block;
  width: 142px;
  height: auto;
  background: #fff;
  border-radius: 6px;
  padding: 4px 6px;
}
.admin-title { flex: 1; font-weight: 800; font-size: 18px; }

/* ── Layout ─────────────────────────────────────────────────────── */
.admin-layout {
  display: grid;
  grid-template-columns: 200px 1fr;
  min-height: calc(100vh - 56px);
}

.admin-nav {
  background: #fff;
  border-right: 1px solid #e8ecf0;
  padding: 16px 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tab-btn {
  background: none;
  border: none;
  text-align: left;
  padding: 10px 20px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: #555;
  cursor: pointer;
  border-radius: 0;
  transition: background .15s, color .15s;
}
.tab-btn:hover  { background: #f0f9f5; color: #25ae7c; }
.tab-btn.active { background: #e8f8f1; color: #1a9e6e; border-right: 3px solid #25ae7c; }

.admin-main { padding: 28px 32px 70px; max-width: 960px; }
.admin-footer {
  position: fixed;
  right: 24px;
  bottom: 16px;
  font-size: 13px;
  font-weight: 700;
}
.admin-footer a {
  color: #7a8494;
  text-decoration: none;
}
.admin-footer a:hover { color: #25ae7c; text-decoration: underline; }

/* ── Section ────────────────────────────────────────────────────── */
.tab-section.hidden { display: none; }

.section-head {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}
.section-head h2 { font-size: 20px; font-weight: 800; flex: 1; }

/* ── Buttons ────────────────────────────────────────────────────── */
.btn {
  padding: 8px 18px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  border: 2px solid transparent;
  transition: background .15s, color .15s;
  white-space: nowrap;
}
.btn-primary { background: #25ae7c; color: #fff; border-color: #25ae7c; }
.btn-primary:hover { background: #1a9e6e; }
.btn-outline { background: transparent; color: #25ae7c; border-color: #25ae7c; }
.btn-outline:hover { background: #e8f8f1; }
.btn-danger  { background: #e74c3c; color: #fff; border-color: #e74c3c; font-size: 12px; padding: 5px 10px; }
.btn-danger:hover { background: #c0392b; }
.btn-reset   { background: #f39c12; color: #fff; border-color: #f39c12; font-size: 12px; padding: 5px 10px; }
.btn-reset:hover { background: #d68910; }

/* ── Form ───────────────────────────────────────────────────────── */
.form-card {
  background: #fff;
  border: 1px solid #e8ecf0;
  border-radius: 12px;
  padding: 20px 24px;
  margin-bottom: 20px;
}
.form-card h3 { font-size: 15px; font-weight: 700; margin-bottom: 14px; }
.form-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.form-col { display: flex; flex-direction: column; gap: 10px; }
.form-col label { font-size: 13px; font-weight: 700; color: #555; margin-top: 4px; }

input[type="text"], input[type="password"], select, textarea {
  padding: 8px 12px;
  border: 1.5px solid #d0d7de;
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  background: #fff;
  color: #1a1a2e;
  transition: border-color .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: #25ae7c;
}
select { cursor: pointer; }
.form-hint { font-size: 12px; color: #888; margin-top: 8px; }

.hidden { display: none !important; }

/* ── Tabellen ───────────────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid #e8ecf0;
  font-size: 14px;
}
.data-table th {
  background: #f5f7fa;
  padding: 10px 14px;
  text-align: left;
  font-weight: 700;
  font-size: 12px;
  color: #666;
  text-transform: uppercase;
  letter-spacing: .04em;
  border-bottom: 1px solid #e8ecf0;
}
.data-table td {
  padding: 10px 14px;
  border-bottom: 1px solid #f0f2f5;
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #fafcfb; }

.badge-admin   { background: #fde8d8; color: #c0392b; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 700; }
.badge-schueler{ background: #e8f8f1; color: #1a9e6e; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 700; }
.badge-seen    { color: #888; font-size: 12px; }
.badge-unseen  { color: #e67e22; font-weight: 700; font-size: 12px; }
.badge-done    { color: #1a9e6e; font-weight: 700; font-size: 12px; }
.muted { color: #aaa; font-size: 13px; }

.btn-group { display: flex; gap: 6px; }

/* ── Navigation Editor ──────────────────────────────────────────── */
#nav-editor {
  width: 100%;
  height: 500px;
  font-family: 'Courier New', monospace;
  font-size: 13px;
  line-height: 1.6;
  padding: 16px;
  border: 1.5px solid #d0d7de;
  border-radius: 8px;
  resize: vertical;
  background: #1e1e2e;
  color: #cdd6f4;
}

/* ── Dialog ─────────────────────────────────────────────────────── */
.dialog-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
}
.dialog {
  background: #fff;
  border-radius: 16px;
  padding: 28px 32px;
  max-width: 380px;
  width: 90%;
  text-align: center;
}
.dialog h3 { font-size: 18px; font-weight: 800; margin-bottom: 12px; }
.pw-box {
  background: #fff3cd;
  border: 2px solid #ffc107;
  border-radius: 8px;
  padding: 14px 20px;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: .04em;
  margin: 12px 0;
}

/* ── Toast ──────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 28px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #1a1a2e;
  color: #fff;
  padding: 10px 22px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
  opacity: 0;
  transition: opacity .25s, transform .25s;
  pointer-events: none;
  z-index: 999;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Aufgabe erstellen ──────────────────────────────────────────── */
.aufgabe-grid {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 28px;
  align-items: start;
}
@media (max-width: 860px) {
  .aufgabe-grid { grid-template-columns: 1fr; }
}
.neues-thema-box {
  background: #f0fdf8;
  border: 1px solid #c8f0e0;
  border-radius: 8px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.neues-thema-box label { margin-top: 0 !important; }
.input-with-check { display: flex; align-items: center; gap: 8px; }
.input-with-check input { flex: 1; min-width: 0; }
#auf-titel-status { font-size: 12px; font-weight: 700; white-space: nowrap; flex-shrink: 0; }
.field-readonly { background: #f5f7fa !important; color: #999 !important; font-family: monospace !important; font-size: 12px !important; }
#auf-dateiname { font-family: 'Courier New', monospace; font-size: 11px; color: #999; margin-top: -4px; }
.editor-col { display: flex; flex-direction: column; gap: 8px; }
.editor-toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 2px; }
.editor-label { font-size: 13px; font-weight: 700; color: #555; }
#auf-editor {
  width: 100%;
  height: 520px;
  font-family: 'Courier New', monospace;
  font-size: 13px;
  line-height: 1.6;
  padding: 16px;
  border: 1.5px solid #d0d7de;
  border-radius: 8px;
  resize: vertical;
  background: #1e1e2e;
  color: #cdd6f4;
  tab-size: 2;
}
.btn-sm { padding: 5px 12px !important; font-size: 12px !important; }
.auf-save-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid #e8ecf0;
}
#auf-save-msg { font-size: 13px; font-weight: 600; color: #25ae7c; }

/* ── Nav View Toggle ────────────────────────────────────────────── */
.nav-view-toggle { display: flex; gap: 4px; }
.nav-view-btn {
  padding: 6px 14px;
  border-radius: 6px;
  border: 1.5px solid #d0d7de;
  background: #fff;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: #555;
  cursor: pointer;
  transition: all .15s;
}
.nav-view-btn.active { background: #25ae7c; border-color: #25ae7c; color: #fff; }

/* ── DnD Tree ───────────────────────────────────────────────────── */
#nav-dnd-tree {
  background: #fff;
  border: 1px solid #e8ecf0;
  border-radius: 12px;
  padding: 8px;
  min-height: 120px;
}

.dnd-item { position: relative; }
.dnd-fach { border-radius: 8px; margin-bottom: 6px; }
.dnd-thema { border-radius: 6px; margin-bottom: 2px; }
.dnd-seite { border-radius: 4px; margin-bottom: 2px; }

.dnd-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: inherit;
  position: relative;
  user-select: none;
}
.dnd-fach > .dnd-row  { background: #f0f9f5; }
.dnd-thema > .dnd-row { background: #f8f9fb; }
.dnd-seite > .dnd-row { background: transparent; }
.dnd-row:hover { background: #e8f8f1 !important; }

.dnd-handle {
  cursor: grab;
  color: #bbb;
  font-size: 16px;
  line-height: 1;
  padding: 0 2px;
  flex-shrink: 0;
}
.dnd-handle:active { cursor: grabbing; }

.dnd-label {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  overflow: hidden;
}
.dnd-icon { flex-shrink: 0; }
.dnd-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; font-weight: 600; }
.dnd-fach  > .dnd-row .dnd-title { font-weight: 800; font-size: 15px; }
.dnd-thema > .dnd-row .dnd-title { font-weight: 700; color: #444; }
.dnd-seite > .dnd-row .dnd-title { font-weight: 600; color: #666; font-size: 13px; }

.dnd-actions { display: flex; gap: 4px; flex-shrink: 0; }
.dnd-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 3px 7px;
  border-radius: 4px;
  font-size: 13px;
  opacity: 0;
  transition: opacity .15s, background .15s;
}
.dnd-row:hover .dnd-btn { opacity: 1; }
.dnd-btn-add  { color: #1a7fc4; font-weight: 700; font-size: 11px !important; }
.dnd-btn-add:hover  { background: #e8f0fb; }
.dnd-btn-edit { color: #25ae7c; }
.dnd-btn-edit:hover { background: #e8f8f1; }
.dnd-btn-del  { color: #e74c3c; }
.dnd-btn-del:hover  { background: #fde8e8; }

.dnd-children { padding-left: 24px; }
.dnd-dragging { opacity: .35; }

.dnd-item.drop-before > .dnd-row::before,
.dnd-item.drop-after  > .dnd-row::after {
  content: '';
  position: absolute;
  left: 0; right: 0;
  height: 2px;
  background: #25ae7c;
  border-radius: 2px;
  pointer-events: none;
  z-index: 10;
}
.dnd-item.drop-before > .dnd-row::before { top: 0; }
.dnd-item.drop-after  > .dnd-row::after  { bottom: 0; }

/* ── Nav-Edit Dialog ────────────────────────────────────────────── */
.dialog-wide { max-width: 460px !important; }
.dialog-btns { display: flex; gap: 10px; justify-content: center; margin-top: 8px; }
