/* ================================================================
   WS Assessment Pro — Frontend CSS v2.0
   Includes: fullscreen test mode, anti-cheat overlays, mobile-first
   ================================================================ */

:root {
    --wsa-primary:    #1a56db;
    --wsa-primary-dk: #1e429f;
    --wsa-success:    #057a55;
    --wsa-danger:     #c81e1e;
    --wsa-warning:    #c27803;
    --wsa-bg:         #f3f4f6;
    --wsa-card:       #ffffff;
    --wsa-border:     #e5e7eb;
    --wsa-text:       #111827;
    --wsa-muted:      #6b7280;
    --wsa-radius:     12px;
    --wsa-shadow:     0 4px 24px rgba(0,0,0,.08);
}

/* ── Base ─────────────────────────────────────────────────────── */
.wsa-wrap {
    max-width: 900px;
    margin: 0 auto;
    padding: 24px 16px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: var(--wsa-text);
}

/* ── Card ─────────────────────────────────────────────────────── */
.wsa-card {
    background: var(--wsa-card);
    border-radius: var(--wsa-radius);
    box-shadow: var(--wsa-shadow);
    padding: 28px 32px;
    margin-bottom: 20px;
}
@media (max-width: 600px) { .wsa-card { padding: 20px 16px; } }

/* ── Buttons ──────────────────────────────────────────────────── */
.wsa-btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 13px 26px; background: var(--wsa-primary); color: #fff;
    border: none; border-radius: 8px; font-size: 15px; font-weight: 600;
    cursor: pointer; text-decoration: none;
    transition: background .15s, transform .1s;
}
.wsa-btn:hover  { background: var(--wsa-primary-dk); color:#fff; transform: translateY(-1px); }
.wsa-btn:active { transform: translateY(0); }
.wsa-btn-outline { background: transparent; border: 2px solid var(--wsa-primary); color: var(--wsa-primary); }
.wsa-btn-outline:hover { background: var(--wsa-primary); color: #fff; }
.wsa-btn-danger  { background: var(--wsa-danger); }
.wsa-btn-danger:hover { background: #9b1c1c; }
.wsa-btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }

/* ── Notices ──────────────────────────────────────────────────── */
.wsa-notice {
    padding: 14px 18px; border-radius: 8px; margin-bottom: 16px;
    background: #eff6ff; border-left: 4px solid var(--wsa-primary); font-size: 14px;
}
.wsa-notice.wsa-error   { background: #fef2f2; border-color: var(--wsa-danger); color: #991b1b; }
.wsa-notice.wsa-success { background: #ecfdf5; border-color: var(--wsa-success); color: #065f46; }
.wsa-notice.wsa-warn    { background: #fffbeb; border-color: var(--wsa-warning); color: #78350f; }

/* ── Meta bar ─────────────────────────────────────────────────── */
.wsa-meta-bar { display: flex; flex-wrap: wrap; gap: 16px; margin: 14px 0; font-size: 14px; color: var(--wsa-muted); }
.wsa-instructions { background: #f3f4f6; border-radius: 8px; padding: 16px 20px; margin: 16px 0; font-size: 14px; line-height: 1.7; }
.wsa-instructions ul { margin: 8px 0 0 16px; }
.wsa-instructions li { margin-bottom: 4px; }

/* ════════════════════════════════════════════════════════════════
   FULLSCREEN TEST ENGINE
   ════════════════════════════════════════════════════════════════ */
body.wsa-fullscreen-active {
    overflow: hidden !important;
}

/* The fullscreen overlay covers the entire viewport */
#wsa-fullscreen-overlay {
    position: fixed;
    inset: 0;
    z-index: 999999;
    background: var(--wsa-bg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: var(--wsa-text);
    /* Anti-cheat: disable text selection globally */
    -webkit-user-select: none;
    -moz-user-select: none;
    user-select: none;
}

/* ── Fullscreen Header Bar ────────────────────────────────────── */
#wsa-fs-header {
    background: #fff;
    border-bottom: 1px solid var(--wsa-border);
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
    z-index: 10;
}
.wsa-fs-title { font-size: 15px; font-weight: 700; max-width: 40%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wsa-fs-meta  { display: flex; align-items: center; gap: 20px; }
.wsa-progress-wrap { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--wsa-muted); }
.wsa-progress-bar  { width: 120px; height: 6px; background: #e5e7eb; border-radius: 99px; overflow: hidden; }
.wsa-progress-fill { height: 100%; background: linear-gradient(90deg, var(--wsa-primary), #60a5fa); border-radius: 99px; transition: width .4s; }

/* ── Timer ────────────────────────────────────────────────────── */
.wsa-timer        { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--wsa-primary); min-width: 60px; }
.wsa-timer-warn   { color: var(--wsa-warning); animation: wsa-blink 1s step-start infinite; }
.wsa-timer-crit   { color: var(--wsa-danger);  animation: wsa-blink .5s step-start infinite; }
@keyframes wsa-blink { 50% { opacity: .35; } }

/* ── Fullscreen Body (scrollable question area) ───────────────── */
#wsa-fs-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    gap: 20px;
}
@media (max-width: 768px) { #wsa-fs-body { flex-direction: column; padding: 16px; } }

/* ── Question Panel ───────────────────────────────────────────── */
#wsa-question-panel {
    flex: 1;
    min-width: 0;
}

/* ── Question Navigator Sidebar ───────────────────────────────── */
#wsa-q-sidebar {
    width: 200px;
    flex-shrink: 0;
}
@media (max-width: 768px) { #wsa-q-sidebar { width: 100%; } }

.wsa-sidebar-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--wsa-muted); margin-bottom: 10px; }
.wsa-q-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
@media (max-width: 768px) { .wsa-q-grid { grid-template-columns: repeat(10, 1fr); } }

.wsa-q-dot {
    width: 32px; height: 32px;
    border-radius: 6px; border: 2px solid var(--wsa-border);
    background: transparent; cursor: pointer;
    font-size: 11px; font-weight: 700; color: var(--wsa-muted);
    transition: all .15s; display: flex; align-items: center; justify-content: center;
}
.wsa-q-dot:hover    { border-color: var(--wsa-primary); color: var(--wsa-primary); }
.wsa-q-dot.active   { border-color: var(--wsa-primary); background: var(--wsa-primary); color: #fff; }
.wsa-q-dot.answered { border-color: #3b82f6; background: #dbeafe; color: #1e40af; }
.wsa-q-dot.answered.active { background: var(--wsa-primary); color: #fff; }

/* Sidebar legend */
.wsa-legend { margin-top: 16px; display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--wsa-muted); }
.wsa-legend-item { display: flex; align-items: center; gap: 6px; }
.wsa-legend-dot  { width: 14px; height: 14px; border-radius: 3px; flex-shrink: 0; }

/* ── Question Card ────────────────────────────────────────────── */
.wsa-q-card {
    background: #fff;
    border-radius: var(--wsa-radius);
    box-shadow: var(--wsa-shadow);
    padding: 28px 32px;
    margin-bottom: 16px;
    animation: wsa-fadeIn .2s ease;
}
@keyframes wsa-fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@media (max-width: 600px) { .wsa-q-card { padding: 20px 16px; } }

.wsa-q-header { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 20px; }
.wsa-q-num    { background: var(--wsa-primary); color: #fff; border-radius: 8px; width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; flex-shrink: 0; }
.wsa-q-text   { font-size: 16px; font-weight: 500; line-height: 1.6; flex: 1; }
.wsa-q-meta   { font-size: 13px; color: var(--wsa-muted); margin-top: 6px; }

/* Type badges */
.wsa-q-badge      { display: inline-block; padding: 3px 9px; border-radius: 99px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; }
.wsa-badge-mcq         { background: #dbeafe; color: #1e40af; }
.wsa-badge-msq         { background: #e0e7ff; color: #3730a3; }
.wsa-badge-coding      { background: #f3e8ff; color: #6b21a8; }
.wsa-badge-behavioural { background: #fef9c3; color: #854d0e; }
.wsa-badge-short       { background: #dcfce7; color: #166534; }
.wsa-badge-long        { background: #fce7f3; color: #9d174d; }
.wsa-badge-true_false  { background: #ffedd5; color: #9a3412; }
.wsa-badge-rating      { background: #e0f2fe; color: #075985; }

/* ── MCQ Options ──────────────────────────────────────────────── */
.wsa-options { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.wsa-option  { display: flex; align-items: center; gap: 12px; padding: 13px 16px; border: 2px solid var(--wsa-border); border-radius: 9px; cursor: pointer; font-size: 15px; transition: all .15s; }
.wsa-option:hover    { border-color: var(--wsa-primary); background: #eff6ff; }
.wsa-option.selected { border-color: var(--wsa-primary); background: #eff6ff; }
.wsa-option input[type=radio],
.wsa-option input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--wsa-primary); cursor: pointer; flex-shrink: 0; }
/* Re-enable selection inside inputs/textareas only */
.wsa-option label      { user-select: none; cursor: pointer; flex: 1; }
.wsa-short-answer,
.wsa-long-answer       { -webkit-user-select: text !important; user-select: text !important; }

/* ── Text Inputs ──────────────────────────────────────────────── */
.wsa-short-answer,
.wsa-long-answer {
    width: 100%; padding: 12px 14px;
    border: 2px solid var(--wsa-border); border-radius: 8px;
    font-size: 15px; font-family: inherit; box-sizing: border-box;
    transition: border-color .15s;
}
.wsa-short-answer:focus, .wsa-long-answer:focus { outline: none; border-color: var(--wsa-primary); }
.wsa-long-answer { min-height: 130px; resize: vertical; }

/* ── Coding Editor ────────────────────────────────────────────── */
.wsa-code-wrap    { border: 2px solid var(--wsa-border); border-radius: 8px; overflow: hidden; }
.wsa-code-toolbar { display: flex; align-items: center; gap: 8px; padding: 8px 14px; background: #1f2937; }
.wsa-code-lang    { color: #9ca3af; font-size: 13px; font-family: monospace; }
.CodeMirror       { height: 280px; font-size: 14px; }

/* ── Rating ───────────────────────────────────────────────────── */
.wsa-rating { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 4px; }
.wsa-rating > div { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.wsa-rating input { display: none; }
.wsa-rating label { padding: 10px 18px; border: 2px solid var(--wsa-border); border-radius: 8px; cursor: pointer; font-size: 16px; font-weight: 700; transition: all .15s; }
.wsa-rating input:checked + label,
.wsa-rating label:hover { border-color: var(--wsa-primary); background: var(--wsa-primary); color: #fff; }

/* ── Footer Navigation Bar ────────────────────────────────────── */
#wsa-fs-footer {
    background: #fff;
    border-top: 1px solid var(--wsa-border);
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    box-shadow: 0 -1px 4px rgba(0,0,0,.05);
}
.wsa-nav-right { display: flex; gap: 10px; }

/* ── Thank-you / Success Screen ───────────────────────────────── */
#wsa-thankyou {
    position: fixed; inset: 0; z-index: 9999999;
    background: linear-gradient(135deg, #1e3a5f 0%, #1a56db 100%);
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    text-align: center; padding: 24px;
    animation: wsa-fadeIn .4s ease;
}
.wsa-ty-box { max-width: 560px; }
.wsa-ty-icon { font-size: 72px; margin-bottom: 20px; animation: wsa-pop .5s cubic-bezier(.36,.07,.19,.97); }
@keyframes wsa-pop { 0%{transform:scale(0)} 80%{transform:scale(1.15)} 100%{transform:scale(1)} }
.wsa-ty-box h1 { font-size: 28px; font-weight: 800; margin: 0 0 12px; }
.wsa-ty-box p  { font-size: 16px; line-height: 1.7; margin: 0 0 20px; opacity: .92; }
.wsa-ty-link   { display: inline-block; padding: 13px 28px; background: #fff; color: var(--wsa-primary); border-radius: 8px; font-weight: 700; font-size: 15px; text-decoration: none; margin-top: 8px; transition: transform .15s; }
.wsa-ty-link:hover { transform: translateY(-2px); color: var(--wsa-primary); }

/* ── Anti-cheat Warning Overlay ───────────────────────────────── */
#wsa-cheat-warning {
    position: fixed; inset: 0; z-index: 9999998;
    background: rgba(200,30,30,.97);
    display: none; align-items: center; justify-content: center;
    color: #fff; text-align: center; padding: 32px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
#wsa-cheat-warning.show { display: flex; }
.wsa-cw-box h2 { font-size: 28px; font-weight: 800; margin: 0 0 12px; }
.wsa-cw-box p  { font-size: 16px; opacity: .9; margin: 0 0 20px; }
.wsa-cw-counter { font-size: 48px; font-weight: 900; }
.wsa-cw-close   { padding: 12px 28px; background: #fff; color: #c81e1e; border: none; border-radius: 8px; font-weight: 700; font-size: 15px; cursor: pointer; margin-top: 16px; }

/* ── Submitting Spinner ───────────────────────────────────────── */
.wsa-submitting-screen {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    height: 100%; color: var(--wsa-muted); gap: 16px;
}
.wsa-spinner { width: 40px; height: 40px; border: 4px solid #e5e7eb; border-top-color: var(--wsa-primary); border-radius: 50%; animation: wsa-spin .7s linear infinite; }
@keyframes wsa-spin { to { transform: rotate(360deg); } }

/* ── Mobile tweaks ────────────────────────────────────────────── */
@media (max-width: 480px) {
    .wsa-fs-title { max-width: 30%; font-size: 13px; }
    .wsa-timer    { font-size: 17px; }
    #wsa-fs-footer { flex-direction: column; gap: 10px; }
    .wsa-q-grid   { grid-template-columns: repeat(8,1fr); }
}

/* ── Intro page (before fullscreen) ──────────────────────────── */
.wsa-intro-card { max-width: 680px; margin: 40px auto; }
.wsa-intro-badge { display: inline-block; padding: 4px 12px; border-radius: 99px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; margin-bottom: 12px; background: #dbeafe; color: #1e40af; }

/* Leaderboard & My Results */
.wsa-leaderboard-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.wsa-leaderboard-table th { text-align: left; padding: 12px 16px; border-bottom: 2px solid var(--wsa-border); font-weight: 600; color: var(--wsa-muted); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }
.wsa-leaderboard-table td { padding: 14px 16px; border-bottom: 1px solid var(--wsa-border); vertical-align: middle; }
.wsa-leaderboard-table tr:hover td { background: #f9fafb; }
.wsa-avatar { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; }
.wsa-user-cell { display: flex; align-items: center; gap: 10px; }
.wsa-pct-bar  { height: 5px; background: #e5e7eb; border-radius: 99px; overflow: hidden; min-width: 70px; margin-top: 4px; }
.wsa-pct-fill { height: 100%; background: var(--wsa-primary); border-radius: 99px; }
.wsa-status-pill { display: inline-block; padding: 4px 12px; border-radius: 99px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; }
.wsa-status-pill.passed        { background: #dcfce7; color: #166534; }
.wsa-status-pill.failed        { background: #fee2e2; color: #991b1b; }
.wsa-status-pill.pending_review{ background: #fef9c3; color: #854d0e; }
