/* App shell, top bar, sidebar nav, dashboard grid. */

.app-loading {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: var(--page);
}

.boot-card {
  min-width: 240px;
  padding: var(--s-7);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-lg);
  background: var(--canvas);
  box-shadow: var(--shadow-float);
  text-align: left;
}

.boot-sub {
  margin-top: var(--s-2);
  color: var(--text-tertiary);
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 1.26px;
  text-transform: uppercase;
}

.app-shell {
  min-height: 100vh;
  height: 100vh;
  display: grid;
  grid-template-rows: 56px minmax(0, 1fr);
  background: var(--page);
}

/* ---------- Top bar ---------- */
/* Full-width border + background; inner wrapper is capped to the
   workspace width so the brand aligns with the sidebar's left edge
   and the meta aligns with the queue's right edge. */
.top-bar {
  height: 56px;
  border-bottom: 1px solid var(--border-subtle);
  background: rgb(255 255 255 / 92%);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  z-index: 5;
}

.top-bar-inner {
  height: 100%;
  width: min(1280px, 100%);
  margin: 0 auto;
  padding: 0 var(--s-6);
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: var(--s-5);
}

/* ⌘K search field — center column */
.top-search {
  position: relative;
  display: flex;
  align-items: center;
  width: min(420px, 100%);
  margin: 0 auto;
}

.top-search-icon {
  position: absolute;
  left: var(--s-3);
  pointer-events: none;
  color: var(--text-tertiary);
}

.top-search-input {
  width: 100%;
  height: 36px;
  padding: 0 var(--s-9) 0 calc(var(--s-3) + 22px);
  border: 1px solid var(--border-default);
  border-radius: var(--r-md);
  background: var(--surface-1);
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.07px;
  appearance: none;
  -webkit-appearance: none;
  outline: none;
  transition: border-color 140ms ease, background 140ms ease;
}

.top-search-input::placeholder {
  color: var(--text-tertiary);
  font-weight: 400;
}

.top-search-input:focus {
  border-color: var(--accent);
  background: var(--canvas);
}

.top-search-shortcut {
  position: absolute;
  right: var(--s-3);
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.4px;
  color: var(--text-tertiary);
  padding: 2px 6px;
  border: 1px solid var(--border-default);
  border-radius: 4px;
  background: var(--canvas);
  pointer-events: none;
}

.top-search-input:focus ~ .top-search-shortcut {
  display: none;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: var(--s-3);
  min-width: 0;
  flex: 0 0 auto;
}

.brand-mark {
  font-family: var(--font-serif);
  font-size: 22px;
  line-height: 1;
  font-weight: 400;
  letter-spacing: -0.5px;
  color: var(--text-primary);
}

.brand-sep {
  width: 1px;
  height: 14px;
  background: var(--border-default);
  display: inline-block;
  align-self: center;
}

.brand-clinic {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 1.26px;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.top-right {
  display: flex;
  align-items: center;
  gap: var(--s-5);
  flex: 0 0 auto;
}

.top-chips {
  display: flex;
  align-items: center;
  gap: var(--s-2);
}

.top-meta {
  display: flex;
  align-items: center;
  gap: var(--s-4);
  padding-left: var(--s-4);
  border-left: 1px solid var(--border-subtle);
}

.top-staff {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.05px;
  color: var(--text-primary);
  white-space: nowrap;
}

.top-staff-role {
  font-weight: 500;
  color: var(--text-tertiary);
}

.top-clock {
  display: flex;
  align-items: baseline;
  gap: var(--s-2);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.top-clock .date {
  color: var(--text-tertiary);
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 1.05px;
  text-transform: uppercase;
}

.top-clock .time {
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
}

/* ---------- Workspace ---------- */
.stage {
  min-width: 0;
  overflow: auto;
  padding: var(--s-6) var(--s-6) var(--s-9);
}

.workspace {
  width: min(1280px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: var(--s-5);
  align-items: start;
}

/* Sidebar fills the viewport height so its footer can stick to the bottom. */
.sidebar {
  position: sticky;
  top: var(--s-6);
  height: calc(100vh - 56px - var(--s-6) * 2);
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  padding: 0;
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-lg);
  background: var(--canvas);
  box-shadow: var(--shadow-float);
  overflow: hidden;
}

.sidebar-top {
  padding: var(--s-4);
  display: grid;
  gap: var(--s-5);
  overflow: auto;
}

/* Persistent live-status footer block — clickable, jumps to Live status view. */
.sidebar-foot {
  display: grid;
  gap: var(--s-2);
  padding: var(--s-4) var(--s-4) var(--s-4);
  border: 0;
  border-top: 1px solid var(--border-subtle);
  background: var(--surface-1);
  text-align: left;
  cursor: pointer;
  transition: background 140ms ease;
}

.sidebar-foot:hover { background: var(--surface-2); }

.foot-status { display: flex; align-items: center; gap: var(--s-2); }

.foot-shift {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: -0.05px;
  color: var(--text-secondary);
}

.foot-shift .dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: currentColor;
}

.foot-shift.shift-open { color: var(--success); }
.foot-shift.shift-notAccepting { color: var(--warning); }
.foot-shift.shift-closed { color: var(--danger); }

.foot-line {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 13px;
  color: var(--text-primary);
}

.foot-busy { font-weight: 600; }
.foot-busy.busy-light { color: var(--success); }
.foot-busy.busy-moderate { color: var(--text-primary); }
.foot-busy.busy-busy { color: var(--warning); }
.foot-busy.busy-very_busy { color: var(--danger); }

.foot-sep { color: var(--text-tertiary); }

.foot-wait {
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
}

.foot-divider {
  height: 1px;
  background: var(--border-subtle);
  margin: var(--s-1) 0;
}

.foot-staff {
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: -0.05px;
  color: var(--text-primary);
}

.foot-staff-role {
  font-weight: 500;
  color: var(--text-tertiary);
}

.foot-clock {
  display: flex;
  align-items: baseline;
  gap: var(--s-2);
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.6px;
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
}

.foot-date { text-transform: uppercase; }

.nav-group {
  display: grid;
  gap: var(--s-1);
}

.nav-group + .nav-group,
.nav-status {
  margin-top: var(--s-3);
  padding-top: var(--s-4);
  border-top: 1px solid var(--border-subtle);
}

.nav-label {
  margin: 0 var(--s-3) var(--s-2);
  color: var(--text-tertiary);
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 1.26px;
  text-transform: uppercase;
}

.nav-item {
  position: relative;
  width: 100%;
  min-height: 44px;
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--s-3);
  padding: 0 var(--s-3);
  border: 0;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--text-secondary);
  text-align: left;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.07px;
  transition: background 140ms ease, color 140ms ease;
}

