/* ═══════════════════════════════════════════════════════
   Floor Planner – Minimal Flat UI
   ═══════════════════════════════════════════════════════ */

:root {
  --bg-app: #f5f5f5;
  --bg-canvas: #eaeaea;
  --bg-panel: #ffffff;
  --bg-toolbar: #ffffff;
  --bg-input: #f5f5f5;
  --bg-hover: #ebebeb;
  --bg-selected: #e8f4fd;

  --border: #e0e0e0;
  --border-input: #d5d5d5;
  --border-focus: #18a0fb;

  --text: #222;
  --text-secondary: #555;
  --text-muted: #999;

  --accent: #18a0fb;
  --accent-hover: #0d8de4;
  --danger: #e53935;

  --toolbar-h: 48px;
  --sidebar-w: 260px;
  --radius: 8px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  overflow: hidden;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 12px;
  color: var(--text);
  background: var(--bg-app);
  -webkit-font-smoothing: antialiased;
}

input,
button,
select,
textarea {
  font: inherit;
  color: inherit;
}

/* ─── App ──────────────────────────────────────────── */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* ─── Toolbar ──────────────────────────────────────── */
#toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  height: var(--toolbar-h);
  padding: 0 16px;
  background: var(--bg-toolbar);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 100;
}

.toolbar-section {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toolbar-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.toolbar-divider {
  width: 1px;
  height: 20px;
  background: var(--border);
}

.toolbar-actions {
  margin-left: auto;
}

/* ─── Inputs ───────────────────────────────────────── */
.dimension-group {
  display: flex;
  align-items: center;
  gap: 4px;
}

.dim-input-pair {
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--bg-input);
  border: none;
  border-radius: var(--radius);
  padding: 0 8px;
  height: 34px;
}

.dim-input-pair:focus-within {
  box-shadow: 0 0 0 2px var(--border-focus);
}

.dim-input-pair.compact {
  flex: 1;
}

.dim-input {
  width: 32px;
  padding: 2px 0;
  background: transparent;
  border: none;
  outline: none;
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

.dim-input-sm {
  width: 24px;
}

.dim-input::-webkit-inner-spin-button {
  opacity: 0;
  width: 0;
}

.dim-unit {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 500;
  user-select: none;
}

.dim-x {
  font-size: 11px;
  color: var(--text-muted);
  margin: 0 2px;
}

.text-input {
  width: 100%;
  height: 34px;
  padding: 0 10px;
  background: var(--bg-input);
  border: none;
  border-radius: var(--radius);
  outline: none;
}

.text-input:focus {
  box-shadow: 0 0 0 2px var(--border-focus);
}



.select-input {
  height: 34px;
  padding: 0 22px 0 10px;
  background: var(--bg-input);
  border: none;
  border-radius: var(--radius);
  outline: none;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='8' height='5' viewBox='0 0 8 5' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l3 3 3-3' stroke='%23999' stroke-width='1.2' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
}

.select-input:focus {
  box-shadow: 0 0 0 2px var(--border-focus);
}

.color-input {
  width: 34px;
  height: 34px;
  border: none;
  border-radius: var(--radius);
  background: none;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
}

.color-input::-webkit-color-swatch-wrapper {
  padding: 3px;
}

.color-input::-webkit-color-swatch {
  border: none;
  border-radius: 5px;
}

.range-input {
  width: 70px;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--border);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

.range-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
  box-shadow: 0 0 2px rgba(0, 0, 0, 0.2);
  cursor: pointer;
}

.color-pick-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.preset-colors {
  display: flex;
  gap: 3px;
  flex-wrap: wrap;
}

.preset-swatch {
  width: 18px;
  height: 18px;
  border-radius: 3px;
  border: 1px solid rgba(0, 0, 0, 0.06);
  cursor: pointer;
  transition: transform 0.1s;
}

.preset-swatch:hover {
  transform: scale(1.15);
}

/* ─── Buttons ──────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 34px;
  padding: 0 12px;
  border: none;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.1s;
  outline: none;
}

.btn svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.btn-sm {
  height: 30px;
  padding: 0 10px;
  font-size: 11px;
}

.btn-full {
  width: 100%;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-accent {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  height: 36px;
  font-size: 13px;
}

.btn-accent:hover {
  background: var(--accent-hover);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-input);
}

.btn-ghost:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.btn-tool {
  background: transparent;
  color: var(--text-secondary);
  gap: 4px;
  padding: 0 10px;
  height: 34px;
}

.btn-tool:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.btn-tool.active {
  background: var(--bg-selected);
  color: var(--accent);
}

.btn-tool svg {
  width: 14px;
  height: 14px;
}

.btn-tool .chevron {
  width: 8px;
  height: 8px;
  margin-left: 1px;
  opacity: 0.5;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover {
  background: #c62828;
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  background: none;
  border: none;
  border-radius: var(--radius);
  color: var(--text-muted);
  cursor: pointer;
}

.btn-icon:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.btn-icon svg {
  width: 14px;
  height: 14px;
}

/* ─── Dropdown ─────────────────────────────────────── */
.dropdown {
  position: relative;
  display: inline-flex;
}

.dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 170px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px;
  z-index: 200;
}

.dropdown.open .dropdown-menu {
  display: block;
}

.dropdown-section-title {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  padding: 6px 8px 3px;
  letter-spacing: 0.04em;
}

.dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: 3px 0;
}

.dropdown-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 6px 8px;
  border: none;
  background: none;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.dropdown-item:hover {
  background: var(--bg-hover);
}

.dropdown-hint {
  font-size: 10px;
  color: var(--text-muted);
}

/* ─── Workspace ────────────────────────────────────── */
#workspace {
  display: flex;
  flex: 1;
  min-height: 0;
}

#canvas-container {
  flex: 1;
  position: relative;
  background: var(--bg-canvas);
  overflow: hidden;
}

#floorCanvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: default;
}

#canvas-info {
  position: absolute;
  bottom: 12px;
  left: 12px;
  display: flex;
  gap: 10px;
  padding: 4px 10px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  pointer-events: none;
}

#measure-info {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  padding: 5px 14px;
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 600;
  pointer-events: none;
  display: none;
  z-index: 50;
}

/* ─── Sidebar ──────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-w);
  background: var(--bg-panel);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  flex-shrink: 0;
}

#left-sidebar {
  width: var(--sidebar-w);
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  flex-shrink: 0;
}

#left-sidebar .panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

#left-sidebar .layers-body {
  flex: 1;
  overflow-y: auto;
}

#sidebar::-webkit-scrollbar,
#left-sidebar::-webkit-scrollbar {
  width: 4px;
}

#sidebar::-webkit-scrollbar-track,
#left-sidebar::-webkit-scrollbar-track {
  background: transparent;
}

#sidebar::-webkit-scrollbar-thumb,
#left-sidebar::-webkit-scrollbar-thumb {
  background: #d0d0d0;
  border-radius: 10px;
}

/* ─── Panels ───────────────────────────────────────── */
.panel {
  border-bottom: 1px solid var(--border);
}

.panel-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 12px 16px 8px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: default;
  user-select: none;
}

/* ─── Properties ───────────────────────────────────── */
.panel-body {
  padding: 4px 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.prop-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 36px;
  padding: 3px 0;
}

.prop-row>label {
  width: 60px;
  flex-shrink: 0;
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

.prop-row>.text-input,
.prop-row>.dim-input-pair,
.prop-row>.color-pick-row,
.prop-row>.color-input {
  flex: 1;
  min-width: 0;
}

.badge {
  margin-left: auto;
  padding: 1px 6px;
  background: var(--bg-hover);
  color: var(--text-muted);
  border-radius: 8px;
  font-size: 10px;
  font-weight: 600;
}

/* ─── Layers ───────────────────────────────────────── */
.layers-body {
  padding: 0 !important;
  max-height: 360px;
  overflow-y: auto;
}

.layer-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 16px;
  cursor: pointer;
  transition: background 0.08s;
  border-bottom: 1px solid #f5f5f5;
  user-select: none;
  min-height: 36px;
}

.layer-item:hover {
  background: var(--bg-hover);
}

.layer-item.selected {
  background: var(--bg-selected);
  border-left: 2px solid var(--accent);
  padding-left: 14px;
}

.layer-swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex-shrink: 0;
}

.layer-info {
  flex: 1;
  min-width: 0;
}

.layer-name {
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.layer-dims {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 1px;
}

.layer-actions {
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.08s;
}

.layer-item:hover .layer-actions,
.layer-item.selected .layer-actions {
  opacity: 1;
}

.empty-state {
  padding: 30px 16px;
  color: var(--text-muted);
  text-align: center;
}

.empty-icon {
  width: 32px;
  height: 32px;
  margin-bottom: 8px;
  opacity: 0.15;
}

.empty-state p {
  font-weight: 600;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 2px;
}

.empty-state span {
  font-size: 11px;
}

/* ─── Doors Section ────────────────────────────────── */
.prop-section {
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.prop-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.doors-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.door-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  background: var(--bg-input);
  border-radius: var(--radius);
  font-size: 11px;
}

.door-item select {
  height: 26px;
  padding: 0 4px;
  font-size: 11px;
  border: none;
  border-radius: 4px;
  background: var(--bg-panel);
  outline: none;
  cursor: pointer;
}

.door-item .dim-input {
  width: 42px;
  height: 26px;
  font-size: 11px;
  text-align: center;
  border: none;
  border-radius: 4px;
  background: var(--bg-panel);
}

.door-item .btn-icon {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

.door-item .btn-icon svg {
  width: 12px;
  height: 12px;
}

/* ─── Edit Actions ─────────────────────────────────── */
.edit-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

/* ─── Panel Footer ─────────────────────────────────── */
.panel-footer {
  padding: 8px 16px 12px;
  border-top: 1px solid var(--border);
}

/* ─── Responsive ───────────────────────────────────── */
@media (max-width: 900px) {
  :root {
    --sidebar-w: 240px;
  }
}

@media (max-width: 700px) {
  #toolbar {
    flex-wrap: wrap;
    height: auto;
    padding: 8px 10px;
    gap: 6px;
  }

  :root {
    --sidebar-w: 200px;
  }
}