/* =============================================
   BIBLIOTRACK — STYLES PRINCIPAUX
   ============================================= */

:root {
  --primary: #4f46e5;
  --primary-dark: #3730a3;
  --primary-light: #e0e7ff;
  --secondary: #0ea5e9;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --purple: #8b5cf6;
  --gold: #d97706;

  --bg: #f1f5f9;
  --bg-dark: #0f172a;
  --surface: #ffffff;
  --surface2: #f8fafc;
  --border: #e2e8f0;
  --border-hover: #cbd5e1;

  --text: #1e293b;
  --text-muted: #64748b;
  --text-light: #94a3b8;

  --sidebar-bg: #0f172a;
  --sidebar-text: #cbd5e1;
  --sidebar-active: #4f46e5;
  --sidebar-hover: #1e293b;
  --sidebar-width: 260px;
  --topbar-h: 70px;

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

  --transition: all 0.2s ease;
}

/* ---- RESET ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
  font-size: 14px;
}

/* =============================================
   SIDEBAR
   ============================================= */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  height: 100vh;
  position: fixed;
  left: 0; top: 0;
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s ease;
  overflow: hidden;
}

.sidebar.collapsed { width: 72px; }

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  height: var(--topbar-h);
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  color: white;
  font-family: 'Playfair Display', serif;
  font-weight: 700;
  font-size: 1.2rem;
  white-space: nowrap;
  overflow: hidden;
}
.logo i { color: var(--primary); font-size: 1.4rem; flex-shrink: 0; }
.sidebar.collapsed .logo span { display: none; }

.sidebar-toggle {
  background: none;
  border: none;
  color: var(--sidebar-text);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  font-size: 1rem;
  transition: var(--transition);
}
.sidebar-toggle:hover { background: rgba(255,255,255,0.08); color: white; }

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  overflow-y: auto;
  overflow-x: hidden;
}
.sidebar-nav::-webkit-scrollbar { width: 3px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 10px; }

.nav-section-label {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-light);
  padding: 10px 8px 6px;
  white-space: nowrap;
  overflow: hidden;
  transition: opacity 0.2s;
}
.sidebar.collapsed .nav-section-label { opacity: 0; height: 0; padding: 0; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.875rem;
  transition: var(--transition);
  margin-bottom: 3px;
  white-space: nowrap;
  position: relative;
}
.nav-item i { font-size: 1rem; width: 20px; flex-shrink: 0; text-align: center; }
.nav-item span:not(.badge) { flex: 1; overflow: hidden; }
.nav-item:hover { background: var(--sidebar-hover); color: white; }
.nav-item.active {
  background: var(--primary);
  color: white;
  box-shadow: 0 4px 12px rgba(79,70,229,0.35);
}
.sidebar.collapsed .nav-item span:not(.badge) { display: none; }
.sidebar.collapsed .nav-item .badge { display: none; }

.badge {
  background: var(--primary-light);
  color: var(--primary);
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
  min-width: 20px;
  text-align: center;
}
.badge-gold { background: #fef3c7; color: var(--gold); }
.badge-purple { background: #ede9fe; color: var(--purple); }
.badge-teal { background: #ccfbf1; color: #0d9488; }

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255,255,255,0.05);
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--sidebar-text);
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}
.sidebar-user:hover { background: var(--sidebar-hover); color: white; }
.user-avatar {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  flex-shrink: 0;
  font-size: 0.9rem;
}
.sidebar.collapsed .sidebar-user span { display: none; }

/* =============================================
   MAIN WRAPPER
   ============================================= */
.main-wrapper {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.sidebar.collapsed ~ .main-wrapper { margin-left: 72px; }

/* =============================================
   TOPBAR
   ============================================= */
.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}
.topbar-left { display: flex; align-items: center; gap: 16px; }
.menu-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 6px;
  border-radius: 6px;
  display: none;
}
.menu-btn:hover { color: var(--text); background: var(--bg); }
.page-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
}

