/* ==========================================================================
   Sahih al-Bukhari English & Arabic - Modern Design System
   Maktabah Morba Hadith Portal
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Amiri:ital,wght@0,400;0,700;1,400&family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=Scheherazade+New:wght@400;600;700&display=swap');

/* --- CSS Variables & Design Tokens --- */
:root {
  /* Colors - Light Theme (Emerald & Gold) */
  --bg-primary: #f8fafc;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #ffffff;
  --bg-surface-secondary: #f1f5f9;
  --bg-highlight: #ecfdf5;
  --bg-accent-subtle: #f0fdf4;
  --bg-nav: rgba(255, 255, 255, 0.92);
  --bg-toolbar: #f8fafc;

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --text-arabic: #1e293b;
  
  --primary: #047857;
  --primary-hover: #065f46;
  --primary-light: #d1fae5;
  --primary-dark: #064e3b;
  --primary-glow: rgba(4, 120, 87, 0.18);
  
  --gold: #d97706;
  --gold-light: #fef3c7;
  --gold-dark: #b45309;

  --accent: #2563eb;
  --accent-light: #dbeafe;

  --border-subtle: #e2e8f0;
  --border-medium: #cbd5e1;
  --border-focus: #10b981;

  --card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --card-shadow-hover: 0 10px 25px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --modal-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);

  --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-arabic: 'Amiri', 'Scheherazade New', 'Traditional Arabic', 'KFGQPC Uthman Taha Naskh', serif;
  
  --arabic-size: 1.45rem;
  --arabic-line-height: 2.1;
  --english-size: 1.05rem;
  --english-line-height: 1.75;
  
  --header-height: 72px;
  --border-radius-sm: 8px;
  --border-radius-md: 14px;
  --border-radius-lg: 20px;
  --border-radius-full: 9999px;

  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark Theme */
[data-theme="dark"] {
  --bg-primary: #090d16;
  --bg-surface: #111827;
  --bg-surface-elevated: #1a2234;
  --bg-surface-secondary: #1e293b;
  --bg-highlight: #064e3b33;
  --bg-accent-subtle: #132e27;
  --bg-nav: rgba(17, 24, 39, 0.92);
  --bg-toolbar: #161f30;

  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-arabic: #e2e8f0;

  --primary: #10b981;
  --primary-hover: #34d399;
  --primary-light: #064e3b;
  --primary-dark: #059669;
  --primary-glow: rgba(16, 185, 129, 0.25);

  --gold: #fbbf24;
  --gold-light: #78350f44;
  --gold-dark: #f59e0b;

  --accent: #60a5fa;
  --accent-light: #1e3a8a;

  --border-subtle: #1e293b;
  --border-medium: #334155;
  --border-focus: #34d399;

  --card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
  --card-shadow-hover: 0 10px 25px -3px rgba(0, 0, 0, 0.6);
  --modal-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
}

/* Sepia / Warm Theme */
[data-theme="sepia"] {
  --bg-primary: #fbf0d9;
  --bg-surface: #f4e8c1;
  --bg-surface-elevated: #efe1b3;
  --bg-surface-secondary: #e9d8a6;
  --bg-highlight: #e0d09d;
  --bg-accent-subtle: #ebdcb2;
  --bg-nav: rgba(244, 232, 193, 0.94);
  --bg-toolbar: #ebdcb2;

  --text-primary: #433422;
  --text-secondary: #634f37;
  --text-muted: #826a4c;
  --text-arabic: #2f2214;

  --primary: #8b5a2b;
  --primary-hover: #6f421d;
  --primary-light: #dfc79b;
  --primary-dark: #5c3516;
  --primary-glow: rgba(139, 90, 43, 0.2);

  --gold: #b45309;
  --gold-light: #fae1b8;
  --gold-dark: #92400e;

  --border-subtle: #dfc8a0;
  --border-medium: #cbb084;
  --border-focus: #8b5a2b;

  --card-shadow: 0 4px 6px -1px rgba(67, 52, 34, 0.08);
  --card-shadow-hover: 0 10px 25px -3px rgba(67, 52, 34, 0.12);
}

