/* 3D Warehouse: the 3D view (canvas owned by js), its toolbar, and the 2D storage-row layer. */

.w3 { --w3-ink: #0f172a; --w3-muted: #64748b; --w3-line: #e2e8f0; --w3-accent: #2563EB; --w3-stock: #c9a47a; --w3-pick: #f97316; --w3-empty: #22c55e;
      container: w3 / inline-size; position: relative; width: 100%; min-height: 420px; overflow: hidden; border-radius: 12px; background: #eef1f5; color: var(--w3-ink); font-size: 13px; isolation: isolate; }
.w3 *, .w3 *::before, .w3 *::after { box-sizing: border-box; }
.w3 :focus-visible { outline: 3px solid rgb(37 99 235 / 40%); outline-offset: 2px; }
.w3 button { font: inherit; cursor: pointer; }
.w3-canvas { position: absolute; inset: 0; }
.w3--compact { border-radius: 0; }

.w3-status { position: absolute; inset: 0; display: grid; place-items: center; color: var(--w3-muted); font-weight: 600; pointer-events: none; }
.w3-status-error { color: #b91c1c; background: #fef2f2; pointer-events: auto; }

/* Toolbar floating over the 3D. */
.w3-toolbar { position: absolute; top: 12px; left: 12px; right: 12px; z-index: 3; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; pointer-events: none; }
.w3-toolbar > * { pointer-events: auto; }
.w3-search { position: relative; flex: 1 1 280px; max-width: 420px; }
.w3-search input { width: 100%; min-height: 38px; padding: 0 12px; border: 1px solid var(--w3-line); border-radius: 10px; background: rgb(255 255 255 / 96%); font: inherit; box-shadow: 0 6px 20px rgb(15 23 42 / 8%); }
.w3-hits { position: absolute; top: calc(100% + 6px); left: 0; right: 0; max-height: 340px; overflow: auto; margin: 0; padding: 4px; list-style: none; border: 1px solid var(--w3-line); border-radius: 10px; background: #fff; box-shadow: 0 16px 40px rgb(15 23 42 / 14%); }
.w3-hits button { display: flex; flex-direction: column; gap: 1px; width: 100%; padding: 7px 9px; border: 0; border-radius: 7px; background: transparent; text-align: left; }
.w3-hits button:hover, .w3-hits button.is-active { background: #eef3ff; }
.w3-hits strong { font-size: 13px; }
.w3-hits span { font-size: 11.5px; color: var(--w3-muted); }
.w3-hits-empty { padding: 10px 12px; color: var(--w3-muted); }
.w3-segment, .w3-views { display: inline-flex; padding: 3px; border: 1px solid var(--w3-line); border-radius: 10px; background: rgb(255 255 255 / 96%); box-shadow: 0 6px 20px rgb(15 23 42 / 8%); }
.w3-segment button, .w3-views button { min-height: 30px; padding: 0 11px; border: 0; border-radius: 7px; background: transparent; font-size: 12px; font-weight: 600; color: var(--w3-muted); }
.w3-segment button.is-active { background: var(--w3-ink); color: #fff; }
.w3-views button:hover { color: var(--w3-ink); }
.w3-levels { display: inline-flex; align-items: center; gap: 6px; min-height: 38px; padding: 0 6px 0 11px; border: 1px solid var(--w3-line); border-radius: 10px; background: rgb(255 255 255 / 96%); font-size: 12px; font-weight: 600; color: var(--w3-muted); box-shadow: 0 6px 20px rgb(15 23 42 / 8%); }
.w3-levels select { min-height: 28px; border: 0; background: transparent; font: inherit; color: var(--w3-ink); }

.w3-legend { position: absolute; left: 12px; bottom: 12px; z-index: 2; display: flex; align-items: center; gap: 12px; padding: 7px 11px; border-radius: 9px; background: rgb(255 255 255 / 92%); font-size: 11.5px; color: var(--w3-muted); pointer-events: none; }
.w3-legend span { display: inline-flex; align-items: center; gap: 6px; }
.w3-legend-hint { padding-left: 12px; border-left: 1px solid var(--w3-line); }
.w3-swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; }
.w3-swatch-stock { background: var(--w3-stock); }
.w3-swatch-pick { background: var(--w3-pick); }
.w3-swatch-empty { background: var(--w3-empty); opacity: .6; }

/* Hover card drawn by the 3D view. */
.w3-tip { position: absolute; top: 0; left: 0; z-index: 4; display: flex; flex-direction: column; gap: 2px; max-width: 220px; padding: 8px 10px; border-radius: 9px; background: rgb(15 23 42 / 92%); color: #fff; font-size: 12px; pointer-events: none; box-shadow: 0 10px 30px rgb(15 23 42 / 25%); }
.w3-tip[hidden] { display: none; }
.w3-tip span { color: #cbd5e1; }
.w3-tip small { color: #93c5fd; font-size: 11px; }

/* ── 2D storage row ─────────────────────────────────────────── */
.w3-row-layer { position: absolute; inset: 0; z-index: 5; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; padding: 12px; background: rgb(238 241 245 / 72%); backdrop-filter: blur(6px); animation: w3-veil 520ms ease-out both; }
@keyframes w3-in { from { opacity: 0; transform: scale(0.985); } to { opacity: 1; transform: none; } }

/* The hand-over from 3D (after the camera lands): the 3D softens behind a veil, the row card rises into
   place, then its racks appear left to right. Leaving runs the veil backwards before the camera flies out. */
@keyframes w3-veil { from { opacity: 0; backdrop-filter: blur(0); } to { opacity: 1; backdrop-filter: blur(6px); } }
@keyframes w3-rise { from { opacity: 0; transform: translateY(18px) scale(0.985); } to { opacity: 1; transform: none; } }
@keyframes w3-up { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes w3-out { to { opacity: 0; transform: scale(0.99); } }
.w3-row-layer > .w3-row { animation: w3-rise 480ms cubic-bezier(.2, .7, .2, 1) 140ms both; }
.w3-row-layer .w3-rack { animation: w3-up 420ms cubic-bezier(.2, .7, .2, 1) both; animation-delay: calc(300ms + var(--w3-order, 0) * 80ms); }
.w3-row-layer > .w3-bin-panel { animation: w3-rise 380ms cubic-bezier(.2, .7, .2, 1) both; }
.w3-row-layer.is-leaving { animation: w3-out 320ms ease-in forwards; pointer-events: none; }
.w3-row { display: flex; flex-direction: column; min-width: 0; min-height: 0; border: 1px solid var(--w3-line); border-radius: 12px; background: #fff; box-shadow: 0 16px 50px rgb(15 23 42 / 12%); }
.w3-row-head { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--w3-line); flex-wrap: wrap; }
.w3-back { min-height: 34px; padding: 0 12px; border: 1px solid var(--w3-line); border-radius: 8px; background: #fff; font-weight: 700; }
.w3-back:hover { border-color: var(--w3-accent); color: var(--w3-accent); }
.w3-row-title { display: flex; flex-direction: column; gap: 1px; flex: 1; min-width: 200px; }
.w3-row-title strong { font-size: 15px; }
.w3-row-title span { font-size: 12px; color: var(--w3-muted); }
.w3-row-nav { display: flex; gap: 6px; }
.w3-row-nav button { min-height: 32px; padding: 0 11px; border: 1px solid var(--w3-line); border-radius: 8px; background: #fff; font-size: 12px; font-weight: 600; }
.w3-row-nav button:hover { border-color: var(--w3-accent); color: var(--w3-accent); }

.w3-elevation { flex: 1; min-height: 0; display: flex; align-items: flex-end; gap: 10px; padding: 18px 18px 22px; overflow: auto; background: #fff; }
.w3-rack { display: flex; flex-direction: column; gap: 6px; flex: 1 0 calc(var(--w3-positions) * 74px); max-width: calc(var(--w3-positions) * 130px); height: calc(100% * var(--w3-rack-levels) / var(--w3-levels)); min-height: calc(var(--w3-rack-levels) * 52px); }
.w3-rack-label { align-self: center; padding: 2px 8px; border-radius: 6px; font-size: 12px; font-weight: 700; color: var(--w3-muted); }
.w3-rack.is-focus .w3-rack-label { background: var(--w3-accent); color: #fff; }
.w3-rack-frame { flex: 1; display: flex; flex-direction: column; gap: 0; padding: 0 5px; border-left: 5px solid #475569; border-right: 5px solid #475569; }
.w3-rack.is-pallet .w3-rack-frame { border-color: #1e40af; }
.w3-shelf { position: relative; flex: 1; display: grid; grid-template-columns: repeat(var(--w3-positions), minmax(0, 1fr)); gap: 5px; padding: 5px 0 4px; border-bottom: 4px solid #94a3b8; }
.w3-rack.is-pallet .w3-shelf { border-bottom-color: #f97316; border-bottom-width: 6px; }
.w3-shelf:last-child { border-bottom-color: #334155; }
.w3-level-number { position: absolute; left: -26px; bottom: 6px; width: 16px; text-align: right; font-size: 11px; font-weight: 700; color: #94a3b8; }
.w3-rack:not(:first-child) .w3-level-number { display: none; }

.w3-bin { position: relative; display: flex; align-items: flex-start; justify-content: flex-start; min-height: 40px; padding: 5px 6px; border: 1px solid var(--w3-line); border-radius: 6px; background: #f8fafc; overflow: hidden; text-align: left; transition: transform 120ms ease, box-shadow 120ms ease; }
.w3-bin:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgb(15 23 42 / 12%); }
.w3-bin-code { position: relative; z-index: 1; font-size: 11.5px; font-weight: 700; color: var(--w3-ink); }
.w3-bin-fill { position: absolute; left: 0; right: 0; bottom: 0; opacity: .85; }
.w3-bin.is-stocked .w3-bin-fill { background: var(--w3-stock); }
.w3-bin.is-picking .w3-bin-fill { background: var(--w3-pick); }
.w3-bin.is-picking { border-color: #fdba74; }
.w3-bin.is-empty { background: repeating-linear-gradient(135deg, #f8fafc 0 6px, #f1f5f9 6px 12px); }
.w3-bin.is-dimmed { opacity: .35; }
.w3-bin.is-selected { outline: 3px solid var(--w3-accent); outline-offset: 1px; opacity: 1; }

/* Bin detail panel. */
.w3-bin-panel { width: 280px; align-self: start; display: flex; flex-direction: column; gap: 10px; padding: 14px; border: 1px solid var(--w3-line); border-radius: 12px; background: #fff; box-shadow: 0 16px 50px rgb(15 23 42 / 12%); animation: w3-in 200ms ease-out; }
.w3-bin-panel header { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.w3-bin-panel header div { display: flex; flex-direction: column; }
.w3-bin-panel header strong { font-family: 'DM Mono', ui-monospace, monospace; font-size: 13px; overflow-wrap: anywhere; }
.w3-eyebrow { font-size: 10px; font-weight: 700; letter-spacing: 1.2px; text-transform: uppercase; color: var(--w3-muted); }
.w3-close { width: 28px; height: 28px; border: 1px solid var(--w3-line); border-radius: 7px; background: #fff; font-size: 16px; line-height: 1; }
.w3-pick-note { margin: 0; padding: 7px 9px; border-radius: 7px; background: #fff7ed; color: #c2410c; font-weight: 600; font-size: 12px; }
.w3-muted { margin: 0; color: var(--w3-muted); }
.w3-lines { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; list-style: none; }
.w3-lines li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px; border: 1px solid var(--w3-line); border-radius: 8px; }
.w3-lines li div { display: flex; flex-direction: column; min-width: 0; }
.w3-lines li span { font-size: 11.5px; color: var(--w3-muted); }
.w3-lines li b { font-family: 'DM Mono', ui-monospace, monospace; font-size: 15px; }

/* ── 3D row (desktop): a bar over the 3D row, the bin panel docked on the right ── */
.w3-rowbar { position: absolute; left: 12px; right: 12px; bottom: 12px; z-index: 4; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; pointer-events: none; animation: w3-rise 420ms cubic-bezier(.2, .7, .2, 1) both; }
.w3-rowbar > * { pointer-events: auto; }
.w3-rowbar .w3-row-head { align-self: stretch; border: 1px solid var(--w3-line); border-radius: 12px; background: rgb(255 255 255 / 96%); box-shadow: 0 12px 36px rgb(15 23 42 / 14%); }
.w3-rowbar-hint { margin: 0; padding: 4px 10px; border-radius: 8px; background: rgb(255 255 255 / 86%); font-size: 11.5px; color: var(--w3-muted); pointer-events: none; }
.w3-dock { position: absolute; right: 12px; bottom: 104px; z-index: 4; width: 280px; max-height: calc(100% - 180px); overflow: auto; }
.w3-dock .w3-bin-panel { width: auto; }
.w3-row-nav .w3-view-switch { min-height: 32px; padding: 0 11px; border: 1px solid var(--w3-ink); border-radius: 8px; background: var(--w3-ink); color: #fff; font-size: 12px; font-weight: 600; }
.w3-row-head button:disabled { opacity: .5; cursor: default; }

/* ── Aisle list (the phone default; no 3D downloaded) ───────── */
.w3--list { display: flex; flex-direction: column; background: #f8fafc; }
.w3--list .w3-canvas { display: none; }
.w3--list .w3-toolbar { position: relative; inset: auto; padding: 12px; border-bottom: 1px solid var(--w3-line); background: #fff; }
.w3--list .w3-search input, .w3--list .w3-segment { box-shadow: none; }
.w3-list { flex: 1; min-height: 0; overflow: auto; display: flex; flex-direction: column; gap: 18px; padding: 14px 12px 20px; overscroll-behavior: contain; }
.w3-list-zone > header { display: flex; align-items: baseline; gap: 8px; margin: 0 2px 8px; }
.w3-list-zone > header strong { font-size: 14px; }
.w3-list-zone > header span { font-size: 12px; color: var(--w3-muted); }
.w3-list-dot { display: inline-block; width: 10px; height: 10px; border: 1px solid rgb(15 23 42 / 15%); border-radius: 3px; align-self: center; }
.w3-list-zone ul { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 8px; margin: 0; padding: 0; list-style: none; }
.w3-list-aisle { display: flex; flex-direction: column; gap: 8px; padding: 10px; border: 1px solid var(--w3-line); border-radius: 12px; background: #fff; }
.w3-list-aisle-name { font-size: 11px; font-weight: 700; letter-spacing: .8px; text-transform: uppercase; color: var(--w3-muted); }
.w3-list-sides { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 8px; }
.w3-list-side { display: flex; flex-direction: column; gap: 7px; min-width: 0; min-height: 76px; padding: 10px; border: 1px solid var(--w3-line); border-radius: 10px; background: #f8fafc; color: var(--w3-ink); text-align: left; -webkit-tap-highlight-color: transparent; }
.w3-list-side:hover, .w3-list-side:active { border-color: var(--w3-accent); }
.w3-list-side.has-picks { border-color: #fdba74; background: #fff7ed; }
.w3-list-side-head { display: flex; flex-direction: column; min-width: 0; }
.w3-list-side-head small { overflow: hidden; font-size: 11px; color: var(--w3-muted); text-overflow: ellipsis; white-space: nowrap; }
.w3-list-meter { display: flex; height: 6px; overflow: hidden; border-radius: 3px; background: #e2e8f0; }
.w3-list-meter-stock { background: var(--w3-stock); }
.w3-list-meter-pick { background: var(--w3-pick); }
.w3-list-figure { font-size: 12px; color: var(--w3-muted); }
.w3-list-figure b { color: var(--w3-ink); }

/* Catalog card thumbnail fills the preview box. */
.pb-preview-scaler > .w3 { height: 100% !important; border-radius: 0; }
.pb-demo-shell:fullscreen .w3, .pb-demo-shell.is-maximized .w3 { height: calc(100dvh - 82px) !important; }

/* Narrow frames: the bin panel goes under the row. The component sizes by its own width, not the screen's. */
@container w3 (max-width: 860px) {
    .w3-row-layer { grid-template-columns: 1fr; overflow: auto; }
    .w3-bin-panel { width: auto; }
    .w3-legend-hint { display: none; }
}

/* Phones: full-bleed row, bins big enough for a thumb, the bin panel as a bottom sheet. */
@container w3 (max-width: 700px) {
    .w3-search { flex-basis: 100%; max-width: none; }
    .w3-toolbar { gap: 6px; }
    .w3-segment button { padding: 0 9px; }
    .w3-row-layer { display: block; padding: 0; overflow: hidden; background: #fff; backdrop-filter: none; animation-name: w3-up; }
    .w3-row { height: 100%; border: 0; border-radius: 0; box-shadow: none; }
    .w3-row-head { gap: 8px; padding: 10px 12px; }
    .w3-row-title { min-width: 0; flex-basis: calc(100% - 90px); }
    .w3-row-nav { width: 100%; }
    .w3-row-nav button { flex: 1; }
    .w3-elevation { gap: 8px; padding: 14px 12px 18px 30px; scroll-snap-type: x proximity; }
    .w3-rack { flex-basis: calc(var(--w3-positions) * 66px); scroll-snap-align: center; }
    .w3-bin { min-height: 46px; }
    .w3-bin-panel { position: absolute; left: 0; right: 0; bottom: 0; z-index: 2; max-height: 62%; overflow: auto; border-width: 1px 0 0;
                    border-radius: 16px 16px 0 0; box-shadow: 0 -12px 40px rgb(15 23 42 / 18%); animation: w3-sheet 220ms ease-out; }
    .w3-bin-panel::before { content: ""; align-self: center; width: 40px; height: 4px; margin: -4px 0 2px; border-radius: 2px; background: #cbd5e1; }
}
@keyframes w3-sheet { from { transform: translateY(40%); opacity: 0; } to { transform: none; opacity: 1; } }

/* Touch: controls at least 40 px tall. */
@media (pointer: coarse) {
    .w3-segment button, .w3-views button, .w3-row-nav button, .w3-back { min-height: 40px; }
    .w3-close { width: 40px; height: 40px; }
    .w3-search input { min-height: 44px; font-size: 16px; /* 16 px stops iOS zooming into the field */ }
}

@media (prefers-reduced-motion: reduce) {
    .w3-row-layer, .w3-row-layer > .w3-row, .w3-row-layer .w3-rack, .w3-row-layer > .w3-bin-panel, .w3-bin-panel { animation: none; }
    .w3-bin { transition: none; }
}
