/* ============================================================
   DESIGN TOKENS
   ============================================================ */
:root {
  --bg: #FAFAFA;
  --surface: #FFFFFF;
  --surface-2: #F8F8F8;
  --surface-3: #F0F0F0;
  --ink: #1C2B4A;
  --ink-soft: #49536A;
  --ink-mute: #8B8F9C;
  --line: #DADADA;
  --line-strong: #CCCCCC;

  --blue: #375F9E;
  --green: #2C7355;
  --amber: #B0660F;

  --shadow-sm: 0 1px 2px rgba(28, 43, 74, 0.06);
  --shadow-md: 0 4px 18px -6px rgba(28, 43, 74, 0.16);
  --shadow-lg: 0 18px 48px -16px rgba(28, 43, 74, 0.28);

  --r-sm: 8px;
  --r-md: 12px;

  --font-display: 'Open Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-body: 'Open Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'SFMono-Regular', ui-monospace, 'Cascadia Code', Menlo, monospace;
}

[data-theme="dark"] {
  --bg: #000000;
  --surface: #0F1419;
  --surface-2: #1A1F2E;
  --surface-3: #252C3D;
  --ink: #ECE9DF;
  --ink-soft: #AEB6C7;
  --ink-mute: #727A8E;
  --line: #2C3A5E;
  --line-strong: #3A4A72;

  --blue: #7397D2;
  --green: #5BAE86;
  --amber: #D58A3C;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 18px -6px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 18px 48px -16px rgba(0, 0, 0, 0.6);
}

/* ============================================================
   BASE
   ============================================================ */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  transition: background 0.35s ease, color 0.35s ease;
  display: flex;
  flex-direction: column;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

select { font-family: inherit; font-size: 14px; color: var(--ink); }

/* ============================================================
   HEADER
   ============================================================ */
.header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}

.header-content {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  width: 100%;
}

.brand {
  flex: 1;
  min-width: 0;
}

.brand h1 {
  font-size: 20px;
  font-weight: 600;
  margin: 0 0 4px 0;
  line-height: 1.2;
}

.subtitle {
  font-size: 13px;
  color: var(--ink-mute);
  margin: 0;
  line-height: 1.4;
}

.header-controls {
  display: flex;
  gap: 12px;
  align-items: center;
}

.header-select {
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink);
  font-size: 14px;
  cursor: pointer;
  min-width: 200px;
}

.search-input {
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink);
  font-size: 14px;
  min-width: 200px;
}

.btn-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--ink);
  transition: background 0.2s;
}

.btn-icon:hover {
  background: var(--surface-3);
}

.btn-icon svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
}

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
}

.empty-icon {
  margin-bottom: 24px;
  color: var(--ink-mute);
}

.empty-state h2 {
  font-size: 24px;
  margin: 0 0 12px 0;
}

.empty-state p {
  max-width: 500px;
  color: var(--ink-soft);
  font-size: 15px;
}

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.controls-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.controls-left {
  display: flex;
  gap: 16px;
  align-items: center;
}

.major-label {
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
}

.course-count {
  font-size: 13px;
  color: var(--ink-mute);
}

.controls-right {
  display: flex;
  gap: 8px;
}

.btn {
  padding: 8px 16px;
  border-radius: var(--r-sm);
  background: var(--blue);
  color: white;
  font-size: 13px;
  font-weight: 500;
  transition: opacity 0.2s;
}

.btn:hover {
  opacity: 0.9;
}

.btn.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

/* ============================================================
   COURSE LIST
   ============================================================ */
.course-list-container {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.year-section {
  margin-bottom: 32px;
}

.year-section:last-child {
  margin-bottom: 0;
}

.year-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  padding: 12px 0;
  border-bottom: 3px solid var(--blue);
}

.year-label {
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: 0.03em;
}

.year-description {
  font-size: 14px;
  color: var(--ink-soft);
  font-weight: 500;
}

.requirement-group {
  margin-bottom: 16px;
}

.requirement-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 8px 12px;
  margin-bottom: 12px;
  border-radius: 4px;
  display: inline-block;
}

.required-group .requirement-label {
  background: #375F9E;
  color: white;
}

.elective-group .requirement-label {
  background: #6B46C1;
  color: white;
}

