/* =====================================================================
   Door designer (door-studio-demo.html) — built on the site design system
   (inventory.css, scoped under .iv). Only what the warehouse doesn't have.
   Desktop: doors | properties | elevation | profile side by side.
   Below 1024px: one panel at a time, picked by the bottom nav (#dsApp[data-tab]).
   ===================================================================== */

html, body { margin: 0; padding: 0; height: 100%; background: #f1f5f9; }
.iv.ds { box-sizing: border-box; display: flex; flex-direction: column; height: 100vh; height: 100dvh; padding: 0; background: #f1f5f9; overflow: hidden; }
.ds .hidden { display: none !important; }
.ds .ds-sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.ds input[type=number]::-webkit-inner-spin-button, .ds input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.ds input[type=number] { -moz-appearance: textfield; }
.ds ::-webkit-scrollbar { width: 6px; height: 6px; }
.ds ::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 999px; }

/* ---------- top bar ---------- */
.ds-top { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: var(--iv-panel); border-bottom: 1px solid var(--iv-border-strong); flex-shrink: 0; }
.ds-top .iv-icon-btn { width: 36px; height: 36px; }
.ds-title { min-width: 0; flex: 1; }
.ds-title h1 { margin: 0; font-size: 18px; font-weight: 800; line-height: 1.3; color: var(--iv-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ds-title .sub { font-size: 12.5px; color: var(--iv-text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ds-kpis { display: flex; gap: 6px; align-items: center; }
.ds-kpis .iv-pill { font-size: 12px; padding: 3px 10px; }
.ds-actions { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }

/* ---------- workspace grid ---------- */
.ds-main {
    flex: 1; min-height: 0; display: grid; gap: 12px; padding: 12px;
    grid-template-columns: 15rem 19rem minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    grid-template-areas: "doors props elev prof";
}
#panelDoorsList { grid-area: doors; }
#panelProps { grid-area: props; }
#panelElevationCard { grid-area: elev; }
#panelProfileCard { grid-area: prof; }
@media (max-width: 1399px) {
    .ds-main { grid-template-columns: 14rem 18rem minmax(0, 1fr); grid-template-rows: minmax(0, 1.25fr) minmax(0, 1fr); grid-template-areas: "doors props elev" "doors props prof"; }
}

.ds-panel { background: var(--iv-panel); border: 1px solid var(--iv-border-strong); border-radius: var(--iv-radius-lg); display: flex; flex-direction: column; min-height: 0; min-width: 0; overflow: hidden; }
.ds-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--iv-border); flex-shrink: 0; min-height: 48px; }
.ds-panel-head .t { font-weight: 800; font-size: 14px; display: flex; align-items: center; gap: 6px; }
.ds-panel-head .t .ti { font-size: 17px; color: var(--iv-muted); }
.ds-panel-body { flex: 1; min-height: 0; overflow-y: auto; }
.ds-panel-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 12px; border-top: 1px solid var(--iv-border); font-size: 12.5px; color: var(--iv-text-2); flex-shrink: 0; }
.ds-viewport { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 8px; overflow: hidden; }
.ds-viewport { touch-action: none; position: relative; }
.ds-viewport > svg { width: 100%; height: 100%; max-height: 100% !important; overflow: visible; }
.ds-viewport.ds-zoomed { cursor: grab; }
.ds-viewport.ds-zoomed:active { cursor: grabbing; }
.ds-zoom { display: inline-flex; align-items: center; border: 1px solid var(--iv-border-strong); border-radius: 10px; overflow: hidden; flex-shrink: 0; }
.ds-zoom button { width: 30px; height: 28px; display: inline-flex; align-items: center; justify-content: center; color: #475569; }
.ds-zoom button .ti { font-size: 15px; }
.ds-zoom button:hover { background: var(--iv-sub); color: var(--iv-accent); }
.ds-zoom .lbl { width: auto; min-width: 46px; padding: 0 6px; font-size: 11.5px; font-weight: 700; font-variant-numeric: tabular-nums; border-inline: 1px solid var(--iv-border-strong); }
.ds-panel-head .ds-flat { margin-inline-start: auto; white-space: nowrap; }
.ds-loading { color: var(--iv-muted); font-size: 13px; }

/* ---------- doors list ---------- */
.ds-search { padding: 10px 12px 4px; position: relative; }
.ds-search .ti { position: absolute; left: 22px; top: 50%; transform: translateY(-30%); color: var(--iv-muted); font-size: 16px; }
.ds .ds-search .iv-input.sm { padding-left: 34px; }
#doorsListContainer { padding: 6px 8px 8px; }
.ds-door { display: block; width: 100%; text-align: left; padding: 9px 10px; border-radius: 12px; border: 1px solid transparent; margin-bottom: 4px; transition: background .12s, border-color .12s; }
.ds-door:hover { background: var(--iv-sub); }
.ds-door.on { background: var(--iv-accent-bg); border-color: #c7d2fe; }
.ds-door-row { display: flex; align-items: center; gap: 9px; }
.ds-door-no { min-width: 34px; height: 30px; padding: 0 6px; border-radius: 9px; background: #f1f5f9; color: #334155; font-weight: 800; font-size: 12.5px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.ds-door.on .ds-door-no { background: var(--iv-accent); color: #fff; }
.ds-door .size { font-weight: 700; font-size: 13.5px; color: var(--iv-text); font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; }
.ds-door .meta { font-size: 11.5px; color: var(--iv-text-2); }
.ds-door .qty { font-size: 12px; font-weight: 700; color: var(--iv-text-2); font-variant-numeric: tabular-nums; margin-inline-start: auto; white-space: nowrap; }
.ds-door .tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; padding-inline-start: 43px; }
.ds-door .tags .iv-pill { font-size: 10.5px; padding: 1px 7px; }
.ds-empty { padding: 28px 12px; text-align: center; color: var(--iv-muted); font-size: 13px; }

/* ---------- properties ---------- */
.ds-sec { border-bottom: 1px solid var(--iv-border); padding: 0 14px; }
.ds-sec:last-child { border-bottom: 0; }
.ds-sec > summary { list-style: none; display: flex; align-items: center; justify-content: space-between; padding: 12px 0; cursor: pointer; font-weight: 800; font-size: 13.5px; user-select: none; }
.ds-sec > summary::-webkit-details-marker { display: none; }
.ds-sec > summary .ti { color: var(--iv-muted); font-size: 16px; transition: transform .15s; }
.ds-sec[open] > summary .ti { transform: rotate(90deg); }
.ds-sec-body { padding-bottom: 14px; display: flex; flex-direction: column; gap: 10px; }
.ds .iv-field > span { font-size: 12.5px; color: var(--iv-text-2); margin-bottom: 4px; }
.ds .iv-input.sm, .ds .iv-select.sm { height: 36px; font-size: 13.5px; border-radius: 10px; padding-inline: 10px; }
.ds .iv-select.sm { padding-right: 26px; }
.ds .iv-input[readonly] { background: var(--iv-sub); color: var(--iv-text-2); }
.ds-unit { position: relative; }
.ds .ds-unit .iv-input.sm { padding-right: 34px; }
.ds-unit > i { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font-style: normal; font-size: 11.5px; color: var(--iv-muted); pointer-events: none; }
.ds-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ds-grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.ds-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ds-toggle { cursor: pointer; display: inline-flex; position: relative; }
.ds-toggle .iv-chip { height: 34px; padding: 0 12px; user-select: none; }
.ds-toggle.ds-wide, .ds-toggle.ds-wide .iv-chip { width: 100%; justify-content: center; }
.ds-toggle input:checked + .iv-chip { background: var(--iv-accent-bg) !important; color: var(--iv-accent-text) !important; border-color: #c7d2fe !important; }
.ds-toggle input:checked + .iv-chip.bad { background: var(--iv-bad-bg) !important; color: var(--iv-bad) !important; border-color: var(--iv-bad-border) !important; }
.ds-toggle input:checked + .iv-chip.warn { background: var(--iv-warn-bg) !important; color: var(--iv-warn) !important; border-color: var(--iv-warn-border) !important; }
.ds-toggle input:focus-visible + .iv-chip { box-shadow: 0 0 0 3px var(--iv-accent-soft); }
.ds-toggle input:disabled + .iv-chip { opacity: .45; cursor: not-allowed; }
.ds-sub { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--iv-text-2); background: var(--iv-sub); border: 1px solid var(--iv-border); border-radius: 10px; padding: 8px 10px; }
.ds-sub .iv-input { width: 84px; flex: none; }
.ds-note { font-size: 11.5px; color: var(--iv-muted); }

/* ---------- status footer (door-studio-footer.js) ---------- */
#dsFooter { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; padding: 7px 16px; background: var(--iv-panel); border-top: 1px solid var(--iv-border-strong); font-size: 12.5px; color: var(--iv-text-2); flex-shrink: 0; }
#dsFooter b { color: var(--iv-text); font-weight: 800; font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; }

/* ---------- bottom nav (phones / tablets) ---------- */
.ds-nav { display: none; }

/* ---------- toast ---------- */
.ds-toast { opacity: 0; pointer-events: none; transform: translate(-50%, 12px); transition: opacity .2s, transform .2s; max-width: calc(100vw - 32px); }
.ds-toast.show { opacity: 1; transform: translate(-50%, 0); }
.ds-toast .ic { font-size: 16px; }
.ds-toast.ok .ic { color: #6ee7b7; }
.ds-toast.bad .ic { color: #fda4af; }
.ds-toast.warn .ic { color: #fcd34d; }
.ds-toast.info .ic { color: #a5b4fc; }

/* ---------- modals ---------- */
.ds .iv-modal-head p { margin: 2px 0 0; font-size: 12.5px; color: var(--iv-text-2); }
.ds-json { width: 100%; height: 150px; padding: 10px 12px; font-family: ui-monospace, monospace; font-size: 11.5px; background: var(--iv-dark); color: #a7f3d0; border-radius: var(--iv-radius); border: 0; outline: none; resize: vertical; }
.ds-dim-input { width: 100%; height: 56px; text-align: center; font-size: 26px; font-weight: 800; border: 1px solid var(--iv-border-input); border-radius: var(--iv-radius); outline: none; font-variant-numeric: tabular-nums; }
.ds-dim-input:focus { border-color: var(--iv-accent); box-shadow: 0 0 0 3px var(--iv-accent-soft); }
.ds-steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }

/* ---------- below 1024px: one panel at a time ---------- */
@media (max-width: 1023px) {
    .ds-main { display: block; padding: 8px; }
    .ds-main > .ds-panel { display: none; height: 100%; }
    .ds[data-tab="doors"] #panelDoorsList,
    .ds[data-tab="props"] #panelProps,
    .ds[data-tab="elevation"] #panelElevationCard,
    .ds[data-tab="profile"] #panelProfileCard { display: flex; }
    .ds-viewport { padding: 4px; }

    .iv.ds { padding-bottom: calc(60px + env(safe-area-inset-bottom)); }
    .ds-nav {
        display: grid; grid-template-columns: repeat(4, 1fr);
        position: fixed; bottom: 0; right: 0; left: 0; z-index: 41;
        background: var(--iv-panel); border-top: 1px solid var(--iv-border-strong);
        padding-bottom: env(safe-area-inset-bottom); box-shadow: 0 -4px 16px rgba(15, 23, 42, .05);
    }
    .ds-nav button { height: 60px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 11.5px; color: var(--iv-muted); position: relative; }
    .ds-nav button .ti { font-size: 22px; }
    .ds-nav button.on { color: var(--iv-accent); font-weight: 700; }
    .ds-nav .badge { position: absolute; top: 6px; right: calc(50% - 24px); background: var(--iv-accent); color: #fff; border-radius: 999px; font-size: 10px; line-height: 16px; min-width: 16px; padding: 0 4px; }
    .ds-toast { bottom: calc(72px + env(safe-area-inset-bottom)); }
    .ds-kpis { display: none; }
    #dsFooter { padding: 6px 12px; gap: 12px; }
    /* 16px stops iOS from zooming into a focused field */
    .ds .iv-input.sm, .ds .iv-select.sm, .ds .iv-input, .ds .iv-select { font-size: 16px; height: 42px; }
    .ds .ds-sub .iv-input { height: 38px; }
    .ds-toggle .iv-chip { height: 38px; }
    .ds-door { padding: 11px 10px; }
    .ds-zoom button { width: 38px; height: 34px; }
}
@media (max-width: 767px) {
    .ds-top { padding: 8px 10px; gap: 8px; }
    .ds-title h1 { font-size: 16px; }
    .ds-title .sub { font-size: 11.5px; }
    .ds-actions .iv-btn.sm { height: 36px; padding: 0 10px; }
    .ds-actions .ds-lbl { display: none; }
    .ds-actions .iv-btn.primary .ds-lbl { display: inline; }
    .ds .iv-modal-scrim { align-items: flex-end; padding: 0; }
    .ds .iv-modal { max-width: none !important; border-radius: 22px 22px 0 0; max-height: 92vh; }
}
