/* ── Main App Layout ─────────────────────────────────────────────── */
#app {
  display: none;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

#app.visible {
  display: flex;
}

/* The body wraps the workspace grid (or physician view) and must fill the
   space between header and viewport bottom so inner panels can scroll.
   Without a definite height here, main's height:100% collapses to content
   height and the Summary/Coverage/Help panels overflow with no scrollbar. */
.body {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

/* ── Header (Phase 3 M3.4: neutral, theme-aware) ─────────────────── */
header {
  background: var(--surface);
  color: var(--text);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
  border-bottom: 1px solid var(--border-subtle);
  /* Above sticky table cells (z 10/20) so header dropdowns aren't sliced
     by the schedule thead; below backdrops/drawers/modals (z 299+). */
  z-index: 50;
}

.hdr-row1 {
  display: flex;
  align-items: center;
  padding: 0 14px;
  height: 46px;
  gap: 10px;
}

.hdr-row2 {
  display: flex;
  align-items: center;
  padding: 4px 10px;
  min-height: 40px;
  gap: 4px;
  background: var(--bg);
  border-top: 1px solid var(--border-subtle);
  flex-wrap: wrap;          /* wrap instead of horizontal scroll */
  overflow: visible;        /* dropdowns must not be clipped */
}

.logo {
  font-weight: 800;
  font-size: 1.1rem;
  letter-spacing: -0.02em;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 6px;
}

.logo .ic { color: var(--primary); }

.month-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 4px 10px;
}

.month-nav button {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.1rem;
  cursor: pointer;
  line-height: 1;
  padding: 2px 4px;
  border-radius: var(--radius-xs);
}

.month-nav button:hover {
  background: var(--hl);
  color: var(--primary);
}

#month-label {
  font-weight: 700;
  font-size: 0.95rem;
  min-width: 120px;
  text-align: center;
  color: var(--text);
}

/* ── Header Buttons ──────────────────────────────────────────────── */
.hdr-btn {
  background: transparent;
  border: none;
  color: var(--text);
  padding: 5px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
  height: 30px;
  display: flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
}

.hdr-btn:hover {
  background: var(--hl);
  color: var(--primary);
}

.hdr-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.hdr-btn:disabled:hover {
  background: transparent;
  color: var(--text);
}

/* Primary action — the single filled accent in the header */
#btn-autoschedule {
  background: var(--primary);
  color: #fff;
}

#btn-autoschedule:hover {
  background: var(--primary-dark);
  color: #fff;
}

.hdr-btn.danger {
  color: var(--danger);
}

.hdr-btn.danger:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

.hdr-sep {
  width: 1px;
  height: 22px;
  background: var(--border);
  margin: 0;
  flex-shrink: 0;
}

/* ── Header Dropdown Menus ───────────────────────────────────────── */
.hdr-menu {
  position: relative;
  flex-shrink: 0;
}

.hdr-menu-trigger::after {
  content: "▾";
  margin-left: 4px;
  font-size: 0.75em;
  opacity: 0.65;
}

.hdr-menu-list {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 200px;
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 4px;
  z-index: 300;
  flex-direction: column;
  gap: 2px;
}

.hdr-menu.open .hdr-menu-list {
  display: flex;
}

.hdr-menu-list.flip {
  left: auto;
  right: 0;
}

.hdr-menu.open .hdr-menu-trigger {
  background: var(--hl);
  color: var(--primary);
}

.hdr-menu-list .hdr-btn {
  width: 100%;
  justify-content: flex-start;
  padding: 7px 10px;
  text-align: left;
}

/* Amber dot on the Requests trigger when pending items exist inside */
.menu-dot {
  display: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #f59e0b;
  margin-left: 5px;
  flex-shrink: 0;
}

.hdr-menu:has(#leave-reqs-badge:not(:empty)) .menu-dot,
.hdr-menu:has(#swaps-badge:not(:empty)) .menu-dot {
  display: inline-block;
}

/* ── User Badge ──────────────────────────────────────────────────── */
.user-badge {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--muted);
  white-space: nowrap;
}

.user-badge button {
  background: transparent;
  border: none;
  color: var(--text);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.user-badge .hdr-lbl {
  font-weight: 600;
}

.user-badge button:hover {
  background: var(--hl);
  color: var(--primary);
}

#btn-signout {
  border: 1px solid var(--border-subtle);
}

/* ── Workspace Switcher ──────────────────────────────────────────── */
.ws-switch {
  display: none;
  align-items: center;
  gap: 6px;
}

#ws-select {
  padding: 4px 8px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  max-width: 230px;
}

#ws-select option {
  color: var(--text);
  background: var(--surface);
}

#ws-badge {
  display: none;
  font-size: 0.74rem;
  background: var(--hl);
  color: var(--primary);
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  white-space: nowrap;
}

.share-hint {
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 2px;
  line-height: 1.45;
}

#btn-leave-ws {
  display: none;
  background: transparent;
  border: 1px solid var(--danger);
  color: var(--danger);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.74rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  height: 26px;
}

#btn-leave-ws:hover {
  background: var(--danger-soft);
}


