/* ==========================================================================
   GLB Studio — Layout (nutzt DGM-UI Tokens aus dgm-ui.css)
   ========================================================================== */

html, body { height: 100%; margin: 0; overflow: hidden; }

:root {
  --sidebar-left-w: 280px;
  --sidebar-right-w: 300px;
}

.app {
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100vh;
  background: var(--admin-bg);
  color: var(--admin-text);
}

/* ---------- Kopfzeile ---------- */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: 52px;
  background: var(--admin-bg-elevated);
  border-bottom: 1px solid var(--admin-border);
}
.app-header__brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}
.app-header__brand i { color: var(--admin-primary); width: 20px; height: 20px; }
.app-header__sub {
  color: var(--admin-text-muted);
  font-weight: 400;
  font-size: 0.8rem;
  margin-left: 2px;
}
.app-header__actions { display: flex; align-items: center; gap: 8px; }

/* ---------- Hauptbereich: 3 Spalten + 2 Resizer ---------- */
.app-body {
  display: grid;
  grid-template-columns: var(--sidebar-left-w) 5px 1fr 5px var(--sidebar-right-w);
  min-height: 0;
  overflow: hidden;
}

/* ---------- Resizer (Sidebar-Breite ziehen) ---------- */
.resizer {
  cursor: col-resize;
  background: var(--admin-border);
  transition: background 0.12s;
  position: relative;
  z-index: 2;
}
.resizer:hover, .resizer.dragging { background: var(--admin-primary); }
.resizer::after {
  content: ""; position: absolute; inset: 0 -3px; /* groessere Trefferflaeche */
}

/* ---------- Sidebar-Schrift: einheitlich 0.6rem (ID-Selektor ueberschreibt alle Klassengroessen) ---------- */
#sidebar-left, #sidebar-right,
#sidebar-left *, #sidebar-right * {
  font-size: 0.6rem;
}

/* ---------- Sidebars ---------- */
.sidebar {
  display: flex;
  flex-direction: column;
  background: var(--admin-bg-elevated);
  overflow-y: auto;
  min-height: 0;
}
.sidebar--left  { border-right: 1px solid var(--admin-border); overflow: hidden; }
.sidebar--right { border-left:  1px solid var(--admin-border); }

.panel { border-bottom: 1px solid var(--admin-border); }
.panel__head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--admin-text-muted);
  background: var(--admin-card);
  position: sticky;
  top: 0;
  z-index: 1;
}
.panel__head i { width: 15px; height: 15px; }
.panel__head-action { margin-left: auto; }
.panel__body { padding: 8px 10px; }

.empty-hint { color: var(--admin-text-faint); font-size: 0.82rem; margin: 4px 2px; }

/* ---------- Objektbaum ---------- */
.tree-node {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  border-radius: var(--admin-radius);
  cursor: pointer;
  font-size: 0.84rem;
  white-space: nowrap;
  user-select: none;
}
.tree-node:hover { background: var(--admin-hover-bg); }
.tree-node.selected { background: var(--admin-primary-faint); color: var(--admin-text); }
.tree-node i { width: 14px; height: 14px; flex: 0 0 auto; color: var(--admin-text-muted); }
.tree-node.is-mesh i { color: var(--admin-primary); }
.tree-node__label { overflow: hidden; text-overflow: ellipsis; }
.tree-toggle { width: 14px; display: inline-flex; justify-content: center; cursor: pointer; }
.tree-children { margin-left: 12px; border-left: 1px solid var(--admin-border); padding-left: 2px; }
.tree-children.collapsed { display: none; }

/* ---------- Material-Chips (verwendete Materialien) ---------- */
.mat-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--admin-radius);
  cursor: pointer;
  font-size: 0.82rem;
}
.mat-chip:hover { background: var(--admin-hover-bg); }
.mat-swatch {
  width: 18px; height: 18px;
  border-radius: var(--admin-radius);
  border: 1px solid var(--admin-border);
  flex: 0 0 auto;
}
.mat-chip__meta { color: var(--admin-text-faint); font-size: 0.72rem; margin-left: auto; }

