/**
 * Simulation Exam — Material Design 3 + BEM
 * Block: exam (extends sim-modal, sim-btn from taplai-mophong.css)
 * Premium M3 redesign
 */

/* ===== Flatsome Reset ===== */
.exam,
.exam *,
.exam *::before,
.exam *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

.exam button,
.exam select,
.exam input,
.exam label {
    all: unset;
    box-sizing: border-box;
    font-family: 'Roboto', sans-serif;
}

.exam button { cursor: pointer; display: inline-flex; align-items: center; }

/* Restore Material Symbols after all:unset */
.exam .material-symbols-outlined {
    font-family: 'Material Symbols Outlined' !important;
    font-weight: normal;
    font-style: normal;
    font-size: 20px;
    line-height: 1;
    letter-spacing: normal;
    text-transform: none;
    display: inline-block;
    white-space: nowrap;
    word-wrap: normal;
    direction: ltr;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: 'liga';
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 20;
}

/* ===== Block: exam ===== */
.exam {
    --panel-bg: #1a2332;
    --panel-bg-light: #243447;
    --panel-border: rgba(255,255,255,.08);

    font-family: 'Roboto', sans-serif;
    max-width: 900px;
    margin: 0 auto;
    padding: 0;
    color: #0f172a;
    line-height: 1.5;
}

/* ===== exam__selection ===== */
.exam__selection {
    text-align: center;
    padding: 32px 24px;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 4px 8px -1px rgba(0,0,0,.08), 0 2px 4px -2px rgba(0,0,0,.04);
    border: 1px solid #e2e8f0;
}

.exam__header { margin-bottom: 28px; }

.exam__title {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 24px;
    font-weight: 700;
    color: #0f172a;
    margin: 0 0 10px;
}

