/* ═══════════════════════════════════════════════════════════════
   Layout — App Bar, Canvas, Inspector, Popover
   ═══════════════════════════════════════════════════════════════ */

/* ── App Bar (frosted glass) ────────────────────────────────── */
.app-bar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: 52px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 max(20px, env(safe-area-inset-left)) 0 max(20px, env(safe-area-inset-right));
  padding-top: env(safe-area-inset-top);
  background: var(--bg-glass);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border-bottom: 0.5px solid var(--separator);
  flex-shrink: 0;
}
.app-bar__left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.app-logo {
  width: 28px;
  height: 28px;
  color: var(--accent);
  flex-shrink: 0;
}
.app-bar__left h1 {
  font-size: 16px;
  font-weight: 700;
  margin: 0;
  white-space: nowrap;
  color: var(--text-primary);
  letter-spacing: -0.2px;
}
.app-bar__center {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 0;
}
.app-bar__right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.app-bar__icon {
  width: 34px;
  height: 34px;
  border: none;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: all var(--dur-fast);
}
.app-bar__icon:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}
.app-bar__icon.is-on {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 30%, transparent);
}
.app-bar__icon.is-on:hover {
  background: color-mix(in srgb, var(--accent) 85%, #000);
  color: #fff;
}
.app-bar__icon svg { pointer-events: none; }


/* ── Popover (paint settings) ───────────────────────────────── */
.popover {
  position: fixed;
  top: 56px;
  right: 20px;
  width: 420px;
  background: var(--bg-primary);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xl);
  border: 0.5px solid var(--separator);
  z-index: 100;
  opacity: 0;
  transform: translateY(-8px) scale(0.97);
  pointer-events: none;
  transition: all var(--dur) var(--ease);
  padding: 0;
}
.popover.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
.popover__body {
  padding: 20px;
}
.popover__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
.popover__field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.popover__section {
  margin-top: 16px;
}
.popover__section:first-child { margin-top: 0; }


/* ── Canvas Layout (main content) ───────────────────────────── */
.canvas-layout {
  position: relative;
  flex: 1;
  display: flex;
  min-height: 0;
  overflow: hidden;
  background: var(--scene-bg);
}

/* Canvas area (full size, holds 3D/2D) */
.canvas {
  flex: 1;
  position: relative;
  min-width: 0;
  overflow: hidden;
}
.canvas__scene {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.canvas__toolbar {
  position: absolute;
  top: 4px;
  left: 48px;
  z-index: 20;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.canvas__tools {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.canvas__zoom {
  display: flex;
  align-items: center;
  gap: 4px;
}
.canvas__btn {
  height: 30px;
  padding: 0 10px;
  border: 1px solid var(--separator-opaque);
  border-radius: var(--r-sm);
  background: var(--bg-glass-thick);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--dur-fast);
}
.canvas__btn:hover {
  background: var(--bg-primary);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

/* Floating chips (bottom-center) */
.canvas__chips {
  position: absolute;
  bottom: 16px;
  left: 50%;
  z-index: 20;
  transform: translateX(-50%);
}


/* ── Wizard (floating glass panel) ────────────────────────── */
.wizard {
  position: absolute;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  width: min(420px, calc(100% - 40px));
  max-height: calc(100vh - 60px);
  display: flex;
  flex-direction: column;
  background: rgba(255,255,255,0.68);
  backdrop-filter: blur(28px) saturate(190%);
  -webkit-backdrop-filter: blur(28px) saturate(190%);
  border-radius: var(--r-xl);
  border: 1px solid rgba(255,255,255,0.55);
  box-shadow:
    0 20px 60px rgba(0,0,0,0.10),
    0 8px 20px rgba(0,0,0,0.05),
    inset 0 1px 0 rgba(255,255,255,0.8);
  z-index: 30;
  overflow: hidden;
  animation: wizPanelIn 600ms var(--ease-spring) both;
}
[data-theme="dark"] .wizard {
  background: rgba(28,28,30,0.65);
  border-color: rgba(255,255,255,0.07);
  box-shadow:
    0 20px 60px rgba(0,0,0,0.35),
    0 8px 20px rgba(0,0,0,0.20),
    inset 0 1px 0 rgba(255,255,255,0.04);
}
/* ── Wizard drag-to-move ──────────────────────────────────── */
.wiz-progress { cursor: grab; }
.wizard.wizard--dragged { animation: none !important; }
.wizard.wizard--dragging {
  box-shadow:
    0 30px 80px rgba(0,0,0,0.18),
    0 12px 30px rgba(0,0,0,0.10),
    inset 0 1px 0 rgba(255,255,255,0.8) !important;
  filter: brightness(1.02);
  will-change: left, top;
  z-index: 40;
}
.wizard.wizard--dragging .wiz-progress { cursor: grabbing; }
.wizard.wizard--dragging, .wizard.wizard--dragging * {
  user-select: none !important;
}
[data-theme="dark"] .wizard.wizard--dragging {
  box-shadow:
    0 30px 80px rgba(0,0,0,0.45),
    0 12px 30px rgba(0,0,0,0.30),
    inset 0 1px 0 rgba(255,255,255,0.06) !important;
  filter: brightness(1.05);
}
@media (max-width: 1023px) {
  .wiz-progress { cursor: default; }
}

@keyframes wizPanelIn {
  from { opacity: 0; transform: translateY(calc(-50% + 30px)) scale(0.90); filter: blur(8px); }
  to   { opacity: 1; transform: translateY(-50%) scale(1); filter: blur(0); }
}

/* Progress bar */
.wiz-progress {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 22px 12px;
  background: transparent;
}
.wiz-progress__dots {
  display: flex;
  align-items: center;
  gap: 6px;
  position: relative;
  padding: 0 2px;
}
/* Connector line between dots */
.wiz-progress__dots::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 8px;
  right: 8px;
  height: 2px;
  background: var(--separator-opaque);
  transform: translateY(-50%);
  z-index: 0;
  border-radius: 1px;
  opacity: 0.5;
}
.wiz-progress__title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.2px;
  white-space: nowrap;
  transition: opacity 250ms var(--ease);
}

/* Step viewport — auto-sizing, scrollable */
.wiz-viewport {
  flex: 0 0 auto;
  position: relative;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 80px;
}

/* Steps — card-like appear/disappear, NOT constrained by viewport height */
.wiz-step {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: none;
  flex-direction: column;
  gap: 14px;
  padding: 10px 22px 18px;
  overflow-x: hidden;
  opacity: 0;
  transform: translateY(20px) scale(0.96);
  transition: opacity 350ms var(--ease), transform 350ms var(--ease-spring), filter 350ms var(--ease);
}
/* Scrollbar on viewport */
.wiz-viewport::-webkit-scrollbar { width: 5px; }
.wiz-viewport::-webkit-scrollbar-track { background: transparent; }
.wiz-viewport::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.08); border-radius: 3px; }
[data-theme="dark"] .wiz-viewport::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); }

