/* ==========================================================================
   CodeNest - Main Stylesheet (Pure Static Modern CSS)
   A dark-first student developer collaboration platform
   ========================================================================== */

:root {
  /* High Density Theme Color Palette - Pure Deep Charcoal & Sleek Developer Neutrals */
  --bg-app: #0a0a0a;
  --bg-sidebar: #0a0a0a;
  --bg-surface: #141414;
  --bg-surface-elevated: #1a1a1a;
  --bg-surface-hover: #1f1f1f;
  --bg-input: #1a1a1a;
  --bg-glass: rgba(20, 20, 20, 0.92);

  /* Borders & Dividers */
  --border-subtle: #222222;
  --border-strong: #2c2c2c;
  --border-focus: #6366f1;

  /* Accent Colors */
  --accent-primary: #4f46e5;       /* Indigo 600 */
  --accent-primary-hover: #4338ca;
  --accent-primary-light: #818cf8; /* Indigo 400 */
  --accent-primary-subtle: rgba(79, 70, 229, 0.12);
  --accent-cyan: #06b6d4;          /* Cyan for Code / Info */
  --accent-cyan-subtle: rgba(6, 182, 212, 0.12);
  --accent-emerald: #10b981;       /* Success / Online / Solved */
  --accent-emerald-subtle: rgba(16, 185, 129, 0.12);
  --accent-amber: #f97316;         /* Orange / Streak / XP */
  --accent-amber-subtle: rgba(249, 115, 22, 0.12);
  --accent-rose: #ef4444;          /* Red / Urgent / Deadline / Error */
  --accent-rose-subtle: rgba(239, 68, 68, 0.12);
  --accent-purple: #a855f7;        /* Challenges / AI */
  --accent-purple-subtle: rgba(168, 85, 247, 0.12);

  /* Typography */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Inter", "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", "Fira Code", monospace;

  /* High Density Text Colors */
  --text-primary: #ffffff;
  --text-secondary: #cbd5e1;       /* slate-300 */
  --text-muted: #64748b;           /* slate-500 */
  --text-subtle: #94a3b8;          /* slate-400 */
  --text-inverse: #0a0a0a;

  /* Sizing & Radius */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 10px;
  --radius-xl: 14px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.5);
  --shadow-md: 0 4px 12px -2px rgba(0, 0, 0, 0.6);
  --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.7);
  --shadow-primary: 0 4px 16px rgba(79, 70, 229, 0.25);
  --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.18);

  /* Transitions */
  --transition-fast: 120ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 180ms cubic-bezier(0.4, 0, 0.2, 1);

  /* App Dimensions */
  --sidebar-width: 256px;
  --header-height: 60px;
  --footer-height: 44px;
}

/* Light Theme Variables (when toggled in settings) */
[data-theme="light"] {
  --bg-app: #f8fafc;
  --bg-sidebar: #ffffff;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #f1f5f9;
  --bg-surface-hover: #e2e8f0;
  --bg-input: #f8fafc;
  --bg-glass: rgba(255, 255, 255, 0.9);
  --border-subtle: #e2e8f0;
  --border-strong: #cbd5e1;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 12px 24px rgba(0, 0, 0, 0.12);
}

/* Compact Mode (when enabled in settings) */
body.compact-mode {
  --header-height: 52px;
  --sidebar-width: 230px;
  font-size: 14px;
}

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

html {
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-primary);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
  font-size: 15px;
}

body {
  min-height: 100vh;
  overflow-x: hidden;
  background-color: var(--bg-app);
  display: flex;
}

a {
  color: inherit;
  text-decoration: none;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ==========================================================================
   App Layout Shell
   ========================================================================== */

#app-container {
  display: flex;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  position: relative;
}

/* Sidebar Navigation */
#sidebar {
  width: var(--sidebar-width);
  height: 100%;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 40;
  transition: transform var(--transition-normal);
}

.sidebar-header {
  padding: 1.15rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
}

.logo-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
}

.logo-img {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-name {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.brand-badge {
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.1rem 0.4rem;
  border-radius: var(--radius-full);
  background: var(--accent-primary-subtle);
  color: var(--accent-primary);
  border: 1px solid rgba(99, 102, 241, 0.3);
  text-transform: uppercase;
}

.brand-tagline {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
}

/* Sidebar Nav Groups */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 0.65rem;
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
}

.nav-group-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 0 0.5rem 0.35rem;
}

.nav-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 0.88rem;
  font-weight: 500;
  transition: all var(--transition-fast);
  position: relative;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

.nav-link.active {
  background: rgba(79, 70, 229, 0.12);
  color: var(--accent-primary-light);
  font-weight: 600;
}

