/* ================================================
   FACEN Software Estadístico — Design System
   Premium Dark Mode with Glassmorphism
   ================================================ */

/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ================================================
   CSS Custom Properties (Design Tokens)
   ================================================ */
:root {
  /* Colors */
  --primary:        hsl(241, 83%, 67%);
  --primary-light:  hsl(241, 90%, 80%);
  --primary-dark:   hsl(241, 80%, 50%);
  --accent:         hsl(316, 73%, 52%);
  --accent-light:   hsl(316, 80%, 70%);
  --tertiary:       hsl(187, 85%, 53%);
  --success:        hsl(142, 71%, 45%);
  --warning:        hsl(38,  92%, 50%);
  --danger:         hsl(0,   72%, 51%);

  /* Unit Colors */
  --u1-color: hsl(0,   80%, 65%);
  --u2-color: hsl(210, 80%, 60%);
  --u3-color: hsl(270, 75%, 65%);
  --u4-color: hsl(142, 71%, 45%);
  --u5-color: hsl(38,  92%, 50%);

  /* Dark Background System */
  --bg-dark:        hsl(222, 47%, 5%);
  --bg-surface:     hsl(222, 40%, 8%);
  --bg-elevated:    hsl(222, 35%, 11%);
  --bg-hover:       hsl(222, 30%, 14%);

  /* Glass */
  --glass-bg:       rgba(15, 20, 40, 0.8);
  --glass-border:   rgba(255, 255, 255, 0.08);
  --glass-shine:    rgba(255, 255, 255, 0.04);

  /* Text */
  --text-primary:   hsl(220, 20%, 96%);
  --text-secondary: hsl(220, 15%, 75%);
  --text-muted:     hsl(220, 12%, 55%);
  --text-disabled:  hsl(220, 10%, 35%);

  /* Spacing */
  --sp-xs: 0.25rem;
  --sp-sm: 0.5rem;
  --sp-md: 1rem;
  --sp-lg: 1.5rem;
  --sp-xl: 2rem;
  --sp-2xl: 3rem;

  /* Border Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm:  0 2px 8px rgba(0,0,0,0.3);
  --shadow-md:  0 8px 24px rgba(0,0,0,0.4);
  --shadow-lg:  0 20px 48px rgba(0,0,0,0.5);
  --shadow-glow: 0 0 30px rgba(99, 102, 241, 0.3);

  /* Transitions */
  --transition-fast:   all 0.15s ease;
  --transition-normal: all 0.25s ease;
  --transition-slow:   all 0.4s cubic-bezier(0.16, 1, 0.3, 1);

  /* Sidebar */
  --sidebar-width: 260px;
}

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

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* ================================================
   Scrollbar
   ================================================ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-surface); }
::-webkit-scrollbar-thumb {
  background: rgba(99,102,241,0.4);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

/* ================================================
   Typography
   ================================================ */
h1, h2, h3, h4 { font-weight: 700; line-height: 1.2; }
h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.15rem; }
h4 { font-size: 1rem; }

p { color: var(--text-secondary); }
a { color: var(--primary-light); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ================================================
   Utility Classes
   ================================================ */
.text-gradient {
  background: linear-gradient(135deg, var(--primary-light), var(--accent-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.glass {
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
}

.card {
  background: var(--bg-elevated);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: var(--sp-lg);
  transition: var(--transition-normal);
}

.card:hover {
  border-color: rgba(99,102,241,0.3);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

/* ================================================
   Dashboard Layout
   ================================================ */
.app-wrapper {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-surface);
  border-right: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  transition: var(--transition-slow);
  overflow: hidden;
}

.sidebar-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--glass-border);
  flex-shrink: 0;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.sidebar-logo-icon {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}

.sidebar-logo-text h2 {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-primary);
}

.sidebar-logo-text p {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 0.75rem;
}

.nav-section-label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-disabled);
  padding: 0.5rem 0.75rem 0.25rem;
  margin-top: 0.75rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0.75rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition-fast);
  color: var(--text-secondary);
  font-size: 0.88rem;
  font-weight: 500;
  border: 1px solid transparent;
  margin-bottom: 0.15rem;
  user-select: none;
  position: relative;
}

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

