/*
  Kitchen Designer — internal tool. UI chrome uses NLD's own ink/paper/accent
  tokens for brand consistency across internal tools; the drawing stage stays
  neutral white/light-gray, matching standard CAD-precision-tool convention
  (the work surface should never compete visually with the drawing on it).
*/

:root {
  --ink: #1A1A1A;
  --paper: #F5F2EC;
  --accent: #FF6B35;
  --surface: #FFFFFF;
  --border: #E2DDD6;
  --text-muted: #6B6560;
  --canvas-bg: #FAFAF8;
  --grid-line: #E8E5DF;
  --danger: #C94040;
  /* Palette subgroup-heading color (2026-07-19 owner ask: "orange for visual
     separation"). A separate variable from --accent on purpose -- --accent
     also drives selection/hover/interactive states elsewhere, and the owner
     wants one dedicated place to retune the palette's own label color
     without touching those. Close to --accent's hue by default, not a
     forced reuse of it. */
  --palette-category: #E8791A;

  --toolbar-h: 48px;
  --rail-w: 64px;
  --panel-w: 280px;
}

* , *::before, *::after { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  font-family: -apple-system, "Segoe UI", Inter, sans-serif;
  font-size: 13px;
  color: var(--ink);
  background: var(--paper);
}

#app {
  height: 100vh;
  display: grid;
  grid-template-rows: var(--toolbar-h) 1fr;
}

/* ---------- Top toolbar ---------- */
#top-toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 16px;
  background: var(--ink);
  color: var(--paper);
  border-bottom: 1px solid var(--border);
}

.brand {
  font-weight: 700;
  letter-spacing: 0.02em;
  font-size: 13px;
  white-space: nowrap;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 4px;
}

.tbtn {
  background: transparent;
  border: 1px solid rgba(245, 242, 236, 0.18);
  color: var(--paper);
  border-radius: 4px;
  padding: 6px 10px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.tbtn:hover:not(:disabled) {
  background: rgba(245, 242, 236, 0.1);
  border-color: rgba(245, 242, 236, 0.32);
}

.tbtn:disabled {
  opacity: 0.35;
  cursor: default;
}

/* Public demo build only (js/app.js lockPublicDemo). */
.tbtn.tbtn--hero { background: #FF6B35; border-color: #FF6B35; color: #1A1A1A; font-weight: 700; }
.tbtn.tbtn--hero:hover:not(:disabled) { background: #ff8455; border-color: #ff8455; }
.demo-note {
  font-size: 12px;
  color: rgba(245, 242, 236, 0.7);
  margin-left: 6px;
  white-space: nowrap;
}
.demo-note a { color: #FF6B35; font-weight: 600; text-decoration: none; }
.demo-note a:hover { text-decoration: underline; }

.tbtn-sep {
  width: 1px;
  height: 20px;
  background: rgba(245, 242, 236, 0.15);
  margin: 0 4px;
}

.toolbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.project-name {
  font-size: 12px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  outline: none;
  max-width: 240px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.project-name:focus {
  background: rgba(245, 242, 236, 0.1);
}

.save-status {
  font-size: 11px;
  color: rgba(245, 242, 236, 0.55);
  letter-spacing: 0.02em;
  min-width: 46px;
}

.save-status.dirty { color: var(--accent); }

/* ---------- Body row ---------- */
#body-row {
  display: grid;
  grid-template-columns: var(--rail-w) var(--panel-w) 1fr;
  min-height: 0;
}

/* ---------- Left icon rail ---------- */
#left-rail {
  background: var(--ink);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding-top: 8px;
  border-right: 1px solid var(--border);
}

.rail-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: transparent;
  border: none;
  color: rgba(245, 242, 236, 0.6);
  padding: 10px 4px;
  cursor: pointer;
  font-family: inherit;
  font-size: 10px;
  letter-spacing: 0.02em;
}

.rail-btn:hover { color: var(--paper); }

.rail-btn.active {
  color: var(--paper);
  box-shadow: inset 3px 0 0 var(--accent);
  background: rgba(255, 255, 255, 0.04);
}

.rail-icon { font-size: 18px; line-height: 1; }

/* ---------- Side panel ---------- */
#side-panel {
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
}

.panel { display: none; padding: 16px; }
.panel.active { display: block; }

.panel-heading {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.panel-heading-secondary { margin-top: 20px; }

/* Owner ask: Layout panel's own section headings (Wall Type/Layout, Render
   Style, Finish, Room Dimensions, Openings, Room Presets) colored orange to
   match the Cabinets panel's subgroup-heading orange (--palette-category).
   Scoped to #panel-layout only -- the Cabinets/Files panels' own headings
   are untouched. */
#panel-layout .panel-heading,
#panel-layout .panel-heading-secondary {
  color: var(--palette-category);
}

.preset-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.preset-btn {
  margin-bottom: 0;
  text-align: center;
  font-size: 11px;
  padding: 10px 6px;
}

.panel-note {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 12px;
}

.tool-btn {
  display: block;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--ink);
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  margin-bottom: 10px;
  transition: border-color 0.12s ease, background 0.12s ease;
}