.wiz-step.active {
  position: relative;
  display: flex;
  opacity: 1;
  transform: translateY(0) scale(1);
  filter: blur(0);
}
/* Exit: scale down + blur */
.wiz-step.leaving-left,
.wiz-step.leaving-right {
  display: flex;
  opacity: 0;
  transform: scale(0.92);
  filter: blur(3px);
}
/* Enter: rise up + scale */
.wiz-step.entering-right,
.wiz-step.entering-left {
  display: flex;
  opacity: 0;
  transform: translateY(20px) scale(0.96);
  filter: blur(2px);
}
.wiz-step.animating {
  transition: opacity 350ms var(--ease), transform 350ms var(--ease-spring), filter 350ms var(--ease);
}

/* Stagger animation for children inside a step */
.wiz-step.active > * {
  animation: wizFadeUp 420ms var(--ease-spring) both;
}
.wiz-step.active > *:nth-child(1) { animation-delay: 40ms; }
.wiz-step.active > *:nth-child(2) { animation-delay: 100ms; }
.wiz-step.active > *:nth-child(3) { animation-delay: 160ms; }
.wiz-step.active > *:nth-child(4) { animation-delay: 220ms; }
.wiz-step.active > *:nth-child(5) { animation-delay: 280ms; }
.wiz-step.active > *:nth-child(6) { animation-delay: 340ms; }
.wiz-step.active > *:nth-child(7) { animation-delay: 400ms; }

@keyframes wizFadeUp {
  from { opacity: 0; transform: translateY(16px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .wizard { animation: none !important; }
  .wiz-step { transition: none !important; }
  .wiz-step.active > * { animation: none !important; }
}

/* Mini result bar — floating pill inside glass panel */
.wiz-mini {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  height: 36px;
  padding: 0 14px;
  margin: 0 12px 6px;
  background: rgba(255,255,255,0.50);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: var(--r-md);
  border: 1px solid rgba(255,255,255,0.4);
  box-shadow: 0 2px 8px rgba(0,0,0,0.03);
  font-size: 12px;
  color: var(--text-secondary);
}
[data-theme="dark"] .wiz-mini {
  background: rgba(50,50,55,0.45);
  border-color: rgba(255,255,255,0.06);
}
.wiz-mini__item { white-space: nowrap; }
.wiz-mini__item b {
  color: var(--text-primary);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-size: 14px;
}
.wiz-mini__sep {
  width: 1px;
  height: 16px;
  background: var(--separator-opaque);
  flex-shrink: 0;
  opacity: 0.5;
}
.wiz-mini__price:empty { display: none; }

/* Navigation */
.wiz-nav {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 18px 16px;
  background: transparent;
}

/* Prevent overflow */
.wizard label,
.wizard input,
.wizard select { min-width: 0; max-width: 100%; box-sizing: border-box; }
.wizard .sec { overflow-x: hidden; min-width: 0; padding: 0; border-bottom: none; background: transparent; }

/* Global input restyling inside wizard */
.wizard input[type="number"],
.wizard select {
  background: rgba(255,255,255,0.55);
  border: 1px solid rgba(0,0,0,0.06);
  border-radius: var(--r-sm);
  padding: 0 12px;
  height: 38px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  transition: all 200ms var(--ease);
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.02);
  font-family: inherit;
  width: 100%;
}
.wizard input[type="number"]:focus,
.wizard select:focus {
  background: rgba(255,255,255,0.92);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg), inset 0 1px 2px rgba(0,0,0,0.02);
  outline: none;
}
[data-theme="dark"] .wizard input[type="number"],
[data-theme="dark"] .wizard select {
  background: rgba(50,50,55,0.6);
  border-color: rgba(255,255,255,0.1);
}
[data-theme="dark"] .wizard input[type="number"]:focus,
[data-theme="dark"] .wizard select:focus {
  background: rgba(50,50,55,0.85);
}
.wizard input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  flex-shrink: 0;
}

