/* =====================================================================
   SHARED STYLES (CORE DESIGN SYSTEM)
   Contains: Variables, Typography, Components, Animations, Skeleton,
   AI Bubble, and Gamification Badges 🏆
   ===================================================================== */
@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Arabic:wght@300;400;500;600;700&family=Inter:wght@400;500;600;700;800&display=swap");

:root {
  /* --- Colors --- */
  --bg-deep: #030407;
  --bg-surface: #0e121b;
  --bg-elevated: #1a1f2e;

  /* --- Glassmorphism --- */
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-surface: rgba(20, 25, 40, 0.8);
  --glass-highlight: rgba(255, 255, 255, 0.03);

  /* --- Text --- */
  --text-primary: #f2f4f7;
  --text-secondary: #98a2b3;
  --text-tertiary: #667085;

  /* --- Accents --- */
  --accent-primary: #5375ff;
  --accent-success: #12b76a;
  --accent-error: #f04438;
  --accent-warning: #f79009;
  --accent-purple: #7f56d9;
  --accent-gradient: linear-gradient(135deg, #5375ff 0%, #0ba5ec 100%);

  /* --- Dimensions --- */
  --radius-xl: 24px;
  --radius-md: 14px;
}

/* === Global Reset === */
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}
body {
  margin: 0;
  font-family: "IBM Plex Sans Arabic", "Inter", sans-serif;
  background-color: var(--bg-deep);
  background-image: radial-gradient(
    circle at 50% 0%,
    rgba(83, 117, 255, 0.08) 0%,
    transparent 50%
  );
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
  font-size: 16px;
  line-height: 1.6;
  text-rendering: optimizeLegibility;
}

/* Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-thumb {
  background: var(--bg-elevated);
  border-radius: 4px;
}
::-webkit-scrollbar-track {
  background: transparent;
}

/* === SKELETON LOADER (شاشة التحميل) === */
.skeleton-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-deep);
  z-index: 9999;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  transition: opacity 0.6s ease-out, visibility 0.6s;
}
.skeleton-screen.fade-out {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.skeleton-header {
  height: 70px;
  background: var(--bg-elevated);
  border-radius: 16px;
  width: 100%;
  animation: shimmer 2s infinite linear;
}
.skeleton-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 15px;
}
.skeleton-box {
  height: 120px;
  background: var(--bg-elevated);
  border-radius: 20px;
  width: 100%;
  animation: shimmer 2s infinite linear;
  background: linear-gradient(
    to right,
    var(--bg-elevated) 4%,
    var(--bg-surface) 25%,
    var(--bg-elevated) 36%
  );
  background-size: 1000px 100%;
}
@keyframes shimmer {
  0% {
    background-position: -1000px 0;
  }
  100% {
    background-position: 1000px 0;
  }
}

/* === Layout === */
.app-shell {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 1440px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}
.content-wrapper {
  flex: 1;
  display: flex;
  overflow: hidden;
  position: relative;
}
.main-view {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  scroll-behavior: smooth;
}
.panel {
  display: none;
  animation: slideUp 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
  max-width: 900px;
  margin: 0 auto;
}
.panel.active {
  display: block;
}
.hdr {
  padding: 12px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--glass-border);
  background: rgba(3, 4, 7, 0.85);
  backdrop-filter: blur(16px);
  z-index: 50;
  min-height: 64px;
}
.brand {
  display: flex;
  gap: 12px;
  align-items: center;
}
.brand__logo {
  width: 40px;
  height: 40px;
  background: var(--accent-gradient);
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 18px;
  color: white;
  box-shadow: 0 0 20px rgba(83, 117, 255, 0.3);
}
.brand__info h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}
.brand__info p {
  margin: 0;
  font-size: 11px;
  color: var(--text-secondary);
}

/* === Components === */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  padding: 24px;
  margin-bottom: 16px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.5);
}
.word-card {
  background: linear-gradient(
    180deg,
    var(--bg-elevated) 0%,
    var(--bg-surface) 100%
  );
  border: 1px solid var(--glass-border);
  border-radius: 18px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  transition: transform 0.2s ease, border-color 0.2s;
  position: relative;
}
.word-card:active {
  transform: scale(0.98);
}
.word-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.en-word {
  font-size: 22px;
  font-weight: 700;
  font-family: "Inter", sans-serif;
  color: var(--text-primary);
}
.ar-word {
  font-size: 18px;
  color: var(--accent-primary);
  font-weight: 500;
}
.example-box {
  background: rgba(255, 255, 255, 0.03);
  padding: 14px;
  border-radius: 10px;
  font-size: 14px;
  border-left: 3px solid var(--glass-border);
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: 14px;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s;
  width: 100%;
}
.btn-primary {
  background: var(--accent-primary);
  color: white;
  box-shadow: 0 4px 15px rgba(83, 117, 255, 0.4);
}
.btn-primary:active {
  transform: scale(0.96);
  box-shadow: none;
}
.btn-ghost {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-color: var(--glass-border);
}
.btn-ghost:active {
  background: var(--glass-highlight);
}
.btn-icon {
  width: 44px;
  height: 44px;
  padding: 0;
  font-size: 20px;
  border-radius: 12px;
}
.audio-btn {
  background: rgba(83, 117, 255, 0.15);
  color: var(--accent-primary);
  border: none;
  border-radius: 50%;
  width: 42px;
  height: 42px;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: 0.2s;
}
.audio-btn:active {
  transform: scale(0.9);
}
.input-group {
  margin-bottom: 18px;
}
.input-label {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  color: var(--text-secondary);
}
.input-field {
  width: 100%;
  background: var(--bg-deep);
  border: 1px solid var(--glass-border);
  padding: 14px;
  border-radius: 12px;
  color: white;
  font-size: 16px;
  transition: border-color 0.2s;
}
.input-field:focus {
  outline: none;
  border-color: var(--accent-primary);
}
.badge {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 6px;
  font-weight: 700;
  display: inline-block;
  margin-left: 8px;
}
.badge-a1 {
  background: rgba(18, 183, 106, 0.15);
  color: #12b76a;
}
.badge-a2 {
  background: rgba(83, 117, 255, 0.15);
  color: #5375ff;
}
.badge-learned {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
  border-color: var(--glass-border);
}