/* =============================================
   BUTTONS
   ============================================= */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: var(--transition);
  text-decoration: none;
}
.btn-primary {
  background: var(--primary);
  color: white;
  box-shadow: 0 2px 8px rgba(79,70,229,0.3);
}
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(79,70,229,0.4); }
.btn-ghost { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #dc2626; }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-icon { padding: 8px; width: 36px; height: 36px; justify-content: center; border-radius: var(--radius-sm); }

/* =============================================
   PAGE CONTENT
   ============================================= */
.page-content {
  padding: 28px;
  flex: 1;
  animation: fadeIn 0.25s ease;
}
.page-content.hidden { display: none !important; }

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

/* =============================================
   DASHBOARD
   ============================================= */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 22px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow);
  transition: var(--transition);
  border: 1px solid var(--border);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

.stat-icon {
  width: 52px; height: 52px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}
.stat-blue .stat-icon { background: #eff6ff; color: #3b82f6; }
.stat-green .stat-icon { background: #f0fdf4; color: var(--success); }
.stat-gold .stat-icon { background: #fffbeb; color: var(--gold); }
.stat-purple .stat-icon { background: #f5f3ff; color: var(--purple); }
.stat-teal .stat-icon { background: #f0fdfa; color: #0d9488; }

.stat-info { display: flex; flex-direction: column; }
.stat-value { font-size: 1.8rem; font-weight: 800; color: var(--text); line-height: 1; }
.stat-label { font-size: 0.78rem; color: var(--text-muted); margin-top: 4px; }

.dashboard-bottom {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.section-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.section-card.full-width { grid-column: 1 / -1; }

.section-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
.section-card-header h2 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-card-header h2 i { color: var(--primary); }
.link-all { font-size: 0.8rem; color: var(--primary); text-decoration: none; font-weight: 600; }
.link-all:hover { text-decoration: underline; }

/* ---- Currently Reading Cards ---- */
.currently-reading-list, .bible-progress-list, .catechism-progress-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.reading-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.reading-cover {
  width: 40px; height: 54px;
  border-radius: 5px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1.1rem;
}
.reading-info { flex: 1; min-width: 0; }
.reading-title { font-weight: 600; font-size: 0.875rem; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reading-author { font-size: 0.75rem; color: var(--text-muted); margin: 2px 0 6px; }
.reading-progress { display: flex; align-items: center; gap: 8px; }
.progress-bar-wrap {
  flex: 1;
  height: 6px;
  background: var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  border-radius: 10px;
  transition: width 0.5s ease;
}
.bible-fill { background: linear-gradient(90deg, var(--gold), #f59e0b); }
.progress-pct { font-size: 0.72rem; font-weight: 700; color: var(--text-muted); white-space: nowrap; }

/* =============================================
   FILTER BAR
   ============================================= */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}
.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  flex: 1;
  min-width: 220px;
  transition: var(--transition);
}
.search-box:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,0.1); }
.search-box i { color: var(--text-light); font-size: 0.9rem; }
.search-box input { border: none; outline: none; background: transparent; font-size: 0.875rem; color: var(--text); width: 100%; }

.filter-tabs { display: flex; gap: 6px; }
.filter-tab {
  padding: 7px 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
}
.filter-tab:hover { border-color: var(--primary); color: var(--primary); }
.filter-tab.active { background: var(--primary); color: white; border-color: var(--primary); }

/* =============================================
   BOOKS GRID
   ============================================= */
.books-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 20px;
}

.book-card {
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  transition: var(--transition);
  cursor: pointer;
  display: flex;
  flex-direction: column;
}
.book-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }

.book-cover {
  height: 130px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  color: rgba(255,255,255,0.85);
  position: relative;
}
.book-cover-badge {
  position: absolute;
  top: 8px; right: 8px;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 20px;
  background: rgba(255,255,255,0.25);
  color: white;
  backdrop-filter: blur(4px);
}
.status-en_cours .book-cover-badge { background: rgba(16,185,129,0.8); }
.status-terminé .book-cover-badge { background: rgba(79,70,229,0.8); }
.status-à_lire .book-cover-badge { background: rgba(100,116,139,0.8); }

.book-body { padding: 14px; flex: 1; }
.book-title { font-weight: 700; font-size: 0.9rem; margin-bottom: 3px; color: var(--text); line-height: 1.3; }
.book-author { font-size: 0.75rem; color: var(--text-muted); margin-bottom: 10px; }
.book-category { font-size: 0.7rem; background: var(--primary-light); color: var(--primary); padding: 2px 8px; border-radius: 20px; display: inline-block; margin-bottom: 10px; font-weight: 600; }

.book-progress-wrap { margin-bottom: 8px; }
.book-progress-label { display: flex; justify-content: space-between; font-size: 0.72rem; color: var(--text-muted); margin-bottom: 5px; }

.book-footer {
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  background: var(--surface2);
}

/* ---- BIBLE Grid ---- */
.bible-card {
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  transition: var(--transition);
  display: flex;
  flex-direction: column;
}
.bible-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }

.bible-card-header {
  padding: 18px;
  background: linear-gradient(135deg, #1e293b, #334155);
  color: white;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  position: relative;
}
.bible-card-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}
.at-icon { background: linear-gradient(135deg, var(--gold), #b45309); }
.nt-icon { background: linear-gradient(135deg, var(--primary), var(--secondary)); }

.bible-card-info { flex: 1; }
.bible-book-name { font-weight: 700; font-size: 1rem; }
.bible-testament { font-size: 0.72rem; color: rgba(255,255,255,0.6); margin-top: 2px; }
.bible-card-status {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 20px;
  background: rgba(255,255,255,0.15);
  backdrop-filter: blur(4px);
}

.bible-card-body { padding: 14px; flex: 1; }
.bible-stat-row { display: flex; gap: 12px; margin-bottom: 12px; }
.bible-stat {
  flex: 1;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  padding: 10px;
  text-align: center;
  border: 1px solid var(--border);
}
.bible-stat-val { font-size: 1.2rem; font-weight: 800; color: var(--text); }
.bible-stat-lbl { font-size: 0.68rem; color: var(--text-muted); margin-top: 2px; }

.bible-card-footer {
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  background: var(--surface2);
}

/* ---- CATECHISM Grid ---- */
.catechism-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}

.catechism-card {
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  transition: var(--transition);
  display: flex;
  flex-direction: column;
}
.catechism-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }

.catechism-card-header {
  padding: 18px;
  color: white;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  position: relative;
}
.catechism-card-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
  background: rgba(255,255,255,0.2);
}

.catechism-card-info { flex: 1; }
.catechism-part-name { font-weight: 700; font-size: 1rem; }
.catechism-part-title { font-size: 0.75rem; color: rgba(255,255,255,0.8); margin-top: 2px; }
.catechism-card-status {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 20px;
  background: rgba(255,255,255,0.15);
  backdrop-filter: blur(4px);
}

.catechism-card-body { padding: 14px; flex: 1; }
.catechism-section-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #f0fdfa;
  color: #0d9488;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 20px;
  margin-bottom: 12px;
  border: 1px solid #ccfbf1;
}
.catechism-section-badge i { font-size: 0.65rem; }