.exam__title .material-symbols-outlined { font-size: 32px; color: #2563eb !important; }

.exam__subtitle {
    font-size: 14px;
    color: #64748b;
    margin: 0;
    line-height: 1.6;
}

/* ===== exam__sets ===== */
.exam__sets {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

.exam__set-btn {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px;
    padding: 16px 14px !important;
    background: #ffffff !important;
    border: 2px solid #e2e8f0 !important;
    border-radius: 14px !important;
    font-size: 14px;
    font-weight: 600;
    color: #334155 !important;
    transition: all .2s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,.06) !important;
}

.exam__set-btn:hover {
    border-color: #3b82f6 !important;
    color: #2563eb !important;
    transform: translateY(-3px);
    box-shadow: 0 6px 16px rgba(37,99,235,.12) !important;
}

.exam__set-btn--active {
    background: linear-gradient(135deg, #2563eb, #3b82f6) !important;
    color: #ffffff !important;
    border-color: transparent !important;
    box-shadow: 0 4px 16px rgba(37,99,235,.3) !important;
}

.exam__set-btn--random {
    background: linear-gradient(135deg, #f59e0b, #fbbf24) !important;
    color: #1a1a1a !important;
    border-color: transparent !important;
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(245,158,11,.2) !important;
}

.exam__set-btn--random:hover {
    background: linear-gradient(135deg, #d97706, #f59e0b) !important;
    border-color: transparent !important;
    color: #1a1a1a !important;
    box-shadow: 0 6px 16px rgba(245,158,11,.3) !important;
}

.exam__set-btn--random.exam__set-btn--active {
    background: linear-gradient(135deg, #d97706, #f59e0b) !important;
    border-color: #b45309 !important;
    color: #1a1a1a !important;
    box-shadow: 0 4px 16px rgba(245,158,11,.35) !important;
}

/* ===== exam__selected-info ===== */
.exam__selected-info {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 24px;
    background: #dbeafe;
    border-radius: 12px;
    color: #1d4ed8;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 24px;
    border: 1px solid rgba(37,99,235,.1);
}

.exam__selected-info .material-symbols-outlined {
    font-size: 20px;
    color: #2563eb !important;
}

/* ===== exam__start-btn ===== */
.exam__start-btn {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 10px;
    padding: 18px 56px !important;
    background: linear-gradient(135deg, #2563eb, #3b82f6) !important;
    color: #ffffff !important;
    border-radius: 14px !important;
    font-size: 18px;
    font-weight: 700;
    box-shadow: 0 6px 20px rgba(37,99,235,.3) !important;
    transition: all .25s ease;
    text-transform: uppercase;
    letter-spacing: .04em;
    border: none !important;
}

.exam__start-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 32px rgba(37,99,235,.4) !important;
    background: linear-gradient(135deg, #1d4ed8, #2563eb) !important;
}

.exam__start-btn .material-symbols-outlined { font-size: 24px; color: #fff !important; }

/* ===== exam__player-wrap ===== */
.exam__player-wrap {
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 10px 24px -4px rgba(0,0,0,.1), 0 4px 8px -2px rgba(0,0,0,.04);
}

.exam__video-container {
    position: relative;
    width: 100%;
    background: #000;
    aspect-ratio: 16 / 9;
}

.exam__video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.exam__situation-title {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: 12px 20px;
    background: linear-gradient(180deg, rgba(0,0,0,.7) 0%, rgba(0,0,0,.3) 60%, transparent 100%);
    color: #ffffff !important;
    font-size: 14px;
    font-weight: 500;
    z-index: 2;
    text-shadow: 0 1px 4px rgba(0,0,0,.6);
}

.exam__score-overlay {
    position: absolute;
    bottom: 16px;
    right: 16px;
    background: rgba(0,0,0,.8);
    color: #4df974;
    padding: 10px 20px;
    border-radius: 24px;
    font-size: 18px;
    font-weight: 700;
    z-index: 3;
    backdrop-filter: blur(6px);
    border: 1px solid rgba(255,255,255,.1);
}

/* ===== exam__loading ===== */
.exam__loading {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.exam__loading-inner { text-align: center; color: #fff; }

.exam__loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(255,255,255,.15);
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: exam-spin 0.8s linear infinite;
    margin: 0 auto 12px;
}

@keyframes exam-spin { to { transform: rotate(360deg); } }

.exam__loading-text {
    font-size: 16px;
    font-weight: 500;
    color: #fff;
}

/* ===== exam__timeline ===== */
.exam__timeline {
    background: var(--panel-bg);
    height: 8px;
    border-top: 1px solid var(--panel-border);
}

.exam__timeline-track {
    position: relative;
    width: 100%;
    height: 100%;
    background: rgba(255,255,255,.06);
}

.exam__timeline-progress {
    height: 100%;
    background: linear-gradient(90deg, #10b981, #34d399);
    width: 0%;
    transition: width .05s linear;
    z-index: 1;
}

.exam__timeline-flags {
    position: absolute;
    inset: 0;
    z-index: 3;
    pointer-events: none;
}

.exam__flag {
    position: absolute;
    top: -8px;
    font-size: 18px;
    color: #ff5722;
    transform: translateX(-50%);
    filter: drop-shadow(0 1px 3px rgba(0,0,0,.5));
}

/* ===== exam__controls ===== */
.exam__controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px !important;
    background: var(--panel-bg) !important;
    padding: 12px 16px !important;
    flex-wrap: wrap;
    border-bottom: 1px solid var(--panel-border);
}

.exam__ctrl-btn {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px;
    padding: 12px 22px !important;
    border-radius: 24px !important;
    font-size: 14px;
    font-weight: 600;
    color: #fff !important;
    background: rgba(255,255,255,.08) !important;
    border: 1px solid rgba(255,255,255,.12) !important;
    transition: all .2s ease;
}

.exam__ctrl-btn:hover {
    background: rgba(255,255,255,.15) !important;
    border-color: rgba(255,255,255,.2) !important;
}

.exam__ctrl-btn .material-symbols-outlined { color: #fff !important; }

.exam__ctrl-btn--space {
    background: linear-gradient(135deg, #ef4444, #dc2626) !important;
    border-color: transparent !important;
    font-size: 16px;
    font-weight: 700;
    padding: 14px 36px !important;
    box-shadow: 0 2px 10px rgba(239,68,68,.3) !important;
}

.exam__ctrl-btn--space:hover {
    background: linear-gradient(135deg, #dc2626, #b91c1c) !important;
    box-shadow: 0 4px 16px rgba(239,68,68,.4) !important;
}

.exam__ctrl-btn--space:disabled {
    background: #555 !important;
    border-color: transparent !important;
    cursor: not-allowed;
    opacity: .5;
    box-shadow: none !important;
}

.exam__ctrl-btn--hint {
    background: rgba(255,193,7,.15) !important;
    border-color: rgba(255,193,7,.3) !important;
    color: #fbbf24 !important;
}

.exam__ctrl-btn--hint:hover {
    background: rgba(255,193,7,.25) !important;
    border-color: rgba(255,193,7,.5) !important;
}

.exam__ctrl-btn--hint .material-symbols-outlined { color: #fbbf24 !important; }

.exam__ctrl-btn--next {
    background: linear-gradient(135deg, #3b82f6, #2563eb) !important;
    border-color: transparent !important;
    color: #ffffff !important;
    box-shadow: 0 2px 8px rgba(37,99,235,.25) !important;
}

.exam__ctrl-btn--next:hover {
    background: linear-gradient(135deg, #2563eb, #1d4ed8) !important;
    box-shadow: 0 4px 16px rgba(37,99,235,.35) !important;
}

/* ===== exam__scoreboard ===== */
.exam__scoreboard {
    overflow-x: auto;
    margin: 0;
    -webkit-overflow-scrolling: touch;
    background: #ffffff;
}

.exam__table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    text-align: center;
}

.exam__table th,
.exam__table td {
    padding: 10px 6px;
    border: 1px solid #e2e8f0;
    white-space: nowrap;
}

.exam__table th {
    background: linear-gradient(135deg, #2563eb, #3b82f6);
    color: #ffffff;
    font-weight: 600;
    font-size: 12px;
}

.exam__table-label {
    background: #f8fafc;
    font-weight: 600;
    color: #475569;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .03em;
}

/* ===== exam__actions ===== */
.exam__actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px !important;
    padding: 16px 20px !important;
    flex-wrap: wrap;
    background: #f8fafc;
}

.exam__action-btn {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px;
    padding: 12px 24px !important;
    border-radius: 24px !important;
    font-size: 14px;
    font-weight: 500;
    transition: all .2s ease;
}

.exam__action-btn .material-symbols-outlined { font-size: 18px; }

.exam__action-btn--outline {
    background: #ffffff !important;
    border: 2px solid #e2e8f0 !important;
    color: #475569 !important;
}

.exam__action-btn--outline:hover {
    border-color: #3b82f6 !important;
    color: #2563eb !important;
    box-shadow: 0 2px 8px rgba(37,99,235,.1) !important;
}

.exam__action-btn--green {
    background: linear-gradient(135deg, #10b981, #059669) !important;
    color: #fff !important;
    border: none !important;
    box-shadow: 0 2px 8px rgba(16,185,129,.25) !important;
}

.exam__action-btn--green:hover {
    box-shadow: 0 4px 16px rgba(16,185,129,.35) !important;
    transform: translateY(-1px);
}

/* ===== exam__result ===== */
.exam__result-icon {
    text-align: center;
    margin-bottom: 16px;
}

.exam__result-icon .material-symbols-outlined {
    font-size: 72px !important;
    font-variation-settings: 'FILL' 1, 'wght' 500, 'GRAD' 0, 'opsz' 48;
}

.exam__result-icon--pass .material-symbols-outlined { color: #10b981 !important; }
.exam__result-icon--fail .material-symbols-outlined { color: #ef4444 !important; }

.exam__result-status {
    text-align: center;
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 8px;
}

.exam__result-status--pass { color: #10b981; }
.exam__result-status--fail { color: #ef4444; }

.exam__result-score {
    text-align: center;
    font-size: 56px;
    font-weight: 700;
    background: linear-gradient(135deg, #2563eb, #3b82f6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 16px;
}

.exam__result-detail {
    text-align: center;
    font-size: 14px;
    color: #64748b;
    line-height: 2;
}

/* ===== Score ghost animation ===== */
.exam__score-ghost {
    position: fixed;
    font-size: 28px;
    font-weight: 700;
    color: #4df974;
    pointer-events: none;
    animation: exam-float 1s forwards;
    z-index: 9999;
    text-shadow: 0 2px 6px rgba(0,0,0,.5);
}

@keyframes exam-float {
    from { transform: translateY(0); opacity: 1; }
    to { transform: translateY(-50px); opacity: 0; }
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .exam__sets { grid-template-columns: repeat(3, 1fr); gap: 10px; }
    .exam__set-btn { padding: 12px 10px !important; font-size: 13px; }
    .exam__start-btn { padding: 16px 36px !important; font-size: 16px; }
    .exam__controls { gap: 8px !important; padding: 10px !important; }
    .exam__ctrl-btn { padding: 10px 16px !important; font-size: 13px; }
    .exam__ctrl-btn--space { padding: 12px 28px !important; }
    .exam__table { font-size: 11px; }
    .exam__table th, .exam__table td { padding: 6px 3px; }
}

@media (max-width: 480px) {
    .exam__sets { grid-template-columns: repeat(2, 1fr); }
    .exam__title { font-size: 18px; }
    .exam__subtitle { font-size: 12px; }
    .exam__selection { padding: 20px 16px; }
}