/* --- Base Resets & Global Styles --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color var(--transition-normal), color var(--transition-normal);
  overflow-x: hidden;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--primary-hover);
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

/* --- Container & Layout --- */
.site-wrapper {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.container {
  width: 100%;
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 20px;
}

.container-narrow {
  max-width: 900px;
}

/* --- Reading Progress Bar --- */
#reading-progress-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  z-index: 1000;
  background: transparent;
}

#reading-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), var(--gold));
  transition: width 0.1s ease-out;
}

/* --- Navigation Header --- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 900;
  background: var(--bg-nav);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  transition: background-color var(--transition-normal), border-color var(--transition-normal);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height);
  gap: 16px;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
}

.brand-logo-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--border-radius-md);
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-weight: 800;
  font-size: 1.25rem;
  box-shadow: 0 4px 12px var(--primary-glow);
  flex-shrink: 0;
}

.brand-titles {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.brand-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

.nav-center-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-search-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-surface-secondary);
  border: 1px solid var(--border-subtle);
  padding: 8px 16px;
  border-radius: var(--border-radius-full);
  color: var(--text-secondary);
  font-size: 0.9rem;
  transition: all var(--transition-fast);
}

.header-search-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--bg-surface);
}

.kbd-shortcut {
  font-size: 0.72rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--text-muted);
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--border-radius-md);
  color: var(--text-secondary);
  background: var(--bg-surface-secondary);
  border: 1px solid transparent;
  transition: all var(--transition-fast);
}

.icon-btn:hover {
  background: var(--bg-surface);
  border-color: var(--border-subtle);
  color: var(--primary);
  transform: translateY(-1px);
}

.icon-btn.active {
  background: var(--primary-light);
  color: var(--primary-dark);
}

/* --- Hero Banner Section --- */
.hero-section {
  padding: 48px 0 32px;
  background: linear-gradient(180deg, var(--bg-surface-secondary) 0%, var(--bg-primary) 100%);
  border-bottom: 1px solid var(--border-subtle);
  position: relative;
  overflow: hidden;
}

.hero-pattern {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  opacity: 0.04;
  pointer-events: none;
  background-image: radial-gradient(var(--primary) 1px, transparent 1px);
  background-size: 24px 24px;
}

.hero-content {
  position: relative;
  text-align: center;
  max-width: 800px;
  margin: 0 auto;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: var(--border-radius-full);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 16px;
}

.badge-primary {
  background: var(--primary-light);
  color: var(--primary-dark);
}

.badge-gold {
  background: var(--gold-light);
  color: var(--gold-dark);
}

.hero-title-ar {
  font-family: var(--font-arabic);
  font-size: 2.5rem;
  color: var(--primary);
  line-height: 1.4;
  margin-bottom: 8px;
}

.hero-title-en {
  font-size: 2.25rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.25;
  margin-bottom: 14px;
}

.hero-description {
  font-size: 1.05rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 24px;
}

.hero-stats-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
  margin-top: 20px;
}

.hero-stat-card {
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--border-radius-md);
  padding: 12px 20px;
  box-shadow: var(--card-shadow);
  min-width: 140px;
}

.hero-stat-value {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--primary);
}

.hero-stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
}

.hero-actions-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  margin-top: 24px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 22px;
  border-radius: var(--border-radius-md);
  font-weight: 600;
  font-size: 0.95rem;
  transition: all var(--transition-fast);
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 4px 12px var(--primary-glow);
}

.btn-primary:hover {
  background: var(--primary-hover);
  color: #ffffff;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px var(--primary-glow);
}

.btn-secondary {
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
}

.btn-secondary:hover {
  background: var(--bg-surface-secondary);
  border-color: var(--border-medium);
  transform: translateY(-1px);
}

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

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

/* --- Quick Search & Filter Bar --- */
.filter-search-container {
  padding: 24px 0 16px;
}

.filter-search-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--border-radius-lg);
  padding: 18px 24px;
  box-shadow: var(--card-shadow);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.search-input-wrapper {
  position: relative;
  flex: 1;
  min-width: 260px;
}