.tool-btn:hover { border-color: var(--accent); }

.tool-btn.active {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

.project-list { display: flex; flex-direction: column; gap: 6px; }

.room-dimensions-fields { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }

.room-dimension-field { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

.room-dimension-field label { font-size: 12px; color: var(--text-muted); }

.room-dimension-field input {
  width: 90px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  font-family: inherit;
  background: var(--surface);
  color: var(--ink);
  text-align: right;
}

.room-dimension-field input:focus { outline: none; border-color: var(--accent); }

.wall-type-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}

.wall-type-btn {
  margin-bottom: 0;
  text-align: center;
  font-size: 11px;
  padding: 10px 6px;
}

.finish-toggle {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(70px, 1fr));
  gap: 8px;
  margin-bottom: 8px;
}

.finish-btn {
  margin-bottom: 0;
  text-align: center;
  font-size: 11px;
  padding: 10px 6px;
}

.finish-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.render-style-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}

.render-style-btn {
  margin-bottom: 0;
  text-align: center;
  font-size: 11px;
  padding: 10px 6px;
}

.project-list-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  background: var(--surface);
}

.project-list-item:hover { border-color: var(--accent); }
.project-list-item .name { font-weight: 600; font-size: 12px; }
.project-list-item .meta { font-size: 10.5px; color: var(--text-muted); }

/* ---------- Stage ---------- */
#stage-wrap {
  position: relative;
  background: var(--canvas-bg);
  overflow: hidden;
}

#stage {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

#viewer-3d {
  position: absolute;
  inset: 0;
}

#viewer-elevation {
  position: absolute;
  inset: 0;
  overflow: auto;
  background: #ffffff;
}

.hidden { display: none !important; }

#view-toggle {
  position: absolute;
  left: 16px;
  bottom: 16px;
  display: flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.view-btn {
  background: transparent;
  border: none;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  color: var(--text-muted);
  cursor: pointer;
}

.view-btn + .view-btn { border-left: 1px solid var(--border); }
.view-btn.active { background: var(--ink); color: var(--paper); }

/* ---------- Cabinet palette (Milestone 6) ---------- */
.cabinet-subgroup-heading {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--palette-category);
  margin: 14px 0 6px;
}

/* Collapsible subgroups (owner ask: a compact CTA per subgroup -- click to
   reveal that group's cards, click again to close -- so the palette stays
   short by default instead of one long scroll through every card). The
   heading itself becomes the toggle button; .cabinet-subgroup-cards wraps
   that group's cards and is hidden by default via the existing .hidden
   utility, toggled independently per group (not accordion-exclusive). */