.nav-item:hover {
  background: var(--surface-2);
  color: var(--text-primary);
}

.nav-item.is-active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.nav-item.is-active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 10px;
  bottom: 10px;
  width: 2px;
  border-radius: 2px;
  background: var(--accent);
}

.nav-item .nav-count {
  min-width: 22px;
  height: 22px;
  display: inline-grid;
  place-items: center;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.nav-item.is-active .nav-count {
  background: rgb(10 22 40 / 14%);
  color: var(--accent);
}

.nav-status {
  display: grid;
  gap: var(--s-2);
}

.nav-status-row {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: 0 var(--s-3);
  font-size: 13px;
  color: var(--text-primary);
}

.nav-status-row .dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: currentColor;
}

.nav-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
  min-height: 26px;
  padding: 0 var(--s-3);
  font-size: 12px;
}

.nav-meta-row span {
  color: var(--text-tertiary);
  font-weight: 500;
}

.nav-meta-row strong {
  color: var(--text-primary);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ---------- Dashboard content ---------- */
.dashboard {
  display: grid;
  gap: var(--s-5);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: var(--s-5);
  align-items: start;
}

.work-column {
  min-width: 0;
  display: grid;
  gap: var(--s-5);
}

.queue-column {
  position: sticky;
  top: var(--s-6);
  min-width: 0;
}

/* Flow-strip removed — counts now live in the queue group headers and nav. */

/* ---------- View panels (history, capacity, controls) ---------- */
.view-panel {
  min-height: 520px;
  padding: var(--s-6) var(--s-6) var(--s-7);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-lg);
  background: var(--canvas);
  box-shadow: var(--shadow-float);
}

.view-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--s-4);
  margin-bottom: var(--s-6);
  padding-bottom: var(--s-4);
  border-bottom: 1px solid var(--border-subtle);
}

.view-eyebrow {
  margin-bottom: var(--s-2);
}

.view-title {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 32px;
  line-height: 1.1;
  font-weight: 400;
  letter-spacing: -0.8px;
  color: var(--text-primary);
}

.view-counts {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
}

/* ---------- Error state ---------- */
.error-state {
  display: grid;
  place-items: center;
  min-height: 420px;
  padding: var(--s-7);
  border: 1px solid var(--danger-edge);
  border-radius: var(--r-lg);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 14px;
}

/* ---------- Spinner ---------- */
.spinner {
  width: 28px;
  height: 28px;
  border: 2.5px solid var(--border-default);
  border-top-color: var(--accent);
  border-radius: 999px;
  animation: spin 900ms linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .queue-column {
    position: static;
  }
}

@media (max-width: 980px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    grid-template-columns: repeat(3, 1fr);
    grid-auto-flow: column;
  }

  .nav-group + .nav-group,
  .nav-status {
    margin-top: 0;
    padding-top: 0;
    padding-left: var(--s-4);
    border-top: 0;
    border-left: 1px solid var(--border-subtle);
  }
}

@media (max-width: 720px) {
  .top-bar {
    grid-template-columns: 1fr;
    height: auto;
    padding: var(--s-3) var(--s-4);
  }

  .stage {
    padding: var(--s-4);
  }

  .sidebar {
    grid-template-columns: 1fr;
    grid-auto-flow: row;
  }

  .nav-group + .nav-group,
  .nav-status {
    padding-left: 0;
    padding-top: var(--s-4);
    margin-top: var(--s-3);
    border-left: 0;
    border-top: 1px solid var(--border-subtle);
  }
}