.search-input-wrapper svg {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 12px 16px 12px 46px;
  background: var(--bg-surface-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--border-radius-md);
  font-size: 0.95rem;
  color: var(--text-primary);
  transition: all var(--transition-fast);
}

.search-input:focus {
  outline: none;
  border-color: var(--border-focus);
  background: var(--bg-surface);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.filter-pills {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-pill {
  padding: 8px 14px;
  border-radius: var(--border-radius-full);
  font-size: 0.85rem;
  font-weight: 600;
  background: var(--bg-surface-secondary);
  color: var(--text-secondary);
  border: 1px solid transparent;
  transition: all var(--transition-fast);
}

.filter-pill:hover, .filter-pill.active {
  background: var(--primary-light);
  color: var(--primary-dark);
  border-color: var(--primary);
}

/* --- 97 Books Grid Layout --- */
.books-grid-section {
  padding: 24px 0 60px;
}

.books-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 20px;
}

.book-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--border-radius-lg);
  padding: 22px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: var(--card-shadow);
  text-decoration: none;
  color: inherit;
  position: relative;
  overflow: hidden;
  transition: all var(--transition-normal);
}

.book-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: linear-gradient(180deg, var(--primary), var(--gold));
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.book-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--card-shadow-hover);
  border-color: var(--primary);
}

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

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

.book-number-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--border-radius-md);
  background: var(--primary-light);
  color: var(--primary-dark);
  font-weight: 700;
  font-size: 0.9rem;
}

.book-range-tag {
  font-size: 0.8rem;
  color: var(--text-muted);
  background: var(--bg-surface-secondary);
  padding: 4px 10px;
  border-radius: var(--border-radius-full);
  font-weight: 500;
}

.book-title-ar {
  font-family: var(--font-arabic);
  font-size: 1.35rem;
  color: var(--primary);
  line-height: 1.4;
  text-align: right;
  margin-bottom: 6px;
  direction: rtl;
}

.book-title-en {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.35;
  margin-bottom: 16px;
}

.book-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border-subtle);
  padding-top: 12px;
  margin-top: auto;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.book-hadith-count {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  color: var(--text-secondary);
}

.book-read-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--primary);
  font-weight: 600;
}

.book-card:hover .book-read-link {
  transform: translateX(3px);
  transition: transform var(--transition-fast);
}

/* --- Chapter Page Sticky Bar & Breadcrumbs --- */
.chapter-nav-bar {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  padding: 14px 0;
  position: sticky;
  top: var(--header-height);
  z-index: 800;
  box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

.chapter-nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.breadcrumbs a {
  color: var(--text-secondary);
}

.breadcrumbs a:hover {
  color: var(--primary);
}

.breadcrumb-separator {
  color: var(--text-muted);
  opacity: 0.6;
}

.chapter-quick-switcher {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chapter-select {
  padding: 8px 14px;
  background: var(--bg-surface-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--border-radius-md);
  font-size: 0.9rem;
  color: var(--text-primary);
  max-width: 280px;
  text-overflow: ellipsis;
}

.chapter-select:focus {
  outline: none;
  border-color: var(--border-focus);
}

.chapter-pager-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--border-radius-md);
  background: var(--bg-surface-secondary);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 0.88rem;
  font-weight: 600;
}

.chapter-pager-btn:hover:not(:disabled) {
  background: var(--primary-light);
  color: var(--primary-dark);
  border-color: var(--primary);
}

.chapter-pager-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* --- Chapter Page Header --- */
.chapter-header {
  padding: 36px 0 24px;
  text-align: center;
}

.chapter-header-badge {
  display: inline-block;
  background: var(--primary-light);
  color: var(--primary-dark);
  font-weight: 700;
  font-size: 0.85rem;
  padding: 4px 14px;
  border-radius: var(--border-radius-full);
  margin-bottom: 12px;
}

.chapter-header-title-ar {
  font-family: var(--font-arabic);
  font-size: 2.2rem;
  color: var(--primary);
  line-height: 1.4;
  margin-bottom: 8px;
  direction: rtl;
}

.chapter-header-title-en {
  font-size: 1.85rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 10px;
}

