/* ── Variables ───────────────────────────────────────────────────────────────── */
:root {
  --primary:        #1a5276;
  --primary-light:  #2874a6;
  --primary-dark:   #154360;
  --accent:         #c9a84c;
  --accent-dark:    #a07830;
  --success:        #1e8449;
  --success-light:  #d5f5e3;
  --danger:         #c0392b;
  --danger-light:   #fce4e1;
  --warning:        #d68910;
  --warning-light:  #fef9e7;
  --info:           #2471a3;
  --info-light:     #d6eaf8;

  --bg:             #f7f5f0;
  --surface:        #ffffff;
  --surface-alt:    #f0ede6;
  --text:           #1c1c2e;
  --text-muted:     #6b6b7a;
  --border:         #ddd9cf;

  --sidebar-bg:     #12304a;
  --sidebar-text:   #c8dae8;
  --sidebar-active: #ffffff;
  --sidebar-w:      240px;

  --font-latin:     'Inter', system-ui, sans-serif;
  --font-arabic:    'Amiri', 'Traditional Arabic', serif;

  --radius:         10px;
  --radius-sm:      6px;
  --shadow:         0 2px 12px rgba(0,0,0,0.08);
  --shadow-lg:      0 8px 32px rgba(0,0,0,0.12);
}

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

body {
  font-family: var(--font-latin);
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
}

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

h1, h2, h3 { line-height: 1.25; }
h1 { font-size: 1.6rem; font-weight: 600; }
h2 { font-size: 1.2rem; font-weight: 600; }
h3 { font-size: 1rem; font-weight: 600; }

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

/* ── Layout ──────────────────────────────────────────────────────────────────── */
.app-body { display: flex; min-height: 100vh; }

.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  padding: 32px 40px;
  max-width: 1100px;
}

/* ── Sidebar ─────────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  padding: 0 0 16px;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  margin-bottom: 8px;
}

.logo-ar {
  font-family: var(--font-arabic);
  font-size: 1.6rem;
  color: var(--accent);
  line-height: 1;
}

.logo-text {
  font-weight: 600;
  font-size: 1rem;
  color: white;
  letter-spacing: 0.02em;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px 14px;
  margin-bottom: 4px;
}

.user-avatar {
  width: 32px;
  height: 32px;
  background: var(--accent);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.user-name {
  font-size: 0.85rem;
  color: rgba(255,255,255,0.8);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-nav {
  list-style: none;
  flex: 1;
  padding: 0 12px;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  font-size: 0.9rem;
  transition: background 0.15s, color 0.15s;
}

.sidebar-nav a:hover { background: rgba(255,255,255,0.07); color: white; text-decoration: none; }
.sidebar-nav a.active { background: rgba(255,255,255,0.12); color: white; font-weight: 500; }

.sidebar-nav svg { width: 17px; height: 17px; flex-shrink: 0; }

.nav-divider {
  height: 1px;
  background: rgba(255,255,255,0.08);
  margin: 8px 0;
}

.sidebar-logout {
  padding: 0 12px;
  margin-top: auto;
}

.sidebar-logout button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.sidebar-logout button:hover { background: rgba(255,255,255,0.07); color: white; }
.sidebar-logout svg { width: 17px; height: 17px; }

/* ── Page header ─────────────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
}

.back-link {
  display: inline-block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.back-link:hover { color: var(--primary); }

.subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 2px;
}

/* ── Buttons ─────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 0.9rem;
  border: none;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary    { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-light); }

.btn-accent     { background: var(--accent); color: white; }
.btn-accent:hover { background: var(--accent-dark); }

.btn-success    { background: var(--success); color: white; }
.btn-success:hover { background: #27ae60; }

.btn-danger     { background: var(--danger); color: white; }
.btn-danger:hover { background: #e74c3c; }

.btn-outline    {
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--primary);
}
.btn-outline:hover { background: var(--primary); color: white; }

.btn-full { width: 100%; justify-content: center; }
.btn-sm   { padding: 5px 12px; font-size: 0.82rem; }
.ml-2     { margin-left: 8px; }

/* ── Cards ───────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 20px;
}

/* ── Alert ───────────────────────────────────────────────────────────────────── */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  margin-bottom: 16px;
}
.alert-error { background: var(--danger-light); color: var(--danger); border-left: 3px solid var(--danger); }

/* ── Badges ──────────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 500;
}
.badge-success { background: var(--success-light); color: var(--success); }
.badge-info    { background: var(--info-light);    color: var(--info); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-lg      { padding: 5px 14px; font-size: 0.88rem; }

/* ── Forms ───────────────────────────────────────────────────────────────────── */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 0.85rem; font-weight: 500; margin-bottom: 5px; color: var(--text); }
.field input, .field textarea, .field select {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s;
  outline: none;
}
.field input:focus, .field textarea:focus { border-color: var(--primary); }
.field textarea { resize: vertical; min-height: 120px; }
.field small { display: block; margin-top: 4px; font-size: 0.78rem; color: var(--text-muted); }

