/* Style commun pour toutes les pages d'études - Design académique spécial */
:root {
  --etudes-bg: #faf9f6;
  --etudes-paper: #ffffff;
  --etudes-muted: #6b7280;
  --etudes-accent: #2d3748;
  --etudes-accent-dark: #1a202c;
  --etudes-accent-light: #4a5568;
  --etudes-border: rgba(45, 55, 72, 0.15);
  --etudes-shadow: 0 8px 24px rgba(15, 23, 42, 0.1);
  --etudes-lines: rgba(45, 55, 72, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  font-family: 'Rubik', system-ui, -apple-system, 'Segoe UI', Arial, sans-serif;
  background: 
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 39px,
      var(--etudes-lines) 39px,
      var(--etudes-lines) 40px
    ),
    linear-gradient(180deg, #f1f5f9 0%, var(--etudes-bg) 100%);
  background-size: 100% 40px, 100% 100%;
  margin: 0;
  padding: 40px 20px;
  color: #0f172a;
  line-height: 1.7;
  position: relative;
}

body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: 
    radial-gradient(circle at 20% 30%, rgba(45, 55, 72, 0.03) 0%, transparent 50%),
    radial-gradient(circle at 80% 70%, rgba(45, 55, 72, 0.03) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

.wrap {
  max-width: 1000px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

/* Header avec style académique */
header {
  background: var(--etudes-paper);
  border-radius: 20px;
  padding: 32px 40px;
  margin-bottom: 32px;
  box-shadow: var(--etudes-shadow);
  border: 2px solid var(--etudes-border);
  border-top: 6px solid var(--etudes-accent);
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
}

header .header-back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--etudes-accent);
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  padding: 10px 16px;
  border-radius: 10px;
  background: rgba(45, 55, 72, 0.05);
  border: 1px solid var(--etudes-border);
  transition: all 0.3s ease;
  flex-shrink: 0;
  margin-top: 4px;
}

header .header-back-link:hover {
  background: rgba(45, 55, 72, 0.1);
  border-color: var(--etudes-accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(45, 55, 72, 0.15);
}

header .header-back-link span {
  font-size: 1.1rem;
}

header > div:first-of-type {
  display: flex;
  align-items: center;
  gap: 24px;
  flex: 1;
}

header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 6px;
  background: linear-gradient(90deg, var(--etudes-accent), var(--etudes-accent-light), var(--etudes-accent));
  background-size: 200% 100%;
  animation: shimmer 4s ease-in-out infinite;
}

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

header::after {
  content: '';
  position: absolute;
  top: 20px;
  right: 20px;
  width: 120px;
  height: 120px;
  background: radial-gradient(circle, rgba(45, 55, 72, 0.08) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}

.logo {
  width: 80px;
  height: 80px;
  border-radius: 20px;
  background: linear-gradient(135deg, var(--etudes-accent), var(--etudes-accent-dark));
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 700;
  box-shadow: 0 8px 24px rgba(45, 55, 72, 0.3);
  font-size: 32px;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}

.logo::after {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 20px;
  padding: 2px;
  background: linear-gradient(135deg, var(--etudes-accent-light), var(--etudes-accent));
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask-composite: exclude;
  opacity: 0.5;
}

h1 {
  font-size: 32px;
  margin: 0;
  color: #0f172a;
  font-weight: 700;
  position: relative;
  z-index: 1;
  background: linear-gradient(135deg, var(--etudes-accent-dark), var(--etudes-accent));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.5px;
}

p.lead {
  margin: 12px 0 0;
  color: var(--etudes-muted);
  font-size: 16px;
  line-height: 1.6;
  position: relative;
  z-index: 1;
  font-style: italic;
}

/* Navigation avec style spécial */
.nav-links {
  display: flex;
  gap: 12px;
  margin-bottom: 32px;
  flex-wrap: wrap;
}

.nav-links a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--etudes-accent);
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  padding: 12px 20px;
  border-radius: 12px;
  background: var(--etudes-paper);
  border: 2px solid var(--etudes-border);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.05);
  transition: all 0.3s ease;
}

