@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@400;500;700;800;900&display=swap');

:root {
  --navy: #132238;
  --blue: #2563eb;
  --blue-soft: #eaf2ff;
  --gold: #f59e0b;
  --ink: #243447;
  --muted: #64748b;
  --paper: #ffffff;
  --background: #f5f7fb;
  --border: #e2e8f0;
  --code: #101827;
  --success-soft: #ecfdf5;
  --shadow: 0 12px 35px rgba(15, 23, 42, .08);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--background);
  font-family: 'Tajawal', 'Noto Sans Arabic', Tahoma, Arial, sans-serif;
  line-height: 1.9;

}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
.container { width: min(1180px, calc(100% - 32px)); margin-inline: auto; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  color: white;
  background: var(--navy);
  border-bottom: 3px solid var(--gold);
  box-shadow: 0 4px 18px rgba(15, 23, 42, .12);
}
.header-inner { min-height: 70px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.brand { color: white; font-size: 1.25rem; font-weight: 800; white-space: nowrap; }
.brand span { color: #a9c7ff; font-size: .82rem; font-weight: 500; margin-inline-start: 7px; }
.top-nav { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.top-nav a { color: #e5edff; font-size: .9rem; }
.top-nav a:hover { color: white; }

.layout { display: grid; grid-template-columns: 255px minmax(0, 1fr); gap: 28px; align-items: start; padding-block: 34px 60px; }
.sidebar { position: sticky; top: 100px; }
.toc-card, .tip-card { background: var(--paper); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow); padding: 20px; }
.toc-card h2 { margin: 0 0 12px; font-size: 1.05rem; color: var(--navy); }
.toc-card ol { margin: 0; padding-inline-start: 22px; }
.toc-card li { margin: 6px 0; font-size: .88rem; }
.tip-card { margin-top: 16px; border-top: 4px solid var(--gold); font-size: .9rem; }
.tip-card strong { color: var(--navy); }
.tip-card p { margin: 6px 0 0; }

.lesson { min-width: 0; }
.hero { display: flex; align-items: center; justify-content: space-between; gap: 24px; background: linear-gradient(135deg, #10223b, #224c83); color: white; border-radius: 22px; padding: clamp(24px, 5vw, 52px); box-shadow: var(--shadow); overflow: hidden; }
.eyebrow { margin: 0 0 4px; color: #b9d1ff; font-size: .95rem; font-weight: 700; }
h1 { margin: 0; font-size: clamp(1.7rem, 4vw, 3rem); line-height: 1.35; }
.lead { margin: 14px 0 0; color: #e3edff; font-size: 1.05rem; max-width: 680px; }
.hero-image { width: 105px; height: 125px; object-fit: contain; flex: 0 0 auto; filter: drop-shadow(0 10px 18px rgba(0,0,0,.2)); }
.lesson-section { position: relative; scroll-margin-top: 90px; margin-top: 24px; background: var(--paper); border: 1px solid var(--border); border-radius: 18px; padding: clamp(22px, 4vw, 36px); box-shadow: var(--shadow); }
.section-number { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: 50%; background: var(--blue-soft); color: var(--blue); font-weight: 800; font-size: .9rem; }
h2 { color: var(--navy); margin: 8px 0 14px; font-size: clamp(1.3rem, 2.5vw, 1.8rem); }
h3 { color: var(--navy); margin: 0 0 7px; font-size: 1.05rem; }
p { margin: 10px 0; }
.en { color: var(--muted); font-size: .7em; font-weight: 500; direction: ltr; unicode-bidi: embed; }
code { direction: ltr; unicode-bidi: embed; font-family: Consolas, "Courier New", monospace; }
p code, td code, li code, summary code { color: #be185d; background: #fdf2f8; border-radius: 5px; padding: 1px 5px; }
pre { direction: ltr; text-align: left; overflow-x: auto; margin: 14px 0; padding: 17px 19px; border-radius: 11px; color: #dce7ff; background: var(--code); font: .94rem/1.7 Consolas, "Courier New", monospace; box-shadow: inset 0 0 0 1px rgba(255,255,255,.06); }
pre code { color: inherit; background: none; padding: 0; }
pre.output { background: #172b38; color: #a7f3d0; }
.info-box, .note-box { margin: 18px 0; padding: 16px 18px; border-radius: 12px; background: var(--blue-soft); border-inline-start: 5px solid var(--blue); }
.info-box pre { margin-bottom: 0; }
.note-box { background: var(--success-soft); border-inline-start-color: #10b981; }
.code-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.code-grid > div { min-width: 0; }
.table-wrap { width: 100%; overflow-x: auto; margin: 18px 0; border: 1px solid var(--border); border-radius: 12px; }
table { width: 100%; min-width: 650px; border-collapse: collapse; background: white; }
caption { padding: 12px; color: var(--navy); font-weight: 800; text-align: right; background: #f8fafc; }
th, td { padding: 12px 14px; border-bottom: 1px solid var(--border); text-align: right; vertical-align: top; }
th { color: var(--navy); background: #eef4ff; font-weight: 800; }
tr:last-child td { border-bottom: 0; }
tr:nth-child(even) td { background: #fbfdff; }
.examples-table th:first-child, .examples-table td:first-child { width: 62%; }
.exercise-block { padding: 20px; border: 1px dashed #9dbaf0; border-radius: 14px; background: #f8fbff; }
.question { margin-top: 16px; padding: 19px; border: 1px solid var(--border); border-radius: 14px; background: #fff; }
.question:first-of-type { margin-top: 0; }
.choices { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; margin: 15px 0; }
.choices span { padding: 9px; text-align: center; border: 1px solid var(--border); border-radius: 8px; background: #f8fafc; }
details { margin-top: 13px; border-radius: 9px; background: var(--success-soft); padding: 8px 13px; }
summary { cursor: pointer; color: #047857; font-weight: 800; }
details pre { margin-bottom: 5px; }

.quiz-form { margin-top: 20px; }
.quiz-question { margin: 16px 0; padding: 18px; border: 1px solid var(--border); border-radius: 13px; background: #fff; transition: border-color .2s, background .2s, box-shadow .2s; }
.quiz-question legend { padding: 0 6px; color: var(--navy); font-weight: 800; }
.quiz-question label { display: block; margin: 9px 0; padding: 8px 11px; border-radius: 8px; cursor: pointer; background: #f8fafc; transition: background .2s; }
.quiz-question label:hover { background: var(--blue-soft); }
.quiz-question input { accent-color: var(--blue); margin-inline-end: 8px; }
.question-feedback { min-height: 1.6em; margin: 9px 0 0; font-weight: 700; }
.quiz-question.is-correct { border-color: #10b981; background: #f0fdf4; }
.quiz-question.is-correct .question-feedback { color: #047857; }
.quiz-question.is-wrong { border-color: #ef4444; background: #fff7f7; }
.quiz-question.is-wrong .question-feedback { color: #b91c1c; }
.quiz-question.is-unanswered { border-color: var(--gold); background: #fffbeb; }
.quiz-question.is-unanswered .question-feedback { color: #a16207; }
.quiz-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.primary-button, .secondary-button { border: 0; border-radius: 9px; padding: 11px 19px; font: inherit; font-weight: 800; cursor: pointer; transition: transform .2s, opacity .2s; }
.primary-button:hover, .secondary-button:hover { transform: translateY(-1px); opacity: .9; }
.primary-button { color: white; background: var(--blue); }
.secondary-button { color: var(--navy); background: #e2e8f0; }
.quiz-result { display: none; margin-top: 18px; padding: 17px 19px; border-radius: 12px; color: var(--navy); background: var(--blue-soft); border-inline-start: 5px solid var(--blue); }
.quiz-result.visible { display: flex; flex-direction: column; gap: 3px; }
.quiz-result small { color: var(--muted); }

.site-footer { color: #dbe7fb; background: var(--navy); padding: 25px 0; }
.site-footer .container { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 10px 24px; font-size: .9rem; }
.site-footer a { color: #a9c7ff; }

@media (max-width: 850px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; order: 2; }
  .lesson { order: 1; }
  .toc-card ol { columns: 2; column-gap: 30px; }
  .toc-card li { break-inside: avoid; }
}
@media (max-width: 620px) {
  .container { width: min(100% - 22px, 1180px); }
  .header-inner { align-items: flex-start; flex-direction: column; padding: 12px 0; gap: 6px; }
  .top-nav { gap: 3px 12px; }
  .top-nav a { font-size: .78rem; }
  .hero { align-items: flex-start; padding: 25px 20px; }
  .hero-image { width: 65px; height: 84px; }
  .lead { font-size: .92rem; }
  .lesson-section { padding: 20px 16px; }
  .code-grid { grid-template-columns: 1fr; gap: 5px; }
  .choices { grid-template-columns: repeat(2, 1fr); }
  .toc-card ol { columns: 1; }
  pre { font-size: .83rem; padding: 14px; }
  .quiz-actions { flex-direction: column; }
  .primary-button, .secondary-button { width: 100%; }
  th, td { padding: 10px; }
}
@media print {
  .site-header, .sidebar, .site-footer { display: none; }
  body, .lesson-section { background: white; box-shadow: none; }
  .layout { display: block; padding: 0; }
  .hero { color: black; background: white; border: 1px solid #ccc; }
  .lesson-section { break-inside: avoid; }
}

/* تنسيقات صفحة الفهرس الرئيسية */
.home-main { padding-block: 34px 60px; }
.home-hero { display: flex; align-items: center; justify-content: space-between; gap: 30px; min-height: 330px; padding: clamp(28px, 6vw, 65px); color: white; background: linear-gradient(135deg, #10223b, #224c83); border-radius: 22px; box-shadow: var(--shadow); overflow: hidden; }
.home-hero h1 { max-width: 700px; }
.start-button { display: inline-block; margin-top: 18px; color: white; background: var(--blue); }
.hero-mark { display: flex; flex-direction: column; align-items: center; justify-content: center; width: 175px; height: 175px; flex: 0 0 auto; color: #b9d1ff; border: 2px solid rgba(255,255,255,.25); border-radius: 50%; transform: rotate(-8deg); }
.hero-mark span { direction: ltr; font: 800 3.2rem Consolas, monospace; }
.hero-mark small { color: white; font-size: 1rem; }
.lessons-index { margin-top: 28px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.section-heading h2 { margin: 0; }
.dark-eyebrow { margin: 0; color: var(--blue); }
.lesson-count { padding: 5px 13px; color: var(--blue); background: var(--blue-soft); border-radius: 20px; font-weight: 800; }
.lesson-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 17px; }
.lesson-card { display: flex; align-items: flex-start; gap: 17px; min-height: 170px; padding: 22px; color: var(--ink); background: var(--paper); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow); transition: transform .2s, border-color .2s, box-shadow .2s; }
.lesson-card:hover { text-decoration: none; transform: translateY(-4px); border-color: #a9c2f3; box-shadow: 0 16px 38px rgba(15, 23, 42, .13); }
.lesson-card:last-child { grid-column: 1 / -1; }
.card-number { display: inline-flex; align-items: center; justify-content: center; width: 48px; height: 48px; flex: 0 0 auto; color: var(--blue); background: var(--blue-soft); border-radius: 50%; font-weight: 900; }
.lesson-card h3 { margin: 0 0 6px; font-size: 1.15rem; }
.lesson-card p { margin: 0 0 10px; color: var(--muted); font-size: .92rem; }
.card-link { color: var(--blue); font-size: .9rem; font-weight: 800; }
.about-strip { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-top: 28px; padding: 24px 28px; background: var(--paper); border: 1px solid var(--border); border-inline-start: 5px solid var(--gold); border-radius: 16px; box-shadow: var(--shadow); }
.about-strip h2 { margin: 0 0 3px; font-size: 1.25rem; }
.about-strip p { margin: 0; color: var(--muted); }
.about-strip .secondary-button { display: inline-block; white-space: nowrap; }
@media (max-width: 700px) { .home-hero { align-items: flex-start; } .hero-mark { width: 105px; height: 105px; } .hero-mark span { font-size: 1.9rem; } .lesson-cards { grid-template-columns: 1fr; } .lesson-card:last-child { grid-column: auto; } .about-strip { align-items: flex-start; flex-direction: column; } }
@media (max-width: 480px) { .home-hero { padding: 26px 20px; } .hero-mark { width: 68px; height: 68px; } .hero-mark span { font-size: 1.1rem; } .hero-mark small { font-size: .65rem; } .lesson-card { padding: 17px; } }

/* صفحات الدخول ولوحة المعلم */
.auth-main, .dashboard-main { min-height: calc(100vh - 150px); padding-block: 42px 60px; }
.auth-card { width: min(500px, 100%); margin: 0 auto; padding: clamp(25px, 5vw, 42px); background: var(--paper); border: 1px solid var(--border); border-radius: 20px; box-shadow: var(--shadow); text-align: center; }
.auth-card h1 { margin-top: 12px; color: var(--navy); font-size: clamp(1.5rem, 4vw, 2.2rem); }
.auth-intro { color: var(--muted); }
.auth-form { margin-top: 24px; text-align: right; }
.auth-form label { display: block; margin-bottom: 6px; color: var(--navy); font-weight: 800; }
.auth-form input { width: 100%; padding: 12px 14px; color: var(--ink); background: #fff; border: 1px solid #cbd5e1; border-radius: 9px; font: inherit; outline: none; }
.auth-form input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
.auth-form .primary-button { width: 100%; margin-top: 14px; }
.auth-error { min-height: 1.5em; margin: 7px 0 0; color: #b91c1c; font-size: .88rem; }
.local-note { margin: 20px 0 0; padding: 11px 13px; color: #92400e; background: #fffbeb; border-radius: 9px; font-size: .82rem; }
.header-logout { padding: 6px 11px; color: #e5edff; background: transparent; border: 1px solid rgba(255,255,255,.35); border-radius: 7px; font: inherit; cursor: pointer; }
.header-logout:hover { color: white; background: rgba(255,255,255,.1); }
.dashboard-welcome { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: clamp(25px, 5vw, 45px); color: white; background: linear-gradient(135deg, #10223b, #224c83); border-radius: 22px; box-shadow: var(--shadow); }
.dashboard-welcome h1 { font-size: clamp(1.7rem, 4vw, 2.8rem); }
.dashboard-welcome .lead { margin-bottom: 0; }
.dashboard-avatar { display: flex; align-items: center; justify-content: center; width: 105px; height: 105px; flex: 0 0 auto; color: white; border: 2px solid rgba(255,255,255,.35); border-radius: 50%; font-size: 2.8rem; font-weight: 900; }
.dashboard-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 22px; }
.stat-card { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 20px; background: var(--paper); border: 1px solid var(--border); border-radius: 15px; box-shadow: var(--shadow); }
.stat-card strong { color: var(--blue); font-size: 1.65rem; }
.stat-card span { color: var(--muted); font-size: .9rem; }
.dashboard-panel { margin-top: 22px; padding: clamp(22px, 4vw, 34px); background: var(--paper); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow); }
.dashboard-links { display: grid; gap: 10px; }
.dashboard-links a { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 13px 15px; color: var(--ink); background: #f8fafc; border: 1px solid var(--border); border-radius: 9px; font-weight: 700; }
.dashboard-links a:hover { color: var(--blue); background: var(--blue-soft); text-decoration: none; }
.dashboard-links span { color: var(--blue); white-space: nowrap; font-size: .85rem; }
.dashboard-note { margin-top: 18px; }
@media (max-width: 620px) { .dashboard-stats { grid-template-columns: 1fr; } .dashboard-welcome { align-items: flex-start; } .dashboard-avatar { width: 70px; height: 70px; font-size: 1.8rem; } .dashboard-links a { align-items: flex-start; flex-direction: column; gap: 3px; } .top-nav .header-logout { font-size: .78rem; } }

/* تنسيقات فهرس menu_python */
.menu-main { padding-block: 34px 55px; }
.menu-hero { display: flex; align-items: center; justify-content: space-between; gap: 30px; min-height: 315px; padding: clamp(28px, 6vw, 60px); color: white; background: linear-gradient(135deg, #10223b, #224c83); border-radius: 22px; box-shadow: var(--shadow); overflow: hidden; }
.menu-hero h1 { max-width: 720px; }
.menu-hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.menu-hero-actions .primary-button, .menu-hero-actions .secondary-button { display: inline-block; }
.menu-hero-actions .secondary-button { color: var(--navy); background: white; }
.resources-strip { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-top: 20px; padding: 17px 21px; background: var(--paper); border: 1px solid var(--border); border-inline-start: 5px solid var(--gold); border-radius: 14px; box-shadow: var(--shadow); }
.resources-strip strong { color: var(--navy); }
.resources-strip p { margin: 2px 0 0; color: var(--muted); font-size: .88rem; }
.resource-links { display: flex; flex-wrap: wrap; gap: 8px 16px; font-weight: 800; }
.menu-intro { margin: 30px 0 18px; }
.menu-intro h2 { margin: 0 0 4px; }
.menu-intro p:last-child { margin-top: 0; color: var(--muted); }
.menu-stage { scroll-margin-top: 90px; margin-top: 24px; padding: clamp(22px, 4vw, 34px); background: var(--paper); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow); }
.stage-heading { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.stage-heading h2 { margin: 0; }
.stage-heading .eyebrow { margin: 0; }
.stage-number { display: inline-flex; align-items: center; justify-content: center; width: 48px; height: 48px; flex: 0 0 auto; color: var(--blue); background: var(--blue-soft); border-radius: 50%; font-weight: 900; }
.topic-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 13px; }
.topic-card { min-height: 170px; padding: 18px; color: var(--ink); background: #fbfdff; border: 1px solid var(--border); border-radius: 13px; transition: transform .2s, border-color .2s, background .2s; }
.topic-card:hover { color: var(--ink); text-decoration: none; transform: translateY(-3px); border-color: #a9c2f3; background: var(--blue-soft); }
.topic-icon { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; margin-bottom: 7px; color: var(--blue); background: white; border-radius: 50%; font-size: .78rem; font-weight: 900; }
.topic-card h3 { margin: 0 0 5px; font-size: 1rem; }
.topic-card p { margin: 0 0 8px; color: var(--muted); font-size: .86rem; line-height: 1.7; }
.topic-card > span:last-child { color: var(--blue); font-size: .83rem; font-weight: 800; }
.review-stage { border-top: 4px solid var(--gold); }
.review-links { display: grid; grid-template-columns: repeat(2, 1fr); gap: 13px; }
.review-links a { display: flex; flex-direction: column; gap: 3px; padding: 17px; color: var(--ink); background: #f8fafc; border: 1px solid var(--border); border-radius: 11px; }
.review-links a:hover { color: var(--blue); text-decoration: none; background: var(--blue-soft); }
.review-links span { color: var(--muted); font-size: .87rem; }
.references-box { margin-top: 24px; padding: 22px; background: var(--success-soft); border-inline-start: 5px solid #10b981; border-radius: 13px; }
.references-box h2 { margin-top: 0; font-size: 1.25rem; }
.references-box p { margin-bottom: 0; }
.menu-footer-note { display: flex; justify-content: center; flex-wrap: wrap; gap: 9px 20px; margin-top: 25px; color: var(--muted); font-size: .88rem; text-align: center; }
@media (max-width: 850px) { .topic-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 620px) { .menu-hero { align-items: flex-start; } .menu-hero .hero-mark { width: 95px; height: 95px; } .menu-hero .hero-mark span { font-size: 1.8rem; } .resources-strip { align-items: flex-start; flex-direction: column; } .topic-grid, .review-links { grid-template-columns: 1fr; } .menu-hero-actions { flex-direction: column; } .menu-hero-actions a { width: 100%; text-align: center; } }