.choice-group .requirement-label {
  background: #0B8A8A;
  color: white;
}

.pathway-choice-group .requirement-label {
  background: #F59E0B;
  color: white;
}

.courses-in-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.course-item.required-course:hover {
  background: #D4EBFF;
}

[data-theme="dark"] .course-item.required-course {
  background: #1E3A52;
  border-left: 4px solid #4A90FF;
}

[data-theme="dark"] .course-item.required-course:hover {
  background: #2A4A66;
}

.course-item {
  display: flex;
  flex-direction: column;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  gap: 8px;
}

.classification-badge {
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 700;
  border-radius: 4px;
  text-transform: uppercase;
  white-space: nowrap;
}

.required-badge {
  background: #375F9E;
  color: white;
}

.elective-badge {
  background: #6B46C1;
  color: white;
}

.choice-badge {
  background: #0B8A8A;
  color: white;
}

.pathway-choice-badge {
  background: #F59E0B;
  color: white;
}

.course-item.required-course {
  background: #E4ECF7;
  border-left: 4px solid #375F9E;
}

.course-item.required-course:hover {
  background: #D4E4F7;
}

.course-item.elective-course {
  background: #F3EFFF;
  border-left: 4px solid #6B46C1;
}

.course-item.elective-course:hover {
  background: #E8E0FF;
}

.course-item.choice-course {
  background: #E0F7F8;
  border-left: 4px solid #0B8A8A;
}

.course-item.choice-course:hover {
  background: #D0F3F5;
}

.course-item.pathway-choice-course {
  background: #FEF3C7;
  border-left: 4px solid #F59E0B;
}

.course-item.pathway-choice-course:hover {
  background: #FDE68A;
}

/* Required choice courses (same styling as pathway choices) */
.required-choice-group .requirement-label {
  background: #F59E0B;
  color: white;
}

.required-choice-badge {
  background: #F59E0B;
  color: white;
}

.course-item.required-choice-course {
  background: #FEF3C7;
  border-left: 4px solid #F59E0B;
}

.course-item.required-choice-course:hover {
  background: #FDE68A;
}

.course-item:hover {
  background: var(--surface-2);
  border-color: var(--blue);
}

.course-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  width: 100%;
}

.course-code-meta {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.course-title-row {
  font-size: 14px;
  line-height: 1.4;
}

.course-badges {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  align-items: center;
}

.course-code-title {
  display: flex;
  gap: 12px;
  align-items: center;
  min-width: 0;
}

.course-code {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--blue);
  flex-shrink: 0;
}

.course-title {
  font-size: 14px;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.course-meta {
  display: flex;
  gap: 12px;
  align-items: center;
  font-size: 12px;
  color: var(--ink-mute);
  flex-shrink: 0;
}

.course-credits, .course-sem, .course-year {
  white-space: nowrap;
}

.course-badge {
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 4px;
  text-transform: uppercase;
  flex-shrink: 0;
  white-space: nowrap;
}

.required-badge {
  background: var(--required-bg);
  color: var(--blue);
}

.section-badge {
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 4px;
  text-transform: capitalize;
  flex-shrink: 0;
  white-space: nowrap;
}

.pathway-badge {
  background: #E8F4F8;
  color: #0066CC;
  border: 1px solid #99D4E6;
}

.major-badge {
  background: #E6F3E6;
  color: #2C7355;
  border: 1px solid #99D4B8;
}

.elective-badge {
  background: #F5E6FF;
  color: #6B46C1;
  border: 1px solid #D4B8FF;
}

.seminar-badge {
  background: #FFE6E6;
  color: #CC3333;
  border: 1px solid #FF99B2;
}

[data-theme="dark"] .pathway-badge {
  background: #1A3D4D;
  color: #66D9FF;
  border-color: #336B85;
}

[data-theme="dark"] .major-badge {
  background: #1A331A;
  color: #5BAE86;
  border-color: #336B33;
}

[data-theme="dark"] .elective-badge {
  background: #3D1A4D;
  color: #C4B5FF;
  border-color: #664D85;
}

[data-theme="dark"] .course-item.elective-course {
  background: #2D1B3D;
  border-left: 4px solid #6B46C1;
}

[data-theme="dark"] .course-item.elective-course:hover {
  background: #3D2750;
}

[data-theme="dark"] .choice-badge {
  background: #0D3F3F;
  color: #5FDDDD;
  border-color: #0B8A8A;
}

[data-theme="dark"] .course-item.choice-course {
  background: #0D2E2E;
  border-left: 4px solid #0D8A8A;
}

[data-theme="dark"] .course-item.choice-course:hover {
  background: #154545;
}

[data-theme="dark"] .pathway-choice-badge {
  background: #92400E;
  color: #FCD34D;
  border-color: #F59E0B;
}

[data-theme="dark"] .course-item.pathway-choice-course {
  background: #332701;
  border-left: 4px solid #F59E0B;
}

[data-theme="dark"] .course-item.pathway-choice-course:hover {
  background: #3F2F04;
}

/* Dark mode: Required choice courses (same as pathway choices) */
[data-theme="dark"] .required-choice-badge {
  background: #92400E;
  color: #FCD34D;
  border-color: #F59E0B;
}

[data-theme="dark"] .course-item.required-choice-course {
  background: #332701;
  border-left: 4px solid #F59E0B;
}

[data-theme="dark"] .course-item.required-choice-course:hover {
  background: #3F2F04;
}

[data-theme="dark"] .seminar-badge {
  background: #4D1A1A;
  color: #FF8099;
  border-color: #854D5C;
}


/* ============================================================
   DETAIL PANEL
   ============================================================ */
.detail-panel {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--surface);
  z-index: 100;
  overflow-y: auto;
  padding: 80px 20px 40px;
  display: none;
}

