/* JR Academy Admin Portal v2 Design System
 * Quiet-chrome, high-density operational workspace + Cerulean brand accent.
 * Driven strictly by semantic CSS custom properties (Light default, Dark optional).
 */

:root {
  color-scheme: light;
  --bg-canvas: #ffffff;
  --bg-subtle: #f8f9fa;
  --bg-surface: #ffffff;
  --bg-hover: #f3f4f6;
  --bg-active-row: #f0f9ff;
  --bg-backdrop: rgba(9, 9, 11, 0.45);
  --border-hairline: #e5e7eb;
  --border-strong: #d1d5db;

  --text-primary: #111111;
  --text-secondary: #3f3f46;
  --text-muted: #52525b;

  /* Brand Accent: Cerulean Sky */
  --accent-primary: #0ea5e9;
  --accent-primary-hover: #0284c7;
  --accent-primary-fg: #ffffff;
  --accent-soft: rgba(14, 165, 233, 0.1);
  --accent-border: rgba(14, 165, 233, 0.35);

  /* Semantic Status Badges */
  --badge-confirmed-bg: #ecfdf5;
  --badge-confirmed-fg: #047857;
  --badge-confirmed-bd: #a7f3d0;

  --badge-pending-bg: #fffbeb;
  --badge-pending-fg: #b45309;
  --badge-pending-bd: #fde68a;

  --badge-cancelled-bg: #fff1f2;
  --badge-cancelled-fg: #be123c;
  --badge-cancelled-bd: #fecdd3;

  --badge-completed-bg: #f1f5f9;
  --badge-completed-fg: #334155;
  --badge-completed-bd: #cbd5e1;

  --skeleton-base: #e5e7eb;
  --skeleton-sheen: #f3f4f6;

  --shadow-block-hover: 0 4px 12px -2px rgba(15, 23, 42, 0.12);
  --shadow-block-ring: 0 0 0 2px var(--accent-primary), 0 4px 12px -2px rgba(15, 23, 42, 0.14);
  --shadow-popover: 0 10px 25px -5px rgba(15, 23, 42, 0.16), 0 4px 10px -4px rgba(15, 23, 42, 0.08);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg-canvas: #09090b;
  --bg-subtle: #111113;
  --bg-surface: #141417;
  --bg-hover: #1c1c21;
  --bg-active-row: rgba(56, 189, 248, 0.08);
  --bg-backdrop: rgba(0, 0, 0, 0.65);
  --border-hairline: #27272a;
  --border-strong: #3f3f46;

  --text-primary: #fafafa;
  --text-secondary: #d4d4d8;
  --text-muted: #a1a1aa;

  --accent-primary: #38bdf8;
  --accent-primary-hover: #0ea5e9;
  --accent-primary-fg: #09090b;
  --accent-soft: rgba(56, 189, 248, 0.14);
  --accent-border: rgba(56, 189, 248, 0.38);

  --badge-confirmed-bg: rgba(16, 185, 129, 0.15);
  --badge-confirmed-fg: #6ee7b7;
  --badge-confirmed-bd: rgba(16, 185, 129, 0.34);

  --badge-pending-bg: rgba(245, 158, 11, 0.15);
  --badge-pending-fg: #fcd34d;
  --badge-pending-bd: rgba(245, 158, 11, 0.34);

  --badge-cancelled-bg: rgba(244, 63, 94, 0.15);
  --badge-cancelled-fg: #fda4af;
  --badge-cancelled-bd: rgba(244, 63, 94, 0.34);

  --badge-completed-bg: rgba(148, 163, 184, 0.15);
  --badge-completed-fg: #cbd5e1;
  --badge-completed-bd: rgba(148, 163, 184, 0.28);

  --skeleton-base: #1f1f24;
  --skeleton-sheen: #27272e;

  --shadow-block-hover: 0 4px 12px -2px rgba(0, 0, 0, 0.45);
  --shadow-block-ring: 0 0 0 2px var(--accent-primary), 0 4px 12px -2px rgba(0, 0, 0, 0.5);
  --shadow-popover: 0 10px 25px -5px rgba(0, 0, 0, 0.55), 0 4px 10px -4px rgba(0, 0, 0, 0.35);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background-color: var(--bg-canvas);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

.font-display {
  font-family: "Plus Jakarta Sans", "Inter", sans-serif;
}

.font-mono {
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, monospace;
  font-variant-numeric: tabular-nums;
}

.tabular-nums {
  font-variant-numeric: tabular-nums;
}

/* Focus Accessibility */
:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
}

