:root {
  --grid: 25px;
  --bg: #f4f2ee;
  --room-bg: #ffffff;
  --line: #e7e3db;
  --ink: #33302b;
  --muted: #8a847a;
  --accent: #6b8f71;
  --accent-ink: #ffffff;
  --danger: #b45b52;
  --seat-empty: #f0ede7;
  --seat-filled: #dbe7dd;
  --table: #c9bfae;
  --table-edge: #b3a790;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

/* ---------- Toolbar ---------- */
#toolbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 10px 16px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.brand { font-weight: 700; font-size: 16px; letter-spacing: .3px; }
.group { display: flex; align-items: center; gap: 8px; }
.group.stats { margin-left: auto; color: var(--muted); font-size: 13px; gap: 14px; }
.zoom-controls #zoomLabel { font-size: 13px; color: var(--muted); min-width: 42px; text-align: center; font-variant-numeric: tabular-nums; }
.zoom-controls .btn { padding: 6px 10px; }
.room-size .room-label { font-size: 13px; color: var(--muted); }
.room-size .btn { padding: 6px 9px; }

.btn {
  display: inline-block;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  font-size: 13px;
  cursor: pointer;
  user-select: none;
}
.btn:hover { background: #faf9f6; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.danger { color: var(--danger); border-color: #e6c7c3; }
.btn.danger:hover { background: #fbf1f0; }

/* ---------- Layout ---------- */
main {
  display: flex;
  height: calc(100vh - 57px);
}
#roomWrap {
  flex: 1;
  overflow: auto;
  padding: 30px;
}
#roomStage {
  /* width/height set in JS to the zoomed room size so scrollbars match */
}
#room {
  position: relative;
  transform-origin: top left;
  width: 1600px;
  height: 4060px;
  background:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px),
    var(--room-bg);
  background-size: var(--grid) var(--grid);
  border: 2px solid var(--table-edge);
  border-radius: 4px;
  box-shadow: 0 2px 10px rgba(0,0,0,.05);
}

/* ---------- Sidebar ---------- */
#sidebar {
  width: 260px;
  flex-shrink: 0;
  border-left: 1px solid var(--line);
  background: #fff;
  padding: 16px;
  display: flex;
  flex-direction: column;
}
#sidebar h2 { font-size: 14px; margin: 0 0 10px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }

/* ---------- Draggable color palette ---------- */
#paletteWrap { margin-bottom: 16px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.palette-title { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
#palette { display: flex; flex-wrap: wrap; gap: 6px; }
.swatch-drag:active { cursor: grabbing; }
.custom-row { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.custom-row input[type="color"] {
  width: 30px; height: 26px; padding: 0;
  border: 1px solid var(--line); border-radius: 5px; background: none; cursor: pointer;
}
.tiny-hint { font-size: 11px; color: var(--muted); }
/* highlight a guest chip while a color is dragged over it */
.guest.color-target {
  outline: 2px dashed var(--accent);
  outline-offset: 1px;
}
#guestSearch {
  width: 100%;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  margin-bottom: 10px;
  font-size: 13px;
}
#inventory {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  min-height: 60px;
}
#inventory.drag-over { background: #f3f6f3; border-color: var(--accent); }
.hint { color: var(--muted); font-size: 11px; margin-top: 10px; line-height: 1.4; }

/* ---------- Guests ---------- */
.guest {
  font-size: 12px;
  padding: 5px 8px;
  background: var(--seat-filled);
  border: 1px solid #c4d6c8;
  border-radius: 6px;
  cursor: grab;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  user-select: none;
  flex-shrink: 0;               /* don't let the inventory flex column squish chips */
}
.guest:active { cursor: grabbing; }
#inventory .guest { background: #fff; border-color: var(--line); }
.guest.dragging { opacity: .4; }

/* Seated guests show initials; full name appears on hover. */
.guest.seated {
  font-weight: 600;
  letter-spacing: .5px;
  position: relative;
}
.guest.seated::after {
  content: attr(data-full);
  position: absolute;
  bottom: calc(100% + 5px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 3px 8px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: normal;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .1s ease;
  z-index: 100;
}
.guest.seated:hover::after { opacity: 1; }

/* ---------- Tables ---------- */
.table {
  position: absolute;
  /* wrapper origin = surface top-left; seats overflow outside */
}
.surface {
  position: absolute;
  background: var(--table);
  border: 2px solid var(--table-edge);
  border-radius: 6px;
  cursor: move;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-direction: column;
}
.surface .label {
  font-size: 12px;
  font-weight: 600;
  color: #5a5140;
  padding: 4px 6px;
  cursor: text;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.surface .label-edit {
  font-size: 12px;
  font-weight: 600;
  color: #5a5140;
  margin: 3px 5px;
  width: calc(100% - 10px);
  border: 1px solid var(--accent);
  border-radius: 4px;
  padding: 2px 4px;
  background: #fff;
}
.table-controls {
  align-self: flex-end;
  display: flex;
  gap: 2px;
  padding: 2px;
}
.tctrl {
  width: 20px; height: 20px;
  line-height: 18px;
  text-align: center;
  font-size: 12px;
  border: 1px solid var(--table-edge);
  background: rgba(255,255,255,.7);
  border-radius: 4px;
  cursor: pointer;
  padding: 0;
  color: #5a5140;
}
.tctrl:hover { background: #fff; }

.seat {
  position: absolute;
  width: 56px;
  height: 30px;
  border: 1px dashed #b9b1a0;
  border-radius: 6px;
  background: var(--seat-empty);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.seat.occupied { border-style: solid; background: transparent; padding: 0; overflow: visible; }
.seat.occupied:hover { z-index: 100; }
.seat.occupied .guest { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; border-radius: 5px; }
.seat.drag-over { border-color: var(--accent); background: #eaf1eb; }
