/* ============================================================================
   RollingTrayGenerator (RTG) – Oberfläche des Designers.
   Eigene Datei: das Shop-Stylesheet (assets/css/app.css) bleibt unangetastet.
   Nutzt dessen CSS-Variablen (--sun, --leaf, --ink-*, --cream …).
   ========================================================================== */

/* Solange der Designer offen ist, bekommt der Kaufbereich die volle Breite –
   das Designfeld bleibt dabei genau dort, wo das Produktbild war (oben). */
.pdp-hero.rtg-active { display: block; min-height: 0; }
.pdp-hero.rtg-active .pdp-stage {
  /* WICHTIG: die Bühne ist normalerweise ein Grid mit place-items:center –
     ihre Breite richtet sich dann nach dem Inhalt (max-content) und das
     Designfeld würde den Viewport aufblähen. Als Block bleibt sie brav. */
  display: block; aspect-ratio: auto; background: var(--ink-2); overflow: visible;
  padding: clamp(12px, 2vw, 20px); margin-bottom: clamp(24px, 4vw, 40px);
}
.pdp-hero.rtg-active .pdp-stage picture,
.pdp-hero.rtg-active .pdp-stage .pcard-badges { display: none; }

/* Vorschau statt Produktbild, sobald ein Design gespeichert wurde */
.rtg-preview { width: 92%; margin: auto; display: block; }
.rtg-preview svg { width: 100%; height: auto; display: block; border-radius: 10px; }
.rtg-preview-cap {
  text-align: center; font-size: .85rem; color: var(--cream-dim); margin-top: 10px;
}

/* ------------------------------------------------------------------ Panel */
.rtg-panel { display: flex; flex-direction: column; gap: 14px; text-align: left; width: 100%; max-width: 100%; min-width: 0; }
.rtg-panel[hidden] { display: none; }

.rtg-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.rtg-bar h2 { font-size: 1.15rem; margin: 0; font-family: var(--font-display); }
.rtg-bar .rtg-hint { color: var(--cream-dim); font-size: .88rem; margin: 0; }
.rtg-bar .rtg-spacer { margin-left: auto; }
.rtg-format { flex-direction: column; }
.rtg-format select {
  padding: 6px 9px; border: 1px solid var(--line); border-radius: 9px;
  background: #fff; color: var(--cream); font: inherit; font-size: .88rem;
}
.rtg-format[hidden] { display: none; }

/* ---------------------------------------------------------- Arbeitsfläche */
/* min-width:0 auf beiden Spalten: sonst kann die 1fr-Spalte nicht unter die
   feste Pixelbreite des Designfelds schrumpfen (klassischer Grid-Blowout). */
.rtg-work { display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 14px; align-items: start; min-width: 0; }

/* Seitenleiste mit den vorgefertigten Elementen */
.rtg-sb {
  background: var(--ink-1); border: 1px solid var(--line-soft); border-radius: 14px;
  padding: 10px; max-height: 70vh; overflow-y: auto; min-width: 0;
}
.rtg-sb h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em;
  color: var(--cream-faint); margin: 2px 0 8px; }
.rtg-el {
  display: flex; align-items: center; gap: 10px; width: 100%;
  background: #fff; border: 1px solid var(--line-soft); border-radius: 12px;
  padding: 8px; margin-bottom: 8px; cursor: grab; text-align: left;
  touch-action: none; user-select: none; -webkit-user-select: none;
}
.rtg-el:hover { border-color: var(--leaf-soft); }
.rtg-el:active { cursor: grabbing; }
.rtg-el-thumb { width: 44px; height: 34px; flex: 0 0 44px; }
.rtg-el-thumb svg { width: 100%; height: 100%; display: block; }
.rtg-el-name { font-size: .85rem; font-weight: 600; line-height: 1.2; }
.rtg-el-meta { font-size: .74rem; color: var(--cream-faint); }
.rtg-el-lock { font-size: .7rem; color: var(--sun); }

/* Ziehendes Geisterbild */
.rtg-ghost {
  position: fixed; z-index: 9999; pointer-events: none; opacity: .8;
  border: 2px dashed var(--leaf); border-radius: 8px; background: rgba(40,92,20,.10);
}

/* -------------------------------------------------------------- Designfeld */
.rtg-canvas { position: relative; min-width: 0; }

/* Vorlagenauswahl unter dem Designfeld */
.rtg-tpl { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.rtg-tpl[hidden] { display: none; }
.rtg-tpl label { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--cream-faint); }
.rtg-tpl select {
  padding: 7px 10px; border: 1px solid var(--line); border-radius: 9px;
  background: #fff; color: var(--cream); font: inherit; font-size: .88rem; max-width: 100%;
}
.rtg-tpl-hint { font-size: .8rem; color: var(--cream-faint); }
.rtg-df {
  position: relative; background: #fff; margin: 0 auto; max-width: 100%;
  box-shadow: 0 10px 30px rgba(60,42,10,.14); touch-action: none;
  background-image:
    linear-gradient(to right, rgba(40,28,10,.06) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(40,28,10,.06) 1px, transparent 1px);
  outline: 1px solid var(--line);
}
/* Sicherheitsabstand zum Rand (gestrichelt) */
.rtg-safe {
  position: absolute; pointer-events: none; border: 1px dashed rgba(125,70,4,.35);
}

