/* Planungstool Hausbau — Listenansicht, Desktop-first. */

:root {
  --ink:        #10141C;
  --surface:    #171D28;
  --surface-2:  #1F2734;
  --line:       #2B3442;
  --paper:      #EFEDE6;
  --muted:      #8792A3;
  --accent:     #D8A857;
  --bad:        #6FA4D8;
  --fliesen:    #7CB88F;
  --parkett:    #D8A857;
  --sonstige:   #8792A3;
  --danger:     #C57C7C;
  --danger-bg:  #3A2429;
  --garage:     #A88C6B;

  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --r: 12px;
  --pad: 20px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

h1, h2 { font-weight: 600; letter-spacing: -0.01em; margin: 0; }
h2 { font-size: 15px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 12px; }

button, input, select { font: inherit; color: inherit; }
input, select {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  width: 100%;
}
input:focus, select:focus { outline: 1px solid var(--accent); }

label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }

.btn {
  background: var(--accent);
  color: var(--ink);
  border: 0;
  border-radius: 8px;
  padding: 10px 16px;
  font-weight: 600;
  cursor: pointer;
}
.btn:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; color: var(--paper); border: 1px solid var(--line); }
.btn-danger {
  background: var(--danger-bg); color: var(--danger); width: 32px; height: 32px; border-radius: 8px; border: 0;
  cursor: pointer; font-size: 16px; line-height: 1; display: flex; align-items: center; justify-content: center;
}
.btn-small { padding: 6px 10px; font-size: 13px; }

.error { color: var(--danger); font-size: 14px; margin: 8px 0; }

/* ── Anmeldung ───────────────────────────── */

.login { min-height: 100dvh; display: grid; place-items: center; padding: var(--pad); }
.login-inner { width: 100%; max-width: 320px; text-align: center; }
.login h1 { font-size: 24px; margin-bottom: 4px; }
.login-sub { color: var(--muted); font-size: 14px; margin: 0 0 24px; }
.login .field { text-align: left; margin-bottom: 12px; }
.login .btn { width: 100%; margin-top: 8px; }

/* ── Rahmen ──────────────────────────────── */

#app { max-width: 1000px; margin: 0 auto; padding: var(--pad); }

.bar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
}
.bar-right { display: flex; gap: 10px; }

.main-nav { display: flex; gap: 4px; margin-bottom: 4px; border-bottom: 1px solid var(--line); }
.main-nav-item {
  background: transparent; border: 0; color: var(--muted);
  padding: 10px 4px; margin-right: 20px; cursor: pointer; font-weight: 600; font-size: 15px;
  border-bottom: 2px solid transparent; transition: color 0.15s, border-color 0.15s;
}
.main-nav-item.active { color: var(--paper); border-bottom-color: var(--accent); }

.tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.tab {
  background: var(--surface); border: 1px solid var(--line); color: var(--muted);
  padding: 8px 18px; border-radius: 8px; cursor: pointer; font-weight: 600; transition: border-color 0.15s, color 0.15s;
}
.tab.active { background: var(--surface-2); color: var(--paper); border-color: var(--accent); }

