/* ==========================================================================
   دفتر التوجيهي — هوية منصة الابتكار
   ورق الكراسة، خط الهامش الأحمر، تظهير أصفر، حبر أزرق للأزرار،
   وحبر المعلم الأحمر للأخطاء.
   ========================================================================== */
* { box-sizing: border-box; margin: 0; }

:root {
  /* الورق والحبر */
  --paper: #FAF8F1;          /* ورق الكراسة */
  --paper-deep: #F1EDE2;     /* ورق أدفأ للخلفيات الثانوية */
  --card: #FFFFFF;
  --ink: #1B2440;            /* حبر كتابة كحلي */
  --ink-soft: #5B6478;       /* حبر باهت للثانوي */
  --rule: #D9E3F5;           /* أزرق أسطر الدفتر */
  --rule-strong: #B9CBEB;

  /* أقلام */
  --pen: #2B50C7;            /* قلم الحبر الأزرق — الأفعال */
  --pen-deep: #1E3A99;
  --margin-red: #E2564A;     /* خط هامش الكراسة */
  --red-pen: #D64545;        /* حبر تصحيح المعلم — أخطاء */
  --marker: #FFC93D;         /* قلم التظهير */
  --marker-soft: #FFE9AE;
  --mint: #2F9E6E;           /* صح ✓ */
  --mint-soft: #DDF3E8;
  --red-soft: #FBE3E1;
  --amber-soft: #FFF3D4;

  --radius: 14px;
  --shadow: 0 2px 10px rgba(27, 36, 64, .07);
  --font-body: "IBM Plex Sans Arabic", Tahoma, sans-serif;
  --font-display: "Lalezar", "IBM Plex Sans Arabic", sans-serif;
}

body {
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--ink);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.65;
}
a { color: var(--pen); text-decoration: none; }
a:hover { color: var(--pen-deep); }
:focus-visible { outline: 2px dashed var(--pen); outline-offset: 3px; border-radius: 4px; }

/* ---------- العناوين: قلم عريض ---------- */
h1, h2, h3, .stat span, .brand {
  font-family: var(--font-display);
  font-weight: 400;
  line-height: 1.6; /* لا letter-spacing مع العربية — يقطع اتصال الحروف */
}
h1 { font-size: 2.3rem; margin-bottom: 6px; }
h2 { font-size: 1.45rem; margin: 30px 0 12px; }
h3 { font-size: 1.15rem; }

/* تظهير أصفر خلف الكلمة المفتاحية */
.hl { position: relative; display: inline-block; z-index: 0; }
.hl::after {
  content: '';
  position: absolute; z-index: -1;
  inset-inline: -.18em; bottom: .06em; height: .52em;
  background: var(--marker);
  opacity: .62;
  border-radius: .18em .35em .2em .4em;
  transform: skew(-12deg) rotate(-1deg);
  transform-origin: 100% 100%;
}
@media (prefers-reduced-motion: no-preference) {
  .hl::after { animation: swipe .5s .25s cubic-bezier(.2,.8,.3,1) backwards; }
  @keyframes swipe { from { transform: skew(-12deg) rotate(-1deg) scaleX(0); } }
}

/* ---------- شريط التنقل ---------- */
.nav {
  background: rgba(250, 248, 241, .93);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--rule-strong);
  padding: 10px 26px;
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 8px;
  position: sticky; top: 0; z-index: 50;
}
.brand { color: var(--ink); font-size: 1.5rem; }
.brand::before { content: '✎'; color: var(--pen); margin-inline-end: 8px; }
.nav .links a {
  color: var(--ink); margin-inline-start: 4px; display: inline-block;
  padding: 7px 14px; border-radius: 999px; font-weight: 500; font-size: .95rem;
  line-height: 1.8;
}
.nav .links a:hover { background: var(--marker-soft); }

/* ---------- الحاويات ---------- */
.container { max-width: 1080px; width: 100%; margin: 30px auto; padding: 0 18px; flex: 1; }
.container.narrow { max-width: 580px; }
.muted { color: var(--ink-soft); font-size: .92rem; }

