/* Master Control Panel theme -- deliberately a different palette from the
   tenant app's navy/sky/gold (style.css :root) so a master session can
   never be visually mistaken for a tenant session, per PHASE_B_DESIGN.md §2
   and the queue's explicit "never confused" requirement. Reuses every
   structural class from style.css (.card, .btn, .stacked-form, .auth-page,
   .alert-*) by overriding the same custom properties those rules already
   read from, scoped to body.master-theme so it never leaks onto tenant
   pages.

   Links and accents use the tenant app's blues and gold (style.css :root,
   2026-11-02) on the master's own dark surfaces. The dark login console
   keeps its violet: its card sets its own values (auth.css .lp--master),
   and the few rules below that would reach it read logged-in-only values
   (body.master-theme:has(.master-shell)) with the violet as fallback. */
body.master-theme {
  --navy: #0b2545;
  --navy-ink: #ffffff;
  --slate: #1b4965;
  --slate-ink: #ffffff;
  --sky: #5fa8d3;
  --sky-text: #2c6d95;
  --gold: #c9942b;
  --gold-text: #a97918;
  --success: #2e7d53;
  --due: #c2410c;

  --page-plane: #16102e;
  --surface-1: #1f1640;
  --surface-sunken: #2a2058;

  --text-primary: #ece8fb;
  --text-secondary: #c3b8ec;
  --text-muted: #8f81c2;

  --border-hairline: rgba(95, 168, 211, 0.25);
  --gridline: rgba(95, 168, 211, 0.2);

  --accent: var(--sky);
  --accent-ink: #16102e;

  background: var(--page-plane);
  color: var(--text-primary);
  min-height: 100vh;
}

/* Logged-in pages only: the login page has no .master-shell. */
body.master-theme:has(.master-shell) {
  --master-btn-hover: var(--slate);
  --master-link: var(--sky);
  --master-badge-from: #0b2545;
  --master-badge-to: #1b4965;
  --master-badge-glow-rgb: 95, 168, 211;
}

/* Master host (body.master-console, middleware/masterHost.js): the gold of
   its console login -- headings, the active menu item and the top bar's
   dot. After the rule above so it wins at the same specificity. */
body.master-theme.master-console {
  --master-badge-from: #0b2545;
  --master-badge-to: #1b4965;
  --master-badge-glow-rgb: 201, 148, 43;
}

body.master-console .master-main h1,
body.master-console .master-main h2,
body.master-console .master-main h3 {
  color: var(--gold);
}

body.master-theme .btn-primary {
  background: var(--sky-text);
  color: #ffffff;
}

body.master-theme .btn-primary:hover {
  background: var(--master-btn-hover, #6d28d9);
}

body.master-theme .btn-secondary {
  color: var(--text-primary);
  border-color: var(--border-hairline);
}

body.master-theme .btn-secondary:hover {
  background: rgba(95, 168, 211, 0.12);
  border-color: var(--sky);
}

body.master-theme .card {
  color: var(--text-primary);
}

/* --sky rather than --sky-text: the deepened link blue is for light
   backgrounds and is too dark to read on these surfaces. */
body.master-theme a {
  color: var(--master-link, var(--sky-text));
}

/* Persistent brand badge so it's unmistakable at a glance even before any
   page-specific content renders. */
.master-badge {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1.1rem;
  background: linear-gradient(90deg, var(--master-badge-from, #241b4f) 0%, var(--master-badge-to, #4c1d95) 100%);
  color: #ffffff;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-bottom: 1px solid rgba(var(--master-badge-glow-rgb, 167, 139, 250), 0.4);
}

.master-badge__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgb(var(--master-badge-glow-rgb, 167, 139, 250));
  box-shadow: 0 0 8px 2px rgba(var(--master-badge-glow-rgb, 167, 139, 250), 0.7);
}

.master-content {
  padding-top: 2.75rem;
}

.master-footer {
  text-align: center;
  padding: 1.5rem;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.master-shell {
  display: flex;
  min-height: 100vh;
  padding-top: 2.5rem;
}

.master-sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--surface-1);
  border-right: 1px solid var(--border-hairline);
  padding: 1.25rem 0.75rem;
}

.master-sidebar__brand {
  font-weight: 800;
  font-size: 1.1rem;
  color: #ffffff;
  margin-bottom: 1.5rem;
  display: block;
}

.master-sidebar__link {
  display: block;
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.15rem;
}

.master-sidebar__link:hover {
  background: rgba(95, 168, 211, 0.12);
  color: #ffffff;
}

.master-sidebar__link.is-active {
  background: var(--sky-text);
  color: #ffffff;
}

body.master-console .master-sidebar__link.is-active {
  background: var(--gold);
  color: var(--page-plane);
}

.master-main {
  flex: 1;
  padding: 2rem 2.5rem;
  max-width: 1100px;
}

/* Drag-drop feature assignment (Master Plans -> edit) */
.dragdrop-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

.dragdrop-column h3 {
  margin: 0 0 0.6rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.dragdrop-column__list {
  list-style: none;
  margin: 0;
  padding: 0.5rem;
  min-height: 320px;
  background: var(--surface-sunken);
  border: 1px dashed var(--border-hairline);
  border-radius: var(--radius);
}

.dragdrop-column__list.is-drag-over {
  border-color: var(--sky-text);
  background: rgba(167, 139, 250, 0.1);
}

.dragdrop-item {
  padding: 0.55rem 0.75rem;
  margin-bottom: 0.4rem;
  background: var(--surface-1);
  border: 1px solid var(--border-hairline);
  border-radius: 8px;
  cursor: grab;
  font-size: 0.9rem;
  font-weight: 600;
  user-select: none;
}

.dragdrop-item:active {
  cursor: grabbing;
}

.dragdrop-item.is-dragging {
  opacity: 0.4;
}

.dragdrop-item__key {
  display: block;
  font-family: var(--font-mono);
  font-weight: 400;
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}
