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

:root {
  --primary-green: #1b7a66;
  --primary-green-dark: #125547;
  --primary-green-light: #2da188;
  --primary-accent: #26a69a;
  --parchment-bg: #f8f3e6;
  --parchment-text: #261e14;
  --parchment-border: #e2d6bf;
  --font-arabic-classic: 'Amiri', 'Traditional Arabic', serif;
  --font-arabic-quran: 'Scheherazade New', 'Amiri', serif;
  --font-ui: 'Cairo', 'Tajawal', system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  font-family: var(--font-ui);
  direction: rtl;
  text-align: right;
  background-color: #f7f9fa;
  color: #2d3748;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: rgba(0,0,0,0.05);
}
::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--primary-green);
}

/* Logo Calligraphy Style */
.shamela-logo {
  font-family: 'Amiri', serif;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--primary-green);
}

/* Realistic 3D Book Cover */
.book-3d-wrapper {
  perspective: 900px;
  display: inline-block;
  transition: transform 0.3s ease;
}

.book-3d-wrapper:hover {
  transform: translateY(-6px) rotateY(-8deg);
}

.book-3d {
  position: relative;
  width: 130px;
  height: 185px;
  border-radius: 4px 10px 10px 4px;
  box-shadow: 
    -4px 4px 12px rgba(0, 0, 0, 0.15),
    -10px 10px 25px rgba(0, 0, 0, 0.1),
    inset 4px 0 8px rgba(0, 0, 0, 0.25);
  background-color: #ffffff;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 12px 10px;
  text-align: center;
  border: 1px solid rgba(0,0,0,0.08);
}

/* 3D Spine Highlight Effect */
.book-3d::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 14px;
  height: 100%;
  background: linear-gradient(90deg, 
    rgba(255,255,255,0.4) 0%, 
    rgba(0,0,0,0.15) 30%, 
    rgba(255,255,255,0.1) 60%, 
    rgba(0,0,0,0.12) 100%);
  pointer-events: none;
  z-index: 5;
}