.detail-close {
  position: fixed;
  top: 20px;
  right: 20px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  cursor: pointer;
  color: var(--ink-mute);
  background: var(--surface-2);
  border-radius: var(--r-sm);
  z-index: 101;
  transition: background 0.2s;
}

.detail-close:hover {
  background: var(--surface-3);
}

.detail-container {
  max-width: 600px;
  margin: 0 auto;
}

.course-info-section {
  margin-bottom: 32px;
}

.course-info-section h3 {
  font-size: 20px;
  font-weight: 600;
  margin: 0 0 12px 0;
  color: var(--ink);
}

.detail-section {
  margin-bottom: 32px;
}

.detail-section h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 16px 0;
  padding: 0 0 8px 0;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 3px solid var(--blue);
  display: block;
  line-height: 1.4;
}

.list-view-items {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.list-item {
  font-size: 13px;
  color: var(--ink-soft);
  padding: 8px 12px;
  background: var(--surface-2);
  border-radius: 6px;
  border-left: 3px solid var(--blue);
}

.prereq-item {
  margin-bottom: 8px;
}

.prereq-item.has-explanation .list-item {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  margin-bottom: 0;
}

.prereq-explanation {
  display: flex;
  gap: 8px;
  padding: 8px 12px;
  background: color-mix(in srgb, var(--blue) 8%, var(--surface-2));
  border: 1px solid var(--line);
  border-top: none;
  border-bottom-left-radius: 6px;
  border-bottom-right-radius: 6px;
  font-size: 12px;
  color: var(--ink-soft);
  line-height: 1.4;
}

.explanation-icon {
  font-size: 12px;
  flex-shrink: 0;
}

.explanation-text {
  flex: 1;
}

.prereq-connector {
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-mute);
  padding: 6px 0;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 4px 0;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 900px) {
  .header-content {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .header-controls {
    flex-direction: column;
  }

  .header-select, .search-input {
    width: 100%;
    min-width: unset;
  }

  .controls-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .course-item-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .course-meta {
    width: 100%;
    justify-content: flex-start;
  }
}

@media (max-width: 640px) {
  .header-content {
    padding: 16px 16px;
  }

  .brand h1 {
    font-size: 18px;
  }

  .subtitle {
    font-size: 12px;
  }

  .course-list-container {
    padding: 12px;
  }

  .course-item {
    padding: 12px;
    margin-bottom: 6px;
  }

  .course-meta {
    font-size: 11px;
  }

  .detail-panel {
    padding: 60px 16px 30px;
  }

  .detail-close {
    top: 16px;
    right: 16px;
  }
}