.chapter-header-meta {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  font-size: 0.9rem;
  color: var(--text-muted);
  flex-wrap: wrap;
}

/* --- View Customization Floating / Inline Toolbar --- */
.view-customizer-bar {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--border-radius-md);
  padding: 10px 18px;
  margin: 16px auto 28px;
  max-width: 900px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  box-shadow: var(--card-shadow);
}

.customizer-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.customizer-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
}

.font-size-controls {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-surface-secondary);
  padding: 2px;
  border-radius: var(--border-radius-sm);
}

.font-btn {
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.font-btn:hover {
  background: var(--bg-surface);
  color: var(--primary);
}

.toggle-switch-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: var(--border-radius-full);
  background: var(--bg-surface-secondary);
  color: var(--text-secondary);
}

.toggle-switch-btn.active {
  background: var(--primary-light);
  color: var(--primary-dark);
}

/* --- Hadith List & Hadith Card Styling --- */
.hadith-list {
  display: flex;
  flex-direction: column;
  gap: 28px;
  margin-bottom: 60px;
}

.hadith-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--border-radius-lg);
  padding: 28px;
  box-shadow: var(--card-shadow);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  position: relative;
}

.hadith-card:hover {
  border-color: var(--border-medium);
  box-shadow: var(--card-shadow-hover);
}

.hadith-card.highlighted {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-light);
}

/* Hadith Card Header */
.hadith-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 14px;
  margin-bottom: 20px;
  gap: 12px;
  flex-wrap: wrap;
}

.hadith-ref-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-surface-secondary);
  border: 1px solid var(--border-subtle);
  padding: 6px 14px;
  border-radius: var(--border-radius-full);
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--primary);
}

.hadith-number-pill {
  background: var(--primary);
  color: #ffffff;
  font-size: 0.78rem;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: var(--border-radius-full);
}

.hadith-narrator-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--gold-dark);
  background: var(--gold-light);
  padding: 4px 12px;
  border-radius: var(--border-radius-full);
  font-weight: 600;
}

/* Hadith Arabic Text */
.hadith-arabic-box {
  background: var(--bg-accent-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--border-radius-md);
  padding: 20px 24px;
  margin-bottom: 20px;
  direction: rtl;
  text-align: right;
}

.hadith-arabic-text {
  font-family: var(--font-arabic);
  font-size: var(--arabic-size);
  line-height: var(--arabic-line-height);
  color: var(--text-arabic);
  word-spacing: 2px;
}

.no-tashkeel .hadith-arabic-text {
  font-family: var(--font-arabic);
}

/* Hadith English Text */
.hadith-english-box {
  padding: 0 4px;
  margin-bottom: 24px;
}

.hadith-narrator-lead {
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
  font-size: var(--english-size);
}

.hadith-english-text {
  font-size: var(--english-size);
  line-height: var(--english-line-height);
  color: var(--text-primary);
}

.hadith-english-text p {
  margin-bottom: 12px;
}

.hadith-english-text p:last-child {
  margin-bottom: 0;
}

/* Hadith Actions Toolbar */
.hadith-action-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border-subtle);
  padding-top: 16px;
  gap: 8px;
  flex-wrap: wrap;
}

.action-buttons-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.hadith-act-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: var(--border-radius-md);
  background: var(--bg-surface-secondary);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 600;
  transition: all var(--transition-fast);
}

.hadith-act-btn:hover {
  background: var(--bg-surface);
  border-color: var(--border-medium);
  color: var(--primary);
}

.hadith-act-btn.bookmarked {
  background: #fef2f2;
  border-color: #fca5a5;
  color: #ef4444;
}

[data-theme="dark"] .hadith-act-btn.bookmarked {
  background: #450a0a;
  border-color: #991b1b;
  color: #f87171;
}

.hadith-act-btn.audio-playing {
  background: var(--primary-light);
  color: var(--primary-dark);
  border-color: var(--primary);
  animation: pulse-border 1.5s infinite;
}

