/**
 * Kontener i izolacja hosta nowego UI względem klasycznego shellu.
 * Arkusz włączany tylko przy data-prototype-ui-host="1".
 */

#prototype-ui-host {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 5000;
  overflow: auto;
  background: #f4f4ef;
}

html[data-prototype-ui-host="1"] #prototype-ui-host {
  display: block;
}

/* Ukryj klasyczny chrome na czas hosta — topbar/main nie konkurują z planner-app. */
html[data-prototype-ui-host="1"] > body > .topbar,
html[data-prototype-ui-host="1"] > body > #editorial-planner-hero,
html[data-prototype-ui-host="1"] > body > #editorial-workshop-hero,
html[data-prototype-ui-host="1"] > body > #planner-mobile-tabs,
html[data-prototype-ui-host="1"] > body > #main {
  display: none !important;
}

/* Hub Tools nie konkuruje, gdy host (lub host→warsztat) jest aktywny. */
html[data-prototype-ui-host="1"] > body > #view-tools {
  display: none !important;
}

html[data-prototype-ui-host="1"] body {
  overflow: hidden;
}

/* Suspend host → Warsztat: kontener React ukryty, root zachowany (patrz workshop.css). */
html[data-prototype-ui-host="1"][data-host-workshop="1"] #prototype-ui-host {
  display: none !important;
}

/*
 * Stacking: każde .modal nad hostem (z-index 5000), bez malowania wyglądu.
 * Paint tokenami hosta: wyłącznie okna faktycznie otwierane z menu I/O hosta
 * (#modal-import-text, #modal-import-csv). JSON = file picker + window.confirm.
 * OCR paddle / clear / dispatch / admin / Warsztat — poza zakresem paint.
 * Motyw hosta (theme-light|theme-dark) nie zapisuje data-theme.
 */
html[data-prototype-ui-host="1"] .modal {
  z-index: 5200;
  overflow: auto;
  align-items: flex-start;
  padding: 1.5rem 0;
}

html[data-prototype-ui-host="1"] .modal .modal-backdrop {
  position: fixed;
  z-index: 0;
}

html[data-prototype-ui-host="1"] .modal .modal-panel {
  position: relative;
  z-index: 2;
  isolation: isolate;
  margin: 0 auto;
  max-height: none;
}

html[data-prototype-ui-host="1"] .toast {
  z-index: 5300;
}

html[data-prototype-ui-host="1"] #modal-import-text,
html[data-prototype-ui-host="1"] #modal-import-csv {
  --host-modal-bg: #f4f4ef;
  --host-modal-surface: #fbfbf8;
  --host-modal-raised: #fff;
  --host-modal-muted-bg: #f0f1eb;
  --host-modal-ink: #25332b;
  --host-modal-muted: #737d75;
  --host-modal-line: #d9ded6;
  --host-modal-accent: #395b47;
  --host-modal-accent-hover: #2f4d3c;
  --host-modal-shadow: 0 18px 48px #202b2324;
  --host-modal-radius: 12px;
  --host-modal-overlay: rgba(32, 43, 35, 0.42);
}

html[data-prototype-ui-host="1"]:has(.planner-app.theme-dark) #modal-import-text,
html[data-prototype-ui-host="1"]:has(.planner-app.theme-dark) #modal-import-csv {
  --host-modal-bg: #1b211c;
  --host-modal-surface: #252e27;
  --host-modal-raised: #303b33;
  --host-modal-muted-bg: #1f2822;
  --host-modal-ink: #edf0e9;
  --host-modal-muted: #aab3a9;
  --host-modal-line: #414b42;
  --host-modal-accent: #a6c1a7;
  --host-modal-accent-hover: #bdd2bd;
  --host-modal-shadow: 0 18px 48px #0006;
  --host-modal-overlay: rgba(0, 0, 0, 0.55);
}

html[data-prototype-ui-host="1"] #modal-import-text .modal-backdrop,
html[data-prototype-ui-host="1"] #modal-import-csv .modal-backdrop {
  background: var(--host-modal-overlay);
}

html[data-prototype-ui-host="1"] #modal-import-text .modal-panel,
html[data-prototype-ui-host="1"] #modal-import-csv .modal-panel {
  width: min(640px, calc(100% - 2rem));
  background: var(--host-modal-surface);
  color: var(--host-modal-ink);
  border: 1px solid var(--host-modal-line);
  border-radius: var(--host-modal-radius);
  box-shadow: var(--host-modal-shadow);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

