/* FloorBook — admin app styles. Mobile-first, dark-mode aware, brandable. */
:root {
  --navy: #0A1628;
  --blue: #4F8EF7;
  --blue-600: #3b74d6;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #f4f6fb;
  --card: #ffffff;
  --ok: #16a34a;
  --warn: #d97706;
  --danger: #dc2626;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(15,23,42,.06), 0 8px 24px rgba(15,23,42,.06);
  --shadow-lg: 0 12px 40px rgba(15,23,42,.16);
  --tap: 44px;
  --font: 'Space Grotesk', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e6edf6; --muted: #94a3b8; --line: #22314a;
    --bg: #0b1220; --card: #111a2e; --shadow: 0 1px 3px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
    --shadow-lg: 0 12px 40px rgba(0,0,0,.55);
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font); color: var(--ink); background: var(--bg);
  font-size: 15px; line-height: 1.5; overflow: hidden;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea {
  font-family: inherit; font-size: 15px; color: var(--ink);
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 11px 12px; width: 100%; outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(79,142,247,.18); }
label { display: block; font-weight: 600; font-size: 13px; margin: 0 0 6px; }
.hint { color: var(--muted); font-size: 12.5px; font-weight: 400; }

/* App shell ---------------------------------------------------------------- */
.app { display: grid; grid-template-rows: auto 1fr auto; height: 100dvh; }

.topbar {
  display: flex; align-items: center; gap: 12px; padding: 10px 16px;
  background: var(--card); border-bottom: 1px solid var(--line); box-shadow: var(--shadow);
  z-index: 30;
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 800; letter-spacing: -.02em; }
.brand .dot { width: 26px; height: 26px; border-radius: 8px;
  background: linear-gradient(135deg, var(--blue), var(--navy)); }
.brand small { font-weight: 500; color: var(--muted); }
.topbar .grow { flex: 1; }
.iconbtn {
  width: var(--tap); height: 38px; min-width: 38px; border-radius: 10px; display: grid; place-items: center;
  color: var(--muted); border: 1px solid transparent;
}
.iconbtn:hover { background: var(--bg); color: var(--ink); }
.iconbtn:disabled { opacity: .35; cursor: default; }
.btn {
  display: inline-flex; align-items: center; gap: 7px; justify-content: center;
  padding: 10px 16px; border-radius: 11px; font-weight: 700; font-size: 14px;
  background: var(--blue); color: #fff; min-height: 40px; transition: transform .06s, background .15s;
}
.btn:active { transform: translateY(1px); }
.btn.secondary { background: var(--bg); color: var(--ink); border: 1px solid var(--line); }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.danger { background: var(--danger); }
.btn:disabled { opacity: .5; }