.catechism-stat-row { display: flex; gap: 12px; margin-bottom: 12px; }
.catechism-stat {
  flex: 1;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  padding: 10px;
  text-align: center;
  border: 1px solid var(--border);
}
.catechism-stat-val { font-size: 1.2rem; font-weight: 800; color: var(--text); }
.catechism-stat-lbl { font-size: 0.68rem; color: var(--text-muted); margin-top: 2px; }

.catechism-card-footer {
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  background: var(--surface2);
}

/* Catechism progress bar fill */
.catechism-fill { background: linear-gradient(90deg, #0ea5e9, #06b6d4); }

/* Catechism progress list in dashboard */
.catechism-progress-list {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
.catechism-progress-list .reading-item {
  flex: 1;
  min-width: 250px;
}

/* =============================================
   SUMMARIES GRID
   ============================================= */
.summaries-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}

.summary-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  transition: var(--transition);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.summary-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

.summary-card-header {
  padding: 16px 18px;
  background: linear-gradient(135deg, var(--primary), var(--purple));
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}
.summary-chap-num {
  font-size: 0.7rem;
  font-weight: 600;
  opacity: 0.8;
  background: rgba(255,255,255,0.2);
  padding: 2px 8px;
  border-radius: 20px;
  margin-bottom: 4px;
  display: inline-block;
}
.summary-chap-title { font-weight: 700; font-size: 0.95rem; line-height: 1.3; }
.summary-book-name { font-size: 0.75rem; opacity: 0.75; margin-top: 3px; }

.summary-card-body { padding: 14px 18px; flex: 1; }
.summary-preview {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.summary-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.summary-tag {
  font-size: 0.68rem;
  background: var(--bg);
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: 500;
}

.summary-card-footer {
  padding: 10px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface2);
}
.summary-date { font-size: 0.72rem; color: var(--text-light); }

/* =============================================
   VIEW SUMMARY MODAL CONTENT
   ============================================= */
.view-summary-section { margin-bottom: 22px; }
.view-summary-section h4 {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.view-summary-section h4 i { color: var(--primary); }
.view-summary-section p, .view-summary-section .content-text {
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--text);
  background: var(--surface2);
  border-radius: var(--radius-sm);
  padding: 14px;
  border: 1px solid var(--border);
  white-space: pre-wrap;
}
.key-points-list { list-style: none; }
.key-points-list li {
  padding: 8px 12px;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--primary);
  margin-bottom: 6px;
  font-size: 0.875rem;
  color: var(--text);
}
.quote-block {
  border-left: 3px solid var(--gold);
  background: #fffbeb;
  padding: 12px 16px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-style: italic;
  font-size: 0.9rem;
  color: var(--text);
  margin-bottom: 6px;
}

/* =============================================
   STATS PAGE
   ============================================= */
.stats-page { display: flex; flex-direction: column; gap: 18px; }
.stats-row { display: flex; gap: 18px; }
.stats-row.two-col { display: grid; grid-template-columns: 1fr 1fr; }
.stats-row.three-col { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 18px; }

.stats-overview-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}
.stats-overview-item {
  text-align: center;
  padding: 20px;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.stats-overview-val { font-size: 2rem; font-weight: 800; color: var(--primary); }
.stats-overview-label { font-size: 0.78rem; color: var(--text-muted); margin-top: 5px; }

.stats-detail-list { display: flex; flex-direction: column; gap: 12px; }
.stats-detail-item { padding: 12px; background: var(--surface2); border-radius: var(--radius-sm); border: 1px solid var(--border); }
.stats-detail-title { font-weight: 600; font-size: 0.875rem; margin-bottom: 6px; display: flex; justify-content: space-between; align-items: center; }
.stats-detail-pct { font-size: 0.72rem; font-weight: 700; color: var(--primary); }

/* =============================================
   MODALS
   ============================================= */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.6);
  backdrop-filter: blur(4px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: overlayIn 0.2s ease;
}
.modal-overlay.hidden { display: none !important; }

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

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.modal-large { max-width: 720px; }
.modal-small { max-width: 420px; }

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.92) translateY(-20px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal::-webkit-scrollbar { width: 5px; }
.modal::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
}
.modal-header h2 { font-size: 1.05rem; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.modal-header h2 i { color: var(--primary); }
.modal-close {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 32px; height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}
.modal-close:hover { background: var(--danger); color: white; border-color: var(--danger); }
.modal-body { padding: 24px; }
.modal-subtitle { color: var(--text-muted); font-size: 0.875rem; font-weight: 500; }

/* ---- FORMS ---- */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 0.8rem; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  color: var(--text);
  background: var(--surface);
  font-family: inherit;
  transition: var(--transition);
  outline: none;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,0.1);
}
.form-group textarea { resize: vertical; }
.form-row { display: flex; gap: 12px; }
.form-row.two-col > * { flex: 1; }
.form-row.three-col > * { flex: 1; }
.form-hint { font-size: 0.72rem; color: var(--text-muted); margin-top: 4px; display: block; }

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