/* === Quiz & Charts === */
.quiz-modes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
  margin-top: 15px;
}
.mode-card {
  background: var(--bg-elevated);
  border: 1px solid var(--glass-border);
  border-radius: 18px;
  padding: 20px;
  cursor: pointer;
  transition: 0.2s;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: var(--text-primary);
}
.mode-card:active {
  transform: scale(0.96);
  background: var(--glass-highlight);
}
.quiz-top-bar {
  display: flex;
  justify-content: space-between;
  margin-bottom: 20px;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 600;
}
.progress-track {
  height: 8px;
  background: var(--bg-elevated);
  border-radius: 99px;
  margin-bottom: 30px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--accent-gradient);
  transition: width 0.3s ease;
  border-radius: 99px;
}
.quiz-q {
  font-size: 2.2rem;
  font-weight: 700;
  margin-bottom: 30px;
  text-align: center;
  line-height: 1.2;
}
.bar-chart {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  height: 140px;
  gap: 8px;
  padding-top: 20px;
}
.chart-bar {
  flex: 1;
  background: var(--bg-elevated);
  border-radius: 6px 6px 0 0;
  position: relative;
  min-width: 10px;
  transition: height 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.chart-container {
  background: var(--bg-deep);
  border-radius: 16px;
  padding: 20px;
  margin-top: 24px;
  border: 1px solid var(--glass-border);
}

/* === Modals === */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
}
.modal-card {
  width: 90%;
  max-width: 400px;
  background: var(--bg-surface);
  border: 1px solid var(--accent-purple);
  padding: 25px;
  border-radius: 24px;
  animation: slideUp 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
  border-bottom: 1px solid var(--glass-border);
  padding-bottom: 12px;
}
.hidden {
  display: none !important;
}

/* === AI BUBBLE NOTIFICATION (الفقاعة الذكية) === */
.ai-bubble {
  position: fixed;
  bottom: 110px;
  left: 20px;
  right: 20px;
  background: rgba(20, 25, 40, 0.95);
  border: 1px solid var(--accent-purple);
  padding: 16px;
  border-radius: 18px;
  display: flex;
  align-items: center;
  gap: 15px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
  z-index: 10000;
  backdrop-filter: blur(12px);
  animation: slideUpBubble 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  max-width: 500px;
  margin: 0 auto;
}
.ai-bubble-icon {
  font-size: 32px;
  animation: pulse 2s infinite;
}
.ai-bubble-content {
  flex: 1;
}
.ai-bubble-text {
  font-size: 14px;
  margin: 0 0 8px 0;
  line-height: 1.4;
  color: #fff;
}
.ai-bubble-btn {
  background: var(--accent-primary);
  color: white;
  border: none;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

/* === 🏆 GAMIFICATION BADGES STYLES (تصميم الأوسمة) === */
.badges-section {
  margin-top: 20px;
  background: var(--bg-elevated);
  padding: 20px;
  border-radius: 20px;
  border: 1px solid var(--glass-border);
}

.badges-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 15px;
  margin-top: 15px;
}

.badge-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 10px;
  background: var(--bg-surface);
  border-radius: 12px;
  border: 1px solid var(--glass-border);
  transition: transform 0.2s;
  opacity: 1;
  cursor: pointer;
}

/* الوسام المقفل (غير المكتسب) */
.badge-item.locked {
  opacity: 0.4;
  filter: grayscale(100%);
}

.badge-icon {
  font-size: 32px;
  margin-bottom: 6px;
  filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.1));
}

.badge-item.unlocked .badge-icon {
  animation: bounce 2s infinite;
}

.badge-title {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-primary);
}

/* === Animations === */
@keyframes slideUp {
  from {
    transform: translateY(40px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}
@keyframes slideUpBubble {
  from {
    transform: translateY(100px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}
@keyframes pulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
  }
}
@keyframes bounce {
  0%,
  20%,
  50%,
  80%,
  100% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(-6px);
  }
  60% {
    transform: translateY(-3px);
  }
}

/* Confetti */
#confetti-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9999;
  overflow: hidden;
}
.confetti {
  position: absolute;
  width: 8px;
  height: 8px;
  background: red;
  animation: fall 3s linear forwards;
}
@keyframes fall {
  to {
    transform: translateY(100vh) rotate(720deg);
  }
}
