/* ShortletBox — admin & portal shell + workspace components.
 *
 * Skin comes from sb_tokens.css (the brand); this file is layout and
 * behaviour for the signed-in surfaces only: the admin sidebar shell, the
 * portal top bar, tables, stat strips, meters, labels. Nothing in here
 * introduces a colour, radius or font that the tokens don't already define.
 *
 * The reason this file exists at all: inline styles can't carry media
 * queries or hover states, so the shells were frozen at desktop width with
 * no pointer feedback. Everything repeated three or more times across the
 * admin/portal views lives here now.
 */

/* ---------------------------------------------------------------- shells */

.sb-shell {
  display: flex;
  gap: 18px;
  min-height: 100dvh;
  padding: 22px;
  background: var(--sb-mist);
  box-sizing: border-box;
}

/* The rail floats as a rounded card — the booking-site design's sidebar
 * STRUCTURE (radius, padding, sticky inset, section labels, accent bar),
 * adopted 2026-08-11. The palette stays the original navy rail: the owner
 * kept the admin's colours and took only the shape. */
.sb-aside {
  width: 232px;
  flex: none;
  align-self: flex-start;
  background: var(--sb-navy);
  color: var(--sb-mist);
  display: flex;
  flex-direction: column;
  padding: 24px 18px 20px;
  border-radius: var(--sb-r-xl);
  box-shadow: var(--sb-sh-soft);
  position: sticky;
  top: 22px;
  min-height: calc(100dvh - 44px);
  box-sizing: border-box;
}

.sb-aside-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 10px 22px;
}

.sb-aside-brand-name {
  font: 700 17px var(--sb-font-display);
  letter-spacing: 0.2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sb-aside nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 15px;
  overflow-y: auto;
}

.sb-nav-group-label {
  margin: 16px 0 6px;
  padding: 0 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--sb-on-navy-muted);
}

/* Base .sb-nav-link is shared with the portal top bar (portal.html.erb),
 * which keeps its own navy-bar look untouched. Everything specific to the
 * floating admin rail — the wash hover/active and the ember accent bar — is
 * scoped under .sb-aside so it can never bleed into /portal. */
.sb-nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--sb-r-sm);
  text-decoration: none;
  color: inherit;
  transition: background 140ms ease, color 140ms ease;
}

.sb-nav-link:hover {
  background: rgba(246, 247, 249, 0.08);
}

.sb-nav-link.is-active {
  background: rgba(228, 96, 47, 0.18);
  color: var(--sb-ember-400);
  font-weight: 600;
}

.sb-nav-link.is-disabled {
  opacity: 0.38;
  cursor: default;
}

.sb-nav-link.is-disabled:hover {
  background: none;
}

.sb-aside .sb-nav-link {
  position: relative;
  padding: 11px 12px;
  border-radius: 14px;
}

/* The ember accent bar bleeds into the rail's own lateral padding (18px),
 * landing flush with the card's rounded edge — as in the design's active
 * "Booking site" row. */
.sb-aside .sb-nav-link.is-active::before {
  content: "";
  position: absolute;
  left: -18px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 22px;
  border-radius: 3px;
  background: var(--sb-ember);
}

.sb-nav-badge {
  margin-left: auto;
  font-family: var(--sb-font-mono);
  background: var(--sb-navy-500);
  color: var(--sb-paper);
  font-size: 11px;
  font-weight: 600;
  border-radius: 7px;
  padding: 2px 7px;
  font-variant-numeric: tabular-nums;
}

.sb-nav-badge.is-danger {
  background: var(--sb-danger);
  color: #fff;
}

.sb-aside-user {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 10px 0;
  border-top: 1px solid rgba(244, 247, 251, 0.12);
}

.sb-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.sb-topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 28px;
  background: var(--sb-paper);
  border-bottom: 1px solid var(--sb-border);
}

.sb-topbar h1 {
  font-size: 26px;
  margin: 0;
  flex: none;
}

.sb-topbar-search {
  flex: 1;
  max-width: 460px;
  margin-left: auto;
}

.sb-topbar-search input {
  width: 100%;
  box-sizing: border-box;
  background: var(--sb-wash);
  border: 1px solid var(--sb-border);
  border-radius: 10px;
  padding: 9px 14px;
  font-size: 13.5px;
  font-family: inherit;
  color: var(--sb-navy);
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.sb-topbar-search input:focus {
  outline: none;
  border-color: var(--sb-navy-500);
  box-shadow: 0 0 0 3px rgba(46, 78, 134, 0.12);
}

.sb-content {
  padding: 22px 28px;
  flex: 1;
}

.sb-banner-slot {
  padding: 10px 28px 0;
}

/* The admin shell is a desk tool, but a phone in a corridor still has to be
 * able to approve a booking: below 900px the rail becomes a top bar and the
 * nav scrolls sideways rather than vanishing behind a hamburger. */
@media (max-width: 900px) {
  .sb-shell {
    flex-direction: column;
    padding: 10px;
    gap: 10px;
  }

  .sb-aside {
    width: 100%;
    height: auto;
    min-height: auto;
    position: static;
    top: auto;
    padding: 12px 12px 10px;
  }

  .sb-aside-brand {
    padding-bottom: 12px;
  }

  .sb-aside nav {
    flex-direction: row;
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .sb-nav-link {
    white-space: nowrap;
  }

  /* The accent bar bleeds from a vertical rail's left padding; in the
   * horizontal mobile nav there's no equivalent gutter to bleed into, so
   * the active row falls back to wash + navy text alone. */
  .sb-aside .sb-nav-link.is-active::before {
    display: none;
  }

  .sb-aside-user {
    display: none;
  }

  .sb-topbar {
    flex-wrap: wrap;
    padding: 12px 16px;
  }

  .sb-topbar-search {
    order: 3;
    max-width: none;
    flex-basis: 100%;
  }

  .sb-content {
    padding: 16px;
  }

  .sb-banner-slot {
    padding: 10px 16px 0;
  }
}

/* portal top bar */

.sb-portal-bar {
  display: flex;
  align-items: center;
  gap: 22px;
  background: var(--sb-navy);
  color: var(--sb-mist);
  padding: 12px 26px;
  position: sticky;
  top: 0;
  z-index: 5;
  flex-wrap: wrap;
}

.sb-portal-main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 26px 26px 60px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

@media (max-width: 720px) {
  .sb-portal-bar {
    padding: 10px 16px;
    gap: 12px;
  }

  .sb-portal-main {
    padding: 18px 16px 48px;
  }
}

/* ------------------------------------------------------------ components */

/* Uppercase section label — the quiet voice that introduces a block. */
.sb-label {
  font: 600 11px var(--sb-font-text);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--sb-muted);
}

/* Numerals that line up: any cell or figure holding money or a count. */
.sb-num {
  font-variant-numeric: tabular-nums lining-nums;
}

/* Stat strip — one card, hairline-divided, instead of a row of four floating
 * boxes. The figures share a baseline so the eye can sweep once. */
.sb-stat-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  overflow: hidden;
}

