/* Trainivio SCORM — shared styles for video and PDF players */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --primary:  #4361ee;
    --success:  #10b981;
    --danger:   #f94144;
    --warning:  #f8961e;
    --bg:       #0f0f0f;
    --bg2:      #1a1a1a;
    --bg3:      #2d2d2d;
    --border:   rgba(255,255,255,0.1);
    --radius:   12px;
    --radius-sm: 8px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: #fff;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ── HEADER ──────────────────────────────────────────────────────────────────── */
.player-header {
    background: #1a1a2e;
    padding: 0.7rem 1.4rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    border-bottom: 2px solid var(--primary);
    flex-shrink: 0;
}

.player-header .logo  { font-size: 1rem; font-weight: 700; color: var(--primary); letter-spacing: 1px; }
.player-header .title { font-size: 0.9rem; color: #ccc; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── VIDEO WRAPPER ───────────────────────────────────────────────────────────── */
.video-wrapper {
    position: relative;
    flex: 1;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

#scorm-video { width: 100%; height: 100%; object-fit: contain; }

/* Overlay sits on top of video — hides behind video when .hidden */
#question-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.88);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 1.5rem;
}

#question-overlay.hidden { display: none; }

/* ── PDF WRAPPER ─────────────────────────────────────────────────────────────── */
.pdf-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #0a0a0a;
    position: relative;
}

.reading-progress     { height: 3px; background: rgba(255,255,255,0.06); flex-shrink: 0; }
.reading-progress-bar { height: 100%; background: linear-gradient(90deg, var(--primary), var(--success)); transition: width 0.4s ease; width: 0%; }

.canvas-wrapper {
    flex: 1;
    overflow: auto;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 24px 50px;
    position: relative;
}

#pdf-canvas {
    box-shadow: 0 16px 48px rgba(0,0,0,0.7);
    border-radius: 3px;
    max-width: 100%;
    display: block;
    transition: opacity 0.2s ease;
}

#pdf-error {
    display: none;
    color: var(--danger);
    text-align: center;
    padding: 40px;
    font-size: 1rem;
}

/* PDF nav arrows */
.nav-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255,255,255,0.07);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255,255,255,0.4);
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s;
    z-index: 10;
}

.nav-arrow:hover    { background: rgba(67,97,238,0.3); color: white; border-color: var(--primary); }
.nav-arrow.left     { left: 10px; }
.nav-arrow.right    { right: 10px; }
.nav-arrow.disabled { opacity: 0.15; pointer-events: none; }

/* PDF controls bar */
.pdf-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: #141414;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    flex-wrap: wrap;
}

.ctrl-btn {
    padding: 7px 14px;
    background: rgba(255,255,255,0.07);
    color: white;
    border: 1px solid var(--border);
    border-radius: 20px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
    white-space: nowrap;
}