/* App Shell Layout */
.jr-shell {
  display: flex;
  min-height: 100dvh;
  background: var(--bg-canvas);
  color: var(--text-primary);
}

.jr-sidebar {
  display: none;
  width: 240px;
  flex-shrink: 0;
  background: var(--bg-subtle);
  border-right: 1px solid var(--border-hairline);
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100dvh;
  z-index: 40;
  transition: width 160ms ease;
}

@media (min-width: 1024px) {
  .jr-sidebar {
    display: flex;
  }
}

html[data-sidebar-collapsed="true"] .jr-sidebar {
  width: 64px;
}

html[data-sidebar-collapsed="true"] .jr-sidebar-label {
  display: none;
}

html[data-sidebar-collapsed="true"] .jr-nav-item {
  justify-content: center;
  padding-inline: 0;
}

.jr-main-col {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.jr-topbar {
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border-hairline);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 16px;
}

@media (min-width: 1024px) {
  .jr-topbar {
    padding: 0 24px;
  }
}

/* Navigation Items */
.jr-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  min-height: 36px;
  border: 1px solid transparent;
  transition: background-color 120ms ease, color 120ms ease, border-color 120ms ease;
}

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

.jr-nav-item[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent-primary);
  border-color: var(--accent-border);
  font-weight: 600;
}

/* Quiet Chrome Hairline Surface Cards & Controls */
.jr-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-hairline);
  border-radius: 10px;
}

.jr-subtle-panel {
  background: var(--bg-subtle);
  border: 1px solid var(--border-hairline);
  border-radius: 10px;
}

.jr-divider {
  border-color: var(--border-hairline);
}

.jr-btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 12px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  background: var(--accent-primary);
  color: var(--accent-primary-fg);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 120ms ease, opacity 120ms ease;
}

.jr-btn-primary:hover {
  background: var(--accent-primary-hover);
}

.jr-btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 11px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 500;
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-hairline);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 120ms ease, border-color 120ms ease;
}

.jr-btn-secondary:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
}

.jr-btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 10px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 600;
  background: var(--badge-cancelled-bg);
  color: var(--badge-cancelled-fg);
  border: 1px solid var(--badge-cancelled-bd);
  cursor: pointer;
  white-space: nowrap;
}

.jr-input,
.jr-select {
  height: 34px;
  padding: 0 10px;
  border-radius: 7px;
  font-size: 13px;
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-hairline);
}

.jr-input::placeholder {
  color: var(--text-muted);
}

@media (max-width: 1023px) {
  .jr-touch-target {
    min-height: 44px;
    min-width: 44px;
  }
}

/* Status Badges */
.jr-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.4;
  border: 1px solid transparent;
  white-space: nowrap;
}

.badge-confirmed {
  background: var(--badge-confirmed-bg);
  color: var(--badge-confirmed-fg);
  border-color: var(--badge-confirmed-bd);
}

.badge-pending {
  background: var(--badge-pending-bg);
  color: var(--badge-pending-fg);
  border-color: var(--badge-pending-bd);
}

.badge-cancelled {
  background: var(--badge-cancelled-bg);
  color: var(--badge-cancelled-fg);
  border-color: var(--badge-cancelled-bd);
}

