@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;600;700&family=Montserrat:wght@300;400;500;600&display=swap');

/* ==================================================
   CSS CUSTOM PROPERTIES & ROOT VARIABLES
   ================================================== */

:root {
  /* Brand Colors */
  --brand-blue: #5C71F2;
  --brand-purple: #B0B0F9;
  --brand-teal: #66D8E1;

  /* Neutral Colors */
  --neutral-900: #242424;
  --neutral-100: #F2F2F2;
  --neutral-000: #FFFFFF;

  /* Layout Heights */
  --controls-height: 80px;
  --summary-height: 44px;
  --header-height: 50px;

  /* Border & Shadow Colors */
  --border-light: #DADDE6;
  --border-subtle: #E6EAF0;
  --border-table: #F0F2F6;
  --shadow-subtle: rgba(0, 0, 0, 0.04);
}

/* ==================================================
   BASE STYLES & RESET
   ================================================== */

* {
  box-sizing: border-box;
}

body {
  font-family: 'Montserrat', system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  margin: 0;
  padding: 0;
  background-color: var(--neutral-000);
  color: var(--neutral-900);
  height: 100vh;
  overflow: hidden;
}

/* Typography */
h1,
h2,
h3,
.summary-bar {
  font-family: 'IBM Plex Sans', 'Montserrat', system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  font-weight: 700;
}

/* ==================================================
   CONTROLS SECTION
   ================================================== */

#controls {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--controls-height);
  z-index: 3000;
  /* ensure controls and any dropdowns sit above table container */
  background-color: var(--neutral-000);
  padding: 15px 20px;
  display: flex;
  flex-wrap: nowrap;
  gap: 10px;
  align-items: center;
  overflow-x: auto;
  overflow-y: visible;
  /* allow multiselect panel to extend below */
}

#controls>div {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

#controls label {
  white-space: nowrap;
  font-weight: 500;
}

#controls select {
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid var(--border-light);
  font-size: 14px;
  background-color: var(--neutral-000);
  outline: none;
  min-height: 36px;
  min-width: 200px;
}

#controls select:focus {
  border-color: var(--brand-blue);
  /* If color-mix is unsupported, the box-shadow line is ignored */
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--brand-blue) 25%, transparent);
}

#printBtn {
  padding: 8px 18px;
  border: none;
  border-radius: 8px;
  background: var(--brand-blue);
  color: var(--neutral-000);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 1px 2px var(--shadow-subtle);
  transition: filter 0.15s ease, transform 0.02s ease;
  min-height: 36px;
  flex-shrink: 0;
}

#printBtn:hover {
  filter: brightness(1.05);
}

#printBtn:active {
  transform: translateY(1px);
}

/* ==================================================
   SUMMARY BAR
   ================================================== */

.summary-bar {
  position: fixed;
  top: var(--controls-height);
  left: 0;
  right: 0;
  height: var(--summary-height);
  z-index: 900;
  background-color: var(--neutral-000);
  padding: 12px 30px;
  line-height: 1.25;
  font-weight: 600;
  color: var(--neutral-900);
  display: none;
  align-items: center;
}

.summary-bar.visible {
  display: flex;
}

/* ==================================================
   TABLE CONTAINER & LAYOUT
   ================================================== */

.table-container {
  position: fixed;
  top: var(--controls-height);
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--neutral-000);
  border-radius: 6px 6px 0 0;
  margin: 0 20px 20px 20px;
  border: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
}

/* Use :has only if supported, otherwise use the class fallback */
@supports selector(:has(*)) {
  body:has(.summary-bar.visible) .table-container {
    top: calc(var(--controls-height) + var(--summary-height));
  }
}

/* Fallback for browsers without :has support */
body.summary-visible .table-container {
  top: calc(var(--controls-height) + var(--summary-height));
}

/* ==================================================
   TABLE HEADER
   ================================================== */

.table-header {
  background-color: var(--brand-blue);
  border-bottom: 2px solid rgba(0, 0, 0, 0.08);
  /* subtle separator */
  flex-shrink: 0;
}

.table-header table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
}

