/* ═══════════════════════════════════════════════
   LEXI — Premium Language Learning Platform
   Design System v0.9
   ═══════════════════════════════════════════════ */

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

/* ── Design Tokens ────────────────────────────── */
:root {
  --primary: #6366f1;
  --primary-light: #818cf8;
  --primary-dark: #4f46e5;
  --primary-bg: rgba(99, 102, 241, 0.08);
  --accent: #06b6d4;
  --accent-light: #22d3ee;

  --surface: #ffffff;
  --surface-alt: #f8fafc;
  --surface-hover: #f1f5f9;
  --border: #e2e8f0;
  --border-light: #f1f5f9;

  --text: #0f172a;
  --text-secondary: #475569;
  --text-tertiary: #94a3b8;
  --text-inverse: #ffffff;

  --success: #22c55e;
  --success-bg: rgba(34, 197, 94, 0.08);
  --error: #ef4444;
  --error-bg: rgba(239, 68, 68, 0.08);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.08);

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.08), 0 2px 4px -1px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -2px rgba(0,0,0,0.04);
  --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);

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

  --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 350ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Base ────────────────────────────────────── */
* { box-sizing: border-box; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--surface-alt);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.6;
}

/* ── Glass Navigation ────────────────────────── */
.glass-nav {
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-light);
  position: sticky;
  top: 0;
  z-index: 50;
}

/* ── Premium Buttons ──────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.25rem;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: var(--text-inverse);
  box-shadow: 0 1px 2px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-dark);
  box-shadow: 0 4px 8px rgba(99, 102, 241, 0.4);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1.5px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--surface-hover);
  border-color: var(--primary);
  color: var(--primary);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--primary-bg);
  color: var(--primary);
}

.btn-success {
  background: var(--success);
  color: var(--text-inverse);
  box-shadow: 0 1px 2px rgba(34, 197, 94, 0.3);
}

.btn-success:hover:not(:disabled) {
  box-shadow: 0 4px 8px rgba(34, 197, 94, 0.4);
  transform: translateY(-1px);
}

.btn-lg {
  padding: 0.875rem 2rem;
  font-size: 1rem;
  border-radius: var(--radius-lg);
}

.btn-xl {
  padding: 1rem 2.5rem;
  font-size: 1.125rem;
  border-radius: var(--radius-lg);
}

.btn-sm {
  padding: 0.375rem 0.875rem;
  font-size: 0.8125rem;
}

/* ── Premium Cards ────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow);
  transition: all var(--transition);
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card-premium {
  background: var(--surface);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  transition: all var(--transition-slow);
}

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

/* ── Gradient Accents ─────────────────────────── */
.gradient-text {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.gradient-bg {
  background: linear-gradient(135deg, var(--primary), var(--accent-light));
}

.gradient-subtle {
  background: linear-gradient(180deg, var(--primary-bg) 0%, transparent 100%);
}

/* ── Form Inputs ──────────────────────────────── */
.input-group {
  position: relative;
  margin-bottom: 1.25rem;
}

.input-group input,
.input-group select {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 0.9375rem;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  transition: all var(--transition);
  outline: none;
}

.input-group input:focus,
.input-group select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-bg);
}

.input-group input::placeholder {
  color: var(--text-tertiary);
}

.input-group label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.375rem;
}

/* ── Status Badges ────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.625rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: var(--radius-full);
  gap: 0.25rem;
}

.badge-primary { background: var(--primary-bg); color: var(--primary); }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-error { background: var(--error-bg); color: var(--error); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }

/* ── Progress Bars ────────────────────────────── */
.progress-track {
  width: 100%;
  height: 8px;
  background: var(--surface-alt);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  background: linear-gradient(90deg, var(--primary), var(--accent));
}

/* ── Toast Messages ───────────────────────────── */
.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 400px;
}

.toast {
  padding: 0.875rem 1.125rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.3s ease-out;
  display: flex;
  align-items: center;
  gap: 0.625rem;
}