@keyframes pulse-border {
  0% { box-shadow: 0 0 0 0 var(--primary-glow); }
  70% { box-shadow: 0 0 0 8px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

/* Share Dropdown / Popover */
.share-dropdown {
  position: relative;
  display: inline-block;
}

.share-menu {
  position: absolute;
  bottom: 100%;
  left: 0;
  margin-bottom: 8px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--border-radius-md);
  padding: 8px;
  box-shadow: var(--modal-shadow);
  display: none;
  flex-direction: column;
  gap: 4px;
  min-width: 170px;
  z-index: 100;
}

.share-menu.show {
  display: flex;
}

.share-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--border-radius-sm);
  font-size: 0.85rem;
  color: var(--text-primary);
  text-decoration: none;
  transition: background-color var(--transition-fast);
}

.share-menu-item:hover {
  background: var(--bg-surface-secondary);
  color: var(--primary);
}

/* --- Personal Notes Box (Collapsible inside Hadith Card) --- */
.hadith-notes-section {
  display: none;
  margin-top: 16px;
  padding: 14px;
  background: var(--bg-surface-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--border-radius-md);
}

.hadith-notes-section.show {
  display: block;
}

.notes-textarea {
  width: 100%;
  min-height: 80px;
  padding: 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--border-radius-sm);
  font-size: 0.9rem;
  color: var(--text-primary);
  resize: vertical;
  margin-bottom: 8px;
}

.notes-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* --- Search Page & Search Results --- */
.search-hero {
  padding: 40px 0 24px;
  text-align: center;
}

.search-page-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--border-radius-lg);
  padding: 24px;
  box-shadow: var(--card-shadow);
  margin-bottom: 32px;
}

.search-results-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.search-highlight {
  background-color: #fde047;
  color: #1c1917;
  padding: 1px 4px;
  border-radius: 3px;
  font-weight: 600;
}

[data-theme="dark"] .search-highlight {
  background-color: #ca8a04;
  color: #ffffff;
}

/* --- Bookmarks Page Styling --- */
.bookmarks-empty-state {
  text-align: center;
  padding: 60px 20px;
  background: var(--bg-surface);
  border: 1px dashed var(--border-medium);
  border-radius: var(--border-radius-lg);
  margin-bottom: 40px;
}

.bookmarks-empty-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  color: var(--text-muted);
  opacity: 0.5;
}

/* --- Toast Notification --- */
#toast-notification {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1100;
  display: flex;
  align-items: center;
  gap: 10px;
  background: #0f172a;
  color: #ffffff;
  padding: 12px 20px;
  border-radius: var(--border-radius-full);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3);
  font-size: 0.9rem;
  font-weight: 600;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
}

[data-theme="dark"] #toast-notification {
  background: #1e293b;
  border: 1px solid #334155;
}

#toast-notification.show {
  opacity: 1;
  transform: translateY(0);
}

/* --- Back to Top Button --- */
#back-to-top-btn {
  position: fixed;
  bottom: 24px;
  left: 24px;
  z-index: 850;
  width: 44px;
  height: 44px;
  border-radius: var(--border-radius-full);
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 4px 12px var(--primary-glow);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transform: scale(0.8);
  transition: all var(--transition-fast);
}

#back-to-top-btn.visible {
  opacity: 1;
  visibility: visible;
  transform: scale(1);
}

#back-to-top-btn:hover {
  background: var(--primary-hover);
  transform: scale(1.1);
}

/* --- Settings Modal --- */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 1050;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop.show {
  display: flex;
}

.modal-dialog {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--border-radius-lg);
  width: 100%;
  max-width: 480px;
  box-shadow: var(--modal-shadow);
  overflow: hidden;
  animation: modal-slide-in 0.25s ease;
}