html[data-prototype-ui-host="1"] #modal-import-text .modal-title,
html[data-prototype-ui-host="1"] #modal-import-csv .modal-title {
  color: var(--host-modal-ink);
  font-family: inherit;
  font-weight: 650;
  letter-spacing: -0.01em;
}

html[data-prototype-ui-host="1"] #modal-import-text .modal-hint,
html[data-prototype-ui-host="1"] #modal-import-text .field-hint,
html[data-prototype-ui-host="1"] #modal-import-text .field-label,
html[data-prototype-ui-host="1"] #modal-import-csv .modal-hint,
html[data-prototype-ui-host="1"] #modal-import-csv .field-hint,
html[data-prototype-ui-host="1"] #modal-import-csv .field-label {
  color: var(--host-modal-muted);
}

html[data-prototype-ui-host="1"] #modal-import-text .modal-hint code,
html[data-prototype-ui-host="1"] #modal-import-csv .modal-hint code {
  background: var(--host-modal-muted-bg);
  color: var(--host-modal-ink);
  border-radius: 6px;
}

html[data-prototype-ui-host="1"] #modal-import-text .modal-close,
html[data-prototype-ui-host="1"] #modal-import-text .icon-btn,
html[data-prototype-ui-host="1"] #modal-import-csv .modal-close,
html[data-prototype-ui-host="1"] #modal-import-csv .icon-btn {
  color: var(--host-modal-muted);
  border-radius: 8px;
}

html[data-prototype-ui-host="1"] #modal-import-text .modal-close:hover,
html[data-prototype-ui-host="1"] #modal-import-text .icon-btn:hover,
html[data-prototype-ui-host="1"] #modal-import-csv .modal-close:hover,
html[data-prototype-ui-host="1"] #modal-import-csv .icon-btn:hover {
  color: var(--host-modal-ink);
  background: var(--host-modal-muted-bg);
}

html[data-prototype-ui-host="1"] #modal-import-text .modal-close:focus-visible,
html[data-prototype-ui-host="1"] #modal-import-text .icon-btn:focus-visible,
html[data-prototype-ui-host="1"] #modal-import-text .btn:focus-visible,
html[data-prototype-ui-host="1"] #modal-import-text textarea:focus-visible,
html[data-prototype-ui-host="1"] #modal-import-text input:focus-visible,
html[data-prototype-ui-host="1"] #modal-import-text .import-screenshot-dropzone:focus-visible,
html[data-prototype-ui-host="1"] #modal-import-csv .modal-close:focus-visible,
html[data-prototype-ui-host="1"] #modal-import-csv .icon-btn:focus-visible,
html[data-prototype-ui-host="1"] #modal-import-csv .btn:focus-visible,
html[data-prototype-ui-host="1"] #modal-import-csv textarea:focus-visible,
html[data-prototype-ui-host="1"] #modal-import-csv input:focus-visible {
  outline: 2px solid var(--host-modal-accent);
  outline-offset: 2px;
}

html[data-prototype-ui-host="1"] #modal-import-text textarea,
html[data-prototype-ui-host="1"] #modal-import-text input[type="text"],
html[data-prototype-ui-host="1"] #modal-import-text input:not([type]),
html[data-prototype-ui-host="1"] #modal-import-text select,
html[data-prototype-ui-host="1"] #modal-import-csv textarea,
html[data-prototype-ui-host="1"] #modal-import-csv input[type="text"],
html[data-prototype-ui-host="1"] #modal-import-csv input:not([type]),
html[data-prototype-ui-host="1"] #modal-import-csv select {
  background: var(--host-modal-raised);
  color: var(--host-modal-ink);
  border: 1px solid var(--host-modal-line);
  border-radius: 8px;
}

html[data-prototype-ui-host="1"] #modal-import-text .import-screenshot-dropzone {
  background: var(--host-modal-muted-bg);
  border: 1.5px dashed var(--host-modal-line);
  border-radius: 10px;
  color: var(--host-modal-ink);
}

html[data-prototype-ui-host="1"] #modal-import-text .import-screenshot-dropzone:hover,
html[data-prototype-ui-host="1"] #modal-import-text .import-screenshot-dropzone.is-dragover {
  border-color: var(--host-modal-accent);
  background: var(--host-modal-raised);
}

html[data-prototype-ui-host="1"] #modal-import-text .import-screenshot-dropzone-title {
  color: var(--host-modal-ink);
  font-weight: 600;
}