.view-toggle { display: flex; gap: 6px; margin: 14px 0 16px; }
.view-btn {
  background: transparent; border: 1px solid var(--line); color: var(--muted);
  padding: 5px 14px; border-radius: 999px; cursor: pointer; font-weight: 600; font-size: 12px;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.view-btn.active { background: var(--accent); color: var(--ink); border-color: var(--accent); }
.view-btn:not(.active):hover { border-color: var(--muted); color: var(--paper); }

.floor-panel { display: none; }
.floor-panel.active { display: block; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 16px 18px;
  margin-bottom: 16px;
}

.floor-meta { display: flex; gap: 24px; margin-bottom: 16px; flex-wrap: wrap; }
.floor-meta .field { width: 180px; }
.floor-meta .readout { font-size: 13px; color: var(--muted); }
.floor-meta .readout strong { color: var(--paper); }

table.rooms { width: 100%; border-collapse: collapse; margin-bottom: 12px; }
table.rooms th {
  text-align: left; font-size: 12px; color: var(--muted); text-transform: uppercase;
  letter-spacing: 0.03em; padding: 6px 8px; border-bottom: 1px solid var(--line);
}
table.rooms td { padding: 4px 6px; vertical-align: middle; }
table.rooms tr.room-row.status-offen { opacity: 0.7; }
table.rooms tr.room-row.status-offen .r-name { border-color: var(--sonstige); }

input.r-color {
  -webkit-appearance: none; appearance: none; width: 26px; height: 26px; padding: 0;
  border: 2px solid var(--line); border-radius: 50%; cursor: pointer; background: none;
}
input.r-color::-webkit-color-swatch-wrapper { padding: 0; border-radius: 50%; }
input.r-color::-webkit-color-swatch { border: 0; border-radius: 50%; }
input.r-color::-moz-color-swatch { border: 0; border-radius: 50%; }

tfoot.rooms-sum td { padding-top: 10px; border-top: 1px solid var(--line); font-weight: 600; }
tfoot.rooms-sum .sum-label { color: var(--muted); font-weight: 400; }

.add-room-btn { margin-top: 4px; }

table.totals { width: 100%; border-collapse: collapse; }
table.totals th { text-align: left; font-weight: 400; color: var(--muted); padding: 8px 0; width: 55%; }
table.totals td { text-align: right; padding: 8px 0; font-variant-numeric: tabular-nums; }
table.totals input { text-align: right; display: inline-block; width: 100px; }
tr.totals-highlight th, tr.totals-highlight td { font-weight: 700; font-size: 18px; border-top: 1px solid var(--line); padding-top: 12px; }

.site-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.site-grid .field { margin: 0; }
.site-grid input[readonly] { color: var(--muted); }

.garage-grid { display: grid; grid-template-columns: 140px 1fr; gap: 12px; }
.garage-grid .field { margin: 0; }

/* ── Plan-Editor (Phase 2) ─────────────────── */

.plan-wrap { display: flex; gap: 16px; align-items: flex-start; user-select: none; -webkit-user-select: none; }
.plan-sidebar {
  width: 220px; flex-shrink: 0; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); padding: 14px;
}
.unplaced-list { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.unplaced-item {
  background: var(--surface-2); border-radius: 6px; padding: 8px 10px; font-size: 13px;
  cursor: grab; border-left: 3px solid var(--sonstige);
}
.unplaced-item:active { cursor: grabbing; }
.unplaced-garage { border-left-color: var(--garage); }
.plan-empty { color: var(--muted); font-size: 13px; }
.plan-hint { color: var(--muted); font-size: 12px; line-height: 1.5; margin: 0; }

.plan-canvas-wrap { flex: 1; min-width: 0; position: relative; }
.plan-toolbar { display: flex; gap: 6px; margin-bottom: 8px; }
.plan-zoom-btn {
  background: var(--surface-2); border: 1px solid var(--line); color: var(--paper);
  width: 32px; height: 32px; border-radius: 8px; cursor: pointer; font-weight: 600; font-size: 15px;
}
.plan-zoom-btn[data-zoom="fit"] { width: auto; padding: 0 12px; font-size: 13px; }
.plan-zoom-btn:hover { border-color: var(--accent); }

.plan-svg {
  width: 100%; height: 600px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none;
  -webkit-user-drag: none;
}
.plan-svg:active { cursor: grabbing; }
.plan-svg * { -webkit-user-drag: none; }

.plan-boundary { fill: none; stroke: var(--paper); stroke-width: 0.06; opacity: 0.6; }

.plan-room rect:not(.plan-handle) { fill-opacity: 0.4; stroke-width: 0.04; cursor: move; }
.plan-room.plan-garage rect:not(.plan-handle) { fill: var(--garage); stroke: var(--garage); }
.plan-room-label {
  fill: var(--paper); text-anchor: middle; dominant-baseline: central; font-weight: 600;
  pointer-events: none; user-select: none;
  paint-order: stroke; stroke: var(--ink); stroke-width: 0.045px; stroke-linejoin: round;
}
.plan-handle { fill: var(--accent); opacity: 0.9; }
.plan-handle-x { cursor: ew-resize; }
.plan-handle-y { cursor: ns-resize; }

@media (max-width: 800px) {
  .plan-wrap { flex-direction: column; }
  .plan-sidebar { width: 100%; }
}

@media (max-width: 640px) {
  #app { padding: 12px; }
  table.rooms thead { display: none; }
  table.rooms td { display: block; padding: 2px 0; }
  table.rooms tr.room-row { display: block; border-bottom: 1px solid var(--line); padding: 8px 0; }
}
