/* ===== متغيرات التصميم ===== */
:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --text: #1f2430;
  --text-soft: #5c6373;
  --border: #e6e8ef;
  --brand: #4f46e5;
  --brand-dark: #4338ca;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 4px 20px rgba(20, 24, 40, 0.06);
  --shadow-hover: 0 10px 30px rgba(20, 24, 40, 0.12);
  --maxw: 1120px;

  /* ألوان التصنيفات */
  --c-indigo: #4f46e5;
  --c-amber: #d97706;
  --c-emerald: #059669;
  --c-sky: #0284c7;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: 'Tajawal', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.85;
  font-size: 17px;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

.container {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 20px;
}
.container.narrow { max-width: 780px; }

/* ===== الهيدر ===== */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 2px 10px rgba(20, 24, 40, 0.03);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 66px;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 20px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1.35rem;
  color: var(--text);
}
.brand:hover { text-decoration: none; }
.brand-icon { color: var(--brand); }
.site-nav {
  display: flex;
  align-items: center;
  gap: 4px;
}
.nav-link {
  color: var(--text-soft);
  font-weight: 500;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.98rem;
  transition: all 0.15s;
}
.nav-link:hover {
  color: var(--brand);
  background: #eef0fb;
  text-decoration: none;
}
.nav-link i { margin-inline-end: 4px; font-size: 0.85rem; }
.nav-search {
  color: var(--brand);
  background: #eef0fb;
  font-weight: 700;
}
.nav-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.4rem;
  color: var(--text);
  cursor: pointer;
}

/* ===== الهيرو ===== */
.hero {
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 60%, #0284c7 120%);
  color: #fff;
  padding: 64px 0 72px;
  text-align: center;
}
.hero-title {
  font-size: clamp(1.7rem, 4vw, 2.7rem);
  font-weight: 800;
  margin: 0 0 14px;
  line-height: 1.4;
}
.hero-sub {
  max-width: 720px;
  margin: 0 auto 28px;
  font-size: 1.08rem;
  opacity: 0.95;
}
.hero-search {
  display: flex;
  max-width: 560px;
  margin: 0 auto;
  background: #fff;
  border-radius: 999px;
  padding: 6px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.18);
}
.hero-search input {
  flex: 1;
  border: none;
  background: none;
  padding: 10px 18px;
  font-size: 1rem;
  font-family: inherit;
  color: var(--text);
  outline: none;
}
.hero-search button {
  border: none;
  background: var(--brand);
  color: #fff;
  padding: 10px 22px;
  border-radius: 999px;
  font-family: inherit;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.15s;
}
.hero-search button:hover { background: var(--brand-dark); }

/* ===== العناوين ===== */
.section-title {
  font-size: 1.5rem;
  font-weight: 800;
  margin: 40px 0 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.section-title i { color: var(--brand); }
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}
.link-all { font-size: 0.95rem; font-weight: 700; }

/* ===== شبكة التصنيفات ===== */
.cat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
}
.cat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 4px solid var(--brand);
  border-radius: var(--radius);
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: var(--shadow);
  transition: transform 0.15s, box-shadow 0.15s;
  color: var(--text);
}
.cat-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-hover);
  text-decoration: none;
}
.cat-icon {
  width: 52px; height: 52px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 14px;
  font-size: 1.4rem;
  margin-bottom: 6px;
}
.cat-name { font-weight: 800; font-size: 1.15rem; }
.cat-desc { color: var(--text-soft); font-size: 0.92rem; line-height: 1.6; }
.cat-count { color: var(--brand); font-weight: 700; font-size: 0.85rem; margin-top: 4px; }