/* Hilfslinien der magnetischen Ausrichtung */
.rtg-guide { position: absolute; pointer-events: none; background: var(--leaf-soft); z-index: 4; }
.rtg-guide[hidden] { display: none; }
.rtg-guide-v { top: 0; bottom: 0; width: 1px; margin-left: -0.5px; }
.rtg-guide-h { left: 0; right: 0; height: 1px; margin-top: -0.5px; }

.rtg-item {
  position: absolute; box-sizing: border-box; touch-action: none;
  border: 1.5px solid var(--sun); background: rgba(246,231,196,.85);
  cursor: move; user-select: none; -webkit-user-select: none;
}
.rtg-item.is-sel { border-color: var(--leaf); box-shadow: 0 0 0 2px rgba(40,92,20,.25); z-index: 3; }
/* „randlos": der überstehende Teil bleibt sichtbar, damit man sieht, wo die
   Tasche die Kante verlässt – gestrichelt, weil sie dort offen ausläuft. */
.rtg-item.is-bleed { border-style: dashed; }
.rtg-item.is-bad { border-color: var(--danger); background: rgba(210,106,90,.22); }
.rtg-item-lbl {
  position: absolute; inset: 0; display: flex; flex-direction: column; gap: 1px;
  align-items: center; justify-content: center;
  color: var(--sun); pointer-events: none; text-align: center;
  overflow: hidden; padding: 2px; line-height: 1.15;
}
.rtg-item-lbl.is-off { display: none; }
.rtg-lbl-name { font-size: 10px; font-weight: 600; }
.rtg-lbl-size { font-size: 9px; font-style: normal; opacity: .72; }
.rtg-item-lbl.no-size .rtg-lbl-size { display: none; }
.rtg-h {
  position: absolute; width: 14px; height: 14px; background: #fff; border: 2px solid var(--leaf);
  border-radius: 4px; touch-action: none;
}
.rtg-h[data-h="nw"] { left: -8px; top: -8px; cursor: nwse-resize; }
.rtg-h[data-h="ne"] { right: -8px; top: -8px; cursor: nesw-resize; }
.rtg-h[data-h="se"] { right: -8px; bottom: -8px; cursor: nwse-resize; }
.rtg-h[data-h="sw"] { left: -8px; bottom: -8px; cursor: nesw-resize; }

/* ------------------------------------------------------------- Inspektor */
.rtg-insp {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end;
  background: var(--ink-1); border: 1px solid var(--line-soft); border-radius: 14px; padding: 10px 12px;
}
.rtg-insp[hidden] { display: none; }
.rtg-f { display: flex; flex-direction: column; gap: 3px; }
.rtg-f label { font-size: .72rem; color: var(--cream-faint); text-transform: uppercase; letter-spacing: .05em; }
.rtg-f input { width: 88px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 9px;
  background: #fff; color: var(--cream); font: inherit; font-size: .9rem; }
.rtg-f input:disabled { background: var(--ink-3); color: var(--cream-faint); }
.rtg-insp .rtg-insp-name { font-weight: 600; font-size: .95rem; align-self: center; margin-right: auto; }
.rtg-chk { display: flex; align-items: center; gap: 6px; font-size: .88rem; padding-bottom: 7px; }
.rtg-chk[hidden] { display: none; }
.rtg-chk-help {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; border-radius: 50%; background: var(--ink-3);
  font-size: .7rem; color: var(--cream-dim); cursor: help;
}

.rtg-msg { font-size: .88rem; margin: 0; }
.rtg-msg ul { margin: .3em 0 0; padding-left: 1.2em; }
.rtg-msg.err { color: #8d2f20; }
.rtg-msg.ok { color: var(--leaf); }

.rtg-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.rtg-count { font-size: .82rem; color: var(--cream-faint); align-self: center; }

/* Kleiner Button-Stil, falls .btn-sm im Shop fehlt */
.rtg-panel .btn-xs { padding: 7px 12px; font-size: .84rem; }

/* -------------------------------------------------------------- Ergebnis */
.rtg-result {
  background: #fff; border: 2px solid var(--leaf-soft); border-radius: 14px; padding: 12px 14px;
}
.rtg-result[hidden] { display: none; }
.rtg-result h3 { margin: 0 0 6px; font-size: 1rem; }
.rtg-result .rtg-dl { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; }

/* Hinweis im Kaufbereich, solange kein Design vorliegt */
.rtg-need { font-size: .88rem; color: var(--sun); margin: 0 0 .8em; }
.rtg-need[hidden] { display: none; }

/* ------------------------------------------------------------ Schmalbild */
@media (max-width: 780px) {
  .rtg-work { grid-template-columns: 1fr; }
  .rtg-sb { max-height: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
  .rtg-sb h3 { grid-column: 1 / -1; }
  .rtg-el { margin-bottom: 0; }
}