.field-row { display: flex; gap: 16px; }
.field-sm { flex: 0 0 100px; }
.field-grow { flex: 1; }

.required { color: var(--danger); }

.arabic-input { font-family: var(--font-arabic); font-size: 1.2rem; direction: rtl; }

.form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.form-card { max-width: 700px; }

/* ── Auth pages ──────────────────────────────────────────────────────────────── */
.auth-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
}

.auth-wrap {
  width: 100%;
  max-width: 400px;
  padding: 20px;
}

.auth-brand {
  text-align: center;
  margin-bottom: 28px;
}

.brand-logo {
  font-family: var(--font-arabic);
  font-size: 3rem;
  color: var(--primary);
  line-height: 1;
  margin-bottom: 8px;
}

.auth-brand h1 { font-size: 1.5rem; margin-bottom: 2px; }
.auth-brand p  { color: var(--text-muted); font-size: 0.9rem; }

.auth-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 28px 32px;
}

.auth-card h2 { margin-bottom: 20px; }

.auth-switch {
  text-align: center;
  margin-top: 16px;
  font-size: 0.88rem;
  color: var(--text-muted);
}

/* ── Dashboard ───────────────────────────────────────────────────────────────── */
.review-banner {
  background: var(--primary);
  color: white;
  border-radius: var(--radius);
  padding: 18px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
  box-shadow: var(--shadow-lg);
}

.review-banner-done { background: var(--success); }

.review-banner-info {
  display: flex;
  align-items: center;
  gap: 16px;
}

.review-count {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
  min-width: 40px;
}

.review-banner-info strong { display: block; font-size: 1rem; }
.review-banner-info span  { font-size: 0.85rem; opacity: 0.85; }

.lessons-section h2 { margin-bottom: 16px; }

.lessons-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.lesson-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  border: 2px solid transparent;
  transition: transform 0.15s, box-shadow 0.15s;
}

.lesson-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.lesson-card.completed { border-color: var(--success); }
.lesson-card.in_progress { border-color: var(--info); }

.lesson-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.lesson-number { font-size: 0.8rem; font-weight: 500; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }

.lesson-title-ar {
  font-family: var(--font-arabic);
  font-size: 1.4rem;
  margin-bottom: 4px;
  direction: rtl;
  text-align: right;
}

.lesson-desc { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 12px; }
.lesson-vocab-count { font-size: 0.82rem; color: var(--text-muted); margin-bottom: 12px; }
.lesson-progress-label { font-size: 0.78rem; color: var(--text-muted); margin: 4px 0 12px; }

.lesson-progress-bar {
  height: 5px;
  background: var(--surface-alt);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 2px;
}

.lesson-progress-fill {
  height: 100%;
  background: var(--success);
  border-radius: 10px;
  transition: width 0.4s ease;
}

/* ── Lesson page ─────────────────────────────────────────────────────────────── */
.lesson-layout { display: flex; flex-direction: column; gap: 20px; }

.ar-title { font-family: var(--font-arabic); direction: rtl; }

.theory-section h2 { margin-bottom: 16px; }

.theory-content {
  line-height: 1.9;
  color: var(--text);
}

.theory-content h3 { margin: 12px 0 6px; }
.theory-content strong { color: var(--primary-dark); }

.vocab-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.count-badge {
  display: inline-block;
  background: var(--surface-alt);
  padding: 1px 8px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 400;
  color: var(--text-muted);
  margin-left: 6px;
}

.vocab-table-wrap { overflow-x: auto; }

.vocab-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.vocab-table th {
  text-align: left;
  padding: 8px 12px;
  background: var(--surface-alt);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.vocab-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.vocab-table tr:last-child td { border-bottom: none; }
.vocab-table tr:hover td { background: var(--bg); }

.arabic-cell { text-align: right; }
.arabic-word { font-family: var(--font-arabic); font-size: 1.5rem; direction: rtl; }
.translit-cell { color: var(--text-muted); font-style: italic; }

.example { margin-top: 4px; }
.ex-ar { display: block; font-family: var(--font-arabic); font-size: 1rem; direction: rtl; color: var(--primary); }
.ex-fr { display: block; font-size: 0.78rem; color: var(--text-muted); }

.category-tag {
  display: inline-block;
  font-size: 0.75rem;
  background: var(--info-light);
  color: var(--info);
  padding: 1px 7px;
  border-radius: 4px;
}

.col-arabic { width: 140px; }
.col-status { width: 48px; text-align: center; }

.status-dot {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
}
.status-new      { background: var(--border); }
.status-learning { background: var(--warning); }
.status-mastered { background: var(--success); }

.vocab-cta {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
}
.vocab-cta p { margin-bottom: 10px; }

.empty-state { color: var(--text-muted); padding: 20px 0; }

/* ── Flashcards ──────────────────────────────────────────────────────────────── */
.flashcard-main { max-width: 680px; }

.fc-session { min-height: calc(100vh - 64px); display: flex; flex-direction: column; }

.fc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 32px;
}