.nav-item.active {
  background: rgba(99, 102, 241, 0.15);
  color: var(--primary-light);
  border-color: rgba(99, 102, 241, 0.2);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 60%;
  background: var(--primary);
  border-radius: 0 2px 2px 0;
}

.nav-item-icon { font-size: 1.1rem; width: 20px; text-align: center; }
.nav-item-badge {
  margin-left: auto;
  background: var(--primary);
  color: white;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.15rem 0.4rem;
  border-radius: var(--radius-full);
}

.nav-unit-indicator {
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-left: auto;
  flex-shrink: 0;
}

/* User info in sidebar bottom */
.sidebar-user {
  padding: 1rem 1.2rem;
  border-top: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.user-avatar {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.user-info { flex: 1; min-width: 0; }
.user-info strong { font-size: 0.85rem; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-info small { font-size: 0.7rem; color: var(--text-muted); }

.btn-logout {
  width: 28px; height: 28px;
  background: rgba(255,100,100,0.1);
  border: 1px solid rgba(255,100,100,0.2);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  transition: var(--transition-fast);
  flex-shrink: 0;
}
.btn-logout:hover { background: rgba(255,100,100,0.2); }

/* Main Content */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Top Bar */
.topbar {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--glass-border);
  padding: 0.75rem 2rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(10px);
}

.topbar-title { font-size: 1rem; font-weight: 600; flex: 1; }

.topbar-actions { display: flex; align-items: center; gap: 0.75rem; }

/* XP Pills */
.xp-pill {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.8rem;
  background: rgba(99,102,241,0.1);
  border: 1px solid rgba(99,102,241,0.2);
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--primary-light);
}

/* Page content */
.page-content {
  padding: 2rem;
  flex: 1;
  animation: fadeIn 0.4s ease;
}

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

/* ================================================
   Hero / Welcome Section
   ================================================ */
.hero-section {
  background: linear-gradient(135deg,
    rgba(99,102,241,0.15) 0%,
    rgba(236,72,153,0.1) 50%,
    rgba(6,182,212,0.1) 100%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  padding: 2rem;
  margin-bottom: 2rem;
  position: relative;
  overflow: hidden;
}

.hero-section::before {
  content: '';
  position: absolute;
  top: -50%; right: -10%;
  width: 300px; height: 300px;
  background: radial-gradient(circle, rgba(99,102,241,0.2), transparent 70%);
  border-radius: 50%;
}

.hero-content { position: relative; z-index: 1; }
.hero-content h1 { font-size: 1.6rem; margin-bottom: 0.5rem; }
.hero-content p { color: var(--text-secondary); max-width: 600px; }

/* Progress Grid */
.progress-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  margin-top: 1.5rem;
}

.progress-stat {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 1rem;
  text-align: center;
}

.progress-stat .stat-value {
  font-size: 1.6rem;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 0.25rem;
}

.progress-stat .stat-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ================================================
   Unit Cards Grid
   ================================================ */
.units-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.unit-card {
  background: var(--bg-elevated);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  transition: var(--transition-slow);
  cursor: pointer;
  position: relative;
}

.unit-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.unit-card-header {
  padding: 1.5rem;
  position: relative;
  overflow: hidden;
}

.unit-card-header::before {
  content: '';
  position: absolute;
  inset: 0;
  opacity: 0.15;
}

.unit-card[data-unit="1"] .unit-card-header { background: linear-gradient(135deg, hsla(0,80%,65%,0.2), transparent); border-bottom: 1px solid hsla(0,80%,65%,0.2); }
.unit-card[data-unit="2"] .unit-card-header { background: linear-gradient(135deg, hsla(210,80%,60%,0.2), transparent); border-bottom: 1px solid hsla(210,80%,60%,0.2); }
.unit-card[data-unit="3"] .unit-card-header { background: linear-gradient(135deg, hsla(270,75%,65%,0.2), transparent); border-bottom: 1px solid hsla(270,75%,65%,0.2); }
.unit-card[data-unit="4"] .unit-card-header { background: linear-gradient(135deg, hsla(142,71%,45%,0.2), transparent); border-bottom: 1px solid hsla(142,71%,45%,0.2); }
.unit-card[data-unit="5"] .unit-card-header { background: linear-gradient(135deg, hsla(38,92%,50%,0.2), transparent); border-bottom: 1px solid hsla(38,92%,50%,0.2); }

.unit-number {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  opacity: 0.7;
  margin-bottom: 0.5rem;
}

.unit-card-header h3 { font-size: 1rem; line-height: 1.3; }

.unit-icon-big {
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 2.5rem;
  opacity: 0.3;
}

.unit-card-body { padding: 1.2rem 1.5rem 1.5rem; }

.unit-progress-bar {
  height: 4px;
  background: var(--bg-hover);
  border-radius: var(--radius-full);
  margin-bottom: 0.75rem;
  overflow: hidden;
}

.unit-progress-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 1s cubic-bezier(0.16,1,0.3,1);
}

