/* ═══════════ Rouby Marketing — مشغّل الكورس ═══════════
   الهوية الكحلي (#003366) مترجمة لواجهة داكنة premium */

:root {
    --w-accent:      #3d8bfd;
    --w-accent-2:    #1f6fe5;
    --w-gold:        #e8b53f;
    --w-bg:          #05101c;
    --w-panel:       #0a1a2b;
    --w-surface:     #10263c;
    --w-surface-2:   #16324e;
    --w-line:        #17334f;
    --w-text:        #eef4fb;
    --w-muted:       #90a8c2;
    --w-green:       #2ecc71;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Tajawal', sans-serif;
    background: var(--w-bg);
    color: var(--w-text);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ═══ شريط الأدمن ═══ */
.admin-bar {
    display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
    direction: rtl; background: #3a2a08; border-bottom: 1px solid #6d5015;
    padding: 9px 22px; font-size: .8rem; color: #ffd79a;
    position: sticky; top: 0; z-index: 60;
}
.admin-bar .ab-tag {
    background: var(--w-gold); color: #2a1c04; padding: 4px 12px;
    border-radius: 20px; font-weight: 800; font-size: .72rem; flex-shrink: 0;
}
.admin-bar .ab-note { flex-grow: 1; line-height: 1.7; }
.admin-bar .ab-link {
    background: rgba(255,255,255,.12); color: #ffd79a; padding: 6px 14px;
    border-radius: 8px; text-decoration: none; font-weight: 700; flex-shrink: 0;
}
.admin-bar .ab-link:hover { background: var(--w-gold); color: #2a1c04; }

.watch-shell { display: flex; min-height: 100vh; direction: rtl; }
.watch-shell.has-admin-bar .curriculum { height: calc(100vh - 40px); top: 40px; }

/* ═══════════ المنهج ═══════════ */
.curriculum {
    width: 370px; flex-shrink: 0;
    background: var(--w-panel);
    border-left: 1px solid var(--w-line);
    display: flex; flex-direction: column;
    position: sticky; top: 0; height: 100vh; z-index: 30;
}

.cur-head { padding: 22px 22px 18px; border-bottom: 1px solid var(--w-line); }

.back-link {
    display: inline-flex; align-items: center; gap: 8px;
    color: var(--w-muted); text-decoration: none;
    font-size: .8rem; font-weight: 700; margin-bottom: 13px; transition: color .2s;
}
.back-link:hover { color: var(--w-accent); }

.cur-head h1 { font-size: 1.05rem; font-weight: 800; line-height: 1.55; margin-bottom: 11px; }

.cur-meta { display: flex; gap: 15px; flex-wrap: wrap; font-size: .76rem; color: var(--w-muted); margin-bottom: 16px; }
.cur-meta i { color: var(--w-accent); margin-inline-end: 4px; }

.prog-wrap { margin-bottom: 16px; }
.prog-row { display: flex; justify-content: space-between; font-size: .76rem; color: var(--w-muted); margin-bottom: 7px; }
.prog-row strong { color: var(--w-accent); font-size: .85rem; }
.prog-track { height: 6px; background: rgba(255,255,255,.08); border-radius: 20px; overflow: hidden; }
.prog-fill {
    height: 100%; border-radius: 20px;
    background: linear-gradient(90deg, var(--w-accent), var(--w-accent-2));
    transition: width .5s ease;
}

/* ═══ كارت الشهادة ═══ */
.cert-box {
    display: flex; align-items: center; gap: 12px;
    background: var(--w-surface); border: 1px solid var(--w-line);
    border-radius: 13px; padding: 13px 14px;
}
.cert-box.issued, .cert-box.ready {
    background: linear-gradient(135deg, rgba(232,181,63,.14), rgba(232,181,63,.04));
    border-color: rgba(232,181,63,.4);
}
.cert-ico {
    width: 38px; height: 38px; border-radius: 11px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    background: rgba(232,181,63,.18); color: var(--w-gold); font-size: 1.05rem;
}
.cert-ico.locked { background: rgba(255,255,255,.06); color: var(--w-muted); }
.cert-body { flex-grow: 1; min-width: 0; }
.cert-body strong { display: block; font-size: .85rem; font-weight: 800; }
.cert-body span { display: block; font-size: .72rem; color: var(--w-muted); margin-top: 2px; word-break: break-all; }
.cert-btn {
    background: var(--w-gold); color: #2a1c04; border: none;
    padding: 8px 15px; border-radius: 8px; font-family: inherit;
    font-weight: 800; font-size: .78rem; cursor: pointer;
    text-decoration: none; white-space: nowrap; flex-shrink: 0;
}
.cert-btn:hover { background: #f3c353; }

/* ═══ قائمة الأقسام ═══ */
.cur-list { flex-grow: 1; overflow-y: auto; padding-bottom: 30px; }
.cur-list::-webkit-scrollbar { width: 7px; }
.cur-list::-webkit-scrollbar-track { background: transparent; }
.cur-list::-webkit-scrollbar-thumb { background: var(--w-line); border-radius: 10px; }

.sec { border-bottom: 1px solid var(--w-line); }
.sec > summary {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 15px 20px; cursor: pointer; list-style: none;
    background: rgba(255,255,255,.02); transition: background .2s;
}
.sec > summary::-webkit-details-marker { display: none; }
.sec > summary:hover { background: rgba(61,139,253,.07); }
.sec-main { min-width: 0; }
.sec-label { display: block; font-size: .68rem; color: var(--w-accent); font-weight: 800; letter-spacing: .5px; margin-bottom: 3px; }
.sec-title { display: block; font-size: .9rem; font-weight: 700; line-height: 1.5; }
.sec-meta { display: flex; align-items: center; gap: 10px; font-size: .7rem; color: var(--w-muted); flex-shrink: 0; }
.chev { transition: transform .25s ease; font-size: .65rem; }
.sec[open] .chev { transform: rotate(180deg); }

.sec ul { list-style: none; }
.sec li a {
    display: flex; align-items: flex-start; gap: 11px;
    padding: 12px 20px 12px 16px; text-decoration: none; color: var(--w-text);
    border-inline-start: 3px solid transparent; transition: background .2s;
}
.sec li a:hover { background: rgba(61,139,253,.08); }

.tick {
    width: 22px; height: 22px; flex-shrink: 0; margin-top: 2px;
    border-radius: 50%; border: 1.5px solid var(--w-line);
    display: flex; align-items: center; justify-content: center;
    font-size: .55rem; color: var(--w-muted);
}
.sec li.done .tick { background: var(--w-green); border-color: var(--w-green); color: #06240f; font-size: .7rem; }
.sec li.active .tick { border-color: var(--w-accent); color: var(--w-accent); }
.sec li.active.done .tick { background: var(--w-green); border-color: var(--w-green); color: #06240f; }

.l-text { min-width: 0; flex-grow: 1; }
.l-title { display: block; font-size: .86rem; line-height: 1.6; }
.l-dur { display: block; font-size: .68rem; color: var(--w-muted); margin-top: 3px; }
.l-dur i { font-size: .55rem; margin-inline-end: 3px; }

.sec li.active a { background: rgba(61,139,253,.14); border-inline-start-color: var(--w-accent); }
.sec li.active .l-title { font-weight: 800; color: #fff; }
.sec li.done .l-title { color: var(--w-muted); }
.sec li.active.done .l-title { color: #fff; }

.cur-empty {
    padding: 40px 22px; text-align: center; color: var(--w-muted); font-size: .86rem;
    display: flex; flex-direction: column; gap: 12px; align-items: center;
}
.cur-empty i { font-size: 2rem; opacity: .3; }

/* ═══════════ المسرح ═══════════ */
.stage { flex-grow: 1; min-width: 0; display: flex; flex-direction: column; }

.stage-head {
    display: flex; align-items: center; gap: 14px;
    padding: 16px 32px;
    background: rgba(5,16,28,.86);
    border-bottom: 1px solid var(--w-line);
    position: sticky; top: 0; z-index: 20;
    backdrop-filter: blur(10px);
}
.head-text { flex-grow: 1; min-width: 0; }
.crumb { display: block; font-size: .7rem; color: var(--w-accent); font-weight: 700; margin-bottom: 3px; }
.stage-head h2 { font-size: 1.1rem; font-weight: 800; line-height: 1.5; }

.burger {
    display: none; background: var(--w-surface); border: 1px solid var(--w-line);
    color: var(--w-text); width: 38px; height: 38px; border-radius: 9px;
    cursor: pointer; font-size: 1rem; flex-shrink: 0;
}
.burger:hover { background: var(--w-accent); border-color: var(--w-accent); }

.btn-attach {
    display: inline-flex; align-items: center; gap: 8px;
    background: var(--w-surface-2); border: 1px solid var(--w-line); color: var(--w-text);
    padding: 9px 16px; border-radius: 9px; text-decoration: none;
    font-weight: 700; font-size: .82rem; flex-shrink: 0; transition: .2s;
}
.btn-attach:hover { background: var(--w-accent); border-color: var(--w-accent); }

.stage-body { flex-grow: 1; width: 100%; max-width: 1080px; margin: 0 auto; padding: 28px 24px 70px; }

/* ═══ المشغّل ═══ */
.player {
    position: relative;
    aspect-ratio: 16/9;
    background: #000;
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid var(--w-line);
    box-shadow: 0 26px 70px rgba(0,0,0,.6);
    cursor: pointer;
}
.player-thumb { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.player-veil {
    position: absolute; inset: 0;
    background: radial-gradient(ellipse at center, rgba(5,16,28,.25) 0%, rgba(5,16,28,.72) 100%);
    transition: background .3s;
}
.player:hover .player-veil { background: radial-gradient(ellipse at center, rgba(5,16,28,.15) 0%, rgba(5,16,28,.62) 100%); }

.player-play {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%);
    width: 84px; height: 84px; border-radius: 50%;
    background: var(--w-accent); color: #fff; border: none;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.7rem; cursor: pointer;
    box-shadow: 0 10px 34px rgba(61,139,253,.5);
    transition: transform .25s ease, background .25s;
}
.player-play i { margin-inline-start: 5px; }
.player:hover .player-play { transform: translate(-50%,-50%) scale(1.09); background: var(--w-accent-2); }

.player-brand { position: absolute; top: 16px; inset-inline-start: 18px; opacity: .85; }
.player-brand img { height: 30px; width: auto; filter: drop-shadow(0 2px 6px rgba(0,0,0,.6)); }

/* بيغطي شريط يوتيوب العلوي (العنوان + Watch on YouTube) بعد التشغيل */
.player-mask {
    display: none;
    position: absolute; top: 0; inset-inline: 0; height: 62px;
    z-index: 3; background: transparent;
}
.player.playing .player-mask { display: block; }

/* ركن لوجو يوتيوب في شريط التحكم */
.player-mask-corner {
    display: none;
    position: absolute; bottom: 0; inset-inline-start: 0;
    width: 92px; height: 46px; z-index: 3; background: transparent;
}
.player.playing .player-mask-corner { display: block; }
.player.playing { cursor: default; }
.player.playing .player-thumb,
.player.playing .player-veil,
.player.playing .player-play,
.player.playing .player-brand { display: none; }

.player iframe, .player.is-file video {
    position: absolute; inset: 0; width: 100%; height: 100%; border: 0; z-index: 2;
}
.player.is-file { cursor: default; }

/* ═══ شريط الإجراءات ═══ */
.action-row {
    display: flex; align-items: center; justify-content: space-between;
    gap: 14px; margin-top: 22px; flex-wrap: wrap;
}
.done-form { margin: 0; }
.btn-done {
    display: inline-flex; align-items: center; gap: 9px;
    background: var(--w-surface); border: 1.5px solid var(--w-line);
    color: var(--w-text); padding: 12px 22px; border-radius: 11px;
    font-family: inherit; font-weight: 800; font-size: .88rem; cursor: pointer; transition: .2s;
}
.btn-done:hover { border-color: var(--w-green); color: var(--w-green); }
.btn-done.on { background: rgba(46,204,113,.14); border-color: var(--w-green); color: var(--w-green); }

.nav-pair { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-inline-start: auto; }
.nav-btn {
    display: inline-flex; align-items: center; gap: 11px;
    background: var(--w-surface); border: 1px solid var(--w-line); color: var(--w-text);
    padding: 11px 18px; border-radius: 11px; text-decoration: none; max-width: 260px; transition: .2s;
}
.nav-btn:hover { border-color: var(--w-accent); background: rgba(61,139,253,.1); }
.nav-btn i { color: var(--w-accent); flex-shrink: 0; font-size: .8rem; }
.nav-btn span { display: flex; flex-direction: column; font-weight: 700; font-size: .85rem; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.nav-btn small { color: var(--w-muted); font-weight: 400; font-size: .68rem; }
.nav-end { color: var(--w-muted); font-size: .82rem; }
.nav-end i { color: var(--w-gold); margin-inline-end: 6px; }

/* ═══ وصف الدرس ═══ */
.lesson-desc {
    margin-top: 28px; background: var(--w-panel);
    border: 1px solid var(--w-line); border-radius: 14px; padding: 24px 26px;
}
.lesson-desc h3 { font-size: 1rem; font-weight: 800; margin-bottom: 12px; }
.lesson-desc h3 i { color: var(--w-accent); margin-inline-end: 8px; }
.lesson-desc div { color: var(--w-muted); line-height: 2; font-size: .93rem; }

/* ═══ حالات ═══ */
.state {
    background: var(--w-panel); border: 1px solid var(--w-line);
    border-radius: 16px; padding: 60px 30px; text-align: center;
}
.state > i { font-size: 3.2rem; color: var(--w-accent); opacity: .45; margin-bottom: 18px; }
.state h3 { font-size: 1.25rem; font-weight: 800; margin-bottom: 8px; }
.state p { color: var(--w-muted); font-size: .92rem; line-height: 1.8; }
.state .muted { font-size: .84rem; margin-top: 10px; }
.state-detail {
    background: rgba(0,0,0,.3); border: 1px solid var(--w-line);
    border-radius: 11px; padding: 15px 18px; margin: 22px auto 0; max-width: 620px; text-align: right;
}
.state-detail .dlabel { font-size: .73rem; color: var(--w-muted); margin-bottom: 6px; }
.state-detail code {
    display: block; background: rgba(0,0,0,.4); padding: 9px 12px; border-radius: 7px;
    font-size: .8rem; color: #ffb4b4; word-break: break-all; direction: ltr; text-align: left;
}
.state-btn {
    display: inline-flex; align-items: center; gap: 8px; margin-top: 22px;
    background: var(--w-accent); color: #fff; padding: 11px 26px;
    border-radius: 10px; text-decoration: none; font-weight: 800; font-size: .88rem;
}
.state-btn:hover { background: var(--w-accent-2); }

/* ═══ الموبايل ═══ */
.sb-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.65); z-index: 25; }
.sb-overlay.show { display: block; }

@media (max-width: 991px) {
    .curriculum {
        position: fixed; top: 0; right: -370px; height: 100vh;
        transition: right .3s ease; box-shadow: -12px 0 44px rgba(0,0,0,.55);
        max-width: 88vw;
    }
    .curriculum.open { right: 0; }
    .watch-shell.has-admin-bar .curriculum { top: 0; height: 100vh; }
    .burger { display: flex; align-items: center; justify-content: center; }
    .stage-head { padding: 13px 16px; }
    .stage-head h2 { font-size: .96rem; }
    .stage-body { padding: 16px 14px 50px; }
    .player { border-radius: 11px; }
    .player-play { width: 62px; height: 62px; font-size: 1.2rem; }
    .action-row { flex-direction: column; align-items: stretch; }
    .nav-pair { margin-inline-start: 0; }
    .nav-btn { flex-grow: 1; max-width: 100%; }
    .btn-done { justify-content: center; }
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ═══ شريط المعاينة المجانية ═══ */
.preview-bar {
    display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
    direction: rtl;
    background: linear-gradient(90deg, #0a2e18, #0f3d22);
    border-bottom: 1px solid #1d6b3c;
    padding: 9px 22px; font-size: .82rem; color: #b9f0cf;
    position: sticky; top: 0; z-index: 60;
}
.preview-bar .pv-tag {
    background: var(--w-green); color: #06240f; padding: 4px 12px;
    border-radius: 20px; font-weight: 800; font-size: .72rem; flex-shrink: 0;
}
.preview-bar .pv-note { flex-grow: 1; line-height: 1.7; }
.preview-bar .pv-note strong { color: #fff; }
.preview-bar .pv-cta {
    background: var(--w-green); color: #06240f; padding: 7px 18px;
    border-radius: 8px; text-decoration: none; font-weight: 800; flex-shrink: 0;
}
.preview-bar .pv-cta:hover { background: #4ee08a; }

/* دروس مقفولة أثناء المعاينة */
.sec li.locked a { opacity: .5; }
.sec li.locked a:hover { background: rgba(255,255,255,.03); opacity: .75; }
.sec li.locked .tick { border-color: var(--w-line); color: var(--w-muted); }