/* ---------- Material-Bibliothek (Karten) ---------- */
.lib-grid { display: flex; flex-direction: column; gap: 6px; }
.lib-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--admin-border);
  border-radius: var(--admin-radius);
  background: var(--admin-card);
  cursor: pointer;
}
.lib-card:hover { background: var(--admin-card-hover); }
.lib-card.selected { border-color: var(--admin-primary); }
.lib-card__sphere {
  width: 32px; height: 32px; border-radius: 50%; flex: 0 0 auto;
  border: 1px solid var(--admin-border);
  box-shadow: inset -4px -4px 8px rgba(0,0,0,0.4), inset 3px 3px 6px rgba(255,255,255,0.15);
}
.lib-card__info { min-width: 0; flex: 1; }
.lib-card__name { font-size: 0.84rem; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-card__engine { font-size: 0.7rem; color: var(--admin-text-faint); }
.lib-card__assign { flex: 0 0 auto; }
.lib-card__icon { display: flex; align-items: center; justify-content: center; background: var(--admin-bg); box-shadow: none; }
.lib-card__icon i { width: 16px; height: 16px; color: var(--admin-text-muted); }

/* ---------- Inspektor (Eigenschaften) ---------- */
.insp-row { margin-bottom: 10px; }
.insp-row label {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--admin-text-muted);
  margin-bottom: 4px;
}
.insp-row .insp-value { display: flex; align-items: center; gap: 8px; }
.insp-range { flex: 1; }
.insp-num { width: 52px; text-align: right; color: var(--admin-text-muted); font-size: 0.8rem; font-variant-numeric: tabular-nums; }
.insp-color { width: 38px; height: 28px; padding: 0; border: 1px solid var(--admin-border); border-radius: var(--admin-radius); background: none; cursor: pointer; }
.insp-section-title { font-size: 0.76rem; font-weight: 600; color: var(--admin-text); margin: 4px 0 8px; padding-top: 8px; border-top: 1px solid var(--admin-border); }
.insp-meshname { font-weight: 600; font-size: 0.9rem; margin-bottom: 2px; }
.insp-meshmeta { font-size: 0.74rem; color: var(--admin-text-faint); margin-bottom: 10px; }

/* ---------- Viewport ---------- */
.viewport-wrap { position: relative; min-width: 0; background: #1a1a1a; }
#viewport { position: absolute; inset: 0; }
#viewport canvas { display: block; }

.viewport-drop {
  position: absolute; inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(132, 7, 50, 0.18);
  border: 2px dashed var(--admin-primary);
  pointer-events: none;
  z-index: 5;
}
.viewport-drop.active { display: flex; }
.viewport-drop__inner { text-align: center; color: #fff; }
.viewport-drop__inner i { width: 48px; height: 48px; }

.viewport-stats {
  position: absolute;
  left: 10px; bottom: 10px;
  font-size: 0.72rem;
  color: var(--admin-text-muted);
  background: rgba(0,0,0,0.45);
  padding: 4px 8px;
  border-radius: var(--admin-radius);
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

/* ---------- Statuszeile ---------- */
.app-footer {
  height: 28px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  font-size: 0.76rem;
  color: var(--admin-text-muted);
  background: var(--admin-bg-elevated);
  border-top: 1px solid var(--admin-border);
}

.btn-icon { padding: 0; width: 28px; justify-content: center; }

/* ---------- Reiter (rechte Sidebar) ---------- */
.sidebar--right { overflow: hidden; } /* nur der Panel-Body scrollt */
.tabbar {
  display: flex;
  flex: 0 0 auto;
  background: var(--admin-card);
  border-bottom: 1px solid var(--admin-border);
}
.tabbar .tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 9px 4px;
  white-space: nowrap;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--admin-text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
}
.tabbar .tab i { width: 15px; height: 15px; }
.tabbar .tab:hover { color: var(--admin-text); background: var(--admin-hover-bg); }
.tabbar .tab.active { color: var(--admin-text); border-bottom-color: var(--admin-primary); }

.tab-panel { display: none; flex-direction: column; min-height: 0; flex: 1; }
.tab-panel.active { display: flex; }
.tab-panel__body { overflow-y: auto; padding: 10px; min-height: 0; }

.tab-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 10px;
  border-bottom: 1px solid var(--admin-border);
  flex: 0 0 auto;
}
.tab-toolbar__title {
  font-size: 0.78rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--admin-text-muted);
}

/* Bibliothek-Toolbar mit Projekt-Auswahl */
.tab-toolbar--lib { flex-direction: column; align-items: stretch; gap: 6px; }
.lib-toolbar__row { display: flex; align-items: center; gap: 6px; }
.lib-toolbar__row select { flex: 1; min-width: 0; }

/* ---------- Material-Editor (Reiter "Material") ---------- */
.med-head { margin-bottom: 12px; }
.med-name {
  width: 100%; font-size: 0.95rem; font-weight: 600;
  background: var(--admin-bg); color: var(--admin-text);
  border: 1px solid var(--admin-border); border-radius: var(--admin-radius);
  padding: 6px 8px;
}
.med-source {
  display: inline-flex; align-items: center; gap: 5px;
  margin-top: 6px; font-size: 0.72rem; color: var(--admin-text-muted);
}
.med-source i { width: 13px; height: 13px; }
.med-badge {
  display: inline-block; padding: 1px 7px; border-radius: 999px;
  font-size: 0.68rem; font-weight: 600;
  background: var(--admin-subtle-bg); color: var(--admin-text-muted);
}
.med-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--admin-border); }
.med-actions .btn { flex: 1; min-width: 120px; }

