/* Seat Plan — Alix office seating chart tool
   Identity: architectural drawing. Blueprint grid, mono callouts, one indigo accent. */

:root {
  /* neutrals, biased slightly blue toward the accent */
  --bg:        #f4f6fa;
  --surface:   #ffffff;
  --surface-2: #eceff6;
  --line:      #d3d9e6;
  --line-soft: #e4e8f1;
  --ink:       #161b26;
  --ink-2:     #4a5468;
  --ink-3:     #78829a;

  --accent:      #4338ca;
  --accent-soft: #e6e5fb;
  --accent-ink:  #ffffff;

  --empty-fill:  #ffffff;
  --warn:        #a8620a;

  /* A team hue (--h) resolved into a fill, an edge and a text tone.
     Pale washes on a light ground; the edge carries most of the signal. */
  --tint-s: 66%;  --tint-l: 93%;
  --edge-s: 52%;  --edge-l: 55%;
  --mark-s: 58%;  --mark-l: 38%;

  --floor-bg:   #eef1f8;
  --floor-grid: #dfe4ef;
  --floor-rule: #cfd6e6;

  --radius: 6px;
  --shadow: 0 1px 2px rgba(22, 27, 38, .07), 0 6px 16px -8px rgba(22, 27, 38, .16);

  --sans: "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:        #0e1118;
    --surface:   #161b25;
    --surface-2: #1d2330;
    --line:      #2c3444;
    --line-soft: #232a38;
    --ink:       #e9edf5;
    --ink-2:     #a9b3c6;
    --ink-3:     #7b869b;

    --accent:      #8b83ff;
    --accent-soft: #262450;
    --accent-ink:  #10121c;

    --empty-fill:  #1b2231;
    --warn:        #e0a458;

    /* On a dark ground the fill has to do the work and the edge steps back,
       or every desk reads as an outline. */
    --tint-s: 38%;  --tint-l: 20%;
    --edge-s: 42%;  --edge-l: 40%;
    --mark-s: 72%;  --mark-l: 68%;

    --floor-bg:   #11161f;
    --floor-grid: #1c2331;
    --floor-rule: #2a3243;

    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 20px -10px rgba(0,0,0,.6);
  }
}

:root[data-theme="dark"] {
  --bg:        #0e1118;
  --surface:   #161b25;
  --surface-2: #1d2330;
  --line:      #2c3444;
  --line-soft: #232a38;
  --ink:       #e9edf5;
  --ink-2:     #a9b3c6;
  --ink-3:     #7b869b;

  --accent:      #8b83ff;
  --accent-soft: #262450;
  --accent-ink:  #10121c;

  --empty-fill:  #1b2231;
  --warn:        #e0a458;

  /* On a dark ground the fill has to do the work and the edge steps back,
     or every desk reads as an outline. */
  --tint-s: 38%;  --tint-l: 20%;
  --edge-s: 42%;  --edge-l: 40%;
  --mark-s: 72%;  --mark-l: 68%;

  --floor-bg:   #11161f;
  --floor-grid: #1c2331;
  --floor-rule: #2a3243;

  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 20px -10px rgba(0,0,0,.6);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 14px;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

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

.app {
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr;
  grid-template-columns: 292px 1fr;
  grid-template-areas: "bar bar" "rail floor";
}

/* ---------- top bar ---------- */

.bar {
  grid-area: bar;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding-right: 4px;
  margin-right: 2px;
  border-right: 1px solid var(--line);
  height: 28px;
}
.brand b {
  font-size: 15px;
  letter-spacing: -.01em;
}
.brand span {
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--ink-3);
  padding-right: 10px;
}

#title {
  flex: 1 1 200px;
  min-width: 140px;
  max-width: 360px;
  padding: 5px 8px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 14px;
}
#title:hover { border-color: var(--line); }
#title:focus { outline: none; border-color: var(--accent); background: var(--surface); }

.spacer { flex: 1 1 auto; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink-2);
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); color: var(--ink); }
.btn:disabled { opacity: .4; cursor: default; background: var(--surface); color: var(--ink-3); }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}
.btn.primary:hover { filter: brightness(1.08); }
.btn.icon { padding: 0 8px; font-family: var(--mono); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.seg {
  display: inline-flex;
  padding: 2px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.seg button {
  height: 22px;
  padding: 0 12px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
  font-size: 13px;
}
.seg button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(0,0,0,.12);
}

/* ---------- people rail ---------- */

.rail {
  grid-area: rail;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--surface);
  border-right: 1px solid var(--line);
}

.rail-head { padding: 12px 14px 10px; border-bottom: 1px solid var(--line-soft); }

.eyebrow {
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--ink-3);
}