/* ── Sidebar ─────────────────────────────────────────────────────── */
aside {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
}

.sidebar-section {
  padding: 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.sidebar-section h3 {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  margin-bottom: 8px;
}

.sidebar-section input,
.sidebar-section select {
  width: 100%;
  padding: 6px 9px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  margin-bottom: 5px;
  outline: none;
}

.sidebar-section input:focus,
.sidebar-section select:focus {
  border-color: var(--primary);
}

.sb-row {
  display: flex;
  gap: 5px;
}

.sb-row input {
  flex: 1;
}

/* ── Buttons ─────────────────────────────────────────────────────── */
.btn-sm {
  padding: 6px 10px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-add {
  background: var(--primary);
  color: #fff;
  width: 100%;
}

.btn-add:hover {
  background: var(--primary-dark);
}

.btn-ghost {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  background: var(--border);
}

/* ── Doctor List ─────────────────────────────────────────────────── */
.doc-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px;
}

.doc-item {
  display: flex;
  align-items: center;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  gap: 6px;
  font-size: 0.83rem;
  border: 1px solid transparent;
}

.doc-item:hover {
  background: var(--bg);
}

.doc-item.selected {
  background: var(--hl);
  border-color: var(--hl-border);
}

.doc-item .doc-name {
  flex: 1;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.doc-team {
  font-size: 0.7rem;
  padding: 1px 5px;
  border-radius: 10px;
  font-weight: 700;
  color: #fff;
}

.team-T1 {
  background: #3b82f6;
}

.team-T2 {
  background: #10b981;
}

.team-T3 {
  background: #8b5cf6;
}

.doc-del {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.85rem;
  opacity: 0;
  padding: 2px 5px;
  border-radius: var(--radius-xs);
  border: none;
  background: none;
  cursor: pointer;
}

.doc-item:hover .doc-del {
  opacity: 1;
}

.doc-del:hover {
  color: var(--danger);
  background: var(--danger-soft);
}

.doc-email-btn {
  color: var(--muted);
  font-size: 0.8rem;
  opacity: 0;
  padding: 2px 4px;
  border-radius: var(--radius-xs);
  border: none;
  background: none;
  cursor: pointer;
}

.doc-item:hover .doc-email-btn {
  opacity: 0.7;
}

.doc-email-btn:hover {
  color: var(--primary);
  background: var(--hl);
}

/* Phase 6 M6-5: reset a physician's calendar feed link (owner action). */
.doc-cal-btn {
  color: var(--muted);
  font-size: 0.8rem;
  opacity: 0;
  padding: 2px 4px;
  border-radius: var(--radius-xs);
  border: none;
  background: none;
  cursor: pointer;
}

.doc-item:hover .doc-cal-btn {
  opacity: 0.7;
}

.doc-cal-btn:hover {
  color: var(--danger);
  background: var(--danger-soft);
}

/* ── Main Content ──────────────────────────────────────────────── */
main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

.tab {
  padding: 10px 20px;
  font-size: 0.87rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.15s;
}

.tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.tab-panel {
  display: none;
  flex: 1;
  overflow: auto;
}

.tab-panel.active {
  display: flex;
  flex-direction: column;
}

/* ── Status Bar ──────────────────────────────────────────────────– */
.statusbar {
  padding: 4px 14px;
  font-size: 0.77rem;
  color: var(--muted);
  background: var(--surface);
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

/* ── Sidebar Drawer Toggle (Mobile) ──────────────────────────────– */
#btn-toggle-sidebar {
  display: none;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 7px;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

#btn-toggle-sidebar:hover {
  background: var(--hl);
}

#sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 399;
}

#sidebar-backdrop.visible {
  display: block;
}

.sidebar-mobile-hdr {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px 8px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--surface);
  flex-shrink: 0;
}

.sidebar-mobile-hdr span {
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--primary);
}

#btn-close-sidebar {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1rem;
  cursor: pointer;
  padding: 3px 7px;
  border-radius: 5px;
}

#btn-close-sidebar:hover {
  color: var(--danger);
  background: var(--danger-soft);
}

/* ── Inline icons (Phase 3 M3.3) ─────────────────────────────────── */
.ic { width: 1.05em; height: 1.05em; vertical-align: -0.15em; flex-shrink: 0; display: inline-block; }
.hdr-btn .ic, .canvas-mode-btn .ic { margin-right: 3px; }
.logo .ic { width: 1.15em; height: 1.15em; }

/* Phase 12 M12-5: per-physician day/night side, shown only in 12h mode.
   Always visible (unlike .doc-email-btn, which reveals on hover) because in a
   fixed-cohort workspace it determines whether the physician can be scheduled
   at all — it must be readable at a glance, not discovered. */
.doc-shift-btn {
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  min-width: 30px;
  padding: 2px 5px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
  background: none;
  color: var(--muted);
  cursor: pointer;
}
.doc-shift-btn:hover { color: var(--primary); background: var(--hl); }
.doc-shift-btn.day   { color: #b45309; border-color: #b45309; }
.doc-shift-btn.night { color: #4338ca; border-color: #4338ca; }
