/* ═══════════════════════════════════════════════════════════════
   training.css — فضاء التكوين | PEDAGOIMPACT.COM
   RTL — يُحمَّل بعد css/main.css
   ═══════════════════════════════════════════════════════════════ */
:root {
  --tr-main: #e11d48;
  --tr-dark: #9f1239;
  --tr-ink: #0f172a;
  --tr-muted: #64748b;
  --tr-line: #e2e8f0;
  --tr-soft: #f8fafc;
  --tr-ok: #059669;
  --tr-bad: #dc2626;
  --tr-warn: #d97706;
}
body.tr-page { background: #f6f7fb; direction: rtl; text-align: right; }
.tr-page [hidden] { display: none !important; }
html, body.tr-page { overflow-x: hidden; }
.tr-main { padding-top: 68px; min-height: 70vh; }
.tr-container { max-width: 1180px; margin: 0 auto; padding: 0 1.25rem; }
.tr-narrow { max-width: 860px; }

/* ── Hero ── */
.tr-hero { background: linear-gradient(140deg, #0f172a 0%, #1e293b 45%, #9f1239 100%); color: #fff; padding: 3rem 0 2.5rem; position: relative; overflow: hidden; }
.tr-hero::after { content: ''; position: absolute; left: -120px; bottom: -160px; width: 420px; height: 420px; border-radius: 50%; background: rgba(255,255,255,.05); }
.tr-hero .tr-container { position: relative; z-index: 1; }
.tr-hero h1 { color: #fff; font-size: clamp(1.6rem, 4vw, 2.4rem); font-weight: 900; margin: .4rem 0 .6rem; }
.tr-hero p { color: rgba(255,255,255,.86); max-width: 720px; font-size: 1rem; margin: 0; }
.tr-kicker { display: inline-flex; align-items: center; gap: .45rem; background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.22); padding: .3rem .85rem; border-radius: 50px; font-size: .78rem; font-weight: 700; }
.tr-hero-stats { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1.4rem; }
.tr-hero-stat { background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.18); border-radius: 12px; padding: .55rem 1rem; font-size: .85rem; font-weight: 700; }
.tr-hero-stat b { font-size: 1.15rem; margin-left: .3rem; }
.tr-breadcrumb { font-size: .8rem; color: rgba(255,255,255,.7); display: flex; gap: .4rem; flex-wrap: wrap; }
.tr-breadcrumb a { color: rgba(255,255,255,.9); text-decoration: underline; text-underline-offset: 3px; }

/* ── Sections / cards ── */
.tr-section { padding: 2rem 0; }
.tr-section-title { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.1rem; }
.tr-section-title h2 { font-size: 1.3rem; margin: 0; }
.tr-card { background: #fff; border: 1px solid var(--tr-line); border-radius: 16px; padding: 1.35rem; box-shadow: 0 2px 10px rgba(15,23,42,.04); }
.tr-card + .tr-card { margin-top: 1rem; }
.tr-card h3 { font-size: 1.05rem; margin-bottom: .6rem; }
.tr-grid { display: grid; gap: 1.1rem; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.tr-two { display: grid; gap: 1.25rem; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); align-items: start; }

/* ── Course card (hub) ── */
.tr-course { background: #fff; border-radius: 18px; border: 1px solid var(--tr-line); overflow: hidden; display: flex; flex-direction: column; box-shadow: 0 3px 14px rgba(15,23,42,.05); transition: transform .2s, box-shadow .2s; }
.tr-course:hover { transform: translateY(-2px); box-shadow: 0 10px 28px rgba(15,23,42,.1); }
.tr-course-head { padding: 1.2rem 1.3rem 1rem; color: #fff; background: var(--c, var(--tr-main)); position: relative; }
.tr-course-head .tr-num { font-size: .72rem; font-weight: 800; opacity: .85; }
.tr-course-head h3 { color: #fff; font-size: 1.12rem; margin: .25rem 0 .35rem; }
.tr-course-head p { color: rgba(255,255,255,.9); font-size: .84rem; margin: 0; line-height: 1.7; }
.tr-course-icon { position: absolute; left: 1rem; top: 1rem; font-size: 1.6rem; opacity: .35; }
.tr-course-body { padding: 1rem 1.3rem 1.2rem; display: flex; flex-direction: column; gap: .8rem; flex: 1; }
.tr-meta { display: flex; flex-wrap: wrap; gap: .4rem; }
.tr-pill { display: inline-flex; align-items: center; gap: .3rem; font-size: .74rem; font-weight: 700; padding: .22rem .65rem; border-radius: 50px; background: var(--tr-soft); color: var(--tr-muted); border: 1px solid var(--tr-line); }
.tr-pill.ok { background: #ecfdf5; color: var(--tr-ok); border-color: #a7f3d0; }
.tr-pill.warn { background: #fffbeb; color: var(--tr-warn); border-color: #fde68a; }
.tr-pill.bad { background: #fef2f2; color: var(--tr-bad); border-color: #fecaca; }
.tr-pill.official { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.tr-pill.example { background: #fdf4ff; color: #a21caf; border-color: #f5d0fe; }

/* ── Progress ── */
.tr-progress { display: flex; align-items: center; gap: .6rem; }
.tr-bar { flex: 1; height: 9px; background: #eef2f7; border-radius: 6px; overflow: hidden; }
.tr-bar > span { display: block; height: 100%; width: 0; background: var(--c, var(--tr-main)); border-radius: 6px; transition: width .6s; }
.tr-progress b { font-size: .8rem; min-width: 38px; text-align: left; color: var(--tr-ink); }
.tr-progress-label { font-size: .78rem; color: var(--tr-muted); }

/* ── Buttons ── */
.tr-btn { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; padding: .62rem 1.15rem; border-radius: 10px; border: 1.5px solid transparent; font-weight: 700; font-size: .88rem; cursor: pointer; font-family: inherit; text-decoration: none; transition: .2s; line-height: 1.3; background: var(--c, var(--tr-main)); color: #fff; }
.tr-btn:hover { filter: brightness(1.07); transform: translateY(-1px); color: #fff; }
.tr-btn:disabled, .tr-btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; transform: none; filter: none; }
.tr-btn.ghost { background: #fff; color: var(--tr-ink); border-color: var(--tr-line); }
.tr-btn.ghost:hover { border-color: var(--c, var(--tr-main)); color: var(--c, var(--tr-main)); }
.tr-btn.ok { background: var(--tr-ok); }
.tr-btn.dark { background: var(--tr-ink); }
.tr-btn.danger { background: #fff; color: var(--tr-bad); border-color: #fecaca; }
.tr-btn.sm { padding: .38rem .75rem; font-size: .78rem; border-radius: 8px; }
.tr-btn.block { width: 100%; }
.tr-actions { display: flex; flex-wrap: wrap; gap: .5rem; }

/* ── Lessons list ── */
.tr-lessons { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .5rem; }
.tr-lesson-item a { display: flex; align-items: center; gap: .8rem; padding: .75rem .9rem; border: 1.5px solid var(--tr-line); border-radius: 12px; background: #fff; color: var(--tr-ink); text-decoration: none; transition: .2s; }
.tr-lesson-item a:hover { border-color: var(--c, var(--tr-main)); background: #fffafb; }
.tr-lesson-item .n { width: 34px; height: 34px; border-radius: 10px; background: var(--tr-soft); border: 1px solid var(--tr-line); display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: .85rem; flex-shrink: 0; }
.tr-lesson-item.done .n { background: var(--tr-ok); color: #fff; border-color: var(--tr-ok); }
.tr-lesson-item.current a { border-color: var(--c, var(--tr-main)); box-shadow: 0 0 0 3px rgba(225,29,72,.08); }
.tr-lesson-item .t { flex: 1; font-weight: 700; font-size: .9rem; }
.tr-lesson-item .d { font-size: .74rem; color: var(--tr-muted); white-space: nowrap; }

/* ── Objectives ── */
.tr-objectives { list-style: none; padding: 0; margin: 0; display: grid; gap: .45rem; }
.tr-objectives li { display: flex; gap: .55rem; align-items: flex-start; font-size: .9rem; line-height: 1.8; color: #334155; }
.tr-objectives li::before { content: '\f00c'; font-family: 'Font Awesome 6 Free'; font-weight: 900; color: var(--c, var(--tr-main)); font-size: .8rem; margin-top: .35rem; }

/* ── Lesson content ── */
.tr-lesson { font-size: .96rem; line-height: 2; color: #1f2937; }
.tr-lesson h3 { font-size: 1.08rem; margin: 1.3rem 0 .5rem; color: var(--tr-ink); }
.tr-lesson h4 { font-size: .98rem; margin: 1rem 0 .35rem; }
.tr-lesson p { color: #334155; margin: 0 0 .8rem; }
.tr-lesson ul, .tr-lesson ol { padding-right: 1.3rem; margin: 0 0 .9rem; list-style: disc; }
.tr-lesson ol { list-style: decimal; }
.tr-lesson li { margin-bottom: .35rem; color: #334155; }
.tr-lesson table { width: 100%; border-collapse: collapse; margin: .6rem 0 1rem; font-size: .88rem; }
.tr-lesson th, .tr-lesson td { border: 1px solid var(--tr-line); padding: .5rem .65rem; text-align: right; vertical-align: top; }
.tr-lesson th { background: var(--tr-soft); }
.tr-block { border-radius: 14px; padding: 1.1rem 1.25rem; margin: 1.1rem 0; border: 1px solid var(--tr-line); }
.tr-block-title { display: flex; align-items: center; gap: .5rem; font-weight: 800; margin-bottom: .55rem; font-size: .95rem; flex-wrap: wrap; }
.tr-block.example { background: #fdf8ff; border-color: #f0d5f7; }
.tr-block.exercise { background: #f0fdf9; border-color: #b7ebd9; }
.tr-block.key { background: #fff7ed; border-color: #fed7aa; }
.tr-block.official { background: #eff6ff; border-color: #bfdbfe; }
.tr-note { font-size: .8rem; color: var(--tr-muted); }
details.tr-reveal { margin-top: .7rem; background: #fff; border: 1px dashed #94a3b8; border-radius: 10px; padding: .6rem .85rem; }
details.tr-reveal summary { cursor: pointer; font-weight: 700; font-size: .86rem; color: var(--tr-ink); }
details.tr-reveal[open] summary { margin-bottom: .45rem; }
.tr-textarea { width: 100%; min-height: 90px; border: 1.5px solid var(--tr-line); border-radius: 10px; padding: .65rem .8rem; font-family: inherit; font-size: .9rem; resize: vertical; direction: rtl; }
.tr-textarea:focus, .tr-input:focus, .tr-select:focus { outline: none; border-color: var(--c, var(--tr-main)); box-shadow: 0 0 0 3px rgba(225,29,72,.1); }
.tr-lesson-nav { display: flex; justify-content: space-between; align-items: center; gap: .6rem; flex-wrap: wrap; margin-top: 1.4rem; padding-top: 1.1rem; border-top: 1px solid var(--tr-line); }

/* ── Quiz ── */
.tr-q { background: #fff; border: 1px solid var(--tr-line); border-radius: 16px; padding: 1.2rem 1.3rem; margin-bottom: 1rem; }
.tr-q-head { display: flex; justify-content: space-between; gap: .6rem; align-items: center; margin-bottom: .6rem; flex-wrap: wrap; }
.tr-q-stem { font-weight: 800; font-size: .98rem; line-height: 1.9; margin-bottom: .7rem; color: var(--tr-ink); }
.tr-q-case { background: var(--tr-soft); border-right: 4px solid var(--c, var(--tr-main)); border-radius: 10px; padding: .75rem .95rem; font-size: .9rem; line-height: 1.9; margin-bottom: .75rem; color: #334155; }
.tr-opt { display: flex; align-items: flex-start; gap: .65rem; padding: .65rem .85rem; border: 1.5px solid var(--tr-line); border-radius: 11px; margin-bottom: .45rem; cursor: pointer; font-size: .9rem; line-height: 1.8; transition: .15s; background: #fff; }
.tr-opt:hover { border-color: #94a3b8; }
.tr-opt input { margin-top: .45rem; accent-color: var(--c, var(--tr-main)); flex-shrink: 0; }
.tr-opt.sel { border-color: var(--c, var(--tr-main)); background: #fff7f8; }
.tr-opt.right { border-color: var(--tr-ok); background: #ecfdf5; }
.tr-opt.wrong { border-color: var(--tr-bad); background: #fef2f2; }
.tr-feedback { margin-top: .7rem; border-radius: 10px; padding: .75rem .95rem; font-size: .88rem; line-height: 1.9; }
.tr-feedback.ok { background: #ecfdf5; border: 1px solid #a7f3d0; color: #065f46; }
.tr-feedback.no { background: #fef2f2; border: 1px solid #fecaca; color: #7f1d1d; }
.tr-score { text-align: center; padding: 1.6rem 1rem; }
.tr-score-num { font-size: 3rem; font-weight: 900; line-height: 1.1; }
.tr-score.pass .tr-score-num { color: var(--tr-ok); }
.tr-score.fail .tr-score-num { color: var(--tr-bad); }
.tr-sticky-submit { position: sticky; bottom: 0; background: linear-gradient(to top, #f6f7fb 70%, rgba(246,247,251,0)); padding: 1rem 0 .8rem; z-index: 5; }

/* ── Tables ── */
.tr-table-wrap { overflow-x: auto; }
.tr-table { width: 100%; border-collapse: collapse; font-size: .86rem; background: #fff; }
.tr-table th, .tr-table td { padding: .6rem .7rem; border-bottom: 1px solid var(--tr-line); text-align: right; vertical-align: middle; }
.tr-table th { background: var(--tr-soft); font-weight: 800; color: #334155; white-space: nowrap; }

/* ── Alerts ── */
.tr-alert { border-radius: 12px; padding: .85rem 1rem; font-size: .9rem; line-height: 1.8; display: flex; gap: .6rem; align-items: flex-start; }
.tr-alert i { margin-top: .35rem; }
.tr-alert-info { background: #eff6ff; border: 1px solid #bfdbfe; color: #1e3a8a; }
.tr-alert-ok { background: #ecfdf5; border: 1px solid #a7f3d0; color: #065f46; }
.tr-alert-warn { background: #fffbeb; border: 1px solid #fde68a; color: #78350f; }
.tr-alert-error { background: #fef2f2; border: 1px solid #fecaca; color: #7f1d1d; }
.tr-loading { text-align: center; padding: 3rem 1rem; color: var(--tr-muted); }
.tr-loading i { font-size: 1.6rem; color: var(--tr-main); margin-bottom: .6rem; display: block; }

/* ── Forms (admin) ── */
.tr-field { display: flex; flex-direction: column; gap: .3rem; margin-bottom: .8rem; }
.tr-field label { font-size: .82rem; font-weight: 700; color: #334155; }
.tr-input, .tr-select { border: 1.5px solid var(--tr-line); border-radius: 10px; padding: .55rem .75rem; font-family: inherit; font-size: .9rem; background: #fff; direction: rtl; width: 100%; }
.tr-row { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.tr-tabs { display: flex; gap: .35rem; overflow-x: auto; border-bottom: 2px solid var(--tr-line); margin-bottom: 1.2rem; scrollbar-width: thin; }
.tr-tab { background: none; border: none; padding: .65rem 1rem; font-weight: 800; font-size: .88rem; color: var(--tr-muted); border-bottom: 3px solid transparent; margin-bottom: -2px; cursor: pointer; white-space: nowrap; font-family: inherit; }
.tr-tab.active { color: var(--tr-main); border-bottom-color: var(--tr-main); }
.tr-modal { position: fixed; inset: 0; background: rgba(15,23,42,.55); z-index: 3000; display: none; align-items: flex-start; justify-content: center; padding: 2rem 1rem; overflow-y: auto; }
.tr-modal.open { display: flex; }
.tr-modal-box { background: #fff; border-radius: 16px; width: 100%; max-width: 820px; padding: 1.4rem; box-shadow: 0 25px 70px rgba(0,0,0,.3); }
.tr-modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; gap: 1rem; }
.tr-modal-head h3 { margin: 0; font-size: 1.1rem; }

/* ── Sources ── */
.tr-source { padding: .9rem 1rem; border: 1px solid var(--tr-line); border-radius: 12px; background: #fff; margin-bottom: .6rem; }
.tr-source-cite { font-size: .9rem; line-height: 1.9; color: #1f2937; direction: auto; unicode-bidi: plaintext; }
.tr-source-note { font-size: .82rem; color: var(--tr-muted); margin-top: .3rem; }
.tr-source a { color: #1d4ed8; word-break: break-all; font-size: .8rem; }

/* ── Certificate (A4 landscape 1123×794) ── */
.tr-cert-stage { overflow: hidden; margin: 0 auto; }
.tr-cert { width: 1123px; height: 794px; background: #fff; position: relative; direction: rtl; font-family: 'Cairo', Arial, sans-serif; color: #0f172a; transform-origin: top right; box-sizing: border-box; padding: 34px; }
.tr-cert-frame { position: absolute; inset: 22px; border: 3px solid #9f1239; border-radius: 6px; }
.tr-cert-frame::after { content: ''; position: absolute; inset: 8px; border: 1px solid #e5b3c0; border-radius: 3px; }
.tr-cert-inner { position: relative; z-index: 1; height: 100%; display: flex; flex-direction: column; align-items: center; text-align: center; padding: 36px 70px 26px; }
.tr-cert-brand { font-size: 17px; font-weight: 900; color: #9f1239; direction: ltr; }
.tr-cert-sub { font-size: 13px; color: #64748b; margin-top: 2px; }
.tr-cert-title { font-size: 44px; font-weight: 900; color: #0f172a; margin: 22px 0 6px; line-height: 1.3; }
.tr-cert-lead { font-size: 17px; color: #475569; margin: 0; }
.tr-cert-name { font-size: 38px; font-weight: 900; color: #9f1239; margin: 12px 0 8px; padding: 0 40px 8px; border-bottom: 2px solid #f1d5dc; line-height: 1.4; }
.tr-cert-course { font-size: 25px; font-weight: 800; color: #0f172a; margin: 6px 0 4px; line-height: 1.5; }
.tr-cert-result { display: inline-block; margin-top: 10px; font-size: 16px; font-weight: 800; color: #065f46; background: #ecfdf5; border: 1px solid #a7f3d0; padding: 5px 18px; border-radius: 30px; }
.tr-cert-foot { margin-top: auto; width: 100%; display: grid; grid-template-columns: 1fr 1fr 1fr; align-items: end; gap: 20px; }
.tr-cert-info { text-align: right; font-size: 13.5px; line-height: 2; color: #334155; }
.tr-cert-info b { color: #0f172a; }
.tr-cert-sign { text-align: center; }
.tr-cert-sign-mark { font-family: 'Aref Ruqaa', 'Cairo', serif; font-size: 30px; color: #1e3a8a; line-height: 1.2; }
.tr-cert-sign-brand { font-size: 14px; font-weight: 900; color: #0f172a; border-top: 1.5px solid #0f172a; padding-top: 5px; margin-top: 4px; direction: ltr; }
.tr-cert-sign-note { font-size: 11px; color: #64748b; }
.tr-cert-qr { text-align: left; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.tr-cert-qr img { width: 118px; height: 118px; border: 1px solid #e2e8f0; padding: 4px; background: #fff; }
.tr-cert-qr span { font-size: 11px; color: #64748b; }
.tr-cert-seal { position: absolute; top: 58px; left: 70px; width: 96px; height: 96px; border-radius: 50%; border: 3px double #9f1239; display: flex; align-items: center; justify-content: center; flex-direction: column; color: #9f1239; font-weight: 900; font-size: 12px; line-height: 1.3; transform: rotate(-12deg); }
.tr-cert-seal i { font-size: 24px; margin-bottom: 2px; }

/* ── Summary doc (for PDF) ── */
.tr-summary-doc { width: 794px; background: #fff; padding: 46px 52px; direction: rtl; font-family: 'Cairo', Arial, sans-serif; color: #0f172a; }
.tr-summary-doc h1 { font-size: 26px; margin: 0 0 4px; }
.tr-summary-doc h2 { font-size: 17px; margin: 22px 0 8px; color: #9f1239; border-bottom: 1px solid #f1d5dc; padding-bottom: 4px; }
.tr-summary-doc li, .tr-summary-doc p { font-size: 13.5px; line-height: 2; color: #334155; }
.tr-summary-doc ul { padding-right: 20px; margin: 0; list-style: disc; }
.tr-summary-doc .brand { direction: ltr; text-align: left; font-weight: 900; color: #9f1239; font-size: 13px; }

/* ── Toast ── */
.tr-toast { position: fixed; bottom: 1.2rem; left: 50%; transform: translateX(-50%) translateY(120%); background: #0f172a; color: #fff; padding: .7rem 1.2rem; border-radius: 12px; font-size: .88rem; font-weight: 700; z-index: 5000; transition: transform .3s; box-shadow: 0 10px 30px rgba(0,0,0,.25); max-width: 90vw; }
.tr-toast.show { transform: translateX(-50%) translateY(0); }
.tr-toast.ok { background: var(--tr-ok); }
.tr-toast.error { background: var(--tr-bad); }

/* ── Footer ── */
.tr-footer { background: #0f172a; color: rgba(255,255,255,.7); padding: 1.6rem 0; margin-top: 2rem; font-size: .82rem; }
.tr-footer .tr-container { display: flex; justify-content: space-between; flex-wrap: wrap; gap: .6rem; }
.tr-footer a { color: rgba(255,255,255,.85); }

/* ── Responsive ── */
@media (max-width: 900px) {
  .tr-two { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .tr-grid { grid-template-columns: 1fr; }
  .tr-container { padding: 0 .9rem; }
  .tr-hero { padding: 2.2rem 0 1.8rem; }
  .tr-card { padding: 1.05rem; border-radius: 14px; }
  .tr-q { padding: 1rem; }
  .tr-lesson { font-size: .93rem; }
  .tr-btn { padding: .6rem .95rem; }
  .tr-lesson-nav .tr-btn { flex: 1; }
  .tr-table { font-size: .8rem; }
  .tr-modal { padding: .6rem; }
  .tr-modal-box { padding: 1rem; }
}

/* ── Print ── */
@media print {
  @page { size: A4 landscape; margin: 0; }
  body.tr-print-cert * { visibility: hidden; }
  body.tr-print-cert .tr-cert, body.tr-print-cert .tr-cert * { visibility: visible; }
  body.tr-print-cert .tr-cert { position: fixed; top: 0; right: 0; transform: none !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .navbar, .tr-footer, .tr-no-print { display: none !important; }
}