/* ---- Color Picker ---- */
.color-picker {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.color-option {
  width: 28px; height: 28px;
  border-radius: 50%;
  cursor: pointer;
  transition: var(--transition);
  border: 2px solid transparent;
}
.color-option:hover { transform: scale(1.2); }
.color-option.selected { border: 3px solid white; box-shadow: 0 0 0 2px var(--text); transform: scale(1.1); }

/* ---- Page Update Box ---- */
.page-update-box {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 16px 0;
}
.page-btn {
  width: 40px; height: 40px;
  border: 1px solid var(--border);
  background: var(--surface2);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  transition: var(--transition);
}
.page-btn:hover { background: var(--bg); color: var(--text); border-color: var(--border-hover); }
.page-btn.page-btn-plus { background: var(--primary-light); color: var(--primary); border-color: var(--primary-light); }
.page-btn.page-btn-plus:hover { background: var(--primary); color: white; }
.page-display {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 1.4rem;
  font-weight: 800;
}
.page-display input {
  width: 80px;
  text-align: center;
  font-size: 1.4rem;
  font-weight: 800;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  padding: 0;
}
.page-display span { font-size: 0.9rem; color: var(--text-muted); font-weight: 500; }

.progress-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.progress-preview .progress-bar-wrap { flex: 1; height: 8px; }
.progress-preview span { font-size: 0.8rem; font-weight: 700; color: var(--primary); min-width: 40px; text-align: right; }

/* =============================================
   EMPTY STATE
   ============================================= */
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state.small { padding: 24px; }
.empty-state i { font-size: 2.5rem; margin-bottom: 12px; opacity: 0.3; display: block; }
.empty-state.small i { font-size: 1.5rem; }
.empty-state h3 { font-size: 1.1rem; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.empty-state p { font-size: 0.875rem; margin-bottom: 16px; }
.empty-state .btn { margin: 0 auto; }

/* =============================================
   TOAST
   ============================================= */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #1e293b;
  color: white;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: var(--shadow-xl);
  z-index: 9999;
  animation: toastIn 0.3s ease;
}
.toast.hidden { display: none; }
.toast i { color: var(--success); font-size: 1rem; }
.toast.error i { color: var(--danger); }

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

/* =============================================
   RESPONSIVE
   ============================================= */
@media (max-width: 1200px) {
  .dashboard-grid { grid-template-columns: repeat(2, 1fr); }
  .stats-overview-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 900px) {
  :root { --sidebar-width: 72px; }
  .sidebar .logo span, .sidebar .nav-item span:not(.badge),
  .sidebar .nav-section-label, .sidebar .nav-item .badge,
  .sidebar .sidebar-user span { display: none !important; }
  .sidebar { width: 72px; }
  .main-wrapper { margin-left: 72px; }
  .dashboard-bottom { grid-template-columns: 1fr; }
  .stats-row.two-col { grid-template-columns: 1fr; }
  .stats-row.three-col { grid-template-columns: 1fr; }
  .menu-btn { display: block; }
}

@media (max-width: 640px) {
  .main-wrapper { margin-left: 0; }
  .sidebar { transform: translateX(-100%); width: var(--sidebar-width) !important; }
  .sidebar.mobile-open { transform: translateX(0); width: 260px !important; }
  .sidebar.mobile-open .logo span, .sidebar.mobile-open .nav-item span:not(.badge),
  .sidebar.mobile-open .nav-section-label, .sidebar.mobile-open .nav-item .badge,
  .sidebar.mobile-open .sidebar-user span { display: block !important; }
  .page-content { padding: 16px; }
  .dashboard-grid { grid-template-columns: 1fr 1fr; }
  .filter-bar { flex-direction: column; align-items: stretch; }
  .form-row { flex-direction: column; }
  .topbar { padding: 0 16px; }
}

/* =============================================
   COVER IMAGE UPLOAD
   ============================================= */
.cover-upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  min-height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface2);
  overflow: hidden;
}
.cover-upload-area:hover { border-color: var(--primary); background: var(--primary-light); }