.fc-progress { display: flex; align-items: center; gap: 12px; flex: 1; margin-left: 20px; }

.fc-progress-bar {
  flex: 1;
  height: 6px;
  background: var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.fc-progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 10px;
  transition: width 0.4s ease;
}

.fc-progress-text { font-size: 0.82rem; color: var(--text-muted); white-space: nowrap; }

.fc-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
}

/* Carte 3D */
.fc-container {
  width: 100%;
  max-width: 560px;
  height: 300px;
  perspective: 1200px;
  cursor: pointer;
  margin-bottom: 28px;
}

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

.fc-card.is-flipped { transform: rotateY(180deg); }

.fc-front, .fc-back {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px;
}

.fc-front {
  background: var(--surface);
  border: 2px solid var(--border);
}

.fc-back {
  background: var(--primary-dark);
  color: white;
  transform: rotateY(180deg);
}

.fc-lesson-tag {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 12px;
}

.fc-arabic {
  font-family: var(--font-arabic);
  font-size: 3.5rem;
  line-height: 1.3;
  direction: rtl;
  text-align: center;
  color: var(--text);
}

.fc-hint {
  margin-top: 16px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.fc-french {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 8px;
  text-align: center;
}

.fc-translit {
  font-style: italic;
  font-size: 0.95rem;
  opacity: 0.75;
  margin-bottom: 6px;
}

.fc-category {
  font-size: 0.78rem;
  background: rgba(255,255,255,0.15);
  padding: 2px 8px;
  border-radius: 4px;
  margin-bottom: 12px;
}

.fc-example {
  text-align: center;
  margin-top: 4px;
}

.fc-example .ex-ar {
  color: var(--accent);
  font-family: var(--font-arabic);
  font-size: 1.2rem;
  direction: rtl;
}

.fc-example .ex-fr { color: rgba(255,255,255,0.7); font-size: 0.82rem; }

/* Boutons de notation */
.fc-rating {
  display: flex;
  gap: 10px;
  width: 100%;
  max-width: 560px;
}

.btn-rating {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 8px;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: transform 0.1s, filter 0.1s;
  font-family: inherit;
}

.btn-rating:hover { transform: translateY(-2px); filter: brightness(1.08); }
.btn-rating:active { transform: translateY(0); }
.btn-rating:disabled { opacity: 0.5; cursor: default; transform: none; }

.btn-rating.again { background: #fde8e6; color: var(--danger); }
.btn-rating.hard  { background: #fef3e2; color: var(--warning); }
.btn-rating.good  { background: #d5f5e3; color: var(--success); }
.btn-rating.easy  { background: var(--info-light); color: var(--info); }

.rating-label    { font-weight: 600; font-size: 0.88rem; }
.rating-interval { font-size: 0.75rem; opacity: 0.7; margin-top: 2px; }

/* Écran fin de session */
.fc-done {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 400px;
  gap: 12px;
}

.done-icon { font-size: 3rem; }
.fc-done h2 { font-size: 1.5rem; }
.fc-done p  { color: var(--text-muted); }
.done-actions { display: flex; gap: 12px; margin-top: 12px; }

/* Écran vide */
.empty-review {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 400px;
  gap: 10px;
}
.empty-icon { font-size: 3rem; }
.empty-review h2 { font-size: 1.5rem; }
.empty-review p  { color: var(--text-muted); max-width: 360px; }
.next-review-time { font-size: 0.88rem; }
.empty-actions { display: flex; gap: 12px; margin-top: 12px; }

/* ── Stats ───────────────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 4px;
}

.stat-value { font-size: 2rem; font-weight: 700; color: var(--primary); }
.stat-label { font-size: 0.8rem; color: var(--text-muted); }
.stat-due .stat-value      { color: var(--warning); }
.stat-mastered .stat-value { color: var(--success); }
.stat-learning .stat-value { color: var(--info); }

.stats-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.stats-table th { text-align: left; padding: 8px 12px; background: var(--surface-alt); font-size: 0.78rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.stats-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.stats-table tr:last-child td { border-bottom: none; }

.mini-progress { height: 5px; background: var(--border); border-radius: 10px; overflow: hidden; margin-bottom: 2px; min-width: 80px; }
.mini-progress-fill { height: 100%; background: var(--success); border-radius: 10px; }

/* ── Admin ───────────────────────────────────────────────────────────────────── */
.admin-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.admin-table th { text-align: left; padding: 8px 12px; background: var(--surface-alt); font-size: 0.75rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.admin-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: var(--bg); }

.action-cell { display: flex; gap: 6px; align-items: center; }
.lesson-num-badge { display: inline-block; background: var(--primary); color: white; border-radius: 4px; padding: 2px 8px; font-size: 0.8rem; font-weight: 600; }

.ar-inline { font-family: var(--font-arabic); direction: rtl; }
.ar-sm { font-family: var(--font-arabic); font-size: 1.1rem; direction: rtl; }

/* ── Utilities ───────────────────────────────────────────────────────────────── */
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 20px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 20px; }