.cabinet-subgroup-toggle {
  display: flex;
  align-items: center;
  gap: 5px;
  width: 100%;
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
  font: inherit;
  text-align: left;
}
.cabinet-subgroup-disclosure {
  font-size: 9px;
  flex: none;
}
.cabinet-subgroup-cards {
  /* Plain block flow -- .cabinet-card's own margin-bottom already spaces
     cards, matching their original layout before this wrapper existed. */
  margin-top: 2px;
}

.cabinet-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  margin-bottom: 6px;
  cursor: grab;
  user-select: none;
  touch-action: none;
}

.cabinet-card:hover { border-color: var(--accent); }
.cabinet-card.dragging { opacity: 0.4; }
.cabinet-card .sku { font-weight: 700; font-size: 11.5px; }
.cabinet-card .name { font-size: 10.5px; color: var(--text-muted); }
.cabinet-card .dims { font-size: 10px; color: var(--text-muted); white-space: nowrap; }

.cabinet-ghost {
  position: fixed;
  z-index: 50;
  pointer-events: none;
  padding: 4px 10px;
  border-radius: 4px;
  background: var(--ink);
  color: var(--paper);
  font-size: 11px;
  font-weight: 700;
  transform: translate(-50%, -50%);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

/* ---------- Dimension edit input (Milestone 3) ---------- */
.dim-edit-input {
  position: absolute;
  transform: translate(-50%, -50%);
  z-index: 20;
  font: 700 12px -apple-system, "Segoe UI", Inter, sans-serif;
  padding: 2px 6px;
  border: 1.5px solid var(--accent);
  border-radius: 4px;
  background: var(--surface);
  color: var(--ink);
  text-align: center;
  min-width: 78px;
}

.dim-edit-input:focus { outline: none; }


/* ---------- Tool strip, docked in the left rail under Layout/Cabinets/Files (2026-10-12) ---------- */
.rail-sep { height: 1px; background: rgba(255, 255, 255, 0.14); margin: 8px 10px; }
.tool-strip { display: flex; flex-direction: column; align-items: stretch; gap: 2px; padding: 0 4px; }
.tool-strip.hidden { display: none; }
.ts-btn {
  width: 100%; padding: 7px 0 5px; border: 0; border-radius: 6px; background: transparent;
  display: flex; flex-direction: column; align-items: center; gap: 3px; cursor: pointer;
  color: rgba(245, 242, 236, 0.62); font-family: inherit; font-size: 10px; font-weight: 600; line-height: 1; letter-spacing: .01em;
}
.ts-btn svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linejoin: round; stroke-linecap: round; }
.ts-btn:hover { color: var(--paper); background: rgba(255, 255, 255, 0.06); }
.ts-btn.active { color: var(--paper); background: rgba(255, 255, 255, 0.10); box-shadow: inset 0 0 0 1px var(--accent); }
.ts-btn.active svg { stroke: var(--accent); }
.ts-sep { height: 1px; background: rgba(255, 255, 255, 0.14); margin: 3px 6px; }
.rail-collapse { margin-top: auto; margin-bottom: 8px; }

/* Collapsed side panel: more room to design. */
#body-row.panel-collapsed { grid-template-columns: var(--rail-w) 0 1fr; }
#body-row.panel-collapsed #side-panel { overflow: hidden; border-right: 0; }

/* ---------- Wall height controls ---------- */
.wall-height-controls { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 6px; }
.wall-height-controls .tool-btn { padding-left: 2px; padding-right: 2px; font-size: 12px; white-space: nowrap; margin: 0; }
.wall-height-input { grid-column: 1 / -1; border: 1px solid var(--border); border-radius: 6px; padding: 7px 10px; font-family: inherit; font-size: 13px; text-align: right; }
.wall-height-input::placeholder { color: var(--text-muted); text-align: left; }
.wall-height-controls.disabled .tool-btn, .wall-height-controls.disabled input { opacity: .45; pointer-events: none; }