.cover-upload-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
}
.cover-upload-placeholder i { font-size: 2rem; color: var(--text-light); }
.cover-upload-placeholder span { font-size: 0.875rem; font-weight: 500; }
.cover-upload-placeholder small { font-size: 0.72rem; color: var(--text-light); }

.cover-image-preview {
  max-height: 160px;
  max-width: 120px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
}

.cover-remove-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--danger);
  color: white;
  border: none;
  border-radius: 50%;
  width: 26px;
  height: 26px;
  cursor: pointer;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  z-index: 2;
}
.cover-remove-btn:hover { background: #dc2626; transform: scale(1.1); }

/* =============================================
   SOURCE TYPE TABS (Book / Bible résumés)
   ============================================= */
.source-type-tabs {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}
.source-tab {
  flex: 1;
  padding: 10px 16px;
  border: 2px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-muted);
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.source-tab:hover { border-color: var(--primary); color: var(--primary); }
.source-tab.active { background: var(--primary); color: white; border-color: var(--primary); box-shadow: 0 2px 8px rgba(79,70,229,0.3); }

/* =============================================
   TTS CONTROLS IN MODAL HEADER
   ============================================= */
.tts-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
}

.tts-btn {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  background: var(--primary-light);
  color: var(--primary);
}
.tts-btn:hover { background: var(--primary); color: white; }
.tts-btn.tts-active { background: var(--success); color: white; animation: pulse 1.5s infinite; }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(16,185,129,0.4); }
  50% { box-shadow: 0 0 0 6px rgba(16,185,129,0); }
}