/* ألوان التصنيفات */
.badge-indigo { background: #eef0fb; color: var(--c-indigo); }
.badge-amber { background: #fef3e2; color: var(--c-amber); }
.badge-emerald { background: #e6f7f0; color: var(--c-emerald); }
.badge-sky { background: #e2f2fb; color: var(--c-sky); }
.badge-border-indigo { border-top-color: var(--c-indigo); }
.badge-border-amber { border-top-color: var(--c-amber); }
.badge-border-emerald { border-top-color: var(--c-emerald); }
.badge-border-sky { border-top-color: var(--c-sky); }

/* ===== شبكة البطاقات ===== */
.card-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-bottom: 20px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform 0.15s, box-shadow 0.15s;
}
.card:hover { transform: translateY(-4px); box-shadow: var(--shadow-hover); }
.card-link { display: block; padding: 22px; color: var(--text); height: 100%; }
.card-link:hover { text-decoration: none; }
.card-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 999px;
  margin-bottom: 12px;
}
.card-title { font-size: 1.12rem; font-weight: 700; margin: 0 0 10px; line-height: 1.5; }
.card-summary { color: var(--text-soft); font-size: 0.93rem; margin: 0 0 16px; }
.card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.chip {
  background: #f0f1f6;
  color: var(--text-soft);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 999px;
}
.card-more { color: var(--brand); font-weight: 700; font-size: 0.88rem; }

/* ===== breadcrumb ===== */
.breadcrumb { margin: 22px 0 8px; font-size: 0.88rem; }
.breadcrumb ul {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0; margin: 0;
  align-items: center;
}
.breadcrumb a { color: var(--text-soft); }
.breadcrumb .sep { color: var(--border); }
.breadcrumb span[aria-current] { color: var(--text); font-weight: 600; }

/* ===== رأس الصفحة ===== */
.page-header {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 4px solid var(--brand);
  border-radius: var(--radius);
  padding: 26px;
  margin: 12px 0 28px;
  display: flex;
  align-items: center;
  gap: 20px;
  box-shadow: var(--shadow);
}
.page-header-icon {
  width: 64px; height: 64px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 16px;
  font-size: 1.7rem;
  flex-shrink: 0;
}
.page-title { font-size: 1.8rem; font-weight: 800; margin: 0 0 6px; }
.page-desc { color: var(--text-soft); margin: 0; }

/* ===== المقال ===== */
.article-wrap { max-width: 820px; }
.article {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 34px;
  box-shadow: var(--shadow);
  margin-bottom: 30px;
}
.article-header { border-bottom: 1px solid var(--border); padding-bottom: 22px; margin-bottom: 24px; }
.article-cat {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 5px 14px;
  border-radius: 999px;
  margin-bottom: 14px;
}
.article-cat:hover { text-decoration: none; opacity: 0.9; }
.article-title {
  font-family: 'Amiri', 'Tajawal', serif;
  font-size: clamp(1.6rem, 3.5vw, 2.2rem);
  font-weight: 700;
  line-height: 1.5;
  margin: 0 0 14px;
}
.article-summary { color: var(--text-soft); font-size: 1.05rem; margin: 0 0 16px; }
.article-meta { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.meta-date { color: var(--text-soft); font-size: 0.85rem; }

.article-body { font-size: 1.06rem; }
.article-body p { margin: 0 0 18px; }
.section-heading {
  font-size: 1.35rem;
  font-weight: 800;
  margin: 32px 0 14px;
  padding-inline-start: 14px;
  border-inline-start: 4px solid var(--brand);
}
.content-list { margin: 0 0 20px; padding-inline-start: 8px; }
.content-list li {
  position: relative;
  list-style: none;
  padding-inline-start: 30px;
  margin-bottom: 12px;
}
.content-list:not(.ordered) li::before {
  content: "\f058";
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  color: var(--c-emerald);
  position: absolute;
  inset-inline-start: 0;
  top: 2px;
}
.content-list.ordered { counter-reset: step; }
.content-list.ordered li::before {
  counter-increment: step;
  content: counter(step);
  position: absolute;
  inset-inline-start: 0;
  top: 3px;
  width: 22px; height: 22px;
  background: var(--brand);
  color: #fff;
  border-radius: 50%;
  font-size: 0.78rem;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  line-height: 1;
}

/* الأسئلة الشائعة */
.faq { margin-top: 30px; }
.faq-item {
  background: #f9fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 18px;
  margin-bottom: 12px;
}
.faq-item summary {
  cursor: pointer;
  font-weight: 700;
  padding: 10px 0;
  list-style: none;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::before { content: "\f055"; font-family: "Font Awesome 6 Free"; font-weight: 900; color: var(--brand); margin-inline-end: 10px; }
.faq-item[open] summary::before { content: "\f056"; }
.faq-item p { margin: 0 0 12px; color: var(--text-soft); }

.tag-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 26px; }
.tag { background: #f0f1f6; color: var(--text-soft); font-size: 0.82rem; padding: 4px 12px; border-radius: 999px; }

.related { max-width: 820px; }

/* ===== البحث ===== */
.page-search {
  display: flex;
  gap: 8px;
  margin-bottom: 30px;
  max-width: 620px;
}
.page-search input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-family: inherit;
  font-size: 1rem;
  outline: none;
}
.page-search input:focus { border-color: var(--brand); }
.page-search button {
  border: none;
  background: var(--brand);
  color: #fff;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-weight: 700;
  cursor: pointer;
}
.page-search button:hover { background: var(--brand-dark); }
.search-info { color: var(--text-soft); margin-bottom: 20px; }
.index-cat { margin-bottom: 20px; }
.empty-state { color: var(--text-soft); padding: 30px 0; text-align: center; }

/* ===== صفحة الخطأ ===== */
.error-page { text-align: center; padding: 60px 0 80px; }
.error-code { font-size: 6rem; font-weight: 800; color: var(--brand); line-height: 1; }
.error-actions { display: flex; gap: 12px; justify-content: center; margin-top: 24px; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--brand); color: #fff;
  padding: 11px 22px; border-radius: var(--radius-sm);
  font-weight: 700;
}
.btn:hover { background: var(--brand-dark); text-decoration: none; }
.btn-ghost { background: var(--surface); color: var(--brand); border: 1px solid var(--border); }
.btn-ghost:hover { background: #eef0fb; }

/* ===== الفوتر ===== */
.site-footer { background: #1c2030; color: #c8ccd8; margin-top: 60px; }
.footer-grid {
  display: grid;
  grid-template-columns: 1.6fr 1fr 1fr;
  gap: 30px;
  padding: 46px 20px 34px;
}
.footer-brand { color: #fff; font-size: 1.3rem; margin-bottom: 12px; }
.footer-brand i { color: #8b93ff; }
.footer-desc { color: #9aa0b3; font-size: 0.93rem; }
.footer-title { color: #fff; font-size: 1.02rem; margin: 0 0 14px; }
.footer-links { list-style: none; padding: 0; margin: 0; }
.footer-links li { margin-bottom: 9px; }
.footer-links a { color: #b3b8c9; font-size: 0.93rem; }
.footer-links a:hover { color: #fff; }
.footer-bottom { border-top: 1px solid #2c3145; padding: 18px 0; }
.footer-bottom p { margin: 0; text-align: center; color: #8a90a3; font-size: 0.87rem; }

/* ===== الاستجابة ===== */
@media (max-width: 900px) {
  .cat-grid { grid-template-columns: repeat(2, 1fr); }
  .card-grid { grid-template-columns: repeat(2, 1fr); }
  .footer-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  body { font-size: 16px; }
  .nav-toggle { display: block; }
  .site-nav {
    position: fixed;
    top: 66px; inset-inline-end: 0;
    background: var(--surface);
    flex-direction: column;
    align-items: stretch;
    width: 250px;
    height: calc(100vh - 66px);
    padding: 16px;
    box-shadow: -4px 0 20px rgba(0,0,0,0.1);
    transform: translateX(-110%);
    transition: transform 0.25s;
  }
  html[dir="rtl"] .site-nav { transform: translateX(110%); }
  .site-nav.open { transform: translateX(0) !important; }
  .cat-grid { grid-template-columns: 1fr; }
  .card-grid { grid-template-columns: 1fr; }
  .footer-grid { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; text-align: center; }
  .article { padding: 22px; }
  .hero-search { flex-direction: column; border-radius: var(--radius); background: transparent; box-shadow: none; gap: 8px; padding: 0; }
  .hero-search input { background: #fff; border-radius: var(--radius-sm); }
  .hero-search button { border-radius: var(--radius-sm); }
}

/* ========== صفحة إنشاء مقال ========== */
.create-hero { background: linear-gradient(135deg, #eef2ff, #e0e7ff); padding: 40px 0 28px; margin-bottom: 24px; }
.create-hero h1 { font-size: 1.9rem; margin: 0 0 10px; color: var(--brand-dark); }
.create-lead { color: var(--text-soft); max-width: 760px; line-height: 1.9; }
.create-layout { display: grid; grid-template-columns: 1.15fr 0.85fr; gap: 28px; align-items: start; margin-bottom: 32px; }
.create-form fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin: 0 0 20px; background: var(--surface); box-shadow: var(--shadow); }
.create-form legend { font-weight: 800; color: var(--brand-dark); padding: 0 8px; font-size: 1.05rem; }
.fieldset-hint { color: var(--text-soft); font-size: 0.88rem; margin: 0 0 14px; }
.field { display: block; margin-bottom: 14px; }
.field-label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 0.95rem; }
.field-label em { font-weight: 400; color: var(--text-soft); font-style: normal; font-size: 0.85rem; }
.field input, .field select, .field textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-family: inherit; font-size: 0.95rem; background: #fff; color: var(--text); }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79,70,229,0.15); }
.field textarea { resize: vertical; }
.field-hint { color: var(--text-soft); font-size: 0.82rem; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field-check { display: flex; align-items: center; gap: 8px; font-size: 0.92rem; color: var(--text-soft); cursor: pointer; }
.field-check input { width: auto; }
.dyn-block { border: 1px dashed var(--border); border-radius: var(--radius-sm); padding: 14px; margin-bottom: 14px; background: #fafbff; }
.dyn-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.btn-remove { border: none; background: #fee2e2; color: #dc2626; width: 30px; height: 30px; border-radius: 8px; font-size: 1.2rem; cursor: pointer; line-height: 1; }
.btn-remove:hover { background: #fecaca; }
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 10px 18px; border-radius: var(--radius-sm); border: none; cursor: pointer; font-family: inherit; font-weight: 600; font-size: 0.95rem; text-decoration: none; }
.btn-ghost { background: #eef2ff; color: var(--brand-dark); }
.btn-ghost:hover { background: #e0e7ff; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-secondary { background: #f1f5f9; color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: #e2e8f0; }
.btn-lg { padding: 14px 28px; font-size: 1.05rem; }
.create-actions { text-align: center; margin: 8px 0 0; }
.create-preview { position: sticky; top: 84px; }
.preview-title { font-size: 1.1rem; margin: 0 0 12px; color: var(--brand-dark); }
.preview-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); min-height: 200px; max-height: 70vh; overflow-y: auto; }
.preview-box h3 { margin: 6px 0 12px; font-size: 1.4rem; }
.preview-box h4 { margin: 16px 0 8px; color: var(--brand-dark); }
.preview-box p { line-height: 1.9; margin: 0 0 10px; }
.preview-box ul, .preview-box ol { padding-inline-start: 22px; line-height: 1.9; }
.preview-badge { display: inline-block; background: #eef2ff; color: var(--brand-dark); font-size: 0.8rem; padding: 4px 10px; border-radius: 999px; font-weight: 600; }
.preview-summary { color: var(--text-soft); font-style: italic; }
.preview-tags { margin-top: 14px; }
.preview-tags span { color: var(--brand); font-size: 0.85rem; }
.muted { color: #b6bccb; }
.output-section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); margin-bottom: 40px; }
.output-section h2 { color: var(--brand-dark); margin-top: 0; }
.output-steps { color: var(--text-soft); line-height: 2; padding-inline-start: 22px; }
.output-steps code { background: #f1f5f9; padding: 2px 6px; border-radius: 6px; font-size: 0.9em; direction: ltr; display: inline-block; }
.output-toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 16px 0; }
.copy-msg { color: var(--c-emerald); font-weight: 600; }
.output-code { background: #0f172a; color: #e2e8f0; padding: 18px; border-radius: var(--radius-sm); overflow-x: auto; direction: ltr; text-align: left; font-size: 0.85rem; line-height: 1.6; }
.output-code code { font-family: 'Courier New', monospace; white-space: pre; }
@media (max-width: 900px) {
  .create-layout { grid-template-columns: 1fr; }
  .create-preview { position: static; }
  .field-row { grid-template-columns: 1fr; }
}