html[data-prototype-ui-host="1"] #modal-import-text .btn-primary,
html[data-prototype-ui-host="1"] #modal-import-csv .btn-primary {
  background: var(--host-modal-accent);
  border-color: var(--host-modal-accent);
  color: #fbfbf8;
}

html[data-prototype-ui-host="1"] #modal-import-text .btn-primary:hover,
html[data-prototype-ui-host="1"] #modal-import-csv .btn-primary:hover {
  background: var(--host-modal-accent-hover);
  border-color: var(--host-modal-accent-hover);
}

html[data-prototype-ui-host="1"] #modal-import-text .btn-secondary,
html[data-prototype-ui-host="1"] #modal-import-csv .btn-secondary {
  background: var(--host-modal-raised);
  border: 1px solid var(--host-modal-line);
  color: var(--host-modal-ink);
}

html[data-prototype-ui-host="1"] #modal-import-text .btn-ghost,
html[data-prototype-ui-host="1"] #modal-import-csv .btn-ghost {
  color: var(--host-modal-muted);
}

html[data-prototype-ui-host="1"] #modal-import-text .btn-ghost:hover,
html[data-prototype-ui-host="1"] #modal-import-csv .btn-ghost:hover {
  color: var(--host-modal-ink);
  background: var(--host-modal-muted-bg);
}

html[data-prototype-ui-host="1"] #modal-import-text .import-ocr-status.is-error,
html[data-prototype-ui-host="1"] #modal-import-text .is-error,
html[data-prototype-ui-host="1"] #modal-import-csv .is-error {
  color: #b3263a;
}

/* Drag 2D — podgląd niedozwolonej pozycji (bez redesignu chrome). */
html[data-prototype-ui-host="1"] .plan-pallet.is-invalid-drop .plan-pallet-face {
  outline: 2px solid #c0393b;
  opacity: 0.85;
}
html[data-prototype-ui-host="1"] .plan-pallet.is-dragging {
  cursor: grabbing;
}
html[data-prototype-ui-host="1"] .plan-2d-svg.is-dragging-cargo {
  touch-action: none;
}