@keyframes modal-slide-in {
  from { opacity: 0; transform: translateY(12px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-subtle);
}

.modal-title {
  font-size: 1.15rem;
  font-weight: 700;
}

.modal-body {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.setting-info {
  display: flex;
  flex-direction: column;
}

.setting-title {
  font-weight: 600;
  font-size: 0.95rem;
}

.setting-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* --- Footer Section --- */
.site-footer {
  margin-top: auto;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
  padding: 40px 0 24px;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 32px;
  margin-bottom: 32px;
}

.footer-col-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 14px;
}

.footer-links {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.footer-links a {
  color: var(--text-secondary);
}

.footer-links a:hover {
  color: var(--primary);
}

.footer-bottom {
  border-top: 1px solid var(--border-subtle);
  padding-top: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* --- Print Stylesheet --- */
@media print {
  body {
    background: #ffffff !important;
    color: #000000 !important;
  }

  .site-header,
  .chapter-nav-bar,
  .view-customizer-bar,
  .hadith-action-toolbar,
  .site-footer,
  #back-to-top-btn,
  #toast-notification,
  .modal-backdrop,
  #reading-progress-container {
    display: none !important;
  }

  .container, .container-narrow {
    max-width: 100% !important;
    padding: 0 !important;
  }

  .hadith-card {
    box-shadow: none !important;
    border: 1px solid #cccccc !important;
    page-break-inside: avoid;
    margin-bottom: 24px !important;
    padding: 16px !important;
  }

  .hadith-arabic-box {
    background: #fafafa !important;
    border: 1px solid #eeeeee !important;
  }
}

/* --- Responsive Media Queries --- */
@media (max-width: 768px) {
  :root {
    --header-height: 56px;
    --arabic-size: 1.3rem;
    --english-size: 1rem;
  }

  html, body {
    overflow-x: hidden;
    max-width: 100vw;
  }

  body {
    padding-bottom: 64px;
  }

  .container {
    padding: 0 12px !important;
  }

  .container-narrow {
    max-width: 100% !important;
  }

  /* Header adjustments */
  .header-inner {
    min-height: 54px !important;
    gap: 6px !important;
  }

  .brand-logo-icon {
    width: 32px !important;
    height: 32px !important;
    font-size: 0.85rem !important;
  }

  .brand-titles {
    max-width: 140px;
  }

  .brand-title {
    font-size: 0.92rem !important;
  }

  .brand-subtitle {
    display: none !important;
  }

  .header-search-btn span,
  .header-search-btn .kbd-shortcut {
    display: none !important;
  }

  .header-search-btn {
    padding: 8px !important;
    border-radius: var(--border-radius-md);
  }

  .header-controls {
    gap: 4px !important;
  }

  .icon-btn {
    width: 34px !important;
    height: 34px !important;
  }

  /* Hero Section */
  .hero-section {
    padding: 24px 0 20px !important;
  }

  .hero-title-ar {
    font-size: 1.8rem !important;
  }

  .hero-title-en {
    font-size: 1.45rem !important;
  }

  .hero-description {
    font-size: 0.9rem !important;
    margin-bottom: 16px !important;
  }

  .hero-stats-row {
    gap: 8px !important;
  }

  .hero-stat-card {
    min-width: 100px !important;
    padding: 8px 12px !important;
  }

  .hero-stat-value {
    font-size: 1.2rem !important;
  }

  /* Search & Filter bar on index */
  .filter-search-card {
    padding: 12px 14px !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
  }

  .search-input-wrapper {
    min-width: 100% !important;
  }

  .filter-pills {
    justify-content: center !important;
    gap: 6px !important;
  }

  .filter-pill {
    padding: 6px 10px !important;
    font-size: 0.78rem !important;
  }

  /* Books Grid */
  .books-grid {
    grid-template-columns: 1fr !important;
    gap: 14px !important;
  }

  .book-card {
    padding: 16px !important;
  }

  /* Chapter Navigation Sticky Bar */
  .chapter-nav-bar {
    padding: 8px 0 !important;
    top: 54px !important;
  }

  .chapter-nav-inner {
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 6px !important;
    flex-wrap: nowrap !important;
  }

  .breadcrumbs {
    font-size: 0.75rem !important;
    max-width: calc(100vw - 120px) !important;
    overflow: hidden !important;
    white-space: nowrap !important;
    text-overflow: ellipsis !important;
    flex-wrap: nowrap !important;
  }

  .breadcrumbs a:not(:first-child):not(:last-child) {
    display: none !important;
  }

  .breadcrumb-separator:not(:last-of-type) {
    display: none !important;
  }

  .chapter-quick-switcher {
    width: auto !important;
    flex-shrink: 0 !important;
  }

  .chapter-select {
    max-width: 120px !important;
    padding: 5px 8px !important;
    font-size: 0.78rem !important;
  }

  /* Chapter Header */
  .chapter-header {
    padding: 20px 0 16px !important;
  }

  .chapter-header-title-ar {
    font-size: 1.7rem !important;
  }

  .chapter-header-title-en {
    font-size: 1.35rem !important;
  }

  /* Customizer Bar */
  .view-customizer-bar {
    padding: 8px 12px !important;
    gap: 8px !important;
    flex-wrap: wrap !important;
    margin-bottom: 20px !important;
  }

  .customizer-group {
    flex-wrap: wrap !important;
    gap: 4px !important;
  }

  /* Hadith Cards & Content */
  .hadith-list {
    gap: 18px !important;
  }

  .hadith-card {
    padding: 16px 12px !important;
    border-radius: var(--border-radius-md) !important;
  }

  .hadith-card-header {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 6px !important;
    padding-bottom: 10px !important;
    margin-bottom: 14px !important;
  }

  .hadith-arabic-box {
    padding: 14px 12px !important;
    margin-bottom: 16px !important;
  }

  .hadith-arabic-text {
    font-size: 1.25rem !important;
    line-height: 1.85 !important;
  }

  .hadith-english-text {
    font-size: 0.98rem !important;
    line-height: 1.65 !important;
  }

  /* Action Buttons: 2-column grid */
  .hadith-action-toolbar {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 8px !important;
    padding-top: 12px !important;
  }

  .action-buttons-group {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 6px !important;
    width: 100% !important;
  }

  .hadith-act-btn {
    justify-content: center !important;
    min-height: 38px !important;
    font-size: 0.8rem !important;
    padding: 6px 8px !important;
  }

  /* Footer */
  .site-footer {
    padding: 28px 0 16px !important;
    margin-top: 32px !important;
  }

  .footer-grid {
    grid-template-columns: 1fr !important;
    gap: 20px !important;
    margin-bottom: 20px !important;
  }

  .footer-bottom {
    flex-direction: column !important;
    text-align: center !important;
    gap: 10px !important;
  }

  /* Toast and Back to Top above bottom nav */
  #toast-notification {
    bottom: 74px !important;
  }

  #back-to-top-btn {
    bottom: 72px !important;
    left: 12px !important;
    width: 38px !important;
    height: 38px !important;
    font-size: 1rem !important;
  }
}