/* ---------- الصفحة الأولى: ورقة مسطّرة ---------- */
.hero {
  text-align: center; padding: 56px 18px 40px;
  background:
    repeating-linear-gradient(0deg, transparent 0 30px, var(--rule) 30px 31px);
  border-radius: var(--radius);
  border: 1px solid var(--rule-strong);
  position: relative; overflow: hidden;
  margin-top: 6px;
}
.hero::before { /* خط هامش الكراسة */
  content: '';
  position: absolute; inset-block: 0; inset-inline-start: 42px;
  width: 2px; background: var(--margin-red); opacity: .75;
}
.hero h1 { font-size: clamp(2.2rem, 5vw, 3.4rem); }
.hero > p { max-width: 520px; margin: 8px auto 0; font-size: 1.08rem; color: var(--ink-soft); }
.hero-actions { margin: 26px 0 10px; display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* أرقام حقيقية تحت البطل */
.chalk-stats { display: flex; gap: 34px; justify-content: center; flex-wrap: wrap; margin-top: 30px; }
.chalk-stats div { font-family: var(--font-display); font-size: 1.9rem; color: var(--ink); line-height: 1.1; }
.chalk-stats div small { display: block; font-family: var(--font-body); font-size: .85rem; color: var(--ink-soft); font-weight: 500; }
.chalk-stats div b { color: var(--pen); font-weight: 400; }

/* ---------- البطاقات ---------- */
.cards { display: flex; flex-wrap: wrap; justify-content: center; gap: 16px; margin-top: 18px; }
.cards .card { text-align: center; flex: 1 1 240px; max-width: 330px; }
.card {
  background: var(--card);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.card.pad { margin: 14px 0; }
.card h3 { margin-bottom: 4px; }
@media (prefers-reduced-motion: no-preference) {
  .cards .card { animation: rise .45s backwards; }
  .cards .card:nth-child(2) { animation-delay: .08s; }
  .cards .card:nth-child(3) { animation-delay: .16s; }
  .cards .card:nth-child(4) { animation-delay: .24s; }
  @keyframes rise { from { opacity: 0; transform: translateY(14px); } }
}
.subject-card { position: relative; overflow: hidden; transition: transform .15s, box-shadow .15s; }
.subject-card::before { /* هامش أحمر لبطاقات المواد */
  content: ''; position: absolute; inset-block: 12px; inset-inline-start: 0;
  width: 3px; background: var(--margin-red); border-radius: 2px;
}
.subject-card:hover { transform: translateY(-3px); box-shadow: 0 8px 20px rgba(27,36,64,.13); border-color: var(--pen); }
.subject-card p { color: var(--ink-soft); font-size: .9rem; }

/* ---------- الأزرار: حبر أزرق ---------- */
.btn {
  display: inline-block;
  background: var(--paper-deep); color: var(--ink);
  border: 1px solid var(--rule-strong); border-radius: 10px;
  padding: 10px 20px; font-size: 1rem; cursor: pointer;
  font-family: var(--font-body); font-weight: 700;
  transition: transform .12s, box-shadow .12s, background .12s;
}
.btn:hover { transform: translateY(-1px); }
.btn.primary { background: var(--pen); border-color: var(--pen); color: #fff; box-shadow: 0 3px 0 var(--pen-deep); }
.btn.primary:hover { background: var(--pen-deep); box-shadow: 0 2px 0 var(--pen-deep); }
.btn.primary:active { transform: translateY(2px); box-shadow: none; }
.btn.danger { background: var(--red-pen); border-color: var(--red-pen); color: #fff; }
.btn.small { padding: 5px 14px; font-size: .85rem; }

/* ---------- النماذج ---------- */
.form {
  display: flex; flex-direction: column; gap: 15px;
  background: var(--card); border: 1px solid var(--rule-strong);
  border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow);
}
.form label { display: flex; flex-direction: column; gap: 6px; font-weight: 700; font-size: .95rem; }
.form input, .form select,
.inline-form input, .inline-form select {
  padding: 10px 13px; border: 1px solid var(--rule-strong); border-radius: 9px;
  font-size: 1rem; font-family: var(--font-body); background: var(--paper);
  color: var(--ink); transition: border-color .12s, box-shadow .12s;
}
.form input:focus, .form select:focus, .inline-form input:focus {
  outline: none; border-color: var(--pen); box-shadow: 0 0 0 3px rgba(43, 80, 199, .15);
}
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 10px 0; }
.inline { display: inline; }
fieldset { border: 1px dashed var(--rule-strong); border-radius: 10px; padding: 12px; }
legend { font-weight: 700; padding: 0 8px; }

/* ---------- التنبيهات: حبر المعلم ---------- */
.alert { padding: 13px 17px; border-radius: 11px; margin: 14px 0; border: 1px solid transparent; }
.alert.error {
  background: var(--red-soft); color: #8C2320; border-color: #EFB7B2;
  border-inline-start: 4px solid var(--red-pen);
}
.alert.info {
  background: var(--amber-soft); color: #6B4E0E; border-color: #F2DCA0;
  border-inline-start: 4px solid var(--marker);
}

/* ---------- الجداول: أسطر الدفتر ---------- */
.table {
  width: 100%; border-collapse: collapse; background: var(--card);
  border-radius: var(--radius); overflow: hidden;
  border: 1px solid var(--rule-strong); box-shadow: var(--shadow);
}
.table th, .table td { padding: 11px 14px; border-bottom: 1px solid var(--rule); text-align: right; }
.table th {
  background: var(--paper-deep); font-family: var(--font-display);
  font-weight: 400; font-size: 1rem; color: var(--ink);
}
.table tr:last-child td { border-bottom: 0; }
.table tr:hover td { background: #FDFCF7; }

/* ---------- وسوم الحالة ---------- */
.tag { padding: 3px 11px; border-radius: 999px; font-size: .8rem; font-weight: 700; white-space: nowrap; }
.tag.ok { background: var(--mint-soft); color: var(--mint); }
.tag.warn { background: var(--amber-soft); color: #855B0B; }
.tag.err { background: var(--red-soft); color: var(--red-pen); }

/* ---------- إحصائيات اللوحة ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin: 20px 0; }
.stat {
  background: var(--card); border: 1px solid var(--rule-strong);
  border-radius: var(--radius); padding: 18px 16px 14px; text-align: center;
  color: var(--ink-soft); font-size: .9rem; font-weight: 500; box-shadow: var(--shadow);
}
.stat span {
  display: block; font-size: 2.3rem; color: var(--ink); line-height: 1.15;
  position: relative; width: fit-content; margin: 0 auto 2px;
}
.stat span::after { /* خط تظهير تحت الرقم */
  content: ''; position: absolute; inset-inline: -6px; bottom: 4px; height: 9px;
  background: var(--marker); opacity: .5; border-radius: 4px; z-index: -1;
  transform: rotate(-1deg);
}

/* ---------- شبكة اختيار المواد ---------- */
.subject-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 9px; margin: 10px 0; }
.check {
  display: flex; gap: 9px; align-items: center; font-weight: 500;
  background: var(--paper); border: 1px solid var(--rule-strong);
  border-radius: 9px; padding: 9px 12px; cursor: pointer; transition: border-color .12s, background .12s;
}
.check:hover { border-color: var(--pen); }
.check:has(input:checked) { background: var(--amber-soft); border-color: var(--marker); font-weight: 700; }
.check input { accent-color: var(--pen); width: 17px; height: 17px; }

/* ---------- شجرة المادة: فهرس الكراسة ---------- */
.unit {
  background: var(--card); border: 1px solid var(--rule-strong);
  border-radius: var(--radius); margin: 12px 0; padding: 4px 18px;
  position: relative; overflow: hidden; box-shadow: var(--shadow);
}
.unit::before { /* خط الهامش داخل الوحدة */
  content: ''; position: absolute; inset-block: 0; inset-inline-start: 34px;
  width: 1.5px; background: var(--margin-red); opacity: .5;
}
.unit summary {
  font-family: var(--font-display); font-size: 1.12rem;
  padding: 12px 0; cursor: pointer; list-style: none; position: relative;
  padding-inline-start: 34px;
}
.unit summary::before {
  content: '▲'; font-size: .6rem; color: var(--pen);
  position: absolute; inset-inline-start: 6px; top: 50%;
  translate: 0 -50%; transition: rotate .15s;
}
.unit:not([open]) summary::before { rotate: 180deg; }
.lesson { padding: 10px 0 10px; padding-inline-start: 34px; border-top: 1px dashed var(--rule-strong); }
.lesson-name { font-weight: 700; margin-bottom: 4px; }
.videos { list-style: none; padding-inline-start: 10px; }
.videos li { padding: 5px 0; display: flex; gap: 10px; flex-wrap: wrap; align-items: baseline; }
.videos li a { font-weight: 700; }

/* ---------- المشغل ---------- */
.player-wrap {
  position: relative; background: #10131C; border-radius: var(--radius);
  overflow: hidden; margin-top: 16px; border: 1px solid var(--ink);
  box-shadow: 0 12px 30px rgba(27, 36, 64, .25);
}
.player-wrap video { width: 100%; display: block; max-height: 75vh; }
.watermark {
  position: absolute; top: 12%; right: 8%;
  color: rgba(255, 255, 255, .45); font-size: .95rem;
  pointer-events: none; user-select: none;
  text-shadow: 0 0 4px rgba(0, 0, 0, .6);
  transition: top 1.5s, right 1.5s; z-index: 5;
}

/* ---------- صفوف اللوحة ---------- */
.payment { display: flex; justify-content: space-between; gap: 14px; flex-wrap: wrap; align-items: center; }
.row-between { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.notifications {
  list-style: none; background: var(--card); border: 1px solid var(--rule-strong);
  border-radius: var(--radius); padding: 6px 18px; box-shadow: var(--shadow);
}
.notifications li { padding: 10px 4px; border-bottom: 1px dashed var(--rule-strong); }
.notifications li:last-child { border-bottom: 0; }
.notifications li.unread { font-weight: 700; }
.notifications li.unread::before { content: '●'; color: var(--margin-red); margin-inline-end: 8px; font-size: .7rem; }

details > summary { cursor: pointer; }

.foot {
  text-align: center; color: var(--ink-soft); padding: 22px; font-size: .85rem;
  border-top: 1px solid var(--rule-strong); margin-top: 30px;
  background: var(--paper-deep);
}

@media (max-width: 640px) {
  h1 { font-size: 1.8rem; }
  .hero::before { inset-inline-start: 18px; }
  .unit::before { inset-inline-start: 24px; }
  .unit summary, .lesson { padding-inline-start: 24px; }
}
