/**
 * =========================================================================
 *  ALLONAJAHT COURSE NOTES - التصميم العصري الأنيق لصفحات الدروس
 * =========================================================================
 * تجربة قراءة تفاعلية حديثة، متوافقة تماماً مع الوضع الليلي وصيغ KaTeX.
 */

.course-notes {
    color: var(--ink, #1e293b);
    font-size: 15px;
    line-height: 1.85;
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    max-width: 100%;
}

/* مصدر الدرس وبيانات التوثيق */
.course-source {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    font-size: 11px;
    font-weight: 600;
    color: var(--muted, #64748b);
    padding: 12px 18px;
    background: rgba(36, 91, 181, 0.04);
    border: 1px dashed var(--line, #cbd5e1);
    border-radius: 12px;
    margin-bottom: 24px;
}

.dark .course-source {
    background: rgba(96, 165, 250, 0.05);
    border-color: #334155;
    color: #94a3b8;
}

/* شريط التنقل السريع بين أقسام الدرس (Table of Contents Pills) */
.notes-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 16px 0 32px;
    padding: 6px;
    background: var(--paper, #f1f5f9);
    border-radius: 9999px;
    width: fit-content;
    max-width: 100%;
    border: 1px solid var(--line, #e2e8f0);
}

.dark .notes-nav {
    background: rgba(15, 23, 42, 0.6);
    border-color: #334155;
}

.notes-nav a {
    padding: 8px 18px;
    background: var(--surface, #ffffff);
    color: var(--ink, #334155);
    border: 1px solid transparent;
    border-radius: 9999px;
    font-size: 12px;
    font-weight: 700;
    text-decoration: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.dark .notes-nav a {
    background: #1e293b;
    color: #cbd5e1;
}

.notes-nav a:hover {
    background: #245bb5;
    color: #ffffff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(36, 91, 181, 0.25);
}

.dark .notes-nav a:hover {
    background: #3b82f6;
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(59, 130, 246, 0.3);
}

/* بطاقات أقسام الدرس الرئيسية (Notes Sections) */
.notes-section {
    background: var(--surface, #ffffff);
    border: 1px solid var(--line, #e2e8f0);
    border-radius: 24px;
    padding: 34px;
    margin: 28px 0;
    scroll-margin-top: 100px;
    box-shadow: 0 4px 20px rgba(15, 23, 42, 0.04);
    transition: box-shadow 0.25s ease, border-color 0.25s ease;
}

.dark .notes-section {
    background: var(--surface, #1e293b);
    border-color: #334155;
    box-shadow: 0 4px 25px rgba(0, 0, 0, 0.2);
}

.notes-section:hover {
    box-shadow: 0 8px 30px rgba(36, 91, 181, 0.07);
}

.dark .notes-section:hover {
    box-shadow: 0 8px 35px rgba(0, 0, 0, 0.35);
}

/* عنوان القسم مع شارة الترقيم */
.notes-section-title {
    display: flex;
    align-items: center;
    gap: 16px;
    border-bottom: 1.5px solid var(--line, #e2e8f0);
    padding-bottom: 20px;
    margin-bottom: 26px;
}

.dark .notes-section-title {
    border-color: #334155;
}

.notes-section-title > span {
    background: linear-gradient(135deg, #245bb5, #1d4ed8);
    color: #ffffff;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    font-size: 13px;
    font-weight: 800;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(36, 91, 181, 0.3);
}

.dark .notes-section-title > span {
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    box-shadow: 0 4px 14px rgba(59, 130, 246, 0.4);
}

.notes-section h2 {
    font-size: 22px;
    font-weight: 800;
    color: var(--ink, #0f172a);
    margin: 0;
    letter-spacing: -0.5px;
    line-height: 1.35;
}

.notes-section h3 {
    font-size: 17px;
    font-weight: 700;
    color: var(--ink, #1e293b);
    line-height: 1.5;
    margin: 0 0 12px;
}

/* الكتل المفاهيمية والقواعد (Concepts) */
.notes-concept {
    margin: 24px 0;
    padding: 20px 24px;
    background: var(--paper, #f8fafc);
    border: 1px solid var(--line, #e2e8f0);
    border-left: 4px solid #245bb5;
    border-radius: 16px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.dark .notes-concept {
    background: rgba(15, 23, 42, 0.4);
    border-color: #334155;
    border-left-color: #60a5fa;
}

.notes-concept:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.04);
}

.notes-concept h3 {
    color: #245bb5;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.dark .notes-concept h3 {
    color: #93c5fd;
}

.notes-concept p {
    margin: 0;
    color: var(--ink, #334155);
}

.notes-concept p + p {
    margin-top: 10px;
}

/* بطاقات التنبيه والأخطاء الشائعة (Piège à éviter) */
.notes-alert {
    background: linear-gradient(135deg, #fffbeb, #fef3c7);
    border: 1.5px solid #fde68a;
    border-left: 5px solid #d97706;
    padding: 20px 24px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.7;
    margin: 28px 0;
    box-shadow: 0 4px 14px rgba(217, 119, 6, 0.08);
}

.dark .notes-alert {
    background: rgba(245, 158, 11, 0.1);
    border-color: rgba(245, 158, 11, 0.3);
    border-left-color: #f59e0b;
}

.notes-alert strong {
    color: #b45309;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    margin-bottom: 6px;
}

.dark .notes-alert strong {
    color: #fcd34d;
}

.notes-alert p {
    margin: 0;
    color: #78350f;
}

.dark .notes-alert p {
    color: #fef3c7;
}

/* بطاقات الأمثلة المحلولة خطوة بخطوة (Examples) */
.notes-example {
    padding: 24px;
    margin: 22px 0;
    background: var(--paper, #f8fafc);
    border: 1px solid var(--line, #e2e8f0);
    border-radius: 18px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.02);
}

.dark .notes-example {
    background: rgba(15, 23, 42, 0.45);
    border-color: #334155;
}

.notes-example-label {
    display: inline-block;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: #245bb5;
    background: rgba(36, 91, 181, 0.08);
    padding: 4px 10px;
    border-radius: 6px;
    margin-bottom: 12px;
}

.dark .notes-example-label {
    color: #60a5fa;
    background: rgba(96, 165, 250, 0.15);
}

.notes-question {
    font-size: 15px;
    font-weight: 700;
    color: var(--ink, #0f172a);
    margin: 10px 0 16px;
}

.notes-solution {
    list-style: none;
    counter-reset: sol-counter;
    padding: 18px 22px;
    background: #ffffff;
    border: 1px solid var(--line, #e2e8f0);
    border-left: 4px solid #10b981;
    border-radius: 14px;
    margin-top: 16px;
}

.dark .notes-solution {
    background: rgba(15, 23, 42, 0.6);
    border-color: #334155;
    border-left-color: #10b981;
}

.notes-solution li {
    counter-increment: sol-counter;
    position: relative;
    padding-left: 28px;
    margin: 10px 0;
    color: var(--ink, #1e293b);
}

.notes-solution li::before {
    content: counter(sol-counter);
    position: absolute;
    left: 0;
    top: 2px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #10b981;
    color: #ffffff;
    font-size: 11px;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* التمارين التطبيقية وأكورديون الحل (Exercises & Details) */
.notes-exercise {
    padding: 22px 0;
    border-bottom: 1px solid var(--line, #e2e8f0);
}

.dark .notes-exercise {
    border-color: #334155;
}

.notes-exercise:last-child {
    border-bottom: 0;
}

.notes-exercise details {
    margin-top: 14px;
    background: var(--paper, #f8fafc);
    border: 1.5px solid var(--line, #e2e8f0);
    border-radius: 14px;
    overflow: hidden;
    transition: all 0.2s ease;
}

.dark .notes-exercise details {
    background: rgba(15, 23, 42, 0.4);
    border-color: #334155;
}

.notes-exercise summary {
    cursor: pointer;
    color: #245bb5;
    font-weight: 700;
    font-size: 13px;
    padding: 14px 18px;
    user-select: none;
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: background 0.2s ease;
}

.notes-exercise summary::-webkit-details-marker {
    display: none;
}

.notes-exercise summary::after {
    content: "＋";
    font-size: 15px;
    font-weight: 800;
    transition: transform 0.2s ease;
}

.notes-exercise details[open] summary::after {
    content: "✕";
    transform: rotate(90deg);
}

.notes-exercise summary:hover {
    background: rgba(36, 91, 181, 0.05);
}

.dark .notes-exercise summary {
    color: #60a5fa;
}

.dark .notes-exercise summary:hover {
    background: rgba(96, 165, 250, 0.1);
}

.notes-exercise details > ol,
.notes-exercise details > p {
    padding: 0 18px 18px;
    margin: 0;
}

/* الرسوم الهندسية التوضيحية (SVG Figures) */
.notes-figure {
    margin: 28px 0;
    padding: 24px;
    background: var(--paper, #f8fafc);
    border: 1px solid var(--line, #e2e8f0);
    border-radius: 20px;
    text-align: center;
}

.dark .notes-figure {
    background: rgba(15, 23, 42, 0.5);
    border-color: #334155;
}

.notes-figure svg {
    display: block;
    width: 100%;
    max-width: 520px;
    height: auto;
    margin: 0 auto;
    color: var(--ink, #1e293b);
}

.notes-figure figcaption {
    font-size: 12px;
    font-weight: 600;
    color: var(--muted, #64748b);
    text-align: center;
    margin-top: 14px;
}

/* بطاقات التنقل بين الدروس في نهاية الصفحة (Pagination) */
.notes-pagination {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin: 32px 0;
}

.notes-pagination a {
    display: flex;
    flex-direction: column;
    padding: 20px 24px;
    background: var(--surface, #ffffff);
    border: 1px solid var(--line, #e2e8f0);
    border-radius: 16px;
    text-decoration: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.dark .notes-pagination a {
    background: var(--surface, #1e293b);
    border-color: #334155;
}

.notes-pagination a:hover {
    border-color: #245bb5;
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(36, 91, 181, 0.12);
}

.dark .notes-pagination a:hover {
    border-color: #60a5fa;
    box-shadow: 0 8px 25px rgba(96, 165, 250, 0.15);
}

.notes-pagination small {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: #245bb5;
    margin-bottom: 6px;
}

.dark .notes-pagination small {
    color: #60a5fa;
}

.notes-pagination strong {
    font-size: 14px;
    line-height: 1.5;
    color: var(--ink, #0f172a);
}

.notes-attribution {
    font-size: 11px;
    color: var(--muted, #64748b);
    line-height: 1.7;
    margin-top: 24px;
    text-align: center;
}

/* تنسيق صيغ KaTeX الرياضية داخل الدروس */
.course-notes .katex-display {
    overflow-x: auto;
    overflow-y: hidden;
    padding: 12px 16px;
    margin: 16px 0;
    background: rgba(36, 91, 181, 0.03);
    border-radius: 12px;
    border: 1px solid rgba(36, 91, 181, 0.08);
}

.dark .course-notes .katex-display {
    background: rgba(96, 165, 250, 0.05);
    border-color: rgba(96, 165, 250, 0.1);
}

.course-notes .katex {
    font-size: 1.1em;
}

.course-notes p {
    overflow-wrap: break-word;
}

/* التجاوب مع شاشات الهواتف */
@media (max-width: 640px) {
    .course-notes { font-size: 14px; }
    .notes-section { padding: 22px 18px; border-radius: 18px; }
    .notes-section h2 { font-size: 18px; }
    .notes-example { padding: 18px 16px; }
    .notes-pagination { grid-template-columns: 1fr; }
    .notes-nav { width: 100%; border-radius: 16px; }
    .notes-nav a { font-size: 11px; padding: 7px 12px; flex: 1; text-align: center; justify-content: center; }
}

@media print {
    .notes-nav, .notes-pagination, .sq-actions-row { display: none !important; }
    .notes-exercise details > ol { display: block !important; }
    .notes-section, .notes-example { break-inside: avoid; box-shadow: none !important; }
}