/* Stepper ------------------------------------------------------------------ */
.steps { display: flex; gap: 6px; }
.steps .step {
  display: flex; align-items: center; gap: 8px; padding: 7px 12px; border-radius: 999px;
  color: var(--muted); font-weight: 600; font-size: 13px; white-space: nowrap;
}
.steps .step .n {
  width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center;
  background: var(--bg); border: 1.5px solid var(--line); font-size: 12px;
}
.steps .step.active { color: var(--ink); background: var(--bg); }
.steps .step.active .n { background: var(--blue); color: #fff; border-color: var(--blue); }
.steps .step.done .n { background: var(--ok); color: #fff; border-color: var(--ok); }
.steps .step.done { color: var(--ink); }

/* Main body ---------------------------------------------------------------- */
.body { overflow: auto; position: relative; }
.pane { max-width: 780px; margin: 0 auto; padding: 22px 16px 40px; }
.pane h1 { font-size: 22px; letter-spacing: -.02em; margin: 0 0 4px; }
.pane .sub { color: var(--muted); margin: 0 0 22px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px; }
.card.compact { padding: 14px; margin-bottom: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field { margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
@media (max-width: 560px) { .grid2 { grid-template-columns: 1fr; } }

/* Footer nav --------------------------------------------------------------- */
.footer {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px;
  background: var(--card); border-top: 1px solid var(--line); z-index: 20;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
}
.footer .grow { flex: 1; }
.footer .status { color: var(--muted); font-size: 12.5px; }

/* Calendar ----------------------------------------------------------------- */
.cal { user-select: none; }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cal-head .mname { font-weight: 800; font-size: 15px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.cal-dow { text-align: center; font-size: 10.5px; font-weight: 700; color: var(--muted); padding: 3px 0; }
.cal-day {
  aspect-ratio: 1; border-radius: 9px; display: grid; place-items: center;
  font-weight: 600; border: 1px solid transparent; position: relative;
  background: var(--bg); font-size: 13px;
}
.cal-day.out { opacity: .32; }
.cal-day.today { border-color: var(--blue); }
.cal-day.sel { background: var(--blue); color: #fff; box-shadow: var(--shadow); }
.cal-day.past { opacity: .28; pointer-events: none; }
.cal-day:not(.past):hover { border-color: var(--blue); }
.cal.compact .cal-grid { max-width: 380px; margin: 0 auto; }

/* Dates & times step: calendar + per-day time summary, side by side */
.sched-grid { display: grid; grid-template-columns: minmax(0, 380px) 1fr; gap: 16px; align-items: start; }
@media (max-width: 760px) { .sched-grid { grid-template-columns: 1fr; } }
.sched-summary { max-height: 480px; overflow-y: auto; }
.day-list { display: flex; flex-direction: column; gap: 8px; }
.day-row {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px;
  background: var(--bg); border: 1px solid var(--line);
}
.day-name { flex: 0 0 auto; min-width: 88px; font-weight: 700; font-size: 13px; }
.day-times { display: flex; align-items: center; gap: 6px; flex: 1; }
.day-times input { padding: 7px 8px; font-size: 12.5px; }
.day-sep { color: var(--muted); font-size: 12px; }
.day-rm {
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  color: var(--muted); font-size: 16px; flex: 0 0 auto;
}
.day-rm:hover { background: var(--card); color: var(--danger); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.chip { display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px; border-radius: 999px;
  background: var(--bg); border: 1px solid var(--line); font-size: 13px; font-weight: 600; }
.chip button { color: var(--muted); font-size: 16px; line-height: 1; }
.seg { display: inline-flex; background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 3px; gap: 3px; }
.seg button { padding: 7px 14px; border-radius: 999px; font-weight: 600; font-size: 13px; color: var(--muted); }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }

/* Builder ------------------------------------------------------------------ */
.builder {
  position: absolute; inset: 0; display: grid; grid-template-columns: 64px 1fr 300px;
  /* Without an explicit row height, a grid's single implicit row sizes to its
     TALLEST child's content (auto) rather than filling the container — even
     though .builder itself has a fixed height via inset:0. That silently
     stretched every column to the toolbar's full button-list height, which
     is what actually defeated .tools's overflow-y — not .tools's own CSS. */
  grid-template-rows: 100%;
  overflow: hidden;
}
.builder.mobile { grid-template-columns: 1fr; }
.tools {
  background: var(--card); border-right: 1px solid var(--line); padding: 10px 8px;
  display: flex; flex-direction: column; gap: 6px; z-index: 10;
  overflow-y: auto; overflow-x: hidden; scrollbar-width: thin;
  /* A grid item's default min-height:auto lets its intrinsic content size
     (11+ buttons) override the row height entirely — "grid blowout" — which
     silently defeated overflow-y above and let the ancestor's overflow:hidden
     clip buttons off with no way to reach them. min-height:0 forces .tools to
     respect its actual allocated row height so overflow-y can do its job. */
  min-height: 0;
}
.tool {
  width: 48px; height: 48px; border-radius: 12px; display: grid; place-items: center;
  color: var(--muted); border: 1px solid transparent; position: relative;
  flex-shrink: 0; /* never let flex compress buttons to "fit" — force real overflow so .tools scrolls instead */
}
.tool small { position: absolute; bottom: 3px; font-size: 8.5px; font-weight: 700; }
.tool:hover { background: var(--bg); color: var(--ink); }
.tool.on { background: var(--blue); color: #fff; }
.tool.sep { height: 1px; background: var(--line); margin: 4px 6px; padding: 0; pointer-events: none; }
.canvas-wrap { position: relative; overflow: hidden; min-height: 0; background:
  repeating-conic-gradient(from 0deg, rgba(120,140,170,.05) 0% 25%, transparent 0% 50%) 50%/22px 22px; touch-action: none; }
@media (prefers-color-scheme: dark) { .canvas-wrap { background:
  repeating-conic-gradient(from 0deg, rgba(120,140,170,.08) 0% 25%, transparent 0% 50%) 50%/22px 22px; } }
.canvas-wrap svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.zoombar { position: absolute; right: 12px; bottom: 12px; display: flex; flex-direction: column; gap: 6px; z-index: 8; }
.zoombar button { width: 40px; height: 40px; border-radius: 11px; background: var(--card);
  border: 1px solid var(--line); box-shadow: var(--shadow); display: grid; place-items: center; font-size: 18px; font-weight: 700; }
.hud { position: absolute; left: 12px; top: 12px; display: flex; gap: 8px; z-index: 8; align-items: flex-start; }
.hud .pill { background: var(--card); border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 12px; font-size: 12px; font-weight: 600; box-shadow: var(--shadow); color: var(--muted); }
.hud-btn { width: 32px; height: 32px; padding: 0; display: grid; place-items: center; font-size: 15px; }
.hud-btn:disabled { opacity: .35; }
.jump-wrap { position: relative; padding: 0; width: 150px; }
.jump-input { border: none; background: transparent; padding: 6px 12px; font-size: 12px; font-weight: 600;
  width: 100%; box-shadow: none; }
.jump-input:focus { box-shadow: none; }
.jump-results { position: absolute; top: calc(100% + 4px); left: 0; right: 0; background: var(--card);
  border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg); overflow: hidden;
  display: none; max-height: 200px; overflow-y: auto; }
.jump-results.open { display: block; }
.jump-row { display: block; width: 100%; text-align: left; padding: 9px 12px; font-size: 13px; font-weight: 600;
  border-bottom: 1px solid var(--line); }
.jump-row:last-child { border-bottom: none; }
.jump-row:hover { background: var(--bg); }
.jump-empty { padding: 12px; font-size: 12.5px; color: var(--muted); text-align: center; }
@media (max-width: 760px) { .jump-wrap { width: 110px; } }

/* Armed-tool hint banner */
.arm-hint {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  background: var(--blue); color: #fff; padding: 9px 16px; border-radius: 999px;
  font-weight: 700; font-size: 13px; box-shadow: var(--shadow-lg); z-index: 9;
  animation: pop .2s ease; white-space: nowrap;
}
@keyframes pop { from { transform: translateX(-50%) scale(.9); opacity: 0; } }

/* Legend */
.legend {
  position: absolute; left: 12px; bottom: 12px; z-index: 8; display: flex; flex-wrap: wrap; gap: 4px 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px;
  box-shadow: var(--shadow); max-width: calc(100% - 90px);
}
.legend span { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 600; color: var(--muted); }
.legend i { width: 12px; height: 12px; border-radius: 4px; display: inline-block; }
@media (max-width: 760px) { .legend { bottom: 74px; } }

/* Empty state */
.empty-canvas { position: absolute; inset: 0; display: grid; place-items: center; z-index: 7; pointer-events: none; padding: 20px; }
.empty-canvas .ec-card {
  pointer-events: auto; background: var(--card); border: 1px solid var(--line); border-radius: 20px;
  box-shadow: var(--shadow-lg); padding: 30px 26px; max-width: 360px; text-align: center;
}
.ec-emoji { font-size: 44px; }
.empty-canvas h2 { margin: 8px 0 6px; font-size: 20px; letter-spacing: -.02em; }
.empty-canvas p { color: var(--muted); margin: 0 0 18px; font-size: 14px; }
.empty-canvas .btn { width: 100%; margin-bottom: 10px; padding: 13px; font-size: 15px; }

/* Properties panel / sheet */
.props { background: var(--card); border-left: 1px solid var(--line); padding: 16px; overflow: auto; min-height: 0; }
.props h3 { margin: 0 0 2px; font-size: 15px; }
.props .empty { color: var(--muted); font-size: 13px; text-align: center; padding: 40px 10px; }
.row { display: flex; gap: 10px; align-items: end; }
.row .field { flex: 1; }
.stepper { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.stepper button { width: 38px; height: 40px; font-size: 18px; color: var(--muted); background: var(--bg); }
.stepper input { border: none; border-radius: 0; text-align: center; }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.sw { width: 30px; height: 30px; border-radius: 8px; border: 2px solid transparent;
  color: #fff; font-weight: 800; font-size: 14px; display: grid; place-items: center; }
.sw.on { border-color: var(--ink); box-shadow: 0 0 0 2px var(--card), 0 0 0 4px var(--ink); }
.colour-preview { margin-top: 14px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.cp-bar { height: 8px; }
.cp-body { padding: 12px 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--bg); }
.cp-label { font-size: 12px; color: var(--muted); }
.cp-btn { padding: 9px 16px; border-radius: 10px; color: #fff; font-weight: 700; font-size: 13px; white-space: nowrap; }

/* Mobile: tools become a bottom bar, props a slide-up sheet */
.builder.mobile .tools {
  flex-direction: row; border-right: none; border-top: 1px solid var(--line);
  position: absolute; bottom: 0; left: 0; right: 0; overflow-x: auto; padding: 8px 10px;
  padding-bottom: max(8px, env(safe-area-inset-bottom)); gap: 8px;
}
.builder.mobile .tool.sep { width: 1px; height: 40px; margin: 0 2px; }
.builder.mobile .props {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 72vh; overflow: auto; border-left: none;
  border-top: 1px solid var(--line); border-radius: 18px 18px 0 0; box-shadow: var(--shadow-lg);
  background: var(--card); z-index: 40;
  transform: translateY(101%); visibility: hidden;              /* hidden when closed — bulletproof */
  transition: transform .28s cubic-bezier(.2,.8,.2,1), visibility .28s;
}
.builder.mobile .props.open { transform: translateY(0); visibility: visible; }
.sheet-grip { width: 42px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 12px; }

/* Toast + modal ------------------------------------------------------------ */
.toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: var(--card); padding: 11px 18px; border-radius: 999px; font-weight: 600;
  font-size: 13px; opacity: 0; pointer-events: none; transition: all .25s; z-index: 100; box-shadow: var(--shadow-lg); }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.overlay { position: fixed; inset: 0; background: rgba(10,22,40,.55); display: grid; place-items: center;
  z-index: 90; padding: 20px; }
.modal { background: var(--card); border-radius: 18px; box-shadow: var(--shadow-lg); padding: 22px;
  max-width: 440px; width: 100%; }
.hidden { display: none !important; }

/* Mobile topbar: never let the stepper widen the page. Collapse to compact
   number chips, keeping only the active step's label. */
@media (max-width: 760px) {
  .app { width: 100vw; overflow-x: hidden; }
  .topbar { gap: 8px; padding: 10px 12px; }
  .brand small { display: none; }
  .brand { font-size: 15px; }
  .steps { gap: 4px; flex: 1; min-width: 0; justify-content: center; overflow: hidden; }
  .steps .step .lbl { display: none; }
  .steps .step.active .lbl { display: inline; }
  .steps .step { padding: 6px 9px; }
  .footer { padding: 10px 12px; gap: 8px; }
  .footer .status { display: none; }
  .footer .btn { flex: 1; }
  .pane { padding: 18px 14px 32px; }
}
