/*
  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;

  --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;
}

.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; }

.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; }

.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;
}

.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;
}

.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(--text-muted);
  margin: 14px 0 6px;
}

.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; }