.unit-card[data-unit="1"] .unit-progress-fill { background: var(--u1-color); }
.unit-card[data-unit="2"] .unit-progress-fill { background: var(--u2-color); }
.unit-card[data-unit="3"] .unit-progress-fill { background: var(--u3-color); }
.unit-card[data-unit="4"] .unit-progress-fill { background: var(--u4-color); }
.unit-card[data-unit="5"] .unit-progress-fill { background: var(--u5-color); }

.unit-meta {
  display: flex;
  gap: 1rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.unit-meta span { display: flex; align-items: center; gap: 0.3rem; }

.btn-unit {
  width: 100%;
  padding: 0.65rem;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  background: var(--bg-hover);
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
}

.btn-unit:hover {
  border-color: var(--primary);
  background: rgba(99,102,241,0.1);
  color: var(--primary-light);
}

/* ================================================
   Unit Detail View
   ================================================ */
.unit-detail-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.btn-back {
  padding: 0.5rem 1rem;
  background: var(--bg-elevated);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  cursor: pointer;
  transition: var(--transition-fast);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.btn-back:hover { 
  border-color: var(--primary);
  color: var(--primary-light);
}

/* Tab pills inside unit */
.unit-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--glass-border);
  padding-bottom: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.unit-tabs::-webkit-scrollbar { display: none; }

.unit-tab {
  padding: 0.7rem 1.2rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: var(--transition-fast);
  border-radius: 0;
  background: none;
  border-left: none;
  border-right: none;
  border-top: none;
  font-family: 'Inter', sans-serif;
  margin-bottom: -1px;
}

.unit-tab:hover { color: var(--text-primary); }
.unit-tab.active { 
  color: var(--primary-light);
  border-bottom-color: var(--primary);
}

/* Materials List */
.materials-list { display: flex; flex-direction: column; gap: 0.75rem; }

.material-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  background: var(--bg-elevated);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  transition: var(--transition-fast);
  text-decoration: none;
  color: var(--text-primary);
}

.material-item:hover {
  border-color: rgba(99,102,241,0.3);
  background: var(--bg-hover);
  transform: translateX(4px);
  text-decoration: none;
}

.material-icon {
  width: 42px; height: 42px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}

.material-info h4 { font-size: 0.9rem; margin-bottom: 0.2rem; }
.material-info p { font-size: 0.75rem; color: var(--text-muted); }

.material-badge {
  margin-left: auto;
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  font-weight: 700;
  flex-shrink: 0;
}

.badge-pdf { background: rgba(239,68,68,0.15); color: #fca5a5; border: 1px solid rgba(239,68,68,0.2); }
.badge-act { background: rgba(99,102,241,0.15); color: var(--primary-light); border: 1px solid rgba(99,102,241,0.2); }
.badge-quiz { background: rgba(236,72,153,0.15); color: #f9a8d4; border: 1px solid rgba(236,72,153,0.2); }

/* ================================================
   Quiz Component
   ================================================ */
.quiz-container { max-width: 720px; }

.quiz-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
  gap: 1rem;
}

.quiz-timer {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.2rem;
  background: var(--bg-elevated);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-full);
  font-size: 1.1rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.quiz-timer.warning { 
  border-color: rgba(239,68,68,0.4);
  animation: pulse 1s ease infinite;
  color: #fca5a5;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.quiz-progress-bar-wrap {
  height: 6px;
  background: var(--bg-hover);
  border-radius: var(--radius-full);
  margin-bottom: 1.5rem;
  overflow: hidden;
}

.quiz-progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: var(--radius-full);
  transition: width 0.5s ease;
}