.badge-completed {
  background: var(--badge-completed-bg);
  color: var(--badge-completed-fg);
  border-color: var(--badge-completed-bd);
}

/* High-Density Bookings Table (44px row height + sticky header + sticky first column) */
.jr-table-wrap {
  position: relative;
  overflow-x: auto;
  max-width: 100%;
  border: 1px solid var(--border-hairline);
  border-radius: 10px;
  background: var(--bg-surface);
}

.jr-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  text-align: left;
  font-size: 13px;
}

.jr-table thead th {
  position: sticky;
  top: 0;
  z-index: 10;
  height: 38px;
  padding: 0 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border-hairline);
  white-space: nowrap;
}

.jr-table tbody tr {
  height: 44px;
  cursor: pointer;
  transition: background-color 100ms ease;
}

.jr-table tbody tr:hover td {
  background: var(--bg-hover);
}

.jr-table tbody tr[data-active-row="true"] td {
  background: var(--bg-active-row);
}

.jr-table tbody td {
  height: 44px;
  padding: 0 12px;
  border-bottom: 1px solid var(--border-hairline);
  background: var(--bg-surface);
  vertical-align: middle;
  white-space: nowrap;
}

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

.jr-table .sticky-col {
  position: sticky;
  inset-inline-start: 0;
  z-index: 8;
  border-right: 1px solid var(--border-hairline);
}

.jr-table thead th.sticky-col {
  z-index: 15;
  background: var(--bg-subtle);
}

/* Native Dialog Top-Layer Overlays */
dialog.jr-dialog {
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text-primary);
  max-width: none;
  max-height: none;
}

dialog.jr-dialog::backdrop {
  background: var(--bg-backdrop);
  backdrop-filter: blur(2px);
}

dialog.jr-drawer-right {
  margin: 0 0 0 auto;
  width: min(100vw, 520px);
  height: 100dvh;
  background: var(--bg-surface);
  border-left: 1px solid var(--border-hairline);
  display: flex;
  flex-direction: column;
  opacity: 0;
  transform: translateX(24px);
  transition: opacity 150ms ease, transform 180ms cubic-bezier(0.22, 1, 0.36, 1);
}

dialog.jr-drawer-right[open] {
  opacity: 1;
  transform: translateX(0);
}

@starting-style {
  dialog.jr-drawer-right[open] {
    opacity: 0;
    transform: translateX(24px);
  }
}

dialog.jr-drawer-right:not([open]) {
  display: none;
}

dialog.jr-drawer-left {
  margin: 0 auto 0 0;
  width: min(85vw, 280px);
  height: 100dvh;
  background: var(--bg-subtle);
  border-right: 1px solid var(--border-hairline);
  display: flex;
  flex-direction: column;
}

dialog.jr-drawer-left:not([open]) {
  display: none;
}

dialog.jr-modal {
  margin: 8vh auto auto auto;
  width: min(94vw, 580px);
  background: var(--bg-surface);
  border: 1px solid var(--border-hairline);
  border-radius: 12px;
  overflow: hidden;
}

dialog.jr-modal:not([open]) {
  display: none;
}

/* Skeleton Loader */
@keyframes jr-pulse {
  0%,
  100% {
    background-color: var(--skeleton-base);
  }
  50% {
    background-color: var(--skeleton-sheen);
  }
}

.jr-skeleton {
  border-radius: 6px;
  animation: jr-pulse 1.4s ease-in-out infinite;
}

/* Day Resource Grid */
.jr-resource-grid {
  border: 1px solid var(--border-hairline);
  border-radius: 10px;
  background: var(--bg-surface);
  overflow-x: auto;
}

.jr-resource-track {
  position: relative;
  min-width: 1540px;
}

.jr-drop-slot {
  position: relative;
}

.jr-drop-slot--half {
  border-right: 1px dashed var(--border-hairline);
}

.jr-drop-slot.is-drag-over {
  background: var(--accent-soft);
}