.nav-links a:hover {
  background: linear-gradient(135deg, #f8fafc, #ffffff);
  border-color: var(--etudes-accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(45, 55, 72, 0.15);
}

.nav-links a span {
  font-size: 1.1rem;
}

/* Cards avec style papier académique */
.card {
  background: var(--etudes-paper);
  border-radius: 20px;
  padding: 40px;
  margin-top: 32px;
  box-shadow: var(--etudes-shadow);
  border: 2px solid var(--etudes-border);
  position: relative;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--etudes-accent), var(--etudes-accent-light));
}

.chapter-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--etudes-accent-dark);
  margin-bottom: 28px;
  padding-bottom: 16px;
  border-bottom: 3px solid var(--etudes-accent);
  display: flex;
  align-items: center;
  gap: 16px;
  position: relative;
}

.chapter-title::before {
  content: '';
  width: 6px;
  height: 32px;
  background: linear-gradient(180deg, var(--etudes-accent), var(--etudes-accent-light));
  border-radius: 3px;
  box-shadow: 0 2px 8px rgba(45, 55, 72, 0.3);
}

.content {
  white-space: normal;
  line-height: 1.9;
  color: #1e293b;
  font-size: 17px;
}

/* Verse sections avec style académique */
.verse-section {
  margin-bottom: 40px;
  padding: 24px;
  background: linear-gradient(180deg, #fafafa 0%, #ffffff 100%);
  border-radius: 16px;
  border-left: 5px solid var(--etudes-accent);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.06);
}

.verse-section h3 {
  font-size: 20px;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 2px solid #e2e8f0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.verse-section h3::before {
  content: '📖';
  font-size: 20px;
}

/* Blockquotes avec style élégant */
blockquote {
  background: linear-gradient(180deg, #f8fafc 0%, #ffffff 100%);
  border-left: 5px solid var(--etudes-accent);
  padding: 24px 28px;
  margin: 28px 0;
  border-radius: 16px;
  font-style: italic;
  line-height: 1.9;
  color: #334155;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.08);
  position: relative;
}

blockquote::before {
  content: '"';
  position: absolute;
  top: 10px;
  left: 10px;
  font-size: 60px;
  color: var(--etudes-accent);
  opacity: 0.2;
  font-family: Georgia, serif;
  line-height: 1;
}

blockquote cite {
  display: block;
  margin-top: 20px;
  font-size: 15px;
  font-style: normal;
  color: var(--etudes-muted);
  font-weight: 600;
  padding-top: 16px;
  border-top: 1px solid #e2e8f0;
}

/* Arabic verses avec style spécial */
.arabic-verse {
  font-family: 'Scheherazade New', 'Amiri', 'Noto Sans Arabic', serif;
  font-size: 28px;
  text-align: right;
  direction: rtl;
  margin: 20px 0;
  padding: 28px;
  background: linear-gradient(135deg, #f1f5f9 0%, #ffffff 100%);
  border-radius: 16px;
  line-height: 2.6;
  color: #0f172a;
  font-style: normal;
  border: 2px solid var(--etudes-border);
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.08);
  position: relative;
}

.arabic-verse::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 60px;
  height: 60px;
  background: radial-gradient(circle, rgba(45, 55, 72, 0.1) 0%, transparent 70%);
  border-radius: 0 16px 0 0;
}

/* Hadith boxes avec style académique */
.hadith-box {
  background: linear-gradient(180deg, #f7fafc 0%, #ffffff 100%);
  border-left: 5px solid #4a5568;
  padding: 28px 32px;
  margin: 32px 0;
  border-radius: 16px;
  font-size: 16px;
  line-height: 1.9;
  color: #1f2937;
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.1);
  position: relative;
}

.hadith-box::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: linear-gradient(180deg, #4a5568, #718096);
}

.hadith-box .hadith-title {
  font-weight: 700;
  color: #2d3748;
  margin-bottom: 16px;
  font-size: 18px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.hadith-arabic {
  font-family: 'Scheherazade New', 'Amiri', serif;
  font-size: 24px;
  text-align: right;
  direction: rtl;
  margin: 16px 0;
  padding: 20px;
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border-radius: 12px;
  line-height: 2.4;
  color: #0f172a;
  border: 1px solid rgba(245, 158, 11, 0.2);
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.1);
}