.question-card {
  background: var(--bg-elevated);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  padding: 2rem;
  margin-bottom: 1.5rem;
}

.question-number {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 1rem;
}

.question-text {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 1.5rem;
  line-height: 1.5;
}

.options-list { display: flex; flex-direction: column; gap: 0.6rem; }

.option-btn {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  background: var(--bg-surface);
  border: 1.5px solid var(--glass-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition-fast);
  text-align: left;
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  width: 100%;
}

.option-btn:hover:not(:disabled) {
  border-color: rgba(99,102,241,0.4);
  background: rgba(99,102,241,0.08);
}

.option-btn .option-letter {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--bg-hover);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
  transition: var(--transition-fast);
}

.option-btn.selected { border-color: var(--primary); background: rgba(99,102,241,0.1); }
.option-btn.selected .option-letter { background: var(--primary); color: white; }
.option-btn.correct { border-color: var(--success) !important; background: rgba(34,197,94,0.1) !important; }
.option-btn.wrong { border-color: var(--danger) !important; background: rgba(239,68,68,0.1) !important; }

.explanation-box {
  padding: 1rem 1.25rem;
  border-radius: var(--radius-md);
  margin-top: 1rem;
  font-size: 0.88rem;
  line-height: 1.5;
  display: none;
}

.explanation-box.correct { 
  background: rgba(34,197,94,0.1);
  border: 1px solid rgba(34,197,94,0.2);
  color: #86efac;
}

.explanation-box.wrong {
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.2);
  color: #fca5a5;
}

.quiz-actions { display: flex; gap: 1rem; align-items: center; }

.btn-primary {
  padding: 0.75rem 1.75rem;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border: none;
  border-radius: var(--radius-md);
  color: white;
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition-normal);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(99,102,241,0.4);
}

.btn-secondary {
  padding: 0.75rem 1.5rem;
  background: var(--bg-elevated);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
}

.btn-secondary:hover { border-color: var(--primary); color: var(--primary-light); }

/* Quiz Result */
.quiz-result {
  text-align: center;
  padding: 3rem 2rem;
}

.result-score {
  font-size: 4rem;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 0.5rem;
}

.result-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1.5rem;
  border-radius: var(--radius-full);
  font-weight: 700;
  font-size: 0.9rem;
  margin-bottom: 2rem;
}

.result-badge.excellent { background: rgba(34,197,94,0.15); border: 1px solid rgba(34,197,94,0.3); color: #86efac; }
.result-badge.good { background: rgba(99,102,241,0.15); border: 1px solid rgba(99,102,241,0.3); color: var(--primary-light); }
.result-badge.needs-work { background: rgba(239,68,68,0.15); border: 1px solid rgba(239,68,68,0.3); color: #fca5a5; }

/* ================================================
   Flashcards Activity
   ================================================ */
.flashcard-container {
  perspective: 1000px;
  width: 100%;
  max-width: 500px;
  margin: 0 auto;
  height: 280px;
  cursor: pointer;
}

.flashcard {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.flashcard.flipped { transform: rotateY(180deg); }

.card-face {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-xl);
  backface-visibility: hidden;
  padding: 2rem;
  text-align: center;
}

.card-front {
  background: linear-gradient(135deg, var(--bg-elevated), var(--bg-hover));
  border: 1px solid var(--glass-border);
}

.card-back {
  background: linear-gradient(135deg, rgba(99,102,241,0.15), rgba(236,72,153,0.1));
  border: 1px solid rgba(99,102,241,0.2);
  transform: rotateY(180deg);
}

.card-face h3 { font-size: 1.15rem; line-height: 1.4; }
.card-face p { color: var(--text-secondary); margin-top: 0.5rem; line-height: 1.5; }

/* ================================================
   Badges / Gamification
   ================================================ */
.badges-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 1rem;
}

.badge-item {
  background: var(--bg-elevated);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 0.75rem;
  text-align: center;
  transition: var(--transition-normal);
}

.badge-item.earned {
  border-color: rgba(255, 193, 7, 0.3);
  background: rgba(255, 193, 7, 0.05);
}

.badge-item.earned:hover { transform: translateY(-3px); box-shadow: 0 8px 20px rgba(255,193,7,0.2); }

.badge-emoji { font-size: 2rem; margin-bottom: 0.5rem; }
.badge-name { font-size: 0.75rem; font-weight: 700; color: var(--text-secondary); }
.badge-item.locked .badge-emoji { filter: grayscale(1) opacity(0.3); }
.badge-item.locked .badge-name { color: var(--text-disabled); }

/* ================================================
   Drag & Drop Activity
   ================================================ */
.dnd-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  margin-top: 1rem;
}