.tts-voice-select {
  font-size: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 6px;
  background: var(--surface);
  color: var(--text-muted);
  max-width: 140px;
  cursor: pointer;
}

.tts-rate {
  width: 70px;
  accent-color: var(--primary);
  cursor: pointer;
}

/* TTS banner when speaking */
.tts-speaking-banner {
  background: linear-gradient(90deg, var(--success), #059669);
  color: white;
  padding: 6px 16px;
  font-size: 0.8rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  animation: fadeIn 0.3s ease;
}

/* =============================================
   BOOK COVER WITH IMAGE
   ============================================= */
.book-cover img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.book-cover { position: relative; }

/* =============================================
   MODAL HEADER WITH TTS (flex adjustments)
   ============================================= */
#modalViewSummary .modal-header {
  flex-wrap: wrap;
  gap: 10px;
}
#modalViewSummary .modal-header h2 {
  flex: 1;
  min-width: 200px;
  font-size: 0.95rem;
}

@media (max-width: 640px) {
  .tts-controls { flex-wrap: wrap; }
  .tts-voice-select { max-width: 100px; }
  .tts-rate { width: 55px; }
}

/* =============================================
   STT — DICTÉE VOCALE BANNER
   ============================================= */
.stt-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 6px;
  transition: var(--transition);
  flex-wrap: wrap;
  gap: 8px;
}
.stt-banner-active {
  background: #f0fdf4;
  border-color: var(--success);
  box-shadow: 0 0 0 3px rgba(16,185,129,0.12);
}
.stt-banner-left {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 500;
}
.stt-indicator {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--border);
  transition: var(--transition);
  flex-shrink: 0;
}
.stt-indicator.stt-listening {
  background: var(--success);
  animation: stt-pulse 1s infinite;
}
@keyframes stt-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(16,185,129,0.5); }
  50%       { box-shadow: 0 0 0 6px rgba(16,185,129,0); }
}
.stt-banner-right {
  display: flex;
  align-items: center;
  gap: 6px;
}
.stt-lang-label { font-size: 0.75rem; color: var(--text-light); }
.stt-lang-select {
  font-size: 0.78rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

/* ---- Mic dictation buttons on fields ---- */
.field-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.field-label-row label { margin-bottom: 0 !important; }

.mic-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid var(--primary-light);
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}
.mic-btn:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}
.mic-btn-active {
  background: var(--danger) !important;
  color: white !important;
  border-color: var(--danger) !important;
  animation: mic-pulse 1s infinite;
}
@keyframes mic-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,0.4); }
  50%       { box-shadow: 0 0 0 6px rgba(239,68,68,0); }
}