/* Very small phones */
@media (max-width: 480px) {
  .brand-title {
    font-size: 0.82rem !important;
  }

  .hadith-arabic-text {
    font-size: 1.18rem !important;
  }

  .hadith-english-text {
    font-size: 0.92rem !important;
  }

  .action-buttons-group {
    grid-template-columns: 1fr 1fr !important;
  }
}

/* ==========================================================================
   BOTTOM MOBILE NAVIGATION BAR (ENGLISH EDITION)
   ========================================================================== */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
  box-shadow: 0 -4px 16px rgba(0,0,0,0.08);
  z-index: 950;
  padding: 0 8px;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.mobile-bottom-nav-inner {
  display: flex;
  align-items: stretch;
  justify-content: space-around;
  height: 100%;
}

.mobile-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  flex: 1;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 0.65rem;
  font-weight: 600;
  padding: 4px 2px;
  border-radius: var(--border-radius-sm);
  transition: color var(--transition-fast), background var(--transition-fast);
  cursor: pointer;
  border: none;
  background: none;
  font-family: var(--font-sans);
}

.mobile-nav-item svg {
  transition: transform var(--transition-fast);
}

.mobile-nav-item:hover,
.mobile-nav-item.active {
  color: var(--primary);
}

.mobile-nav-item:hover svg,
.mobile-nav-item.active svg {
  transform: scale(1.1);
}

.mobile-nav-item.active .mobile-nav-dot {
  display: block;
}

.mobile-nav-dot {
  display: none;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--primary);
  margin-top: -2px;
}

@media (max-width: 768px) {
  .mobile-bottom-nav {
    display: flex;
    align-items: stretch;
  }
}