/* Sylwetka pojazdu 2D — tokeny Appearance / workshop; pointer-events:none w JSX. */
html[data-prototype-ui-host="1"] .plan-vehicle-silhouette {
  color: var(--hw-muted-strong, var(--line-strong, #596558));
}
html[data-prototype-ui-host="1"] .plan-vehicle-cab-glass {
  color: var(--hw-accent, #395b47);
}
html[data-prototype-ui-host="1"] .plan-vehicle-cab-wheel,
html[data-prototype-ui-host="1"] .plan-vehicle-coupler {
  color: var(--hw-muted, #737d75);
}

/* Dynamiczny błąd/odrzucony ruch — nadal u góry, bez stałej instrukcji. */
html[data-prototype-ui-host="1"] .scene-drag-hint {
  position: absolute;
  left: 50%;
  top: 12px;
  transform: translateX(-50%);
  z-index: 4;
  max-width: min(92%, 420px);
  padding: 6px 12px;
  border-radius: 6px;
  background: rgba(32, 39, 33, 0.82);
  color: #f4f4ef;
  font-size: 12px;
  line-height: 1.35;
  text-align: center;
  pointer-events: none;
}
html[data-prototype-ui-host="1"] .scene-drag-hint.is-invalid {
  background: rgba(160, 50, 40, 0.9);
}
html[data-prototype-ui-host="1"] .scene-3d-wrap {
  position: relative;
}

/* Stała instrukcja + gesty kamery — dół sceny, bez przechwytywania gestów. */
html[data-prototype-ui-host="1"] .scene-bottom-bar {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 8px;
  z-index: 3;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 6px 12px;
  pointer-events: none;
}
html[data-prototype-ui-host="1"] .scene-instruction-bar,
html[data-prototype-ui-host="1"] .scene-bottom-bar .camera-hint {
  position: static;
  left: auto;
  right: auto;
  bottom: auto;
  max-width: min(100%, 360px);
  margin: 0;
  padding: 0;
  color: var(--muted, #6b746c);
  font-size: 10px;
  line-height: 1.35;
  pointer-events: none;
}
html[data-prototype-ui-host="1"] .scene-instruction-bar {
  color: var(--muted-strong, #4f5a52);
  font-weight: 550;
}
html[data-prototype-ui-host="1"] .scene-instruction-short {
  display: none;
}
html[data-prototype-ui-host="1"] .cargo-row-wrap {
  display: flex;
  align-items: stretch;
  width: 100%;
  border-bottom: 1px solid var(--line, rgba(24, 36, 28, 0.12));
}
html[data-prototype-ui-host="1"] .cargo-row-wrap:last-child {
  border-bottom: 0;
}
html[data-prototype-ui-host="1"] .cargo-row-wrap .cargo-row {
  flex: 1 1 auto;
  min-width: 0;
  border-bottom: 0;
}
html[data-prototype-ui-host="1"] .cargo-row-delete {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: center;
  min-width: 44px;
  min-height: 44px;
  margin: 0 6px 0 0;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted-strong, #4f5a52);
  cursor: pointer;
}
html[data-prototype-ui-host="1"] .cargo-row-delete:hover:not(:disabled) {
  background: var(--surface-muted, rgba(24, 36, 28, 0.06));
  color: var(--accent, #395b47);
}
html[data-prototype-ui-host="1"] .cargo-row-delete:focus-visible {
  outline: 2px solid var(--accent, #395b47);
  outline-offset: 2px;
}
html[data-prototype-ui-host="1"] .cargo-row-delete:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
html[data-prototype-ui-host="1"] .cargo-row-delete svg {
  width: 16px;
  height: 16px;
}
@media (max-width: 720px) {
  html[data-prototype-ui-host="1"] .scene-bottom-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
  }
  html[data-prototype-ui-host="1"] .scene-instruction-full {
    display: none;
  }
  html[data-prototype-ui-host="1"] .scene-instruction-short {
    display: inline;
  }
  html[data-prototype-ui-host="1"] .scene-instruction-bar,
  html[data-prototype-ui-host="1"] .scene-bottom-bar .camera-hint {
    max-width: 100%;
    font-size: 9px;
  }
}

/* Siatka / Jednolite — segment w command-right, bez resetu kamery. */
html[data-prototype-ui-host="1"] .scene-bg-toggle {
  display: inline-flex;
  align-items: stretch;
  border: 1px solid color-mix(in srgb, currentColor 22%, transparent);
  border-radius: 8px;
  overflow: hidden;
  margin-right: 6px;
}
html[data-prototype-ui-host="1"] .scene-bg-toggle button {
  appearance: none;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 12px;
  line-height: 1.2;
  padding: 6px 10px;
  cursor: pointer;
}
html[data-prototype-ui-host="1"] .scene-bg-toggle button + button {
  border-left: 1px solid color-mix(in srgb, currentColor 18%, transparent);
}
html[data-prototype-ui-host="1"] .scene-bg-toggle button.is-active {
  background: color-mix(in srgb, currentColor 12%, transparent);
  font-weight: 600;
}
html[data-prototype-ui-host="1"] .scene-bg-toggle button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Split CTA „Importuj ładunki” — soft/outline na tokenach hosta (bez restylu .primary-button) */
html[data-prototype-ui-host="1"] .import-cta-group {
  display: inline-flex;
  align-items: stretch;
  gap: 0;
}
html[data-prototype-ui-host="1"] .import-cta-main {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
  min-height: 32px;
  padding-inline: 10px 9px;
}
html[data-prototype-ui-host="1"] .import-cta-soft {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid var(--accent, #395b47);
  border-radius: 4px;
  background: var(--accent-soft, #e8eee8);
  color: var(--accent, #395b47);
  cursor: pointer;
  font-size: 11px;
  font-weight: 650;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}
html[data-prototype-ui-host="1"] .import-cta-soft:hover:not(:disabled) {
  border-color: var(--accent-hover, #2f4d3c);
  background: color-mix(in srgb, var(--accent-soft, #e8eee8) 70%, var(--accent, #395b47) 30%);
  color: var(--accent-hover, #2f4d3c);
}
html[data-prototype-ui-host="1"] .import-cta-soft:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
html[data-prototype-ui-host="1"] .import-cta-soft svg {
  width: 14px;
  height: 14px;
  color: currentColor;
}
html[data-prototype-ui-host="1"] .import-cta-menu {
  min-width: 32px;
  min-height: 32px;
  padding-inline: 7px;
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  border-left: 0;
}
html[data-prototype-ui-host="1"] .import-cta-menu svg {
  width: 14px;
  height: 14px;
}
html[data-prototype-ui-host="1"] .import-cta-wrap .more-menu {
  right: 0;
  left: auto;
  min-width: 260px;
}