.nav-link.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 18%;
  height: 64%;
  width: 3px;
  background: var(--accent-primary-light);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.nav-icon {
  width: 1.15rem;
  height: 1.15rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  flex-shrink: 0;
}

.nav-text {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-pill {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.1rem 0.45rem;
  border-radius: var(--radius-md);
  background: var(--bg-surface-elevated);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
}

.nav-pill.pill-amber {
  background: rgba(249, 115, 22, 0.12);
  color: var(--accent-amber);
  border-color: rgba(249, 115, 22, 0.25);
}

.nav-pill.pill-rose {
  background: rgba(239, 68, 68, 0.12);
  color: var(--accent-rose);
  border-color: rgba(239, 68, 68, 0.25);
}

/* Sidebar Footer Profile Area */
.sidebar-footer {
  padding: 0.75rem 0.85rem;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #0d0d0d;
}

.user-snippet {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  flex: 1;
  min-width: 0;
  padding: 0.35rem 0.5rem;
  border-radius: var(--radius-md);
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  transition: all var(--transition-fast);
}

.user-snippet:hover {
  background: var(--bg-surface-hover);
  border-color: var(--border-strong);
}

.user-avatar-wrap {
  position: relative;
  flex-shrink: 0;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4f46e5, #a855f7);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  color: #ffffff;
}

.status-dot {
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-emerald);
  border: 2px solid var(--bg-sidebar);
}

.user-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.user-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 0.68rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.sidebar-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-left: 0.4rem;
}

/* Main Application Workspace */
#main-workspace {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  background: var(--bg-app);
}

/* Header Top Bar */
#top-bar {
  height: var(--header-height);
  border-bottom: 1px solid var(--border-subtle);
  background: #0d0d0d;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  gap: 1rem;
  flex-shrink: 0;
  z-index: 30;
}

.top-bar-left {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex: 1;
  max-width: 480px;
}

.mobile-menu-btn {
  display: none;
  font-size: 1.3rem;
  padding: 0.4rem;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
}

/* Global Search Input Button (Ctrl + K) */
.search-trigger-btn {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  background: #1a1a1a;
  border: 1px solid #333333;
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: 0.82rem;
  transition: all var(--transition-fast);
  text-align: left;
}

.search-trigger-btn:hover {
  border-color: #4f46e5;
  color: var(--text-secondary);
  background: #1f1f1f;
}

.search-icon {
  font-size: 0.88rem;
  color: var(--text-muted);
}

.search-placeholder {
  flex: 1;
}

.kbd-shortcut {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  background: #222222;
  border: 1px solid #333333;
  padding: 0.12rem 0.4rem;
  border-radius: var(--radius-sm);
  color: var(--text-subtle);
}

/* Header Right Actions */
.top-bar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.deadline-radar-chip {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.3rem 0.65rem;
  border-radius: var(--radius-md);
  background: rgba(249, 115, 22, 0.1);
  border: 1px solid rgba(249, 115, 22, 0.25);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent-amber);
  text-decoration: none;
  transition: transform var(--transition-fast);
}

.deadline-radar-chip:hover {
  transform: scale(1.02);
}

.streak-pill, .xp-pill {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.6rem;
  border-radius: var(--radius-md);
  font-size: 0.78rem;
  font-weight: 700;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
}

.streak-pill {
  color: var(--accent-amber);
}

.xp-pill {
  color: var(--accent-primary-light);
}

.exam-mode-btn {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  font-weight: 600;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.exam-mode-btn:hover, .exam-mode-btn.active {
  background: var(--accent-primary-subtle);
  border-color: var(--accent-primary);
  color: var(--accent-primary-light);
}

.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  position: relative;
  transition: all var(--transition-fast);
}

.icon-btn:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

/* App Footer (High Density Theme) */
.app-footer {
  height: var(--footer-height);
  border-top: 1px solid var(--border-subtle);
  background: #0d0d0d;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  font-size: 0.72rem;
  color: var(--text-muted);
  flex-shrink: 0;
  z-index: 20;
}

.app-footer a {
  color: var(--text-muted);
  transition: color var(--transition-fast);
}

.app-footer a:hover {
  color: var(--text-secondary);
}

.notif-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-rose);
}

/* Content Area & View Router Outlet */
#view-container {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1.5rem 1.75rem;
  position: relative;
}

.view-section {
  display: none;
  animation: fadeIn 180ms cubic-bezier(0.16, 1, 0.3, 1);
  max-width: 1360px;
  margin: 0 auto;
}

.view-section.active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Section Page Header */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.page-title-group h1 {
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.page-subtitle {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

.page-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}
