/* ============================================================
   LAYOUT - application shell and persistent chrome
   ------------------------------------------------------------
   Split out of the original 3,093-line css/components.css on
   2026-08-29. The seven files are loaded in their original
   source order, so the cascade is byte-for-byte unchanged:
     layout -> components -> views-content -> views-cards
     -> overlays -> views-progress -> utilities
   Section numbers below are the original components.css numbering.

     1. App shell / layout grid
     2. Sidebar + navigation
     3. Main content region
     4. Page header
   ============================================================ */

/* ============================================================
   THINKING MASTERY SYSTEM — COMPONENTS
   Every UI component fully styled
   ============================================================ */


/* ──────────────────────────────────────────
   1. APP SHELL / LAYOUT
   ────────────────────────────────────────── */

#app {
  display: flex;
  min-height: 100vh;
  background: var(--bg);
  position: relative;
}


/* ──────────────────────────────────────────
   2. SIDEBAR
   ────────────────────────────────────────── */

#sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: var(--z-sidebar);
  transition: transform var(--transition-medium), width var(--transition-medium);
  overflow: hidden;
}

/* Sidebar Header */
.sidebar-header {
  padding: var(--space-5) var(--space-5) var(--space-4);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

/* Logo */
.logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  text-decoration: none;
}

.logo-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dim));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: white;
  flex-shrink: 0;
  box-shadow: 0 2px 12px rgba(167, 139, 250, 0.35);
}

.logo-text {
  display: flex;
  flex-direction: column;
  line-height: 1;
}

.logo-title {
  font-size: var(--text-lg);
  font-weight: var(--font-bold);
  color: var(--text-primary);
  letter-spacing: var(--tracking-wide);
}

.logo-subtitle {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-weight: var(--font-medium);
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
  margin-top: 2px;
}

/* User Level Display */
.user-level {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.level-badge {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--accent), var(--accent-dim));
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 0 12px var(--accent-glow);
  position: relative;
}

.level-badge::before {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--accent), transparent);
  z-index: -1;
  opacity: 0.5;
}

.level-number {
  font-size: var(--text-sm);
  font-weight: var(--font-bold);
  color: white;
  line-height: 1;
}

.user-meta {
  flex: 1;
  min-width: 0;
}

.user-name {
  display: block;
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  margin-bottom: var(--space-1);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* XP Bar */
.xp-bar {
  height: 4px;
  background: var(--surface-overlay);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-bottom: var(--space-1);
}

.xp-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-blue));
  border-radius: var(--radius-full);
  transition: width var(--transition-slow);
}

.xp-label {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: var(--font-medium);
}


/* ── Navigation ── */

#main-nav {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-3) var(--space-3);
}

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--transition), color var(--transition), border var(--transition);
  position: relative;
  color: var(--text-secondary);
  border-left: 2px solid transparent;
  user-select: none;
}

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

.nav-item.active {
  background: var(--surface-active);
  color: var(--accent);
  border-left-color: var(--accent);
}

.nav-item.active .nav-icon {
  filter: drop-shadow(0 0 6px var(--accent-glow));
}

.nav-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  transition: filter var(--transition);
}

.nav-label {
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-indicator {
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--accent-emerald);
  flex-shrink: 0;
}

.nav-badge {
  background: var(--accent);
  color: white;
  font-size: 10px;
  font-weight: var(--font-bold);
  padding: 1px 6px;
  border-radius: var(--radius-full);
  min-width: 18px;
  text-align: center;
  line-height: 16px;
  height: 16px;
  flex-shrink: 0;
}

.nav-badge:empty {
  display: none;
}


/* Sidebar Footer */
.sidebar-footer {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.streak-display {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: rgba(251, 191, 36, 0.08);
  border-radius: var(--radius);
  border: 1px solid rgba(251, 191, 36, 0.15);
  margin-bottom: var(--space-3);
}

.streak-icon {
  font-size: 18px;
}

.streak-count {
  font-size: var(--text-lg);
  font-weight: var(--font-bold);
  color: var(--accent-gold);
  line-height: 1;
}

.streak-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-weight: var(--font-medium);
}

.sidebar-footer-links {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.version-label {
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: var(--tracking-wider);
}

/* Hamburger Toggle */
.sidebar-toggle-btn {
  display: none;
  position: fixed;
  top: var(--space-4);
  left: var(--space-4);
  z-index: calc(var(--z-sidebar) + 10);
  width: 40px;
  height: 40px;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  transition: background var(--transition), box-shadow var(--transition);
  padding: 0;
}

.sidebar-toggle-btn:hover {
  background: var(--surface-overlay);
  box-shadow: var(--shadow);
}

.hamburger-line {
  width: 18px;
  height: 2px;
  background: var(--text-secondary);
  border-radius: var(--radius-full);
  transition: transform var(--transition), opacity var(--transition);
}

/* Sidebar collapsed on mobile */
#sidebar.collapsed {
  transform: translateX(calc(-1 * var(--sidebar-width)));
}

/* Sidebar overlay for mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(2px);
  z-index: calc(var(--z-sidebar) - 1);
}


/* ──────────────────────────────────────────
   3. MAIN CONTENT
   ────────────────────────────────────────── */

#main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left var(--transition-medium);
}

#page-container {
  flex: 1;
  padding: var(--space-8) var(--space-8);
  max-width: 1400px;
  width: 100%;
}

#view-root {
  animation: fadeIn 0.25s ease;
}


/* ──────────────────────────────────────────
   4. PAGE HEADER
   ────────────────────────────────────────── */

.page-header {
  margin-bottom: var(--space-8);
}

.page-breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
  font-weight: var(--font-medium);
}

.page-breadcrumb span + span::before {
  content: '›';
  margin-right: var(--space-2);
}

.page-header-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
}

.page-title {
  font-size: var(--text-4xl);
  font-weight: var(--font-bold);
  color: var(--text-primary);
  letter-spacing: var(--tracking-tight);
  line-height: var(--leading-tight);
}

.page-subtitle {
  font-size: var(--text-base);
  color: var(--text-secondary);
  margin-top: var(--space-2);
  line-height: var(--leading-relaxed);
}

.page-actions {
  display: flex;
  gap: var(--space-3);
  align-items: center;
  flex-shrink: 0;
}