/* Book Pattern Styles */
.book-theme-green {
  background: linear-gradient(145deg, #ffffff 0%, #f4faf7 100%);
  border: 2px solid #2da188;
}
.book-theme-green .pattern-box {
  border: 2px solid #1b7a66;
  border-radius: 6px;
  padding: 8px 4px;
  background: radial-gradient(circle, rgba(27,122,102,0.06) 0%, rgba(255,255,255,0) 70%);
}

.book-theme-leather {
  background: linear-gradient(135deg, #442a15 0%, #291709 100%);
  color: #f7d58b !important;
  border: 2px solid #b8860b;
  box-shadow: 
    -4px 4px 12px rgba(0, 0, 0, 0.3),
    inset 4px 0 10px rgba(0, 0, 0, 0.6);
}
.book-theme-leather .pattern-box {
  border: 2px solid #d4af37;
  border-radius: 6px;
  padding: 8px 4px;
  background: rgba(0,0,0,0.2);
}
.book-theme-leather .book-title {
  color: #ffd700 !important;
  text-shadow: 0 1px 2px rgba(0,0,0,0.8);
}
.book-theme-leather .book-author {
  color: #e6ca65 !important;
}

.book-theme-antique {
  background: linear-gradient(135deg, #f7ebd2 0%, #ecd9b5 100%);
  color: #3d2c14 !important;
  border: 2px solid #c2a677;
}
.book-theme-antique .pattern-box {
  border: 2px double #8c6d3f;
  border-radius: 4px;
  padding: 8px 4px;
}

.book-theme-navy {
  background: linear-gradient(135deg, #102a43 0%, #061524 100%);
  color: #e2e8f0 !important;
  border: 2px solid #334e68;
  box-shadow: -4px 4px 12px rgba(0, 0, 0, 0.3), inset 4px 0 10px rgba(0, 0, 0, 0.6);
}
.book-theme-navy .pattern-box {
  border: 2px solid #627d98;
  border-radius: 6px;
  padding: 8px 4px;
  background: rgba(0,0,0,0.25);
}
.book-theme-navy .book-title {
  color: #f0b429 !important;
  text-shadow: 0 1px 2px rgba(0,0,0,0.8);
}
.book-theme-navy .book-author {
  color: #9fb3c8 !important;
}

.book-theme-ruby {
  background: linear-gradient(135deg, #4a0e17 0%, #2b050c 100%);
  color: #fed7d7 !important;
  border: 2px solid #9b2c2c;
  box-shadow: -4px 4px 12px rgba(0, 0, 0, 0.3), inset 4px 0 10px rgba(0, 0, 0, 0.6);
}
.book-theme-ruby .pattern-box {
  border: 2px solid #d4af37;
  border-radius: 6px;
  padding: 8px 4px;
  background: rgba(0,0,0,0.25);
}
.book-theme-ruby .book-title {
  color: #ffd700 !important;
  text-shadow: 0 1px 2px rgba(0,0,0,0.8);
}
.book-theme-ruby .book-author {
  color: #feb2b2 !important;
}

/* Custom Uploaded Image Cover inside 3D Book Shell */
.book-3d.book-has-image {
  padding: 0 !important;
  background-color: #f8f9fa;
  border: 1px solid rgba(0,0,0,0.15);
}
.book-3d.book-has-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Book Sizes */
.book-3d.book-sm {
  width: 80px;
  height: 114px;
  padding: 6px 4px;
}
.book-3d.book-sm .pattern-box {
  padding: 2px;
}
.book-3d.book-sm .book-title {
  font-size: 8px;
  line-height: 1.1;
}
.book-3d.book-sm .book-author {
  font-size: 7px;
}

.book-3d.book-lg {
  width: 160px;
  height: 228px;
  padding: 16px 12px;
}
.book-3d.book-lg .book-title {
  font-size: 13px;
}

/* Islamic Geometric Pattern Motif (SVG inline background) */
.islamic-motif {
  background-image: radial-gradient(#1b7a66 1px, transparent 1px), radial-gradient(#1b7a66 1px, #ffffff 1px);
  background-size: 20px 20px;
  background-position: 0 0, 10px 10px;
  opacity: 0.08;
}

/* Reader Container Themes */
.theme-parchment {
  background-color: var(--parchment-bg) !important;
  color: var(--parchment-text) !important;
}
.theme-parchment .reader-paper {
  background-color: #faf5e8;
  box-shadow: 0 4px 20px rgba(74, 53, 20, 0.08);
  border: 1px solid var(--parchment-border);
}

.theme-white {
  background-color: #f8fafc !important;
  color: #1e293b !important;
}
.theme-white .reader-paper {
  background-color: #ffffff;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
  border: 1px solid #e2e8f0;
}

.theme-dark {
  background-color: #12161a !important;
  color: #e2e8f0 !important;
}
.theme-dark .reader-paper {
  background-color: #1a2026 !important;
  color: #e2e8f0 !important;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  border: 1px solid #2d3748;
}
.theme-dark .reader-topbar,
.theme-dark .reader-bottombar {
  background-color: #161b20 !important;
  border-color: #2d3748 !important;
  color: #e2e8f0 !important;
}
.theme-dark .toolbar-btn {
  color: #94a3b8 !important;
}
.theme-dark .toolbar-btn:hover,
.theme-dark .toolbar-btn.active {
  color: #38bdf8 !important;
}

.theme-green {
  background-color: #eaf3ed !important;
  color: #1a3325 !important;
}
.theme-green .reader-paper {
  background-color: #f2f8f4;
  box-shadow: 0 4px 20px rgba(27, 122, 102, 0.08);
  border: 1px solid #cce3d4;
}

/* Kitab Typography */
.arabic-content {
  font-family: var(--font-arabic-classic);
  font-size: 23px;
  line-height: 2.1;
  text-align: justify;
  text-justify: inter-word;
  word-spacing: 2px;
  direction: rtl;
  user-select: text;
}

.font-amiri {
  font-family: 'Amiri', serif !important;
}
.font-scheherazade {
  font-family: 'Scheherazade New', serif !important;
}
.font-cairo {
  font-family: 'Cairo', sans-serif !important;
}

/* Harakat / Tashkeel hiding logic */
.hide-tashkeel {
  /* will be dynamically handled or via font features */
}

/* Reader Toolbar Button */
.toolbar-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  font-size: 11px;
  color: #475569;
  border-radius: 8px;
  transition: all 0.2s ease;
  cursor: pointer;
  border: none;
  background: transparent;
  text-decoration: none;
}
.toolbar-btn i {
  font-size: 18px;
  margin-bottom: 3px;
}
.toolbar-btn:hover {
  background-color: rgba(27, 122, 102, 0.08);
  color: var(--primary-green);
}
.toolbar-btn.active {
  color: var(--primary-green);
  font-weight: bold;
}

/* Bottom App Navigation for Mobile */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 64px;
  background: #ffffff;
  border-top: 1px solid #e2e8f0;
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 40;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #64748b;
  font-size: 12px;
  font-weight: 500;
  text-decoration: none;
  transition: color 0.2s;
  padding: 6px 12px;
}

.bottom-nav-item.active {
  color: var(--primary-green);
  font-weight: 700;
}

.bottom-nav-item i {
  font-size: 20px;
  margin-bottom: 2px;
}

/* Drawer / Modal Animation */
.drawer {
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.drawer-closed {
  transform: translateX(100%);
}
.drawer-open {
  transform: translateX(0);
}

/* Luxury Islamic Category Card */
.category-card {
  background: #ffffff;
  border: 1px solid rgba(180, 83, 9, 0.12);
  border-radius: 20px;
  padding: 20px 22px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03), 0 1px 2px rgba(0, 0, 0, 0.02);
  transition: all 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  display: block;
  text-decoration: none;
  position: relative;
  overflow: hidden;
}

.category-card::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 3.5px;
  background: linear-gradient(90deg, #047857 0%, #10b981 50%, #d97706 100%);
  opacity: 0;
  transition: opacity 0.25s ease;
}

.category-card:hover {
  border-color: rgba(5, 150, 105, 0.45);
  box-shadow: 0 14px 30px -6px rgba(6, 78, 59, 0.12), 0 8px 14px -4px rgba(0, 0, 0, 0.04);
  transform: translateY(-4px);
}

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

/* Luxury Book Item Card */
.book-item-card {
  background: #ffffff;
  border: 1px solid rgba(180, 83, 9, 0.1);
  border-radius: 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
  transition: all 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}

.book-item-card:hover {
  border-color: rgba(5, 150, 105, 0.35);
  box-shadow: 0 14px 30px -8px rgba(6, 78, 59, 0.14);
  transform: translateY(-4px);
}

/* Tab indicator */
.tab-link {
  padding: 10px 16px;
  color: #64748b;
  font-weight: 600;
  border-bottom: 3px solid transparent;
  text-decoration: none;
  transition: all 0.2s ease;
  white-space: nowrap;
}
.tab-link.active {
  color: var(--primary-green);
  border-bottom-color: var(--primary-green);
}

/* Floating Action Button */
.fab-btn {
  position: fixed;
  bottom: 80px;
  left: 20px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--primary-green);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(27, 122, 102, 0.4);
  cursor: pointer;
  z-index: 35;
  transition: all 0.2s;
}
.fab-btn:hover {
  background: var(--primary-green-dark);
  transform: scale(1.05);
}

/* ==========================================================================
   Kitab Footnotes & Tahqiq (الهامش والتحقيق)
   ========================================================================== */
html {
  scroll-behavior: smooth;
}

.footnote-ref {
  cursor: pointer;
  font-weight: 700;
  transition: all 0.15s ease;
  vertical-align: baseline;
  position: relative;
  top: -0.4em;
  font-size: 0.82em;
}
.footnote-ref:hover {
  text-decoration: underline;
  color: #b45309;
}

.footnote-divider-wrap {
  margin: 2.5rem 0 1rem 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.footnote-divider-line {
  width: 140px;
  height: 1.5px;
  background-color: currentColor;
  opacity: 0.35;
}

.footnotes-box {
  font-size: 0.88em;
  opacity: 0.95;
  border-top: 1px dashed rgba(120, 80, 40, 0.25);
  padding-top: 1rem;
  margin-top: 2rem;
}

.theme-dark .footnotes-box {
  border-top-color: rgba(255, 255, 255, 0.15);
}

.footnote-item {
  scroll-margin-top: 90px;
  border-radius: 6px;
  transition: background-color 0.3s ease;
}

.footnote-item:target {
  background-color: rgba(234, 179, 8, 0.22);
  padding-right: 6px;
  padding-left: 6px;
}

.footnote-backlink {
  cursor: pointer;
  padding: 0 4px;
}

/* Numbered Paragraph Badges (فقرات المتن المرقّمة) */
.kitab-point-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-arabic-classic), 'Amiri', serif;
  font-weight: 700;
  font-size: 0.85em;
  color: #065f46;
  background-color: #d1fae5;
  border: 1px solid #6ee7b7;
  border-radius: 8px;
  padding: 1px 8px;
  margin-inline-end: 8px;
  margin-inline-start: 2px;
  line-height: 1.5;
  vertical-align: middle;
  user-select: none;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.theme-dark .kitab-point-badge {
  color: #a7f3d0;
  background-color: rgba(6, 78, 59, 0.5);
  border-color: #047857;
}

.theme-parchment .kitab-point-badge {
  color: #064e3b;
  background-color: #dcfce7;
  border-color: #86efac;
}

/* Decorative Section / Rubric Badges */
.kitab-section-badge {
  display: inline-block;
  font-family: var(--font-arabic-classic), 'Amiri', serif;
  font-weight: 700;
  color: #064e3b;
  background-color: #fef3c7;
  border: 1px solid #fde68a;
  border-radius: 8px;
  padding: 2px 10px;
  margin: 4px 6px;
  line-height: 1.6;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}
.theme-dark .kitab-section-badge {
  color: #fef3c7;
  background-color: rgba(180, 83, 9, 0.35);
  border-color: #b45309;
}
.theme-parchment .kitab-section-badge {
  color: #064e3b;
  background-color: #fef3c7;
  border-color: #fcd34d;
}

/* Language Dropdown (Model Dropdown Hemat Ruang) */
details.lang-dropdown summary::-webkit-details-marker {
  display: none;
}
details.lang-dropdown summary {
  list-style: none;
}
details.lang-dropdown summary::-moz-list-bullet {
  list-style-type: none;
}
details.lang-dropdown summary::marker {
  display: none;
}