/* Labels inside wizard */
.wizard label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 5px;
  letter-spacing: 0.01em;
}
.wizard .muted { font-size: 12px; color: var(--text-secondary); }
.wizard .lab { font-size: 12px; color: var(--text-secondary); margin-bottom: 2px; }

/* Table in wizard — compact but readable */
.wizard table { font-size: 13px; width: 100%; }
.wizard th { font-size: 10px; padding: 4px 3px; white-space: nowrap; }
.wizard td { padding: 5px 3px; font-size: 13px; }
.wizard .table-surfaces { table-layout: fixed; }
.wizard .table-surfaces th { font-size: 8px; letter-spacing: 0; padding: 4px 2px; text-transform: uppercase; overflow: hidden; text-overflow: ellipsis; }
.wizard .table-surfaces td { padding: 4px 2px; }
.wizard .table-surfaces td:first-child { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 70px; }
.wizard .table-surfaces input[type="number"].mini { width: 100%; min-width: 40px; padding: 4px 3px; font-size: 12px; }
/* Simple table override — auto layout, no name truncation */
.wizard .table-surfaces--simple { table-layout: auto; }
.wizard .table-surfaces--simple td:first-child { max-width: none; overflow: visible; text-overflow: clip; }
.wizard .inline-input { width: 60px; padding: 4px 6px; font-size: 13px; font-weight: 600; }

/* Hide room management in simple mode */
#insideWrap.simple #roomManageButtons,
#insideWrap.simple #roomsList { display: none !important; }

/* Grid layout fixes for wizard width */
.wizard .grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.wizard .grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.wizard .row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

/* Surface header compact */
.wizard .surface-header { margin-bottom: 8px; }
.wizard .surface-header__top strong { font-size: 14px; }
.wizard .surface-header__area { font-size: 12px; }

/* Cards inside wizard — compact */
.wizard .card { border-radius: var(--r-md); }
.wizard .card header { padding: 8px 10px; font-size: 13px; }
.wizard .card section { padding: 8px 10px; }

/* Facade/sidecard inside wizard */
.wizard .sidecard { border-radius: var(--r-md); padding: 10px; }
.wizard .sidecard__head { gap: 6px; margin-bottom: 4px; }
.wizard .facade-toolbar { gap: 8px; }
.wizard .facade-toolbar__group { gap: 6px; }

/* Pill-seg inside wizard */
.wizard .pill-seg { font-size: 12px; }
.wizard .pill-seg button { padding: 4px 10px; font-size: 11px; }

/* Tool strip inside wizard */
.wizard .tool-strip { padding: 4px 0; border-top: none; }
.wizard .tool-strip__btns .tool-btn { padding: 5px 10px; font-size: 12px; }

/* Legacy inspector compat (hidden elements) */
.inspector__section-label { display: none; }
.inspector__tool-section { display: none; }
.inspector__subtitle {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-tertiary);
  padding: 14px 0 6px;
  border-top: 0.5px solid var(--separator);
  margin: 12px 0 0;
}


/* Hide muted hint text inside canvas scene */
.canvas__scene #planMuted,
.canvas__scene #roomMuted,
.canvas__scene > section > .muted,
.canvas__scene > section > p { display: none !important; }

/* Canvas scene sections fill space */
.canvas__scene > section {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  width: 100%;
  height: 100%;
}
.canvas__scene .room-stage,
.canvas__scene .house-stage {
  flex: 1;
  min-height: 0;
}

/* Override floorplan inline styles inside canvas */
.canvas__scene #planWrap {
  border: none !important;
  border-radius: 0 !important;
  background: var(--bg-secondary) !important;
  min-height: 0 !important;
  flex: 1;
}


/* ── Calc mode wrappers ─────────────────────────────────────── */
.calc header { display: none; }
.calc.mode-attached { border: none; border-radius: 0; margin-top: 0; background: transparent; }
.modebar { display: none; }

/* ── Developer Footer ─────────────────────────────────────── */
.dev-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 20px;
  border-top: 0.5px solid var(--separator);
  background: var(--bg-glass);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
}
.dev-footer__text {
  font-size: 12px;
  color: var(--text-tertiary);
  letter-spacing: 0.02em;
}
.dev-footer__link {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  opacity: 0.7;
  transition: opacity var(--dur-fast);
}
.dev-footer__link:hover { opacity: 1; }
.dev-footer__logo {
  height: 36px;
  width: auto;
}
[data-theme="dark"] .dev-footer__logo {
  filter: brightness(2.5);
}