.counts {
  display: flex;
  gap: 6px;
  align-items: baseline;
  margin-top: 6px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-2);
}
.counts b { font-size: 20px; color: var(--ink); font-weight: 600; }

.add-row { display: flex; gap: 6px; margin-top: 10px; }
.add-row input {
  flex: 1;
  min-width: 0;
  height: 28px;
  padding: 0 8px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.add-row input:focus { outline: none; border-color: var(--accent); background: var(--surface); }
#team { flex: 0 0 84px; }

#search {
  width: 100%;
  height: 28px;
  margin-top: 8px;
  padding: 0 8px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
#search:focus { outline: none; border-color: var(--accent); background: var(--surface); }

.rail-scroll { flex: 1; overflow-y: auto; padding: 8px 10px 24px; }

.group-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 12px 4px 6px;
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--ink-3);
}

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

.chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  background: var(--bg);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  cursor: grab;
  touch-action: none;
  user-select: none;
}
.chip:hover { border-color: var(--line); background: var(--surface-2); }
.chip.armed { border-color: var(--accent); background: var(--accent-soft); }
.chip.seated { opacity: .78; }
.chip .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip .where {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-3);
}
.chip .x {
  border: 0;
  background: transparent;
  color: var(--ink-3);
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  font-size: 15px;
}
.chip .x:hover { color: var(--ink); }

.dot {
  flex: 0 0 auto;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: hsl(var(--h) var(--edge-s) var(--edge-l));
}
.chip.noteam .dot { background: transparent; border: 1px solid var(--ink-3); }

/* the chip picks up a wash of its team, so the rail and the floor agree */
.chip:not(.noteam) {
  background: hsl(var(--h) var(--tint-s) var(--tint-l));
  border-color: hsl(var(--h) var(--edge-s) var(--edge-l) / .45);
}
.chip:not(.noteam):hover { border-color: hsl(var(--h) var(--edge-s) var(--edge-l)); }

.empty-note {
  padding: 10px 6px;
  color: var(--ink-3);
  font-size: 13px;
  line-height: 1.5;
}

/* ---------- floor ---------- */

.floorstage {
  grid-area: floor;
  position: relative;
  overflow: hidden;
  background: var(--floor-bg);
}

.floorwrap {
  position: absolute;
  inset: 0;
  overflow: auto;
  padding: 16px;
}

#floorsizer { position: relative; }

#floor {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 0 0;
  background-color: var(--floor-bg);
  background-image:
    linear-gradient(var(--floor-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--floor-grid) 1px, transparent 1px),
    linear-gradient(var(--floor-rule) 1px, transparent 1px),
    linear-gradient(90deg, var(--floor-rule) 1px, transparent 1px);
  background-size: 20px 20px, 20px 20px, 100px 100px, 100px 100px;
  box-shadow: inset 0 0 0 1px var(--floor-rule);
}

.item { position: absolute; }

.zone {
  border: 1px dashed var(--line);
  border-radius: 4px;
  background: rgba(125, 135, 160, .07);
  color: var(--ink-3);
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .1em;
  padding: 5px 8px;
  overflow: hidden;
}

.desk {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 5px 7px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--empty-fill);
  overflow: hidden;
}
.desk {
  border-style: dashed;          /* an empty desk reads as an opening */
}
.desk .id {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .06em;
  color: var(--ink-3);
}
.desk .who {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.15;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.desk .team {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-3);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.desk.filled {
  border-style: solid;
  border-width: 2px;
  background: hsl(var(--h) var(--tint-s) var(--tint-l));
  border-color: hsl(var(--h) var(--edge-s) var(--edge-l));
  cursor: grab;
}
.desk.filled .who { color: var(--ink); }
.desk.filled .id,
.desk.filled .team { color: hsl(var(--h) var(--mark-s) var(--mark-l)); }

/* seated, but no team recorded — occupied without claiming a colour */
.desk.filled.noteam {
  background: var(--surface-2);
  border-color: var(--ink-3);
}
.desk.filled.noteam .id,
.desk.filled.noteam .team { color: var(--ink-3); }

.item.sel { outline: 2px solid var(--accent); outline-offset: 1px; }
.desk.drop { border-color: var(--accent); background: var(--accent-soft); }
.desk.drop.swap { border-style: dashed; }

.mode-layout .item { cursor: move; touch-action: none; }
.mode-layout .handle {
  position: absolute;
  right: -5px; bottom: -5px;
  width: 12px; height: 12px;
  background: var(--accent);
  border: 2px solid var(--surface);
  border-radius: 3px;
  cursor: nwse-resize;
  touch-action: none;
}

#ghost {
  position: fixed;
  z-index: 60;
  pointer-events: none;
  padding: 6px 10px;
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 13px;
  box-shadow: var(--shadow);
  transform: translate(-50%, -50%) rotate(-1.5deg);
}
#ghost[hidden] { display: none; }