/* Eingabe-Zeilen (auch im Inspektor genutzt) */
.insp-select {
  flex: 1; background: var(--admin-bg); color: var(--admin-text);
  border: 1px solid var(--admin-border); border-radius: var(--admin-radius);
  height: 28px; padding: 0 6px; font-size: 0.82rem;
}
.insp-toggle { display: flex; align-items: center; gap: 8px; }
.insp-toggle input { width: 16px; height: 16px; accent-color: var(--admin-primary); }

/* ---------- Textur-Slots ---------- */
.tex-row {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 0; border-bottom: 1px solid var(--admin-border);
}
.tex-row:last-child { border-bottom: none; }
.tex-thumb {
  width: 34px; height: 34px; flex: 0 0 auto;
  border: 1px solid var(--admin-border); border-radius: var(--admin-radius);
  background-color: var(--admin-bg); background-size: cover; background-position: center;
  display: flex; align-items: center; justify-content: center;
}
.tex-thumb.empty i { width: 15px; height: 15px; color: var(--admin-text-faint); }
.tex-info { flex: 1; min-width: 0; }
.tex-label { font-weight: 500; }
.tex-state { color: var(--admin-text-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tex-actions { display: flex; gap: 4px; flex: 0 0 auto; }

/* ---------- Hilfe-Headlines ---------- */
.setting-head { margin: 12px 0 8px; padding-top: 9px; border-top: 1px solid var(--admin-border); }
.setting-head:first-child { margin-top: 0; padding-top: 0; border-top: none; }
.setting-head__row { display: flex; align-items: center; gap: 6px; }
.setting-head__title {
  font-weight: 600; color: var(--admin-text);
  text-transform: uppercase; letter-spacing: 0.03em;
}
.help-btn {
  background: none; border: none; padding: 0; cursor: pointer;
  color: var(--admin-text-muted); display: inline-flex; align-items: center;
}
.help-btn:hover { color: var(--admin-primary); }
.help-btn i { width: 13px; height: 13px; }
.help-box {
  display: none; margin-top: 6px; padding: 7px 9px;
  background: var(--admin-subtle-bg); border: 1px solid var(--admin-border);
  border-radius: var(--admin-radius); color: var(--admin-text-muted); line-height: 1.5;
}
.help-box.open { display: block; }
.help-box b { color: var(--admin-text); font-weight: 600; }

/* ---------- Tab-Zähler (z.B. Anzahl Animationen) ---------- */
.tab-count {
  display: inline-block; margin-left: 4px; padding: 0 5px;
  background: var(--admin-primary); color: #fff;
  border-radius: 999px; font-weight: 600; line-height: 1.5;
}

/* ---------- Animations-Transport ---------- */
.anim-transport { display: flex; gap: 6px; margin: 10px 0 4px; }
.anim-transport .btn { flex: 1; }
.anim-time { color: var(--admin-text-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- C4D-Import: Material-Abgleich-Fenster ---------- */
.c4d-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,0.55);
  display: flex; align-items: center; justify-content: center;
}
.c4d-modal {
  background: var(--admin-bg-elevated); color: var(--admin-text);
  border: 1px solid var(--admin-border); border-radius: 8px;
  width: min(720px, 94vw); max-height: 86vh;
  display: flex; flex-direction: column;
  box-shadow: var(--admin-shadow-heavy);
}
.c4d-modal__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--admin-border);
}
.c4d-modal__head h3 { margin: 0; font-size: 0.95rem; font-weight: 600; }
.c4d-close { background: none; border: none; color: var(--admin-text-muted); cursor: pointer; display: inline-flex; }
.c4d-close:hover { color: var(--admin-text); }
.c4d-modal__body { padding: 12px 16px; overflow-y: auto; }
.c4d-modal__foot {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 12px 16px; border-top: 1px solid var(--admin-border);
}
.c4d-hint { color: var(--admin-text-muted); font-size: 0.82rem; margin: 0 0 12px; line-height: 1.5; }
.c4d-hint b { color: var(--admin-text); }

.c4d-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 0; border-bottom: 1px solid var(--admin-border);
}
.c4d-row:last-child { border-bottom: none; }
.c4d-src { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.c4d-src > div { min-width: 0; }
.c4d-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.c4d-meta { color: var(--admin-text-faint); font-size: 0.72rem; }
.c4d-swatch { width: 22px; height: 22px; border-radius: var(--admin-radius); border: 1px solid var(--admin-border); flex: 0 0 auto; }
.c4d-badge { font-size: 0.66rem; padding: 1px 7px; border-radius: 999px; margin-left: auto; flex: 0 0 auto; white-space: nowrap; }
.c4d-badge.auto { background: rgba(34,197,94,0.18); color: var(--admin-success); }
.c4d-badge.manual { background: var(--admin-subtle-bg); color: var(--admin-text-muted); }
.c4d-arrow { color: var(--admin-text-faint); flex: 0 0 auto; width: 16px; height: 16px; }
.c4d-target { flex: 1; display: flex; }
.c4d-target select { width: 100%; }
