/* Editorul vizual de temă. Fișierul se încarcă pe toate paginile admin, deci fiecare regulă e sub .te sau body.te-body. */

body.te-body { margin: 0; display: block; overflow: hidden; }
/* Cu un mesaj .flash deasupra, editorul umple înălțimea rămasă (nu mai iese din ecran). */
body.te-body main.te-main { display: flex; flex-direction: column; height: 100dvh; }

.te {
  --te-text: #1b211d;
  --te-muted: #5a635d;
  --te-page: #f2f3f1;
  --te-surface: #ffffff;
  --te-surface-2: #f7f8f6;
  --te-hover: #f2f4f1;
  --te-border: #e5e8e4;
  --te-border-strong: #858d87;
  --te-accent: #17694b;
  --te-accent-soft: #e6f2ec;
  --te-danger: #b3261e;
  --te-bar-bg: #101814;
  --te-bar-fg: #dfe6e1;

  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  height: 100dvh;
  background: var(--te-page);
  color: var(--te-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
}

.te *, .te *::before, .te *::after { box-sizing: border-box; }

.te :is(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--te-accent);
  outline-offset: 2px;
}

/* Bara de sus */
.te .te-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  padding: 0.5rem 1rem;
  background: var(--te-bar-bg);
  color: var(--te-bar-fg);
  flex: none;
}
.te .te-bar :is(a, button):focus-visible { outline-color: #c8ff3d; }
.te .te-title { margin: 0; font-size: 0.9375rem; font-weight: 600; color: #fff; min-width: 0; max-width: 16rem; overflow-wrap: anywhere; }
.te .te-devices { display: flex; gap: 0.25rem; }
.te .te-history { display: flex; gap: 0.25rem; }
/* Starea e text în bară, nu mesajul verde al adminului (`:is(body.admin, ...) [role=status]` are specificitate mai mare decât
   `.te .te-status`). Ia tot locul liber dintre selectoare și butoanele din dreapta: când textul ei se schimbă, butoanele nu se mută
   (un clic pornit pe un buton în timp ce starea trece la „Se salvează…” nu mai cade alături). Goală, rămâne în arborele de
   accesibilitate (primul mesaj se anunță), fără cutie. */
body.te-body .te .te-status { flex: 1 1 8rem; min-width: 0; margin: 0; padding: 0; border: 0; border-radius: 0; background: none; box-shadow: none; font-size: 0.8125rem; line-height: 1.25; text-align: right; color: #b4c1b9; }
body.te-body .te .te-status.te-status-error { color: #ffb4ab; font-weight: 600; }

/* Panourile */
.te .te-panes {
  display: grid;
  grid-template-columns: auto 280px minmax(0, 1fr) 340px;
  flex: 1;
  min-height: 0;
}
.te .te-tree, .te .te-settings {
  overflow-y: auto;
  padding: 1rem;
  background: var(--te-surface);
  min-width: 0;
}
.te .te-tree { border-right: 1px solid var(--te-border-strong); }
.te .te-settings { border-left: 1px solid var(--te-border-strong); }

.te .te-stage {
  display: flex;
  justify-content: center;
  align-items: stretch;
  overflow: auto;
  padding: 0.75rem;
  min-width: 0;
  background: var(--te-page);
}
.te .te-stage iframe {
  width: 100%;
  height: 100%;
  border: 1px solid var(--te-border-strong);
  border-radius: 8px;
  background: #fff;
}

.te .te-start { padding: 1.5rem; max-width: 40rem; }

.te .te-pane-title { margin: 0 0 0.5rem; font-size: 0.8125rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--te-muted); overflow-wrap: anywhere; }
.te :is(.te-settings, .te-dialog) .te-pane-title { font-size: 1rem; text-transform: none; letter-spacing: 0; color: var(--te-text); }
.te .te-subtitle { margin: 1.25rem 0 0.5rem; font-size: 0.9375rem; }
.te .te-empty, .te .te-note, .te .te-muted { color: var(--te-muted); font-size: 0.875rem; margin: 0.25rem 0 0.75rem; }

/* Arborele */
.te .te-group { margin-bottom: 1.5rem; }
.te .te-list { list-style: none; margin: 0 0 0.5rem; padding: 0; }
.te .te-list-nested { margin: 0.25rem 0 0 0.75rem; padding-left: 0.5rem; border-left: 2px solid var(--te-border); }
.te .te-item {
  position: relative;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin: 2px 0;
  padding: 2px 4px 2px 6px;
  border-left: 4px solid transparent;
  border-radius: 6px;
}
.te .te-item:hover { background: var(--te-hover); }
.te .te-item.is-selected { background: var(--te-accent-soft); border-left-color: var(--te-accent); font-weight: 700; }
.te .te-item.is-dragging { opacity: 0.5; }
.te .te-item.te-drop-before::before, .te .te-item.te-drop-after::after {
  content: "";
  position: absolute;
  left: 0; right: 0;
  height: 3px;
  background: var(--te-accent);
  border-radius: 2px;
}
.te .te-item.te-drop-before::before { top: -3px; }
.te .te-item.te-drop-after::after { bottom: -3px; }

.te .te-select {
  flex: 1;
  min-width: 0;
  padding: 0.5rem 0.25rem;
  background: none;
  border: 0;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  overflow-wrap: anywhere;
}
.te .te-handle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  background: none;
  border: 0;
  border-radius: 6px;
  color: var(--te-muted);
  cursor: grab;
}
.te .te-handle:hover { background: var(--te-border); color: var(--te-text); }
.te .te-badges { display: inline-flex; gap: 0.25rem; flex-wrap: wrap; }
.te .te-badge { padding: 0 0.4rem; border-radius: 999px; background: #e9ebe8; color: #3a423d; font-size: 0.6875rem; font-weight: 600; line-height: 1.5; font-style: normal; }
.te .te-add { margin-top: 0.25rem; }

/* Setările */
.te .te-form { display: grid; gap: 0.75rem; margin-bottom: 1rem; }
.te .te-form .field { margin: 0; }
.te .te-form :is(input:not([type="checkbox"], [type="color"]), select, textarea) { width: 100%; max-width: 100%; }
.te .te-field-check { display: flex; align-items: center; gap: 0.5rem; }
.te .te-field-check label { margin: 0; }
.te .te-form small { display: block; margin-top: 0.25rem; color: var(--te-muted); }
.te .te-form small.te-unsaved { color: var(--te-danger); font-weight: 600; }
.te .te-reset { margin-top: 0.5rem; }
.te .te-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; padding-top: 0.75rem; border-top: 1px solid var(--te-border); }
.te .te-blocks { padding-top: 0.5rem; }
.te .te-block-list { list-style: none; margin: 0 0 0.75rem; padding: 0; display: grid; gap: 0.5rem; }
.te .te-block { padding: 0.5rem; border: 1px solid var(--te-border-strong); border-radius: 8px; background: var(--te-surface-2); }
.te .te-block .te-select { display: block; width: 100%; padding: 0.25rem 0; font-weight: 600; }
.te .te-block-actions { display: flex; flex-wrap: wrap; gap: 0.25rem; margin-top: 0.25rem; }
.te .te-add-block { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.5rem; }
.te .te-add-block .field { flex: 1; min-width: 8rem; margin: 0; }
.te .te-add-block select { width: 100%; }

/* Dialogul */
.te .te-dialog {
  width: calc(100% - 2rem);
  max-width: 32rem;
  max-height: 80dvh;
  padding: 1.25rem;
  border: 1px solid var(--te-border-strong);
  border-radius: 12px;
  background: var(--te-surface);
  color: var(--te-text);
}
.te .te-dialog::backdrop { background: rgb(16 24 20 / 60%); }
.te .te-add-list { list-style: none; margin: 0.75rem 0; padding: 0; display: grid; gap: 0.5rem; }
.te .te-add-list [hidden] { display: none; }
.te .te-add-choice { width: 100%; justify-content: flex-start; text-align: left; }
.te .te-dialog-actions { display: flex; justify-content: flex-end; }
.te .te-dialog input[type="search"] { width: 100%; }

/* „Sari la setări”: ascuns până primește focusul, apoi deasupra vitrinei. */
.te .te-skip { position: absolute; left: -9999px; top: auto; }
.te .te-skip:focus { position: fixed; left: 50%; top: 0.5rem; transform: translateX(-50%); z-index: 10; padding: 0.5rem 1rem; background: var(--te-surface); color: var(--te-accent); border: 2px solid var(--te-accent); border-radius: 6px; font-weight: 600; }

/* Ecrane înguste: stivuit în ordinea din pagină (arborele, vitrina, setările), deci ordinea vizuală e cea a Tab-ului (2.4.3),
   fără defilare orizontală */
@media (max-width: 900px) {
  body.te-body { overflow: auto; }
  body.te-body main.te-main { height: auto; min-height: 100dvh; }
  .te { height: auto; min-height: 0; }
  .te .te-panes { display: flex; flex-direction: column; }
  .te .te-stage { padding: 0.5rem; }
  .te .te-stage iframe { height: 70vh; }
  .te .te-tree { border-right: 0; }
  .te .te-settings { border-left: 0; border-top: 1px solid var(--te-border-strong); }
}

@media (prefers-reduced-motion: reduce) {
  .te *, .te *::before, .te *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