.dnd-column h4 {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.draggable-item {
  padding: 0.75rem 1rem;
  background: var(--bg-elevated);
  border: 1.5px solid var(--glass-border);
  border-radius: var(--radius-md);
  cursor: grab;
  margin-bottom: 0.5rem;
  font-size: 0.88rem;
  transition: var(--transition-fast);
  user-select: none;
}

.draggable-item:hover { border-color: var(--primary); background: rgba(99,102,241,0.1); }
.draggable-item.dragging { opacity: 0.5; cursor: grabbing; }

.drop-zone {
  min-height: 60px;
  padding: 0.75rem 1rem;
  background: rgba(255,255,255,0.02);
  border: 2px dashed var(--glass-border);
  border-radius: var(--radius-md);
  margin-bottom: 0.5rem;
  transition: var(--transition-fast);
  font-size: 0.85rem;
  color: var(--text-disabled);
}

.drop-zone.drag-over {
  border-color: var(--primary);
  background: rgba(99,102,241,0.08);
  color: var(--primary-light);
}

/* ================================================
   Notification Toast
   ================================================ */
.toast-container {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.toast {
  padding: 0.9rem 1.25rem;
  background: var(--bg-elevated);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 260px;
  max-width: 360px;
  animation: toastIn 0.4s cubic-bezier(0.16,1,0.3,1);
  font-size: 0.88rem;
}

@keyframes toastIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.info { border-left: 3px solid var(--primary); }
.toast.xp { border-left: 3px solid var(--warning); }

/* ================================================
   Progress Page
   ================================================ */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--bg-elevated);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 60px; height: 60px;
  border-radius: 50%;
  transform: translate(20px, -20px);
  opacity: 0.15;
}

.stat-card.primary::before { background: var(--primary); }
.stat-card.accent::before { background: var(--accent); }
.stat-card.success::before { background: var(--success); }
.stat-card.warning::before { background: var(--warning); }

.stat-card .sc-label { font-size: 0.75rem; color: var(--text-muted); margin-bottom: 0.5rem; }
.stat-card .sc-value { font-size: 2rem; font-weight: 800; line-height: 1; }
.stat-card .sc-sub { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.3rem; }

/* ================================================
   Responsive
   ================================================ */
.hamburger {
  display: none;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
  padding: 0.5rem;
  background: none;
  border: none;
}

.hamburger span {
  width: 22px; height: 2px;
  background: var(--text-secondary);
  border-radius: 2px;
  transition: var(--transition-fast);
}

@media (max-width: 768px) {
  :root { --sidebar-width: 0; }

  .sidebar {
    width: 260px;
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }

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

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

  .hamburger { display: flex; }

  .page-content { padding: 1rem; }

  .hero-section { padding: 1.25rem; }

  .dnd-container { grid-template-columns: 1fr; }

  .progress-grid { grid-template-columns: repeat(2, 1fr); }

  .units-grid { grid-template-columns: 1fr; }

  #overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 99;
  }

  #overlay.show { display: block; }
}

@media (max-width: 480px) {
  .topbar { padding: 0.75rem 1rem; }
  .progress-grid { grid-template-columns: 1fr 1fr; }
}