.table-header th {
  padding: 12px;
  text-align: left;
  font-weight: 700;
  color: #FFFFFF;
  /* white text on brand blue */
  font-size: 14px;
  white-space: nowrap;
  border: none;
  background: transparent;
}

/* ==================================================
   TABLE BODY
   ================================================== */

.table-body {
  flex: 1;
  overflow-y: auto;
  background-color: var(--neutral-000);
}

.table-body table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
}

.table-body td {
  padding: 12px;
  text-align: left;
  border-bottom: 1px solid var(--border-table);
  font-size: 12px;
  vertical-align: top;
  border: none;
}

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

/* ==================================================
   TABLE COLUMN WIDTHS
   ================================================== */

.table-header th:nth-child(1),
.table-body td:nth-child(1) {
  width: 37.5%;
}

.table-header th:nth-child(2),
.table-body td:nth-child(2) {
  width: 80px;
  text-align: center;
}

.table-header th:nth-child(3),
.table-body td:nth-child(3) {
  column-count: 2;
  column-gap: 2rem;
}

/* ==================================================
   TABLE STYLING & INTERACTIONS
   ================================================== */

/* Zebra Striping with safe fallback first */
.table-body tr:nth-child(even) {
  background-color: #F9FAFB;
  /* lighter gray zebra */
  /* fallback */
  background-color: color-mix(in oklab, var(--neutral-900) 3%, var(--neutral-000));
}

/* Custom Scrollbar */
.table-body::-webkit-scrollbar {
  width: 8px;
}

.table-body::-webkit-scrollbar-track {
  background: var(--neutral-100);
}

.table-body::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: 4px;
}

.table-body::-webkit-scrollbar-thumb:hover {
  background: #B8BCC8;
}

/* ==================================================
   UTILITY CLASSES
   ================================================== */

.text-primary {
  color: var(--brand-blue);
}

.bg-primary-10 {
  background: #ECF0FF;
  /* fallback */
  background: color-mix(in oklab, var(--brand-blue) 10%, var(--neutral-000));
}

.border-subtle {
  border-color: var(--border-subtle);
}

/* ==================================================
   MEDIA QUERIES - RESPONSIVE VARS & LAYOUTS
   ================================================== */

/* Mobile Layout (≤600px) */
@media (max-width: 600px) {

  /* CSS Variables for Mobile */
  :root {
    --controls-height: 300px;
    --summary-height: 50px;
  }

  #controls {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 20px 15px;
    overflow-x: visible;
    overflow-y: visible;
  }

  #controls>div {
    flex-direction: column;
    gap: 5px;
  }

  #controls label {
    font-weight: 500;
    font-size: 14px;
    color: var(--neutral-900);
    margin: 0;
  }

  #controls select {
    width: 100%;
    margin: 0;
    min-height: 40px;
    min-width: 100%;
  }

  #printBtn {
    width: 100%;
    margin: 10px 0 0 0;
    min-height: 44px;
  }

  .summary-bar {
    padding: 12px 15px;
    font-size: 14px;
  }

  .table-container {
    margin: 0 10px 10px 10px;
  }

  .table-header th:nth-child(1),
  .table-body td:nth-child(1) {
    width: 45%;
  }

  .table-header th:nth-child(2),
  .table-body td:nth-child(2) {
    width: 60px;
  }

  .table-header th:nth-child(3),
  .table-body td:nth-child(3) {
    column-count: 1;
    column-gap: 1rem;
  }

  .table-header th,
  .table-body td {
    font-size: 11px;
    padding: 8px 6px;
  }

  .multi-select {
    display: block;
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }
}

/* Tablet Layout (601px - 900px) */
@media (min-width: 601px) and (max-width: 900px) {

  /* CSS Variables for Tablet */
  :root {
    --controls-height: 130px;
  }

  #controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto auto;
    gap: 15px;
    align-items: start;
    padding: 20px;
    overflow-x: visible;
    overflow-y: visible;
  }

  #controls>div:nth-child(1) {
    grid-column: 1;
    grid-row: 1;
  }

  #controls>div:nth-child(2) {
    grid-column: 2;
    grid-row: 1;
  }

  #controls>div:nth-child(3) {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  #printBtn {
    grid-column: 1 / -1;
    grid-row: 3;
    justify-self: center;
    margin: 0;
    width: auto;
  }

  .multi-select {
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }
}