.sb-stat {
  padding: 16px 20px 18px;
  min-width: 0;
}

.sb-stat + .sb-stat {
  border-left: 1px solid var(--sb-border-soft);
}

.sb-stat-head {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--sb-muted);
  font-size: 12.5px;
}

.sb-stat-value {
  font: 500 28px/1.15 var(--sb-font-display);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums lining-nums;
  color: var(--sb-navy);
  margin-top: 8px;
}

.sb-stat-note {
  font-size: 12px;
  color: var(--sb-muted);
  margin-top: 4px;
}

@media (max-width: 920px) {
  .sb-stat-strip {
    grid-template-columns: repeat(2, 1fr);
  }

  .sb-stat + .sb-stat {
    border-left: none;
  }

  .sb-stat:nth-child(even) {
    border-left: 1px solid var(--sb-border-soft);
  }

  .sb-stat:nth-child(n + 3) {
    border-top: 1px solid var(--sb-border-soft);
  }
}

/* Two-column work split. The ratio rides in as a custom property so the
 * mobile collapse below can win without fighting an inline declaration. */
.sb-cols {
  display: grid;
  gap: 14px;
  align-items: start;
  grid-template-columns: var(--cols, 1fr 1fr);
}

@media (max-width: 900px) {
  .sb-cols {
    grid-template-columns: 1fr;
  }
}

/* Data table — headers whisper, rows answer the pointer, numbers align. */
.sb-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.sb-table th {
  text-align: left;
  padding: 11px 16px;
  border-bottom: 1px solid var(--sb-border);
  font-family: var(--sb-font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--sb-muted);
  font-weight: 600;
  white-space: nowrap;
}

.sb-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--sb-border-soft);
  vertical-align: middle;
}

.sb-table tbody tr:last-child td {
  border-bottom: none;
}

.sb-table tbody tr {
  transition: background 120ms ease;
}

.sb-table tbody tr:hover {
  background: var(--sb-tint);
}

.sb-table th.is-num,
.sb-table td.is-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Back link — the breadcrumb that reads as a door, not a dash of ASCII. */
.sb-back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: var(--sb-muted);
  text-decoration: none;
  transition: color 140ms ease;
}

.sb-back:hover {
  color: var(--sb-navy);
}

/* Meter — occupancy and quota bars. */
.sb-meter {
  height: 6px;
  border-radius: var(--sb-r-pill);
  background: var(--sb-border-soft);
  overflow: hidden;
}

.sb-meter-fill {
  height: 100%;
  border-radius: var(--sb-r-pill);
  background: var(--sb-navy);
}

.sb-meter-fill.is-ember {
  background: var(--sb-ember);
}

/* Status chip shape — the colours stay in the helpers, where they are data. */
.sb-status {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 10px;
  border-radius: var(--sb-r-pill);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

/* Checklist line — a state icon beside a requirement. */
.sb-tickline {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sb-tickline .lucide,
.sb-tickline i[data-lucide] {
  flex: none;
}

/* On/off switch — a checkbox drawn as a pill, keyboard- and screen-reader
   visible through the real input underneath. */
.sb-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex: none;
  cursor: pointer;
}

.sb-switch input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.sb-switch-track {
  width: 46px;
  height: 26px;
  border-radius: var(--sb-r-pill);
  background: var(--sb-line);
  display: inline-flex;
  align-items: center;
  padding: 3px;
  box-sizing: border-box;
  transition: background 0.15s ease;
}

.sb-switch-knob {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--sb-paper);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  transition: transform 0.15s ease;
}

.sb-switch input:checked + .sb-switch-track {
  background: var(--sb-success);
}

.sb-switch input:checked + .sb-switch-track .sb-switch-knob {
  transform: translateX(20px);
}

.sb-switch input:focus-visible + .sb-switch-track {
  outline: 2px solid var(--sb-navy);
  outline-offset: 2px;
}

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

/* Tailwind Preflight sets `margin: 0` on every element, which overrides the
 * UA stylesheet that centres native <dialog> with margin:auto. Without this,
 * showModal() parks every admin modal in the top-left corner. */
dialog {
  margin: auto;
}

dialog::backdrop {
  background: rgba(20, 40, 75, 0.45);
}
