/* Custom Styles for Arabic Educational Notes Platform */
@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;500;600;700;800;900&family=Tajawal:wght@400;500;700;900&display=swap');

:root {
  --font-cairo: 'Cairo', system-ui, -apple-system, sans-serif;
  --font-tajawal: 'Tajawal', system-ui, -apple-system, sans-serif;
  --primary-gradient: linear-gradient(135deg, #e11d48 0%, #ec4899 50%, #8b5cf6 100%);
  --secondary-gradient: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
  --hero-bg: linear-gradient(180deg, #fff1f2 0%, #faf5ff 50%, #ffffff 100%);
}

* {
  font-family: var(--font-cairo);
  box-sizing: border-box;
}

/* Base Hyperlink Styling - Prevent browser default blue/purple colors */
a, a:visited {
  color: inherit;
  text-decoration: none;
}

body {
  direction: rtl;
  text-align: right;
  background-color: #f8fafc;
  color: #1e293b;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: #f1f5f9;
}

::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 9999px;
}

::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Brand Gradients */
.bg-brand-gradient {
  background: linear-gradient(135deg, #e11d48 0%, #d946ef 50%, #7c3aed 100%);
}

.text-brand-gradient {
  background: linear-gradient(135deg, #e11d48 0%, #c026d3 50%, #7c3aed 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Subject Badges & Themes */
.badge-arabic {
  background-color: #ffe4e6;
  color: #be123c;
  border: 1px solid #fecdd3;
}

.badge-math {
  background-color: #d1fae5;
  color: #047857;
  border: 1px solid #a7f3d0;
}

.badge-english {
  background-color: #fef3c7;
  color: #b45309;
  border: 1px solid #fde68a;
}

.badge-science {
  background-color: #ede9fe;
  color: #6d28d9;
  border: 1px solid #ddd6fe;
}

.badge-social {
  background-color: #e0f2fe;
  color: #0369a1;
  border: 1px solid #bae6fd;
}

.badge-math-lang {
  background-color: #e0e7ff;
  color: #4338ca;
  border: 1px solid #c7d2fe;
}

.badge-religion {
  background-color: #dcfce7;
  color: #15803d;
  border: 1px solid #bbf7d0;
}

.badge-ict {
  background-color: #ccfbf1;
  color: #0f766e;
  border: 1px solid #99f6e4;
}

/* Card Hover Animation */
.card-hover {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.card-hover:hover {
  transform: translateY(-5px);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.08), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

/* Hero Badge */
.hero-badge {
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(225, 29, 72, 0.15);
  box-shadow: 0 4px 15px rgba(225, 29, 72, 0.08);
}

/* ==========================================================================
   Article & Content Styles (Typography consolidated in dedicated section below)
   ========================================================================== */

/* ==========================================================
   DYNAMIC TABLE OF CONTENTS (TOC) - جدول المحتويات التلقائي
   ========================================================== */
:root {
  --toc-bg: #ffffff;
  --toc-border-color: #e2e8f0;
  --toc-border-radius: 1.25rem;
  --toc-shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.04), 0 4px 10px -2px rgba(15, 23, 42, 0.02);
  --toc-title-color: #0f172a;
  --toc-icon-color: #e11d48;
  --toc-icon-bg: #fff1f2;
  --toc-link-color: #334155;
  --toc-link-hover-color: #e11d48;
  --toc-link-active-color: #be123c;
  --toc-num-color: #64748b;
  --toc-sub-border-color: #e2e8f0;
  --toc-toggle-bg: #f8fafc;
  --toc-toggle-color: #475569;
  --toc-toggle-hover-bg: #f1f5f9;
  --toc-font-size: 0.935rem;
  --toc-padding: 1.25rem 1.5rem;
  --toc-margin: 1.75rem 0 2.25rem;
}

/* Master TOC Card */
.mozkrat-toc-box {
  position: relative;
  background-color: var(--toc-bg) !important;
  border: 1px solid var(--toc-border-color) !important;
  border-top: 3.5px solid #e11d48 !important;
  border-radius: var(--toc-border-radius) !important;
  box-shadow: var(--toc-shadow) !important;
  padding: var(--toc-padding) !important;
  margin: var(--toc-margin) !important;
  direction: rtl !important;
  text-align: right !important;
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
  overflow: hidden;
}

.mozkrat-toc-box:hover {
  border-color: #cbd5e1 !important;
  border-top-color: #be123c !important;
  box-shadow: 0 14px 30px -5px rgba(15, 23, 42, 0.07), 0 6px 14px -2px rgba(15, 23, 42, 0.03) !important;
}

/* Header Section */
.mozkrat-toc-header {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 0.75rem !important;
  padding-bottom: 0.85rem !important;
  border-bottom: 1px solid #f1f5f9 !important;
}

.mozkrat-toc-title-wrap {
  display: flex !important;
  align-items: center !important;
  gap: 0.65rem !important;
  flex-wrap: wrap !important;
}

.mozkrat-toc-icon-badge {
  width: 2.25rem !important;
  height: 2.25rem !important;
  border-radius: 0.75rem !important;
  background: linear-gradient(135deg, #fff1f2 0%, #ffe4e6 100%) !important;
  border: 1px solid #fecdd3 !important;
  color: var(--toc-icon-color) !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  font-size: 0.9rem !important;
  flex-shrink: 0 !important;
  box-shadow: 0 2px 5px rgba(225, 29, 72, 0.08) !important;
}

.mozkrat-toc-title {
  margin: 0 !important;
  padding: 0 !important;
  border: none !important;
  background: transparent !important;
  font-size: 1.1rem !important;
  font-weight: 800 !important;
  color: var(--toc-title-color) !important;
  line-height: 1.3 !important;
  letter-spacing: -0.01em !important;
}

.mozkrat-toc-count-badge {
  display: inline-flex !important;
  align-items: center !important;
  background-color: #f1f5f9 !important;
  color: #64748b !important;
  font-size: 0.72rem !important;
  font-weight: 700 !important;
  padding: 0.15rem 0.55rem !important;
  border-radius: 9999px !important;
  border: 1px solid #e2e8f0 !important;
}

/* Toggle Accordion Button */
.mozkrat-toc-toggle {
  display: inline-flex !important;
  align-items: center !important;
  gap: 0.45rem !important;
  padding: 0.35rem 0.85rem !important;
  border-radius: 0.625rem !important;
  background-color: var(--toc-toggle-bg) !important;
  color: var(--toc-toggle-color) !important;
  border: 1px solid #e2e8f0 !important;
  font-size: 0.78rem !important;
  font-weight: 700 !important;
  cursor: pointer !important;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
  user-select: none !important;
  outline: none !important;
}

.mozkrat-toc-toggle:hover {
  background-color: var(--toc-toggle-hover-bg) !important;
  border-color: #cbd5e1 !important;
  color: #0f172a !important;
  transform: translateY(-1px) !important;
}

.mozkrat-toc-toggle:active {
  transform: translateY(0) !important;
}

.mozkrat-toc-toggle-icon {
  font-size: 0.75rem !important;
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

.mozkrat-toc-toggle[aria-expanded="false"] .mozkrat-toc-toggle-icon {
  transform: rotate(180deg) !important;
}

/* Nav Container & Collapsed Animation */
.mozkrat-toc-nav {
  padding-top: 0.85rem !important;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

.mozkrat-toc-nav.collapsed {
  display: none !important;
}

/* List Reset: Strictly isolate from file-rich-content ol/ul rules */
.file-rich-content .mozkrat-toc-box ol,
.file-rich-content .mozkrat-toc-box ul,
.mozkrat-toc-list,
.mozkrat-toc-sublist {
  list-style: none !important;
  list-style-type: none !important;
  margin: 0 !important;
  padding: 0 !important;
}

.file-rich-content .mozkrat-toc-box li,
.mozkrat-toc-item {
  list-style: none !important;
  list-style-type: none !important;
  margin: 0.3rem 0 !important;
  padding: 0 !important;
  line-height: inherit !important;
}

/* Interactive TOC Item Links */
.file-rich-content .mozkrat-toc-box a.mozkrat-toc-link,
.mozkrat-toc-link {
  display: flex !important;
  align-items: center !important;
  gap: 0.65rem !important;
  color: var(--toc-link-color) !important;
  font-size: var(--toc-font-size) !important;
  font-weight: 700 !important;
  text-decoration: none !important;
  padding: 0.45rem 0.75rem !important;
  border-radius: 0.625rem !important;
  border-right: 3px solid transparent !important;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
  background: transparent !important;
}

.file-rich-content .mozkrat-toc-box a.mozkrat-toc-link:hover,
.mozkrat-toc-link:hover {
  color: var(--toc-link-hover-color) !important;
  background-color: #fff1f2 !important;
  border-right-color: #f43f5e !important;
  transform: translateX(-4px) !important;
}

.file-rich-content .mozkrat-toc-box a.mozkrat-toc-link.active,
.mozkrat-toc-link.active {
  color: var(--toc-link-active-color) !important;
  background-color: #ffe4e6 !important;
  border-right-color: #e11d48 !important;
  font-weight: 800 !important;
}

/* Hierarchical Number Badges */
.mozkrat-toc-num {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  min-width: 1.7rem !important;
  height: 1.7rem !important;
  padding: 0 0.35rem !important;
  background-color: #f1f5f9 !important;
  color: var(--toc-num-color) !important;
  font-weight: 800 !important;
  font-size: 0.78rem !important;
  border-radius: 0.5rem !important;
  font-family: inherit !important;
  direction: ltr !important;
  transition: all 0.2s ease !important;
  flex-shrink: 0 !important;
}

.mozkrat-toc-link:hover .mozkrat-toc-num,
.mozkrat-toc-link.active .mozkrat-toc-num {
  background-color: #e11d48 !important;
  color: #ffffff !important;
}

.mozkrat-toc-text {
  flex-grow: 1 !important;
  line-height: 1.5 !important;
}

/* Indented H3 Sub-Items (Tree structure) */
.mozkrat-toc-sublist {
  margin-right: 1.6rem !important;
  padding-right: 0.75rem !important;
  border-right: 2px dashed var(--toc-sub-border-color) !important;
  margin-top: 0.25rem !important;
  margin-bottom: 0.4rem !important;
}

.file-rich-content .mozkrat-toc-box .mozkrat-toc-h3 a.mozkrat-toc-link,
.mozkrat-toc-h3 .mozkrat-toc-link {
  font-size: calc(var(--toc-font-size) - 0.065rem) !important;
  font-weight: 600 !important;
  color: #475569 !important;
  padding: 0.35rem 0.6rem !important;
}

.mozkrat-toc-h3 .mozkrat-toc-num {
  min-width: 1.5rem !important;
  height: 1.5rem !important;
  font-size: 0.72rem !important;
  background-color: transparent !important;
  border: 1px solid #e2e8f0 !important;
  color: #94a3b8 !important;
}

.mozkrat-toc-h3 .mozkrat-toc-link:hover .mozkrat-toc-num,
.mozkrat-toc-h3 .mozkrat-toc-link.active .mozkrat-toc-num {
  background-color: #f43f5e !important;
  border-color: #f43f5e !important;
  color: #ffffff !important;
}

/* Heading Anchor Offset for sticky navbars */
.mozkrat-heading-anchor {
  scroll-margin-top: 105px !important;
}

@media (max-width: 640px) {
  .mozkrat-toc-box {
    padding: 1rem 1.15rem !important;
    border-radius: 1rem !important;
  }
  .mozkrat-toc-sublist {
    margin-right: 1rem !important;
    padding-right: 0.5rem !important;
  }
}

/* ==========================================================
   MEMO PAGES PREVIEW GALLERY - صفحات معاينة من داخل الملف
   ========================================================== */
.memo-page-card {
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
}

.memo-page-frame {
  background: #ffffff !important;
  border: 1px solid #e2e8f0 !important;
  border-radius: 1rem !important;
  padding: 0.65rem !important;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04) !important;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
  width: 100% !important;
}

.memo-page-card:hover .memo-page-frame {
  transform: translateY(-4px) !important;
  box-shadow: 0 14px 30px -5px rgba(15, 23, 42, 0.12), 0 6px 12px -2px rgba(15, 23, 42, 0.04) !important;
  border-color: #cbd5e1 !important;
}

.memo-page-frame a {
  display: block !important;
  aspect-ratio: 1 / 1.414 !important;
  overflow: hidden !important;
  border-radius: 0.65rem !important;
  background-color: #f8fafc !important;
}

.memo-page-frame img {
  width: 100% !important;
  height: 100% !important;
  object-fit: contain !important;
  display: block !important;
  transition: transform 0.3s ease !important;
}

.memo-page-card:hover .memo-page-frame img {
  transform: scale(1.02) !important;
}

.memo-page-caption {
  margin-top: 0.75rem !important;
  font-size: 0.875rem !important;
  font-weight: 700 !important;
  color: #475569 !important;
  text-align: center !important;
  transition: color 0.2s ease !important;
}

.memo-page-card:hover .memo-page-caption {
  color: #e11d48 !important;
}

/* ==========================================================
   RICH EDUCATIONAL CONTENT TYPOGRAPHY & LUXURY STYLING
   ========================================================== */
.file-rich-content {
  direction: rtl !important;
  text-align: right !important;
  color: #334155 !important;
  font-weight: 400 !important;
  line-height: 2.15 !important;
  font-size: 1.05rem !important;
  word-break: break-word !important;
}

/* Headings with Modern Educational Ribbons */
.file-rich-content h2 {
  display: flex !important;
  align-items: center !important;
  direction: rtl !important;
  text-align: right !important;
  font-size: 1.35rem !important;
  font-weight: 900 !important;
  color: #0f172a !important;
  border: none !important;
  border-right: 5px solid #e11d48 !important;
  background: linear-gradient(to left, rgba(255, 241, 242, 0.9), rgba(248, 250, 252, 0.4)) !important;
  border-radius: 0 0.6rem 0.6rem 0 !important;
  padding: 0.6rem 1.15rem !important;
  margin: 2.25rem 0 1.25rem !important;
  line-height: 1.5 !important;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.03) !important;
}

.file-rich-content h3 {
  display: block !important;
  direction: rtl !important;
  text-align: right !important;
  font-size: 1.18rem !important;
  font-weight: 800 !important;
  color: #1e293b !important;
  border: none !important;
  border-right: 4px solid #f43f5e !important;
  background: #f8fafc !important;
  padding: 0.45rem 1rem !important;
  border-radius: 0 0.5rem 0.5rem 0 !important;
  margin: 1.85rem 0 1rem !important;
  line-height: 1.5 !important;
  border-bottom: 1px solid #f1f5f9 !important;
}

.file-rich-content h4 {
  display: block !important;
  direction: rtl !important;
  text-align: right !important;
  font-size: 1.05rem !important;
  font-weight: 800 !important;
  color: #334155 !important;
  border: none !important;
  border-right: 3px solid #cbd5e1 !important;
  padding: 0.3rem 0.75rem !important;
  margin: 1.35rem 0 0.75rem !important;
  line-height: 1.45 !important;
  background: transparent !important;
}

/* Paragraphs */
.file-rich-content p {
  display: block !important;
  margin: 0 0 1.35rem !important;
  font-size: 1.05rem !important;
  font-weight: 400 !important;
  line-height: 2.15 !important;
  color: #334155 !important;
}

/* Bold & Emphasis */
.file-rich-content strong,
.file-rich-content b {
  font-weight: 800 !important;
  color: #0f172a !important;
}

/* Links */
.file-rich-content a {
  color: #e11d48 !important;
  font-weight: 800 !important;
  text-decoration: underline !important;
  text-decoration-color: #fca5a5 !important;
  text-decoration-thickness: 1.5px !important;
  text-underline-offset: 4px !important;
  transition: all 0.15s ease !important;
}

.file-rich-content a:hover {
  color: #be123c !important;
  text-decoration-color: #e11d48 !important;
}

/* Feature Checklist Unordered Lists (ul > li) */
.file-rich-content ul {
  list-style: none !important;
  padding-right: 0 !important;
  margin: 1rem 0 1.5rem !important;
}

.file-rich-content ul li {
  position: relative !important;
  padding-right: 2.1rem !important;
  margin-bottom: 0.75rem !important;
  color: #334155 !important;
  line-height: 2 !important;
  font-size: 1.025rem !important;
}

.file-rich-content ul li::before {
  content: "✓" !important;
  position: absolute !important;
  right: 0 !important;
  top: 0.25rem !important;
  width: 1.35rem !important;
  height: 1.35rem !important;
  border-radius: 50% !important;
  background: #ffe4e6 !important;
  color: #e11d48 !important;
  font-size: 0.75rem !important;
  font-weight: 900 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  box-shadow: 0 1px 3px rgba(225, 29, 72, 0.12) !important;
}

/* Numbered Steps Ordered Lists (ol > li) */
.file-rich-content ol {
  counter-reset: file-ol-counter;
  list-style: none !important;
  padding-right: 0 !important;
  margin: 1rem 0 1.5rem !important;
}

.file-rich-content ol li {
  counter-increment: file-ol-counter;
  position: relative !important;
  padding-right: 2.3rem !important;
  margin-bottom: 0.75rem !important;
  color: #334155 !important;
  line-height: 2 !important;
  font-size: 1.025rem !important;
}

.file-rich-content ol li::before {
  content: counter(file-ol-counter) !important;
  position: absolute !important;
  right: 0 !important;
  top: 0.25rem !important;
  width: 1.45rem !important;
  height: 1.45rem !important;
  border-radius: 0.45rem !important;
  background: #f1f5f9 !important;
  color: #0f172a !important;
  border: 1px solid #cbd5e1 !important;
  font-size: 0.75rem !important;
  font-weight: 800 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

/* Blockquotes / Educational Tips */
.file-rich-content blockquote {
  margin: 1.85rem 0 !important;
  padding: 1.25rem 1.6rem !important;
  background: linear-gradient(to left, rgba(255, 241, 242, 0.5), #f8fafc) !important;
  border: 1px solid #e2e8f0 !important;
  border-right: 5px solid #e11d48 !important;
  border-radius: 0 0.85rem 0.85rem 0 !important;
  color: #1e293b !important;
  font-weight: 600 !important;
  font-style: normal !important;
  line-height: 2 !important;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.03) !important;
}

/* Images inside Content */
.file-rich-content img {
  max-width: 100% !important;
  height: auto !important;
  border-radius: 1rem !important;
  margin: 1.5rem auto !important;
  border: 1px solid #e2e8f0 !important;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.04) !important;
  display: block !important;
}

/* Tables inside Content */
.file-rich-content table {
  width: 100% !important;
  border-collapse: separate !important;
  border-spacing: 0 !important;
  margin: 1.5rem 0 !important;
  border-radius: 0.75rem !important;
  overflow: hidden !important;
  border: 1px solid #e2e8f0 !important;
}

.file-rich-content th {
  background-color: #f8fafc !important;
  color: #0f172a !important;
  font-weight: 800 !important;
  padding: 0.75rem 1rem !important;
  border-bottom: 2px solid #e2e8f0 !important;
  text-align: right !important;
}

.file-rich-content td {
  padding: 0.75rem 1rem !important;
  border-bottom: 1px solid #f1f5f9 !important;
  color: #334155 !important;
  text-align: right !important;
}

.file-rich-content tr:last-child td {
  border-bottom: none !important;
}

/* Strict Isolation: Reset Table of Contents so it NEVER inherits list bullets or counters */
.file-rich-content .mozkrat-toc-box ol,
.file-rich-content .mozkrat-toc-box ul {
  counter-reset: none !important;
  list-style: none !important;
  padding: 0 !important;
  margin: 0 !important;
}

.file-rich-content .mozkrat-toc-box li {
  padding: 0 !important;
  margin: 0.3rem 0 !important;
}

.file-rich-content .mozkrat-toc-box li::before {
  content: none !important;
  display: none !important;
}