/* Medium Desktop Layout (901px - 1200px) */
@media (min-width: 901px) and (max-width: 1200px) {
  #controls {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    gap: 15px;
    overflow-x: auto;
  }

  #controls>div {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    min-width: 180px;
  }

  #controls label {
    font-size: 13px;
  }

  #controls select {
    min-width: 120px;
  }

  #printBtn {
    margin-left: auto;
    margin-right: 10px;
  }
}

/* Large Desktop Layout (≥1201px) */
@media (min-width: 1201px) {
  #controls {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    gap: 20px;
  }

  #controls>div {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
  }

  #printBtn {
    margin-left: auto;
    margin-right: 20px;
  }
}

/* Desktop Controls Group Override (≥901px) */
@media (min-width: 901px) {
  #controls>div {
    flex-direction: row;
    align-items: center;
    gap: 8px;
  }
}

/* ==================================================
   MULTISELECT MENU CHIPS (abbreviations in dropdown)
   ================================================== */
.course-chip--menu {
  padding: 0 6px;
  line-height: 16px;
  min-width: 24px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

/* ==================================================
   COURSE CHIP PALETTE (single source of truth)
   ================================================== */
.project-item[data-course="CS Adventures with VR"],
.multi-select-option[data-course="CS Adventures with VR"],
.multi-select-header-option[data-course="CS Adventures with VR"] {
  --chip-bg: #E3E8FF;
  --chip-border: #C2CCFF;
  --chip-fg: #1E2566;
}

.project-item[data-course="CS Breakthroughs with VR"],
.multi-select-option[data-course="CS Breakthroughs with VR"],
.multi-select-header-option[data-course="CS Breakthroughs with VR"] {
  --chip-bg: #EDE9FF;
  --chip-border: #D6CDFF;
  --chip-fg: #32225F;
}

.project-item[data-course="CS Connections with VR"],
.multi-select-option[data-course="CS Connections with VR"],
.multi-select-header-option[data-course="CS Connections with VR"] {
  --chip-bg: #E7F0FF;
  --chip-border: #CFE1FF;
  --chip-fg: #183052;
}

.project-item[data-course="CS Dimensions with VR"],
.multi-select-option[data-course="CS Dimensions with VR"],
.multi-select-header-option[data-course="CS Dimensions with VR"] {
  --chip-bg: #EEF5FF;
  --chip-border: #D8E6FF;
  --chip-fg: #1C2E57;
}

.project-item[data-course="Intro to Python"],
.multi-select-option[data-course="Intro to Python"],
.multi-select-header-option[data-course="Intro to Python"] {
  --chip-bg: #FFF2CC;
  --chip-border: #FFE29A;
  --chip-fg: #5A3A00;
}

.project-item[data-course="Web Development"],
.multi-select-option[data-course="Web Development"],
.multi-select-header-option[data-course="Web Development"] {
  --chip-bg: #FFE6F1;
  --chip-border: #FFC9DF;
  --chip-fg: #6B0038;
}

.project-item[data-course="Data Science & AI"],
.multi-select-option[data-course="Data Science & AI"],
.multi-select-header-option[data-course="Data Science & AI"] {
  --chip-bg: #e7faf1;
  --chip-border: #CFEEDD;
  --chip-fg: #0F3A21;
}



/* ==================================================
   PRINT STYLES
   ================================================== */

@media print {

  /* Ensure browsers print background colors */
  * {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  body {
    height: auto;
    overflow: visible;
    background-color: transparent;
  }

  #controls {
    position: static;
    height: auto;
    flex-wrap: nowrap;
    background-color: transparent;
    border: none;
    padding-left: 0;
  }

  .summary-bar {
    position: static;
    height: auto;
    border: none;
  }

  .table-container {
    position: static;
    margin: 0;
    border: none;
    border-radius: 0;
  }

  .table-header,
  .table-body {
    display: block;
  }

  .table-body {
    overflow: visible;
  }

  .table-body tr:nth-child(even) {
    background-color: #f8f8f8 !important;
  }

  #printBtn {
    display: none;
  }

  .project-item {
    break-inside: avoid;
  }
}

