/* ============================================
   MOS-READY Layout - Sidebar, Topbar, Main
   ============================================ */

/* ---------- App Shell ---------- */
#app {
  display: flex;
  min-height: 100vh;
  position: relative;
  z-index: 1;
  user-select: none;
  -webkit-user-select: none;
}

/* Allow selection in inputs and contenteditable (Word Lab) */
input, textarea, [contenteditable="true"] {
  user-select: text;
  -webkit-user-select: text;
}

/* ---------- Sidebar ---------- */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  z-index: var(--z-sidebar);
  transition: transform var(--transition-base);
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar__brand {
  padding: var(--space-lg) var(--space-lg);
  display: flex;
  align-items: center;
  gap: var(--space-md);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.sidebar__logo {
  width: 40px;
  height: 40px;
  background: var(--gradient-primary);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 800;
  color: white;
  flex-shrink: 0;
}

.sidebar__brand-text {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 800;
  letter-spacing: -0.02em;
}

.sidebar__brand-text span {
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.sidebar__nav {
  flex: 1;
  padding: var(--space-md) var(--space-sm);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar__section-label {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: var(--space-md) var(--space-md) var(--space-xs);
}

.sidebar__footer {
  padding: var(--space-md);
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.sidebar__user {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.sidebar__user:hover {
  background: var(--bg-glass-hover);
}

.sidebar__avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: var(--gradient-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: var(--text-sm);
  color: var(--text-inverse);
  flex-shrink: 0;
}

.sidebar__user-info {
  overflow: hidden;
}

.sidebar__user-name {
  font-weight: 600;
  font-size: var(--text-sm);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar__user-level {
  font-size: var(--text-xs);
  color: var(--accent-yellow);
  font-weight: 600;
}

/* ---------- Topbar ---------- */
.topbar {
  position: fixed;
  top: 0;
  left: var(--sidebar-width);
  right: 0;
  height: var(--topbar-height);
  background: rgba(10, 10, 26, 0.8);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-xl);
  z-index: var(--z-topbar);
  transition: left var(--transition-base);
}

.topbar__left {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.topbar__hamburger {
  display: none;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  font-size: 20px;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.topbar__hamburger:hover {
  background: var(--bg-glass);
  color: var(--text-primary);
}

.topbar__page-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-xl);
}

.topbar__right {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.topbar__xp-display {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  background: rgba(254, 228, 64, 0.08);
  border: 1px solid rgba(254, 228, 64, 0.15);
  border-radius: var(--radius-full);
  padding: 6px 14px;
}

.topbar__xp-icon {
  font-size: 16px;
}

.topbar__xp-value {
  font-weight: 700;
  font-size: var(--text-sm);
  color: var(--accent-yellow);
  font-family: var(--font-display);
}

.topbar__streak {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(255, 107, 53, 0.08);
  border: 1px solid rgba(255, 107, 53, 0.15);
  border-radius: var(--radius-full);
  padding: 6px 14px;
}

.topbar__streak-value {
  font-weight: 700;
  font-size: var(--text-sm);
  color: var(--accent-orange);
  font-family: var(--font-display);
}

/* ---------- Main Content ---------- */
.main-content {
  margin-left: var(--sidebar-width);
  margin-top: var(--topbar-height);
  flex: 1;
  min-height: calc(100vh - var(--topbar-height));
  transition: margin-left var(--transition-base);
}

.page {
  display: none;
  padding: var(--space-xl) var(--space-2xl);
  max-width: var(--content-max-width);
  margin: 0 auto;
  animation: fade-in 300ms ease-out;
}

.page.active {
  display: block;
}

.page__header {
  margin-bottom: var(--space-2xl);
}

.page__title {
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  font-weight: 800;
  margin-bottom: var(--space-xs);
}

.page__subtitle {
  color: var(--text-secondary);
  font-size: var(--text-base);
}

/* ---------- Mobile Overlay ---------- */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: calc(var(--z-sidebar) - 1);
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

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

  .sidebar-overlay.active {
    display: block;
  }

  .topbar {
    left: 0;
  }

  .topbar__hamburger {
    display: flex;
  }

  .main-content {
    margin-left: 0;
  }

  .page {
    padding: var(--space-md);
  }
}