.toast-success { background: #065f46; color: #d1fae5; }
.toast-error { background: #991b1b; color: #fecaca; }
.toast-info { background: #1e3a5f; color: #bae6fd; }

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

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

/* ── Animations ───────────────────────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

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

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

@keyframes popIn {
  from { opacity: 0; transform: scale(0.8); }
  to { opacity: 1; transform: scale(1); }
}

.animate-fade-up { animation: fadeUp 0.4s ease-out; }
.animate-pop-in { animation: popIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1); }
.animate-fade-in { animation: fadeIn 0.3s ease-out; }
.animate-scale-in { animation: scaleIn 0.25s ease-out; }
.animate-slide-down { animation: slideDown 0.3s ease-out; }

/* Staggered children */
.stagger > *:nth-child(1) { animation-delay: 0ms; }
.stagger > *:nth-child(2) { animation-delay: 80ms; }
.stagger > *:nth-child(3) { animation-delay: 160ms; }
.stagger > *:nth-child(4) { animation-delay: 240ms; }
.stagger > *:nth-child(5) { animation-delay: 320ms; }

/* ── Card Shimmer Loading ─────────────────────── */
.shimmer {
  background: linear-gradient(90deg, var(--surface-alt) 25%, var(--surface-hover) 50%, var(--surface-alt) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius);
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Stat Card ────────────────────────────────── */
.stat-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  border: 1px solid var(--border-light);
  transition: all var(--transition);
}

.stat-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.stat-card .stat-value {
  font-size: 1.75rem;
  font-weight: 800;
  line-height: 1.2;
}

.stat-card .stat-label {
  font-size: 0.8125rem;
  color: var(--text-tertiary);
  font-weight: 500;
  margin-top: 0.25rem;
}

/* ── Hero Section ─────────────────────────────── */
.hero-section {
  position: relative;
  overflow: hidden;
  padding: 5rem 0;
}

.hero-section::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -20%;
  width: 800px;
  height: 800px;
  background: radial-gradient(circle, var(--primary-bg) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}

.hero-section::after {
  content: '';
  position: absolute;
  bottom: -30%;
  left: -10%;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(6, 182, 212, 0.06) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}

/* ── Feature Cards ────────────────────────────── */
.feature-card {
  background: var(--surface);
  border-radius: var(--radius-xl);
  padding: 2rem;
  border: 1px solid var(--border-light);
  transition: all var(--transition-slow);
  position: relative;
  overflow: hidden;
}

.feature-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  opacity: 0;
  transition: opacity var(--transition);
}

.feature-card:hover::before { opacity: 1; }

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

/* ── Auth Pages ───────────────────────────────── */
.auth-container {
  min-height: calc(100vh - 4rem);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  background: linear-gradient(135deg, var(--surface-alt) 0%, #eef2ff 100%);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border-radius: var(--radius-xl);
  padding: 2.5rem;
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--border);
}

.auth-card h2 {
  text-align: center;
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.auth-card .subtitle {
  text-align: center;
  color: var(--text-tertiary);
  font-size: 0.875rem;
  margin-bottom: 2rem;
}

/* ── Exercise Card ────────────────────────────── */
.exercise-card {
  max-width: 640px;
  margin: 0 auto;
  background: var(--surface);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.exercise-card .card-media {
  position: relative;
}

.exercise-card .card-body {
  padding: 1.25rem 1.75rem 1.75rem;
}

.exercise-card .card-footer {
  padding: 0 2rem 1.5rem 2rem;
}

/* ── Image Container ──────────────────────────── */
.image-container {
  position: relative;
  width: 100%;
  max-height: 320px;
  background: var(--surface-alt);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.image-container img {
  width: 100%;
  height: auto;
  max-height: 320px;
  display: block;
  object-fit: contain;
  object-position: center;
  background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
}

/* ── Audio Button Row ─────────────────────── */
.audio-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.625rem;
  padding: 0.875rem 0 0;
}

.audio-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 1rem 0.625rem 0.875rem;
  border-radius: var(--radius-full);
  border: 2px solid #e8edf5;
  background: #f8faff;
  color: #334155;
  font-size: 0.875rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  -webkit-tap-highlight-color: transparent;
}

.audio-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.audio-btn:active {
  transform: scale(0.95);
}

.audio-icon {
  font-size: 1.3rem;
  line-height: 1;
}

.audio-label {
  font-size: 0.8125rem;
}

/* ── Session Complete ──────────────────────────── */
.celebration {
  text-align: center;
  padding: 2rem;
}

.celebration .trophy {
  font-size: 4rem;
  animation: pulse 2s ease-in-out infinite;
}

.celebration h2 {
  font-size: 1.75rem;
  font-weight: 800;
  margin: 1rem 0 0.5rem;
}

/* ── Responsive ───────────────────────────────── */
@media (max-width: 640px) {
  .auth-card { padding: 1.75rem; }
  .exercise-card .card-body { padding: 1rem 1.25rem 1.5rem; }
  .stat-card .stat-value { font-size: 1.5rem; }
}

/* ── Focus Ring ───────────────────────────────── */
*:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ── Scrollbar ─────────────────────────────────── */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ── Avatar Animations ──────────────────────── */
@keyframes avatarBreathe {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}
#almira-svg { animation: avatarBreathe 3s ease-in-out infinite; }
#aras-svg { animation: avatarBreathe 3.5s ease-in-out infinite; }

@keyframes wave {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-15deg); }
  75% { transform: rotate(15deg); }
}
.animate-wave { transform-origin: 6px 45px; animation: wave 2s ease-in-out infinite; }

/* ── Avatar Animations ──────────────────────── */
.avatar-container {
  position: relative;
  transition: transform 0.3s ease-out;
}

@keyframes avatarBreathe {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-4px) scale(1.02); }
}
.avatar-breathe {
  animation: avatarBreathe 3s ease-in-out infinite;
}

.avatar-container.celebrate {
  animation: avatarCelebrate 0.5s ease-out;
}
@keyframes avatarCelebrate {
  0% { transform: translateY(0) scale(1); }
  30% { transform: translateY(-12px) scale(1.1); }
  60% { transform: translateY(-6px) scale(1.05); }
  100% { transform: translateY(0) scale(1); }
}

.avatar-container.console {
  animation: avatarConsole 0.6s ease-out;
}
@keyframes avatarConsole {
  0% { transform: translateX(0) rotate(0deg); }
  20% { transform: translateX(6px) rotate(5deg); }
  40% { transform: translateX(-3px) rotate(-2deg); }
  100% { transform: translateX(0) rotate(0deg); }
}

/* ── Blink Animation ────────────────────────── */
@keyframes avatarBlink {
  0%, 96%, 100% { transform: scaleY(1); }
  97% { transform: scaleY(0.1); }
  98% { transform: scaleY(1); }
}
.avatar-container .avatar-img {
  animation: avatarBlink 4s ease-in-out infinite;
  transform-origin: center 55%;
}

.avatar-container.speak .avatar-img {
  animation: avatarNod 0.6s ease-in-out;
}
@keyframes avatarNod {
  0%, 100% { transform: translateY(0); }
  40% { transform: translateY(-6px); }
  60% { transform: translateY(-8px); }
}

/* ── SVG Character Animations ─────────────────── */
@keyframes arasWave {
  0%, 100% { transform: rotate(0deg); }
  15% { transform: rotate(-20deg); }
  30% { transform: rotate(10deg); }
  45% { transform: rotate(-15deg); }
  60% { transform: rotate(0deg); }
}