/* Tableaux pour versets/hadiths - Arabe à gauche, traduction à droite */
.verse-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin: 32px 0;
  background: var(--etudes-paper);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--etudes-shadow);
  border: 2px solid var(--etudes-border);
}

.verse-table thead {
  background: linear-gradient(135deg, var(--etudes-accent), var(--etudes-accent-dark));
  color: #ffffff;
}

.verse-table thead th {
  padding: 18px 24px;
  font-weight: 700;
  font-size: 16px;
  text-align: left;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.verse-table thead th:first-child {
  border-radius: 16px 0 0 0;
  text-align: right;
  direction: rtl;
}

.verse-table thead th:last-child {
  border-radius: 0 16px 0 0;
}

.verse-table tbody tr {
  transition: background-color 0.2s ease;
}

.verse-table tbody tr:nth-child(even) {
  background: linear-gradient(180deg, #fafafa 0%, #ffffff 100%);
}

.verse-table tbody tr:hover {
  background: linear-gradient(180deg, #f1f5f9 0%, #f8fafc 100%);
}

.verse-table tbody td {
  padding: 24px;
  vertical-align: top;
  border-top: 1px solid #e2e8f0;
}

.verse-table tbody td:first-child {
  text-align: right;
  direction: rtl;
  font-family: 'Scheherazade New', 'Amiri', 'Noto Sans Arabic', serif;
  font-size: 26px;
  line-height: 2.4;
  color: #0f172a;
  width: 50%;
  border-right: 2px solid var(--etudes-border);
  background: linear-gradient(135deg, #f8fafc 0%, #ffffff 100%);
  position: relative;
}

.verse-table tbody td:first-child::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 4px;
  height: 100%;
  background: linear-gradient(180deg, var(--etudes-accent), var(--etudes-accent-light));
  opacity: 0.3;
}

.verse-table tbody td:last-child {
  font-size: 17px;
  line-height: 1.9;
  color: #334155;
  width: 50%;
  font-style: italic;
}

.verse-table tbody tr:first-child td {
  border-top: none;
}

.verse-table .verse-ref {
  display: block;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid #e2e8f0;
  font-size: 14px;
  font-style: normal;
  color: var(--etudes-muted);
  font-weight: 600;
  text-align: center;
}

.verse-table .verse-ref::before {
  content: '— ';
}

/* Variante pour hadiths */
.hadith-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin: 32px 0;
  background: linear-gradient(180deg, #f7fafc 0%, #ffffff 100%);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.1);
  border: 2px solid rgba(45, 55, 72, 0.2);
  border-left: 5px solid #4a5568;
}

.hadith-table thead {
  background: linear-gradient(135deg, #4a5568, #2d3748);
  color: #ffffff;
}

.hadith-table thead th {
  padding: 18px 24px;
  font-weight: 700;
  font-size: 16px;
  text-align: left;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.hadith-table thead th:first-child {
  border-radius: 16px 0 0 0;
  text-align: right;
  direction: rtl;
}

.hadith-table thead th:last-child {
  border-radius: 0 16px 0 0;
}

.hadith-table tbody tr {
  transition: background-color 0.2s ease;
}

.hadith-table tbody tr:nth-child(even) {
  background: linear-gradient(180deg, #e2e8f0 0%, #ffffff 100%);
}

.hadith-table tbody tr:hover {
  background: linear-gradient(180deg, #cbd5e0 0%, #e2e8f0 100%);
}

.hadith-table tbody td {
  padding: 24px;
  vertical-align: top;
  border-top: 1px solid rgba(245, 158, 11, 0.2);
}

.hadith-table tbody td:first-child {
  text-align: right;
  direction: rtl;
  font-family: 'Scheherazade New', 'Amiri', serif;
  font-size: 24px;
  line-height: 2.4;
  color: #0f172a;
  width: 50%;
  border-right: 2px solid rgba(45, 55, 72, 0.2);
  background: linear-gradient(135deg, #e2e8f0 0%, #cbd5e0 100%);
  position: relative;
}

.hadith-table tbody td:first-child::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 4px;
  height: 100%;
  background: linear-gradient(180deg, #4a5568, #718096);
  opacity: 0.4;
}

.hadith-table tbody td:last-child {
  font-size: 17px;
  line-height: 1.9;
  color: #334155;
  width: 50%;
  font-style: italic;
}

.hadith-table tbody tr:first-child td {
  border-top: none;
}

.hadith-table .hadith-ref {
  display: block;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid rgba(245, 158, 11, 0.2);
  font-size: 14px;
  font-style: normal;
  color: #2d3748;
  font-weight: 600;
  text-align: center;
}

.hadith-table .hadith-ref::before {
  content: '— ';
}

/* Footer avec style académique */
footer {
  margin-top: 48px;
  padding: 32px;
  text-align: center;
  color: var(--etudes-muted);
  font-size: 15px;
  background: var(--etudes-paper);
  border-radius: 20px;
  box-shadow: var(--etudes-shadow);
  border: 2px solid var(--etudes-border);
  border-top: 4px solid var(--etudes-accent);
}

/* Responsive */
@media (max-width: 768px) {
  body {
    padding: 24px 16px;
    background-size: 100% 35px, 100% 100%;
  }
  
  header {
    padding: 24px 28px;
    border-radius: 16px;
    flex-direction: column;
    align-items: stretch;
  }
  
  header > div:first-of-type {
    flex-direction: row;
    align-items: center;
  }
  
  header .header-back-link {
    margin-top: 16px;
    width: 100%;
    justify-content: center;
  }
  
  .logo {
    width: 64px;
    height: 64px;
    font-size: 28px;
  }
  
  h1 {
    font-size: 24px;
  }
  
  .card {
    padding: 28px 24px;
    border-radius: 16px;
  }
  
  .arabic-verse {
    font-size: 24px;
    line-height: 2.2;
    padding: 20px;
  }
  
  .hadith-arabic {
    font-size: 20px;
  }
  
  .chapter-title {
    font-size: 20px;
  }
  
  .verse-section {
    padding: 20px;
  }
  
  /* Tableaux responsive */
  .verse-table,
  .hadith-table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  .verse-table thead,
  .hadith-table thead {
    display: none;
  }
  
  .verse-table tbody,
  .hadith-table tbody,
  .verse-table tr,
  .hadith-table tr,
  .verse-table td,
  .hadith-table td {
    display: block;
    width: 100%;
  }
  
  .verse-table tbody tr,
  .hadith-table tbody tr {
    margin-bottom: 24px;
    border: 2px solid var(--etudes-border);
    border-radius: 12px;
    overflow: hidden;
    background: var(--etudes-paper);
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
  }
  
  .verse-table tbody td:first-child,
  .hadith-table tbody td:first-child {
    border-right: none;
    border-bottom: 2px solid var(--etudes-border);
    padding: 20px;
    font-size: 22px;
  }
  
  .verse-table tbody td:last-child,
  .hadith-table tbody td:last-child {
    padding: 20px;
  }
  
  .verse-table .verse-ref,
  .hadith-table .hadith-ref {
    margin-top: 12px;
    padding-top: 12px;
  }
}

/* Table of contents navigation */
.table-of-contents {
  background: var(--etudes-card);
  border-radius: var(--etudes-radius);
  padding: 20px 24px;
  margin: 24px 0;
  box-shadow: var(--etudes-shadow);
  border-top: 4px solid var(--etudes-accent);
}

.table-of-contents h2 {
  margin: 0 0 16px 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--etudes-accent);
  display: flex;
  align-items: center;
  gap: 8px;
}

.table-of-contents ol {
  margin: 0;
  padding-left: 24px;
  list-style: none;
  counter-reset: chapter-counter;
}

.table-of-contents li {
  counter-increment: chapter-counter;
  margin: 8px 0;
}

.table-of-contents a {
  color: var(--etudes-text);
  text-decoration: none;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  transition: color 0.2s;
}

.table-of-contents a:hover {
  color: var(--etudes-accent);
}

.table-of-contents a span:first-child {
  color: var(--etudes-accent);
  font-weight: 700;
  min-width: 24px;
}

@media (max-width: 480px) {
  h1 {
    font-size: 20px;
  }
  
  .arabic-verse {
    font-size: 22px;
  }
  
  .card {
    padding: 24px 20px;
  }
  
  header {
    padding: 20px 24px;
  }
  
  .table-of-contents {
    padding: 16px 18px;
  }
  
  .table-of-contents h2 {
    font-size: 16px;
  }
}