.ctrl-btn:hover:not(:disabled)  { background: rgba(255,255,255,0.13); transform: translateY(-1px); }
.ctrl-btn:disabled               { opacity: 0.3; cursor: not-allowed; }
.ctrl-btn.primary                { background: linear-gradient(135deg, var(--primary), #3a56d4); border-color: transparent; }
.ctrl-btn.success                { background: linear-gradient(135deg, var(--success), #047857); border-color: transparent; }

.page-pill {
    margin-left: auto;
    background: rgba(255,255,255,0.06);
    border: 1px solid var(--border);
    color: #ccc;
    font-size: 13px;
    padding: 6px 14px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.page-pill input {
    width: 32px;
    background: transparent;
    border: none;
    outline: none;
    color: white;
    font-size: 13px;
    text-align: center;
    font-weight: 600;
}

/* ── QUESTION / COMPLETION MODAL OVERLAY ─────────────────────────────────────── */
/* Used by both video (#question-overlay children) and PDF (.q-overlay) */

.q-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.82);
    backdrop-filter: blur(8px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.22s ease;
}

@keyframes fadeIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalUp { from { opacity: 0; transform: translateY(22px); } to { opacity: 1; transform: translateY(0); } }

.q-modal {
    background: var(--bg2);
    border: 2px solid var(--primary);
    border-radius: var(--radius);
    width: 92%;
    max-width: 580px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.6);
    overflow: hidden;
    animation: modalUp 0.28s ease;
}

.q-header {
    background: var(--primary);
    padding: 14px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 600;
    font-size: 15px;
}

.q-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.q-count {
    background: rgba(255,255,255,0.2);
    padding: 3px 10px;
    border-radius: 10px;
    font-size: 12px;
}

.q-timer {
    background: rgba(255,255,255,0.2);
    padding: 3px 10px;
    border-radius: 10px;
    font-size: 12px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-variant-numeric: tabular-nums;
    transition: background 0.2s, color 0.2s;
}

.q-timer.low {
    background: var(--danger);
    color: #fff;
    animation: pulseTimer 1s infinite;
}

@keyframes pulseTimer {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.6; }
}

.q-body { padding: 20px 22px; }

/* Danger badge */
.danger-badge {
    display: inline-block;
    background: var(--danger);
    color: white;
    font-size: 0.68rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 20px;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.q-text {
    background: rgba(255,255,255,0.05);
    border-left: 3px solid var(--primary);
    padding: 12px 14px;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-size: 14px;
    line-height: 1.55;
    margin-bottom: 16px;
}

/* Section labels (single-modal layout) */
.q-section-label {
    color: #999;
    font-size: 12px;
    margin: 14px 0 10px;
}

/* Answer options */
.ans-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 9px;
    margin-bottom: 6px;
}

.ans-btn {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 11px 12px;
    border-radius: var(--radius-sm);
    background: rgba(255,255,255,0.05);
    border: 2px solid var(--border);
    color: white;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
    text-align: left;
}

.ans-btn:hover    { background: rgba(67,97,238,0.15); border-color: #4895ef; }
.ans-btn.selected { background: rgba(67,97,238,0.25); border-color: var(--primary); }

.ans-num {
    width: 24px; height: 24px; border-radius: 50%;
    background: rgba(255,255,255,0.1);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 11px; flex-shrink: 0;
}

.ans-btn.selected .ans-num { background: var(--primary); }

/* Confidence buttons */
.conf-row {
    display: flex;
    gap: 7px;
    margin: 6px 0 5px;
}

.conf-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 4px;
    background: rgba(255,255,255,0.05);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
}

.conf-btn:hover    { background: rgba(67,97,238,0.15); border-color: #4895ef; }
.conf-btn.selected { background: rgba(67,97,238,0.25); border-color: var(--primary); }

.conf-num  { font-size: 17px; font-weight: 700; color: white; margin-bottom: 3px; }
.conf-lbl  { font-size: 9px; color: #999; text-align: center; line-height: 1.2; }
.conf-btn.selected .conf-num { color: #4895ef; }
.conf-scale { display: flex; justify-content: space-between; color: #555; font-size: 11px; margin-top: 4px; }

/* Footer / submit (single-modal layout) */
.q-footer {
    padding: 14px 22px 20px;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.q-submit-btn {
    width: 100%;
    padding: 12px 18px;
    border-radius: var(--radius-sm);
    border: none;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: linear-gradient(135deg, var(--success), #047857);
    color: white;
    transition: all 0.2s;
}

.q-submit-btn:hover:not(:disabled) { opacity: 0.88; transform: translateY(-1px); }
.q-submit-btn:disabled             { opacity: 0.35; cursor: not-allowed; }

/* ── COMPLETION CARD (inside #question-overlay or .q-overlay) ────────────────── */
.completion-card {
    background: var(--bg2);
    border-radius: var(--radius);
    padding: 2.2rem;
    max-width: 460px;
    width: 100%;
    text-align: center;
    border: 1px solid #333;
}

.completion-icon {
    width: 68px; height: 68px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.9rem; margin: 0 auto 1.1rem;
}

.completion-icon.passed { background: rgba(16,185,129,0.2); color: #6fcf97; }
.completion-icon.failed { background: rgba(249,65,68,0.2);  color: #eb5757; }

.completion-card h2   { font-size: 1.4rem; font-weight: 700; margin-bottom: 0.6rem; }
.score-display        { font-size: 1.9rem; font-weight: 800; color: #a5b4fc; margin: 0.4rem 0; }
.score-detail         { font-size: 0.9rem; color: #aaa; margin-bottom: 0.3rem; }
.passing-note         { font-size: 0.82rem; color: #666; margin-bottom: 0.6rem; }
.fail-note            { color: var(--danger); font-size: 0.8rem; }

/* ── CUSTOM VIDEO CONTROL BAR (no seekbar) ───────────────────────────────────── */
#scorm-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: #141414;
    border-top: 1px solid rgba(255,255,255,0.07);
    flex-shrink: 0;
}

#scorm-controls .ctrl-btn {
    padding: 7px 14px;
    background: rgba(255,255,255,0.08);
    color: white;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.2s, transform 0.15s;
    white-space: nowrap;
    min-width: 40px;
    text-align: center;
}

#scorm-controls .ctrl-btn:hover {
    background: rgba(255,255,255,0.15);
    transform: translateY(-1px);
}

#scorm-controls .ctrl-time {
    margin-left: auto;
    color: #aaa;
    font-size: 13px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* ══════════════════════════════════════════════════════════════════════════════
   RESULT MODAL — verdict, gates, mindset, per-question feedback
   Shared by player.js and player-pdf.js
   ══════════════════════════════════════════════════════════════════════════════ */
.rs-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.88);
    backdrop-filter: blur(8px);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    animation: fadeIn 0.3s ease;
}

.rs-card {
    background: #1e1e2e;
    border: 2px solid var(--primary);
    border-radius: 16px;
    width: 100%;
    max-width: 640px;
    max-height: 92vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0,0,0,0.6);
    overflow: hidden;
    animation: modalUp 0.3s ease;
}

.rs-scroll {
    padding: 1.6rem 1.6rem 1rem;
    overflow-y: auto;
    flex: 1;
}

.rs-footer {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding: 0.9rem 1.6rem 1.2rem;
    border-top: 1px solid rgba(255,255,255,0.08);
    flex-shrink: 0;
}

.rs-btn {
    padding: 0.7rem 1.6rem;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    border: 1.5px solid transparent;
    transition: opacity 0.2s, transform 0.15s;
}
.rs-btn:hover { opacity: 0.88; transform: translateY(-1px); }
.rs-btn.primary { background: var(--primary); color: #fff; }
.rs-btn.outline { background: transparent; color: #ccc; border-color: rgba(255,255,255,0.2); }

/* Hero */
.rs-hero { text-align: center; margin-bottom: 1.2rem; }
.rs-icon {
    width: 68px; height: 68px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.9rem; margin: 0 auto 0.9rem;
}
.rs-hero h2 { font-size: 1.5rem; font-weight: 800; margin-bottom: 0.5rem; }
.rs-sub { color: #ccc; font-size: 0.9rem; line-height: 1.55; }

.rs-hero.good .rs-icon { background: rgba(16,185,129,0.2); color: var(--success); }
.rs-hero.good h2       { color: var(--success); }
.rs-hero.bad  .rs-icon { background: rgba(249,65,68,0.2);  color: var(--danger); }
.rs-hero.bad  h2       { color: var(--danger); }
.rs-hero.warn .rs-icon { background: rgba(248,150,30,0.2); color: var(--warning); }
.rs-hero.warn h2       { color: var(--warning); }
.rs-hero.crit .rs-icon { background: rgba(190,60,60,0.25); color: #ff7b7b; }
.rs-hero.crit h2       { color: #ff7b7b; }

/* Stat tiles */
.rs-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 1rem;
}
.rs-stat {
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.7rem 0.4rem;
    text-align: center;
    display: flex; flex-direction: column; gap: 4px;
}
.rs-stat-v { font-size: 1.4rem; font-weight: 800; color: #a5b4fc; }
.rs-stat-v.bad { color: var(--danger); }
.rs-stat-l { font-size: 0.66rem; color: #999; line-height: 1.25; }

/* Gate chips */
.rs-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 0.9rem; }
.rs-chip {
    padding: 0.4rem 0.85rem;
    border-radius: 100px;
    font-size: 0.74rem;
    font-weight: 600;
    border: 1.5px solid;
}
.rs-chip.ok   { background: rgba(16,185,129,0.12); border-color: rgba(16,185,129,0.4); color: #6fcf97; }
.rs-chip.fail { background: rgba(249,65,68,0.12);  border-color: rgba(249,65,68,0.4);  color: #ff8587; }
.rs-chip.warn { background: rgba(248,150,30,0.12); border-color: rgba(248,150,30,0.4); color: #ffb454; }

.rs-note {
    padding: 0.75rem 0.95rem;
    border-radius: 10px;
    font-size: 0.8rem;
    line-height: 1.55;
    border-left: 3px solid;
    margin-bottom: 0.9rem;
}
.rs-note.warn { background: rgba(248,150,30,0.1); border-color: var(--warning); color: #ffd7a0; }

/* Section titles */
.rs-section-title {
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #999;
    margin: 1.3rem 0 0.6rem;
}

/* Mindset */
.rs-mindset {
    border-radius: 12px;
    padding: 0.9rem 1rem;
    border: 1.5px solid;
    margin-bottom: 0.7rem;
}
.rs-mindset-name { font-size: 1.15rem; font-weight: 800; margin-bottom: 0.3rem; }
.rs-mindset-why  { font-size: 0.82rem; color: #ddd; line-height: 1.55; }

.rs-mindset.good { background: rgba(16,185,129,0.1); border-color: rgba(16,185,129,0.45); }
.rs-mindset.good .rs-mindset-name { color: var(--success); }
.rs-mindset.bad  { background: rgba(249,65,68,0.1);  border-color: rgba(249,65,68,0.45); }
.rs-mindset.bad  .rs-mindset-name { color: var(--danger); }
.rs-mindset.warn { background: rgba(248,150,30,0.1); border-color: rgba(248,150,30,0.45); }
.rs-mindset.warn .rs-mindset-name { color: var(--warning); }
.rs-mindset.crit { background: rgba(190,60,60,0.12); border-color: rgba(190,60,60,0.5); }
.rs-mindset.crit .rs-mindset-name { color: #ff7b7b; }

.rs-defs {
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.7rem 0.9rem;
    display: flex; flex-direction: column; gap: 6px;
}
.rs-def { font-size: 0.76rem; color: #aaa; line-height: 1.5; padding: 2px 0 2px 8px; border-left: 3px solid transparent; }
.rs-def strong { color: #ddd; }
.rs-def.current { color: #fff; background: rgba(255,255,255,0.06); border-left-color: var(--primary); border-radius: 0 6px 6px 0; }

/* Question feedback */
.rs-qs { display: flex; flex-direction: column; gap: 8px; }
.rs-q {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 0.7rem 0.85rem;
    border-radius: 10px;
    border: 1.5px solid;
}
.rs-q.right { background: rgba(16,185,129,0.08); border-color: rgba(16,185,129,0.35); }
.rs-q.wrong { background: rgba(249,65,68,0.08);  border-color: rgba(249,65,68,0.35); }

.rs-q-icon {
    width: 28px; height: 28px; border-radius: 8px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.9rem; font-weight: 800; color: #fff;
}
.rs-q.right .rs-q-icon { background: var(--success); }
.rs-q.wrong .rs-q-icon { background: var(--danger); }

.rs-q-body { flex: 1; min-width: 0; }
.rs-q-head { font-size: 0.82rem; font-weight: 700; margin-bottom: 3px; }
.rs-q-head .danger-badge { margin: 0 0 0 4px; vertical-align: middle; }
.rs-q-verdict { font-size: 0.7rem; font-weight: 700; margin-left: 6px; opacity: 0.85; }
.rs-q.right .rs-q-verdict { color: #6fcf97; }
.rs-q.wrong .rs-q-verdict { color: #ff8587; }
.rs-q-text { font-size: 0.8rem; color: #ddd; line-height: 1.5; }
.rs-q-meta { font-size: 0.7rem; color: #999; margin-top: 4px; }

/* Print — only the result */
@media print {
    body { background: #fff !important; color: #000 !important; height: auto; overflow: visible; }
    body > *:not(#scormResult) { display: none !important; }
    .rs-overlay { position: static; background: #fff; backdrop-filter: none; padding: 0; display: block; }
    .rs-card { max-height: none; background: #fff; border: 1px solid #999; box-shadow: none; color: #000; }
    .rs-scroll { overflow: visible; }
    .rs-footer { display: none; }
    .rs-sub, .rs-mindset-why, .rs-q-text, .rs-def, .rs-def strong, .rs-stat-l, .rs-q-meta { color: #222 !important; }
    .rs-stat-v { color: #222; }
}

/* ── RESPONSIVE ──────────────────────────────────────────────────────────────── */
@media (max-width: 520px) {
    .ans-grid  { grid-template-columns: 1fr; }
    .conf-row  { gap: 4px; }
    .conf-num  { font-size: 14px; }
    .conf-lbl  { font-size: 8px; }
    .q-body    { padding: 14px 14px; }
    .canvas-wrapper { padding: 14px 30px; }
    .rs-scroll { padding: 1.1rem 1rem 0.8rem; }
    .rs-stats  { grid-template-columns: 1fr; }
    .rs-footer { padding: 0.8rem 1rem 1rem; }
}
