/* خط المراعي المحلي */
@font-face {
  font-family: 'Almarai';
  src: url('/static/fonts/Almarai-Regular.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'Almarai';
  src: url('/static/fonts/Almarai-Bold.woff2') format('woff2');
  font-weight: 700;
  font-display: swap;
}

:root {
  --primary-color: #006400;
  --secondary-color: #4cad7a;
  --bg-color: #f7f9fa;
  --card-bg: #ffffff;
  --text-color: #2c3e50;
  --border-color: #e2e8f0;
  --accent-badge: #ff5722;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

img, picture, svg, video {
  max-width: 100%;
  height: auto;
}

body {
  font-family: 'Almarai', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  direction: rtl;
  text-align: right;
  background-color: var(--bg-color);
  color: var(--text-color);
  line-height: 1.6;
}

/* شريط الترويسة والتنقل */
.navbar {
  background-color: #ffffff;
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 4px rgba(0,0,0,0.03);
}

.nav-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 15px;
}

.brand {
  display: flex;
  align-items: center;
  text-decoration: none;
}

.brand img {
  height: 44px;
  width: auto;
}

.nav-links {
  display: flex;
  list-style: none;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.nav-links a {
  text-decoration: none;
  color: #4a5568;
  font-weight: 700;
  font-size: 14px;
  padding: 6px 12px;
  border-radius: 6px;
  transition: all 0.2s;
}

.nav-links a:hover, .nav-links a.active {
  background-color: #edf2f7;
  color: var(--primary-color);
}

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

.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-box input {
  font-family: inherit;
  font-size: 14px;
  padding: 8px 16px;
  padding-left: 35px;
  border: 1px solid var(--border-color);
  border-radius: 20px;
  width: 240px;
  outline: none;
  background: #f8fafc;
  transition: all 0.2s;
}

.search-box input:focus {
  width: 280px;
  border-color: var(--secondary-color);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(76, 173, 122, 0.2);
}

.search-box button {
  position: absolute;
  left: 10px;
  background: none;
  border: none;
  cursor: pointer;
  color: #718096;
}

/* مسار التنقل Breadcrumbs */
.breadcrumb-container {
  max-width: 1200px;
  margin: 15px auto 0;
  padding: 0 20px;
}

.breadcrumbs {
  font-size: 13px;
  color: #718096;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.breadcrumbs a {
  color: #4a5568;
  text-decoration: none;
}

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

/* المحتوى الرئيسي */
.main-wrapper {
  max-width: 1200px;
  margin: 20px auto 40px;
  padding: 0 20px;
}

.section-header {
  margin-bottom: 20px;
  border-bottom: 2px solid #e2e8f0;
  padding-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.section-title {
  font-size: 20px;
  font-weight: 700;
  color: #1a202c;
}

/* شبكة البطاقات والمواد */
.kv-boxes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.kv-box {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
  display: flex;
  flex-direction: column;
  position: relative;
}

.kv-box:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 16px rgba(0,0,0,0.08);
}

.kv-box-img-link {
  display: block;
  position: relative;
  width: 100%;
  padding-top: 60%;
  overflow: hidden;
  background-color: #f1f5f9;
}

.kv-box-img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.kv-box-title {
  padding: 12px 14px;
  font-size: 14px;
  font-weight: 700;
  color: #2d3748;
  text-decoration: none;
  flex-grow: 1;
  display: flex;
  align-items: center;
}

.kv-box-title:hover {
  color: var(--primary-color);
}

.badge {
  position: absolute;
  top: 10px;
  right: 10px;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* شارات الحالة المحلية */
.status-pill {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 700;
}
.status-cached {
  background: #def7ec;
  color: #03543f;
}
.status-online {
  background: #feecdc;
  color: #9c4221;
}

/* صفحة تفاصيل المادة والمستعرض */
.post-header {
  background: #fff;
  padding: 24px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  margin-bottom: 20px;
}

.post-title {
  font-size: 22px;
  color: #1a202c;
  margin-bottom: 12px;
}

.post-meta {
  font-size: 13px;
  color: #718096;
  display: flex;
  gap: 15px;
  align-items: center;
}

.viewer-wrapper {
  background: #fff;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  margin-bottom: 24px;
  overflow: hidden;
  box-shadow: 0 4px 6px rgba(0,0,0,0.02);
}

.viewer-iframe {
  width: 100%;
  height: 650px;
  border: none;
  border-bottom: 2px solid var(--primary-color);
  display: block;
}

/* أزرار التحميل المباشر */
.action-buttons-container {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin: 25px 0;
  flex-wrap: wrap;
}

.action-btn {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  background: #fff;
  border: 1px solid var(--border-color);
  padding: 12px 24px;
  border-radius: 10px;
  text-decoration: none;
  color: #2d3748;
  font-weight: 700;
  transition: all 0.2s;
  box-shadow: 0 2px 4px rgba(0,0,0,0.04);
}

.action-btn img {
  width: 50px;
  height: auto;
  margin-bottom: 8px;
}

.action-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 12px rgba(0,0,0,0.08);
  border-color: var(--secondary-color);
}

/* صندوق التنبيه */
.wj-alert-box {
  background-color: #fff9db;
  border: 1px solid #ffe066;
  border-right: 4px solid #f59f00;
  padding: 14px 18px;
  border-radius: 6px;
  margin-bottom: 20px;
  font-size: 14px;
  color: #856404;
}

/* محتوى الأسئلة والشرح والمطويات */
.entry-content {
  background: #fff;
  padding: 28px 24px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  margin-bottom: 24px;
  font-size: 16px;
  line-height: 1.9;
  overflow: hidden;
  word-wrap: break-word;
  overflow-wrap: break-word;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

.entry-content * {
  max-width: 100% !important;
  box-sizing: border-box !important;
}

.entry-content img {
  max-width: 100% !important;
  height: auto !important;
  display: block !important;
  margin: 20px auto !important;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.06);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.entry-content a {
  display: block;
  text-align: center;
  max-width: 100%;
}

.entry-content table {
  width: 100% !important;
  max-width: 100% !important;
  display: block;
  overflow-x: auto;
}

/* الفوتر */
.footer {
  background: #fff;
  border-top: 1px solid var(--border-color);
  padding: 30px 20px;
  text-align: center;
  font-size: 13px;
  color: #718096;
}

.footer p {
  margin-bottom: 8px;
}

/* لوحة المزامنة */
.sync-card {
  background: #fff;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  padding: 24px;
  margin-bottom: 20px;
}

.progress-bar-bg {
  background: #e2e8f0;
  border-radius: 10px;
  height: 16px;
  overflow: hidden;
  margin: 15px 0;
}

.progress-bar-fill {
  background: var(--secondary-color);
  height: 100%;
  width: 0%;
  transition: width 0.3s;
}

.btn-primary {
  background: var(--primary-color);
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: 6px;
  font-family: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.2s;
}

.btn-primary:hover {
  opacity: 0.9;
}

/* بطاقات الفصول والصفوف والمواد المصورة */
.semester-card, .grade-card, .subject-card {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  overflow: hidden;
}

.semester-card:hover, .grade-card:hover, .subject-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 16px rgba(0,0,0,0.08);
}

.semester-card .kv-box-img-link:hover .kv-box-img,
.grade-card .kv-box-img-link:hover .kv-box-img,
.subject-card .kv-box-img-link:hover .kv-box-img {
  transform: scale(1.05);
}

.kv-box-img {
  transition: transform 0.3s ease;
}

/* طبقة القيمة التعليمية والصفحات الجديدة */
.eyebrow {
  display: inline-block;
  color: var(--primary-color);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .02em;
  margin-bottom: 6px;
}
.hub-intro {
  background: linear-gradient(135deg, #ecfdf5, #f8fafc 70%);
  border: 1px solid #bbf7d0;
  border-radius: 16px;
  padding: 28px;
  margin-bottom: 18px;
}
.hub-intro.compact { max-width: 850px; }
.hub-intro h1 { color: #123c2a; font-size: clamp(24px, 4vw, 36px); margin: 0 0 8px; }
.hub-intro p { color: #475569; max-width: 850px; line-height: 1.9; margin: 0; }
.hub-actions { display: flex; gap: 10px; flex-wrap: wrap; margin: 0 0 28px; }
.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: #fff;
  color: #1e293b;
  border: 1px solid #cbd5e1;
  padding: 9px 14px;
  border-radius: 7px;
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}
.btn-secondary:hover, .btn-secondary:focus-visible { border-color: var(--secondary-color); color: var(--primary-color); }
.home-value-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 30px; }
.home-value-grid > div { background: #fff; border: 1px solid var(--border-color); border-radius: 12px; padding: 18px; }
.home-value-grid span { font-size: 24px; display: block; margin-bottom: 5px; }
.home-value-grid strong { color: #1e293b; }
.home-value-grid p { font-size: 13px; color: #64748b; line-height: 1.8; min-height: 44px; }
.home-value-grid a { font-size: 12px; color: var(--primary-color); font-weight: 700; text-decoration: none; }
.category-intro { color: #475569; line-height: 1.9; margin: -10px 0 24px; max-width: 850px; }
.curriculum-tree { display: grid; gap: 12px; }
.tree-level { background: #fff; border: 1px solid var(--border-color); border-radius: 10px; padding: 0 15px; }
.tree-level summary { cursor: pointer; list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 15px 0; font-weight: 800; color: #1e293b; }
.tree-level summary::-webkit-details-marker { display: none; }
.tree-level summary::before { content: '＋'; color: var(--primary-color); font-size: 18px; }
.tree-level[open] > summary::before { content: '−'; }
.tree-level summary small { color: #64748b; font-size: 11px; font-weight: 600; }
.tree-level summary a { color: inherit; text-decoration: none; }
.tree-level summary a:hover { color: var(--primary-color); text-decoration: underline; }
.tree-children { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 10px; padding: 0 0 15px; }
.subject-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 8px; padding: 0 0 15px; }
.subject-link { display: flex; flex-direction: column; gap: 3px; padding: 11px 12px; background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 8px; color: #334155; text-decoration: none; }
.subject-link:hover { border-color: #86efac; background: #f0fdf4; }
.subject-link span { color: #64748b; font-size: 11px; }
.editorial-note, .source-card { background: #fff; border: 1px solid var(--border-color); border-radius: 10px; padding: 16px 18px; color: #475569; line-height: 1.8; margin-top: 24px; }
.editorial-note strong, .source-card strong { color: #1e293b; display: block; margin-bottom: 5px; }
.editorial-note a, .source-card a { color: var(--primary-color); font-weight: 700; }
.form-shell { max-width: 900px; margin: 0 auto; }
.public-form { background: #fff; border: 1px solid var(--border-color); border-radius: 12px; padding: 22px; }
.public-form label { display: block; color: #334155; font-weight: 700; font-size: 13px; margin-bottom: 15px; }
.public-form input, .public-form textarea, .public-form select, .advanced-search input, .advanced-search select { width: 100%; margin-top: 6px; border: 1px solid #cbd5e1; border-radius: 7px; padding: 10px 12px; font: inherit; background: #fff; }
.public-form textarea { resize: vertical; min-height: 140px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 15px; }
.form-success, .form-error { padding: 12px 15px; border-radius: 8px; margin: 0 0 14px; font-weight: 700; }
.form-success { background: #dcfce7; color: #166534; }
.form-error { background: #fee2e2; color: #991b1b; }
.honeypot { position: absolute !important; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.learning-brief { background: linear-gradient(180deg, #fff, #f8fffb); border: 1px solid #bbf7d0; border-radius: 12px; padding: 22px 24px; margin: 0 0 20px; }
.brief-heading h2 { margin: 0 0 12px; color: #123c2a; font-size: 21px; }
.brief-summary { color: #334155; line-height: 2; margin-bottom: 16px; white-space: pre-line; }
.brief-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin-bottom: 12px; }
.brief-grid > div { background: #f0fdf4; border-radius: 8px; padding: 10px 12px; }
.brief-label { display: block; color: #64748b; font-size: 11px; margin-bottom: 3px; }
.brief-grid strong { color: #166534; font-size: 13px; }
.objectives h3 { color: #1e293b; font-size: 15px; margin: 12px 0 6px; }
.objectives ul { margin: 0; padding-inline-start: 22px; color: #334155; }
.post-toolbar { display: flex; flex-wrap: wrap; gap: 9px; margin: 0 0 20px; }
.faq-section, .quiz-card { background: #fff; border: 1px solid var(--border-color); border-radius: 12px; padding: 22px 24px; margin: 24px 0; }
.faq-section h2, .quiz-card h2 { color: #1e293b; font-size: 20px; margin: 0 0 14px; }
.faq-section details { border-top: 1px solid #e2e8f0; padding: 12px 0; }
.faq-section summary { cursor: pointer; font-weight: 700; color: #334155; }
.faq-section p { color: #475569; line-height: 1.9; margin: 8px 0 0; }
.quiz-question { border: 1px solid #e2e8f0; border-radius: 8px; padding: 12px 14px; margin: 0 0 12px; }
.quiz-question legend { font-weight: 700; color: #334155; padding: 0 4px; }
.quiz-question label { display: block; padding: 7px; color: #475569; cursor: pointer; }
.quiz-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.quiz-result, .quiz-pass { color: #1d4ed8; font-weight: 800; }
.quiz-pass { color: #166534; }
.advanced-search { display: grid; grid-template-columns: 2fr 1fr 1fr auto; gap: 10px; align-items: end; background: #fff; border: 1px solid var(--border-color); border-radius: 10px; padding: 14px; margin: 0 0 22px; }
.advanced-search label { font-weight: 700; font-size: 12px; color: #475569; }
.empty-state { text-align: center; color: #64748b; padding: 30px 15px; }
.offline-state { background: #fff; border: 1px solid var(--border-color); border-radius: 12px; padding: 50px 20px; }
.offline-icon { font-size: 42px; margin-bottom: 10px; }

@media (max-width: 800px) {
  .home-value-grid { grid-template-columns: 1fr; }
  .advanced-search { grid-template-columns: 1fr 1fr; }
  .advanced-search button { grid-column: 1 / -1; }
}
@media (max-width: 560px) {
  .form-grid { grid-template-columns: 1fr; }
  .advanced-search { grid-template-columns: 1fr; }
  .advanced-search button { grid-column: auto; }
  .hub-intro { padding: 20px; }
  .learning-brief, .faq-section, .quiz-card { padding: 18px 15px; }
}

@media print {
  .navbar, .footer, .ad-container-header, .ad-container-footer, .ad-container-article, .post-toolbar, .viewer-wrapper, .action-buttons-container, #image-modal { display: none !important; }
  body { background: #fff; color: #111827; }
  .main-wrapper { max-width: none; margin: 0; padding: 0; }
  .post-header, .entry-content, .learning-brief, .faq-section, .quiz-card { border: 0; box-shadow: none; padding: 0; }
  a { color: inherit !important; text-decoration: none !important; }
}