/* floating bottom-left toolbar for layout mode + zoom */
.floortools {
  position: absolute;
  left: 14px;
  bottom: 14px;
  display: flex;
  gap: 6px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  flex-wrap: wrap;
  max-width: calc(100% - 28px);
}
#layouttools[hidden] { display: none !important; }
.floortools .sep { width: 1px; background: var(--line); margin: 2px 2px; }
#zoomval { font-family: var(--mono); font-size: 12px; color: var(--ink-3); align-self: center; min-width: 38px; text-align: center; }

.hint {
  position: absolute;
  right: 14px;
  bottom: 14px;
  max-width: 280px;
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink-2);
  font-size: 12px;
  line-height: 1.45;
  box-shadow: var(--shadow);
}
.hint b { color: var(--ink); }

/* ---------- dialogs ---------- */

dialog {
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
  max-width: min(560px, 92vw);
  width: 460px;
}
dialog::backdrop { background: rgba(14, 17, 24, .45); }
.dlg-head {
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--line-soft);
}
.dlg-head h2 { margin: 2px 0 0; font-size: 16px; }
.dlg-body { padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; max-height: 56vh; overflow: auto; }
.dlg-foot { padding: 12px 16px; border-top: 1px solid var(--line-soft); display: flex; gap: 8px; justify-content: flex-end; }

.dlg-body input[type="text"], .dlg-body textarea, .dlg-body input[type="number"] {
  width: 100%;
  padding: 7px 9px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.dlg-body textarea { font-family: var(--mono); font-size: 12px; min-height: 150px; resize: vertical; }
.dlg-body label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--ink-2); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.vlist { display: flex; flex-direction: column; gap: 6px; }
.vrow {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--bg);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
}
.vrow .meta { flex: 1; min-width: 0; }
.vrow .meta b { display: block; font-size: 13px; }
.vrow .meta span { font-family: var(--mono); font-size: 11px; color: var(--ink-3); }

#toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  padding: 9px 14px;
  background: var(--ink);
  color: var(--bg);
  border-radius: 999px;
  font-size: 13px;
  z-index: 90;
  box-shadow: var(--shadow);
}
#toast[hidden] { display: none; }

@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; grid-template-rows: auto auto 1fr; grid-template-areas: "bar" "rail" "floor"; }
  .rail { border-right: 0; border-bottom: 1px solid var(--line); max-height: 34vh; }
  .hint { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

@media print {
  .bar, .rail, .floortools, .hint, #toast { display: none !important; }
  .app { display: block; height: auto; }
  .floorwrap { overflow: visible; background: #fff; }
  #floor { background-image: none; box-shadow: none; }
}

/* group selection */
#marquee {
  position: absolute;
  z-index: 5;
  pointer-events: none;
  border: 1px solid var(--accent);
  background: var(--accent-soft);
  opacity: .55;
  border-radius: 3px;
}
#marquee[hidden] { display: none; }

.selcount {
  align-self: center;
  padding: 0 8px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-3);
  white-space: nowrap;
}
.selcount.on { color: var(--accent); }

.mode-layout .item.sel { outline-width: 2px; }

.savedat {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-3);
  white-space: nowrap;
}
#zoom100 { font-family: var(--mono); font-size: 12px; padding: 0 8px; }

/* rename affordances */
.dlg-body label[hidden] { display: none; }
.chip .x { font-size: 13px; opacity: .55; }
.chip .x:hover { opacity: 1; }
.chip [data-remove] { font-size: 15px; }

/* team combobox */
.combo { position: relative; display: flex; }
.combo input { width: 100%; min-width: 0; }
#team-combo { flex: 0 0 96px; }

.combo-pop {
  /* fixed, and positioned in JS: an absolute popup is clipped by the dialog's
     own scroll box, which hid the list almost entirely inside Edit person. */
  position: fixed;
  z-index: 40;
  min-width: 190px;
  max-height: 210px;
  overflow-y: auto;
  margin: 0;
  padding: 4px;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.combo-pop[hidden] { display: none; }

.combo-opt {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 5px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  white-space: nowrap;
}
.combo-opt[aria-selected="true"] { background: var(--accent-soft); }
.combo-opt:hover { background: var(--surface-2); }
.combo-opt mark { background: transparent; color: var(--accent); font-weight: 600; }
.combo-opt .n { font-family: var(--mono); font-size: 11px; color: var(--ink-3); }
.combo-opt.is-new { color: var(--ink-3); }
.combo-opt.is-new b { color: var(--ink); font-weight: 600; }

/* armed-for-assignment has to beat the team wash */
.chip.armed,
.chip.armed:not(.noteam) {
  background: var(--accent-soft);
  border-color: var(--accent);
}
.chip.seated { opacity: .92; }