/* =============================================
   AUDIO RECORDER BOX
   ============================================= */
.audio-recorder-box {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: var(--transition);
}

/* Idle */
.audio-recorder-idle {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  flex-wrap: wrap;
}
.rec-start-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: white;
  border: none;
  border-radius: 30px;
  font-size: 0.875rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 2px 8px rgba(239,68,68,0.35);
}
.rec-start-btn i { font-size: 0.7rem; animation: rec-blink 1.5s infinite; }
@keyframes rec-blink { 0%,100%{opacity:1} 50%{opacity:0.3} }
.rec-start-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(239,68,68,0.45); }
.rec-hint { font-size: 0.78rem; color: var(--text-light); }

/* Recording active */
.audio-recorder-recording {
  padding: 18px;
  background: linear-gradient(135deg, #1e293b, #0f172a);
  color: white;
  text-align: center;
}

/* Waveform animation */
.rec-waveform {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 4px;
  height: 36px;
  margin-bottom: 10px;
}
.rec-waveform span {
  display: inline-block;
  width: 5px;
  background: #ef4444;
  border-radius: 3px;
  animation: wave 0.8s ease-in-out infinite;
}
.rec-waveform span:nth-child(1)  { animation-delay: 0.0s; height: 12px; }
.rec-waveform span:nth-child(2)  { animation-delay: 0.1s; height: 20px; }
.rec-waveform span:nth-child(3)  { animation-delay: 0.2s; height: 30px; }
.rec-waveform span:nth-child(4)  { animation-delay: 0.3s; height: 24px; }
.rec-waveform span:nth-child(5)  { animation-delay: 0.4s; height: 36px; }
.rec-waveform span:nth-child(6)  { animation-delay: 0.5s; height: 28px; }
.rec-waveform span:nth-child(7)  { animation-delay: 0.6s; height: 18px; }
.rec-waveform span:nth-child(8)  { animation-delay: 0.7s; height: 32px; }
.rec-waveform span:nth-child(9)  { animation-delay: 0.8s; height: 22px; }
.rec-waveform span:nth-child(10) { animation-delay: 0.9s; height: 14px; }
@keyframes wave {
  0%, 100% { transform: scaleY(0.5); }
  50%       { transform: scaleY(1.2); }
}

.rec-timer {
  font-size: 2rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: #f87171;
  margin-bottom: 14px;
  font-family: 'Playfair Display', monospace;
}
.rec-controls {
  display: flex;
  gap: 10px;
  justify-content: center;
}
.rec-pause-btn {
  padding: 8px 18px;
  background: rgba(255,255,255,0.12);
  color: white;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}
.rec-pause-btn:hover { background: rgba(255,255,255,0.2); }
.rec-stop-btn {
  padding: 8px 18px;
  background: #ef4444;
  color: white;
  border: none;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 2px 8px rgba(239,68,68,0.4);
}
.rec-stop-btn:hover { background: #dc2626; transform: translateY(-1px); }

/* Playback */
.audio-recorder-playback { padding: 16px; }
.audio-playback-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
}
.audio-duration-label { font-size: 0.78rem; color: var(--text-muted); font-weight: 500; }

/* Audio saved badge */
.audio-saved-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #f0fdf4;
  color: var(--success);
  border: 1px solid #bbf7d0;
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 0.72rem;
  font-weight: 700;
}

/* ---- Audio tag on summary cards ---- */
.summary-tag-audio {
  background: #fdf2f8 !important;
  color: #9333ea !important;
  border-color: #f5d0fe !important;
}

/* ---- Audio bar in view summary modal ---- */
.view-audio-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 24px;
  background: linear-gradient(90deg, #1e293b, #334155);
  color: white;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.view-audio-label {
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
  color: rgba(255,255,255,0.85);
}
.view-audio-bar audio::-webkit-media-controls-panel {
  background: rgba(255,255,255,0.08);
}

@media (max-width: 640px) {
  .audio-recorder-idle { flex-direction: column; align-items: flex-start; }
  .view-audio-bar { padding: 10px 16px; }
}