.jr-drop-slot.is-drag-over::after {
  content: attr(data-drop-time);
  position: absolute;
  inset: 4px 2px auto 2px;
  text-align: center;
  font-size: 10px;
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, monospace;
  font-weight: 600;
  color: var(--accent-primary);
  pointer-events: none;
}

.jr-session-block {
  position: absolute;
  top: 8px;
  bottom: 8px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  border-radius: 7px;
  padding: 6px 9px 8px 10px;
  border: 1px solid var(--accent-border);
  border-left: 3px solid var(--accent-primary);
  background: var(--accent-soft);
  color: var(--text-primary);
  overflow: hidden;
  cursor: grab;
  transition: left 180ms cubic-bezier(0.22, 1, 0.36, 1), transform 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
}

.jr-session-block:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-block-hover);
  border-color: var(--accent-primary);
}

.jr-session-block:focus-visible {
  transform: translateY(-1px);
  border-color: var(--accent-primary);
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
}

.jr-session-block:active {
  cursor: grabbing;
  transform: scale(0.99);
}

.jr-session-block.has-conflict {
  background: var(--badge-cancelled-bg);
  border-color: var(--badge-cancelled-bd);
  border-left-color: var(--badge-cancelled-fg);
}

.jr-session-block.is-pending-move {
  outline: 2px dashed var(--accent-primary);
  opacity: 0.85;
}

.jr-resource-grid.is-dragging .jr-session-block {
  pointer-events: none;
}

.jr-session-block.is-drag-source {
  opacity: 0.4;
  border-style: dashed;
}

.jr-session-block.is-assistant {
  background: var(--bg-subtle);
  border-style: dashed;
  border-color: var(--border-strong);
  border-left-style: solid;
  border-left-width: 3px;
  border-left-color: var(--text-muted);
}

.jr-session-block.is-assistant.has-conflict {
  background: var(--badge-cancelled-bg);
  border-color: var(--badge-cancelled-bd);
  border-left-color: var(--badge-cancelled-fg);
}

.jr-session-block.is-linked-highlight {
  box-shadow: var(--shadow-block-ring);
  border-color: var(--accent-primary);
}

.jr-session-role-tag {
  display: inline-flex;
  align-items: center;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 9px;
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, monospace;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--bg-hover);
  color: var(--text-muted);
  border: 1px solid var(--border-hairline);
  line-height: 1.3;
  flex-shrink: 0;
}

.jr-session-role-tag--lead {
  background: var(--bg-surface);
  color: var(--accent-primary);
  border-color: var(--accent-border);
}

.jr-session-grip {
  opacity: 0;
  color: var(--text-muted);
  transition: opacity 120ms ease;
  flex-shrink: 0;
}

.jr-session-block:hover .jr-session-grip,
.jr-session-block:focus-visible .jr-session-grip {
  opacity: 0.75;
}

.jr-session-capacity {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 10px;
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, monospace;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  background: var(--bg-surface);
  border: 1px solid var(--border-hairline);
  color: var(--text-secondary);
  line-height: 1.35;
}

.jr-session-fill {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background: transparent;
  pointer-events: none;
}

.jr-session-fill > span {
  display: block;
  height: 100%;
  max-width: 100%;
  background: var(--accent-primary);
  opacity: 0.55;
}

.jr-session-block.has-conflict .jr-session-fill > span {
  background: var(--badge-cancelled-fg);
}

.jr-grid-tooltip {
  position: fixed;
  z-index: 90;
  pointer-events: none;
  width: max-content;
  max-width: 280px;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  padding: 10px 12px;
  box-shadow: var(--shadow-popover);
  color: var(--text-primary);
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 100ms ease, transform 100ms ease;
}

.jr-grid-tooltip.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* Toast Region */
.jr-toast-region {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(92vw, 380px);
  pointer-events: none;
}

.jr-toast {
  pointer-events: auto;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
}
