/* ==========================================================================
   Modern CSS styling with light-dark(), color-scheme, and accessible UI
   ========================================================================== */

:root {
  color-scheme: light dark;

  /* Reflect meta color-scheme override in CSS */
  &:has(> head > meta[name="color-scheme"][content="dark"]) {
    color-scheme: dark;
  }
  &:has(> head > meta[name="color-scheme"][content="light"]) {
    color-scheme: light;
  }

  /* Color Palette using light-dark() */
  --bg-page: light-dark(#f8fafc, #090d16);
  --bg-surface: light-dark(#ffffff, #111827);
  --bg-surface-elevated: light-dark(#f1f5f9, #1a2234);
  --bg-surface-subtle: light-dark(#f8fafc, #131b2c);
  --bg-code: light-dark(#0d1117, #060910);
  
  --text-main: light-dark(#0f172a, #f1f5f9);
  --text-muted: light-dark(#64748b, #94a3b8);
  --text-dim: light-dark(#94a3b8, #64748b);

  --border-subtle: light-dark(#e2e8f0, #1f2937);
  --border-strong: light-dark(#cbd5e1, #374151);

  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: light-dark(#eff6ff, #172554);
  --primary-border: light-dark(#bfdbfe, #1e3a8a);

  --accent-success: #10b981;
  --accent-success-hover: #059669;
  --accent-success-light: light-dark(#ecfdf5, #064e3b);
  --accent-warning: #f59e0b;
  --accent-warning-light: light-dark(#fffbeb, #78350f);

  --shadow-sm: light-dark(0 1px 3px rgba(0, 0, 0, 0.05), 0 1px 3px rgba(0, 0, 0, 0.4));
  --shadow-md: light-dark(0 4px 6px -1px rgba(0, 0, 0, 0.06), 0 4px 6px -1px rgba(0, 0, 0, 0.45));
  --shadow-lg: light-dark(0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 10px 15px -3px rgba(0, 0, 0, 0.5));

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-full: 9999px;

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  --sidebar-width: 290px;
  --header-height: 60px;
}

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-page);
  color: var(--text-main);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* Top Navigation Bar */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-height);
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  box-shadow: var(--shadow-sm);
}

.nav-left {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.sidebar-toggle-btn {
  display: none;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.65rem;
  cursor: pointer;
  font-size: 1.1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  color: var(--text-main);
}

.brand-icon {
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, #2563eb, #4f46e5);
  color: #fff;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  font-weight: 700;
}

.brand-title {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand-subtitle {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-muted);
}

.nav-search {
  position: relative;
  width: 280px;
}

.nav-search input {
  width: 100%;
  padding: 0.45rem 2rem 0.45rem 0.85rem;
  font-size: 0.85rem;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  background-color: var(--bg-surface-elevated);
  color: var(--text-main);
  outline: none;
  transition: all 0.2s ease;
}

.nav-search input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
  background-color: var(--bg-surface);
}

.search-shortcut {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.68rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  color: var(--text-muted);
  pointer-events: none;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.btn-theme-toggle {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-md);
  font-size: 0.825rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: 500;
  transition: background-color 0.2s;
}

.btn-theme-toggle:hover {
  background-color: var(--border-subtle);
}

/* Quick Jump Horizontal Tabs Bar */
.quick-tabs-bar {
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0.5rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  overflow-x: auto;
  white-space: nowrap;
}

.quick-tab-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  margin-right: 0.25rem;
}

.quick-tab-btn {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  padding: 0.3rem 0.75rem;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: all 0.15s ease;
}

.quick-tab-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.quick-tab-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* Main Layout Grid */
.layout-container {
  display: flex;
  flex: 1;
  min-height: calc(100vh - var(--header-height) - 45px);
}

/* Sidebar Styles */
.sidebar {
  width: var(--sidebar-width);
  background-color: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: calc(var(--header-height) + 45px);
  height: calc(100vh - var(--header-height) - 45px);
  overflow-y: auto;
  flex-shrink: 0;
  transition: transform 0.25s ease;
}

.sidebar-header {
  padding: 0.85rem 1rem 0.65rem;
  border-bottom: 1px solid var(--border-subtle);
}

.sidebar-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.4rem;
}

.sidebar-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.assignment-badge-counter {
  font-size: 0.72rem;
  font-weight: 600;
  background-color: var(--accent-success-light);
  color: var(--accent-success);
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-full);
}

/* Filter pills */
.category-filter-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.4rem;
}

.filter-pill {
  font-size: 0.72rem;
  padding: 0.18rem 0.5rem;
  border-radius: var(--radius-full);
  background: var(--bg-surface-elevated);
  color: var(--text-muted);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
}

.filter-pill:hover {
  color: var(--text-main);
  border-color: var(--border-strong);
}

.filter-pill.active {
  background: var(--primary);
  color: #fff;
  font-weight: 600;
}

/* Assignment List in Sidebar */
.assignment-nav-list {
  list-style: none;
  padding: 0.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.assignment-nav-item {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.65rem 0.75rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  text-decoration: none;
  color: var(--text-main);
  transition: all 0.15s ease;
  border: 1px solid transparent;
}

.assignment-nav-item:hover {
  background-color: var(--bg-surface-elevated);
}

.assignment-nav-item.active {
  background-color: var(--primary-light);
  border-color: var(--primary-border);
}

.assignment-nav-item.active .item-num {
  background-color: var(--primary);
  color: #fff;
}

.item-num {
  flex-shrink: 0;
  min-width: 26px;
  height: 24px;
  padding: 0 4px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-muted);
}

.item-details {
  flex: 1;
  min-width: 0;
}

.item-title {
  font-size: 0.825rem;
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 0.2rem;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.item-meta {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* Main Content Area */
.main-content {
  flex: 1;
  padding: 1.75rem 2rem;
  max-width: 1050px;
  margin: 0 auto;
  width: 100%;
}

/* Assignment Banner */
.assignment-banner {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
  position: relative;
}

.banner-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.badge-group {
  display: flex;
  gap: 0.45rem;
  align-items: center;
  flex-wrap: wrap;
}

.tag-badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-full);
}

.tag-category {
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid var(--primary-border);
}

.tag-status-ready {
  background: var(--accent-success-light);
  color: var(--accent-success);
}

/* Quick Action Buttons */
.assignment-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.btn-primary-action {
  background-color: var(--accent-success);
  color: #fff;
  border: none;
  padding: 0.45rem 0.95rem;
  border-radius: var(--radius-md);
  font-size: 0.825rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.15s ease;
  box-shadow: 0 1px 3px rgba(16, 185, 129, 0.3);
}

.btn-primary-action:hover {
  background-color: var(--accent-success-hover);
}

.btn-primary-action.copied {
  background-color: #047857;
}

.action-btn {
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-md);
  font-size: 0.825rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.15s ease;
}

.action-btn:hover {
  background-color: var(--border-subtle);
  border-color: var(--border-strong);
}

.banner-title {
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 0.5rem;
  line-height: 1.3;
}

.banner-objective {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.55;
}

/* Relational Schema Card */
.schema-card {
  background: var(--bg-surface-elevated);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  padding: 0.85rem 1.1rem;
  margin-top: 1rem;
}

.schema-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.schema-content {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-main);
  white-space: pre-wrap;
  word-break: break-all;
}

/* Code Sections */
.content-sections {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.section-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.section-header {
  padding: 0.85rem 1.15rem;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  background-color: var(--bg-surface-subtle);
}

.section-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
}

.section-description {
  padding: 0.65rem 1.15rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-subtle);
  background-color: var(--bg-surface);
}

/* Code Block & Syntax */
.code-container {
  background-color: var(--bg-code);
  position: relative;
}

.code-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.4rem 0.9rem;
  background-color: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.code-lang-label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  color: #94a3b8;
  font-weight: 600;
}

.btn-copy {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #f1f5f9;
  border-radius: var(--radius-sm);
  padding: 0.25rem 0.65rem;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  transition: all 0.15s ease;
}

.btn-copy:hover {
  background: rgba(255, 255, 255, 0.2);
}

.btn-copy.copied {
  background: #10b981;
  color: #fff;
  border-color: #10b981;
}

pre.code-block {
  margin: 0;
  padding: 1.1rem;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.6;
  color: #e2e8f0;
}

/* Highlighting styles */
.hl-keyword {
  color: #f472b6;
  font-weight: 600;
}

.hl-type {
  color: #60a5fa;
  font-weight: 600;
}

.hl-string {
  color: #a7f3d0;
}

.hl-number {
  color: #fbbf24;
}

.hl-comment {
  color: #64748b;
  font-style: italic;
}

.hl-func {
  color: #c084fc;
}

/* Viva Questions */
.viva-container {
  margin-top: 1.75rem;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.viva-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.viva-card {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  margin-bottom: 0.65rem;
  overflow: hidden;
}

.viva-card summary {
  padding: 0.75rem 0.95rem;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  background-color: var(--bg-surface-elevated);
  user-select: none;
}

.viva-answer {
  padding: 0.85rem 0.95rem;
  font-size: 0.85rem;
  color: var(--text-main);
  background: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
  line-height: 1.55;
  white-space: pre-line;
}

/* Responsive adjustments */
@media (max-width: 900px) {
  .sidebar-toggle-btn {
    display: block;
  }

  .sidebar {
    position: fixed;
    top: calc(var(--header-height) + 45px);
    left: 0;
    bottom: 0;
    z-index: 90;
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .nav-search {
    width: 200px;
  }

  .main-content {
    padding: 1.25rem;
  }
}

@media (max-width: 600px) {
  .nav-search {
    display: none;
  }

  .brand-subtitle {
    display: none;
  }

  .assignment-actions {
    width: 100%;
    justify-content: flex-start;
  }
}