/* ==================================================
   MULTISELECT (Courses) — custom dropdown with chips
   ================================================== */
.multi-select {
  position: relative;
  display: inline-block;
  width: 260px;
  min-width: 260px;
  max-width: 260px;
  vertical-align: middle;
}

.multi-select-header {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 6px;
  height: 36px;
  /* match native selects */
  padding: 0 12px;
  /* keep height at 36px */
  background: var(--neutral-000);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  cursor: pointer;
  overflow: hidden;
  /* hide extra chips, no horizontal scroll */
  white-space: nowrap;
}

.multi-select-header-placeholder {
  color: #6b7280;
  /* neutral gray */
  white-space: nowrap;
  font-size: 14px;
  line-height: 36px;
}

.multi-select-header-option {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--chip-bg, #ECF0FF);
  border: 1px solid var(--chip-border, var(--border-light));
  color: var(--chip-fg, #334155);
  font-size: 12px;
  line-height: 20px;
  white-space: nowrap;
}

.multi-select-header-max {
  font-size: 12px;
  color: #374151;
  white-space: nowrap;
  line-height: 20px;
}

.multi-select-options {
  display: none !important;
  /* hidden until header is active */
  position: fixed;
  /* layer above the table */
  left: 0;
  /* set via JS on open */
  top: 0;
  /* set via JS on open */
  z-index: 9999;
  background: var(--neutral-000);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  max-height: 260px;
  overflow: auto;
  padding: 4px;
  min-width: 260px;
  /* match control width by default */
  max-width: 420px;
}

.multi-select-header.multi-select-header-active+.multi-select-options {
  display: block !important;
}

.multi-select-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  user-select: none;
}

.multi-select-option:hover {
  background: #f3f4f6;
}

.multi-select-option-radio {
  width: 16px;
  height: 16px;
  border: 2px solid #9ca3af;
  border-radius: 4px;
  display: inline-block;
}

.multi-select-selected .multi-select-option-radio {
  background: var(--brand-blue);
  border-color: var(--brand-blue);
}

.multi-select-option-text {
  flex: 1;
  font-size: 14px;
  line-height: 20px;
}

/* Helper text next to Courses dropdown */
.helper-text {
  font-size: 12px;
  color: #374151;
  margin-left: 8px;
  max-width: 220px;
  display: inline-block;
  vertical-align: middle;
}

/* Responsive sizing to match selects */
@media (max-width: 600px) {
  .multi-select {
    display: block;
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }
}

@media (min-width: 601px) and (max-width: 900px) {
  .multi-select {
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }
}

/* ==================================================
   PROJECT LIST CHIPS (Course abbreviations)
   ================================================== */
.project-item {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  /* space between projects */
  break-inside: avoid;
  /* avoid column breaks inside a project */
}

.project-item:last-child {
  margin-bottom: 0;
}

.course-chip {
  display: inline-block;
  padding: 0 6px;
  line-height: 18px;
  min-width: 26px;
  /* keeps very short codes readable */
  text-align: center;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.2px;
  background: var(--chip-bg, #ECF0FF);
  border: 1px solid var(--chip-border, var(--border-light));
  color: var(--chip-fg, #334155);
  box-shadow: 0 1px 0 rgba(0, 0, 0, .03);
  flex-shrink: 0;
}

.project-name {
  font-size: 12px;
  line-height: 18px;
  color: var(--neutral-900);
}

/* Print — expand courses list; hide panel & helper */
@media print {

  /* Hide dropdown panel and helper text */
  .multi-select-options,
  .helper-text {
    display: none !important;
  }

  /* Let the control expand to show all selected courses */
  .multi-select {
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
  }

  .multi-select-header {
    height: auto !important;
    white-space: normal !important;
    overflow: visible !important;
    padding: 0 !important;
    /* tighter on paper */
    border: none !important;
    /* cleaner print */
    background: transparent !important;
  }

  .multi-select-header-option,
  .multi-select-header-max {
    line-height: 1.4 !important;
    margin-right: 6px;
  }

  /* Safety: ensure +N never prints even if JS fails to swap */
  .multi-select-header-max {
    display: none !important;
  }
}