/**
 * Exam Official - Styles
 * Page d'examen code de la route - Style officiel
 * 
 * @package CanvasQuiz
 * @version 1.0
 */

/* ==========================================================================
   VARIABLES CSS
   ========================================================================== */
:root {
    --exam-bg-dark: #1a1a2e;
    --exam-bg-darker: #0f0f1a;
    --exam-bg-card: #252540;
    --exam-primary: #3498db;
    --exam-success: #27ae60;
    --exam-danger: #e74c3c;
    --exam-warning: #f39c12;
    --exam-text: #ffffff;
    --exam-text-muted: #a0a0b0;
    --exam-border: #3a3a5a;
    --exam-timer-bg: #2c2c4a;
    --exam-radius: 12px;
    --exam-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
}

/* ==========================================================================
   RESET & BASE - FULLPAGE
   ========================================================================== */
.exam-fullpage {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--exam-bg-dark);
    color: var(--exam-text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    overflow: hidden;
    z-index: 99999;
}

.exam-fullpage * {
    box-sizing: border-box;
}

/* Hide WordPress admin bar */
.exam-fullpage ~ #wpadminbar,
body.admin-bar .exam-fullpage {
    top: 0 !important;
}

html.exam-active,
html.exam-active body {
    overflow: hidden !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* ==========================================================================
   ÉTAPE 1 : PRÉSENTATION - COMPACT & RESPONSIVE
   ========================================================================== */
.exam-presentation {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 0;
    text-align: center;
    overflow: hidden;
}

/* Barre supérieure */
.exam-presentation__topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    background: var(--exam-bg-darker);
    flex-shrink: 0;
}

.exam-presentation__back {
    color: var(--exam-text-muted);
    text-decoration: none;
    font-size: 14px;
    transition: color 0.2s;
}

.exam-presentation__back:hover {
    color: var(--exam-text);
}

.exam-presentation__user {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--exam-bg-card);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
}

.exam-presentation__user-icon {
    font-size: 14px;
}

.exam-presentation__user-name {
    color: var(--exam-primary);
    font-weight: 500;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Contenu principal centré */
.exam-presentation__main {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    gap: 20px;
    overflow: hidden;
}

/* Header avec icône et titre côte à côte */
.exam-presentation__header {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-shrink: 0;
}

.exam-presentation__icon {
    font-size: 48px;
    flex-shrink: 0;
}

.exam-presentation__icon-img {
    width: 70px;
    height: 70px;
    object-fit: contain;
    border-radius: 10px;
    flex-shrink: 0;
}

.exam-presentation__header-text {
    text-align: left;
}

.exam-presentation__title {
    font-size: clamp(20px, 5vw, 28px);
    font-weight: 700;
    margin: 0;
    color: var(--exam-text);
    line-height: 1.2;
}

.exam-presentation__subtitle {
    font-size: 14px;
    color: var(--exam-text-muted);
    margin: 4px 0 0;
}

/* Stats en ligne compactes */
.exam-presentation__stats {
    display: flex;
    justify-content: center;
    gap: 25px;
    background: var(--exam-bg-card);
    padding: 15px 30px;
    border-radius: var(--exam-radius);
    flex-shrink: 0;
}

.exam-stat {
    text-align: center;
}

.exam-stat__value {
    display: block;
    font-size: clamp(20px, 4vw, 26px);
    font-weight: 700;
    color: var(--exam-primary);
}

.exam-stat__label {
    font-size: 11px;
    color: var(--exam-text-muted);
    text-transform: uppercase;
}

/* Boutons d'action */
.exam-presentation__actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    max-width: 320px;
    flex-shrink: 0;
}

.exam-presentation__warning {
    background: rgba(243, 156, 18, 0.15);
    color: var(--exam-warning);
    padding: 10px 15px;
    border-radius: 8px;
    font-size: 13px;
    border: 1px solid rgba(243, 156, 18, 0.3);
}

/* Footer compact */
.exam-presentation__footer {
    padding: 12px 20px;
    background: var(--exam-bg-darker);
    flex-shrink: 0;
}

.exam-presentation__footer p {
    margin: 0;
    font-size: 12px;
    color: var(--exam-text-muted);
}

/* Boutons */
.exam-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.exam-btn--primary {
    background: var(--exam-primary);
    color: #fff;
}

.exam-btn--primary:hover {
    background: #2980b9;
    transform: translateY(-2px);
}

.exam-btn--secondary {
    background: var(--exam-bg-card);
    color: var(--exam-text);
    border: 2px solid var(--exam-border);
}

.exam-btn--secondary:hover {
    border-color: var(--exam-primary);
    color: var(--exam-primary);
}

.exam-btn--back {
    background: transparent;
    color: var(--exam-text-muted);
    font-size: 14px;
    padding: 12px 20px;
}

.exam-btn--back:hover {
    color: var(--exam-text);
}

.exam-btn--login {
    background: var(--exam-warning);
    color: #000;
}

.exam-btn--login:hover {
    background: #e67e22;
}

/* ==========================================================================
   ÉTAPE 2 : QUESTIONS
   ========================================================================== */
.exam-question-page {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* Header - supprimé, éléments déplacés sur média */
.exam-header {
    display: none;
}

/* Contenu question */
.exam-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Zone média */
.exam-media {
    flex: 0 0 auto;
    max-height: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
    position: relative;
}

.exam-media__video,
.exam-media__image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.exam-media--hidden {
    display: none;
}

/* Overlays sur le média */
.exam-media__overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 10px 15px;
    pointer-events: none;
}

.exam-media__progress {
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    backdrop-filter: blur(4px);
}

.exam-media__mode {
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.exam-media__mode--evaluation {
    background: rgba(231, 76, 60, 0.85);
    color: #fff;
}

.exam-media__mode--apprentissage {
    background: rgba(52, 152, 219, 0.85);
    color: #fff;
}

/* Timer sur le média - en bas à droite */
.exam-media__timer {
    position: absolute;
    bottom: 10px;
    right: 15px;
    width: 44px;
    height: 44px;
    transition: opacity 0.3s ease;
}

/* Timer caché pendant l'audio */
.exam-media__timer.exam-timer--hidden {
    opacity: 0;
    pointer-events: none;
}

.exam-media__timer .exam-timer__circle {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.exam-media__timer .exam-timer__bg {
    fill: rgba(0, 0, 0, 0.5);
    stroke: rgba(255, 255, 255, 0.3);
    stroke-width: 3;
}

.exam-media__timer .exam-timer__progress {
    fill: none;
    stroke: var(--exam-primary);
    stroke-width: 3;
    stroke-linecap: round;
    stroke-dasharray: 157;
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 1s linear, stroke 0.3s;
}

.exam-media__timer .exam-timer__progress.warning {
    stroke: var(--exam-warning);
}

.exam-media__timer .exam-timer__progress.danger {
    stroke: var(--exam-danger);
}

.exam-media__timer .exam-timer__text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 14px;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

/* Zone question et réponses - Style officiel compact */
.exam-question {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 15px 20px;
    background: var(--exam-bg-darker);
    overflow-y: auto;
}

.exam-question__head {
    font-size: 14px;
    font-weight: 400;
    color: var(--exam-text);
    margin-bottom: 10px;
    line-height: 1.4;
}

.exam-question__number {
    font-weight: 400;
    color: var(--exam-text);
}

/* Groupe de réponses - titre de sous-question */
.exam-answers-group {
    margin-bottom: 8px;
}

.exam-answers-group__title {
    font-size: 13px;
    color: #4fc3f7;
    margin-bottom: 4px;
    padding: 0;
    border: none;
}

/* Réponses en ligne (OUI/NON) */
.exam-answers--inline {
    display: flex;
    gap: 0;
}

.exam-answers--inline .exam-answer {
    flex: 1;
}

/* Réponses en liste */
.exam-answers--list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* Style réponse officiel - ligne pointillée */
.exam-answer {
    display: flex;
    align-items: center;
    padding: 6px 10px;
    background: transparent;
    border: none;
    border-radius: 0;
    cursor: pointer;
    transition: background 0.15s;
}

.exam-answer:hover:not(.exam-answer--disabled) {
    background: rgba(255, 255, 255, 0.05);
}

.exam-answer__text {
    flex: 1;
    font-size: 13px;
    color: var(--exam-text);
    position: relative;
    padding-right: 10px;
}

/* Ligne pointillée entre texte et lettre */
.exam-answer__text::after {
    content: '';
    position: absolute;
    right: 0;
    top: 50%;
    width: calc(100% - 10px);
    border-bottom: 1px dotted rgba(255, 255, 255, 0.3);
    margin-left: 10px;
}

.exam-answer__letter {
    width: auto;
    min-width: 24px;
    height: auto;
    padding: 2px 8px;
    background: transparent;
    border: 1px solid var(--exam-border);
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 12px;
    color: var(--exam-text);
    flex-shrink: 0;
    transition: all 0.15s;
}

/* État sélectionné */
.exam-answer--selected {
    background: transparent;
}

.exam-answer--selected .exam-answer__letter {
    background: var(--exam-primary);
    border-color: var(--exam-primary);
    color: #fff;
}

/* État correct */
.exam-answer--correct .exam-answer__letter {
    background: var(--exam-success);
    border-color: var(--exam-success);
    color: #fff;
}

/* État incorrect */
.exam-answer--incorrect .exam-answer__letter {
    background: var(--exam-danger);
    border-color: var(--exam-danger);
    color: #fff;
}

.exam-answer--disabled {
    cursor: default;
}

/* Cacher le checkbox */
.exam-answer__checkbox {
    display: none;
}

/* Zone correction (mode apprentissage) - compacte */
.exam-correction {
    display: none;
    margin-top: 10px;
    padding: 8px 12px;
    background: rgba(52, 152, 219, 0.1);
    border-radius: 4px;
    border-left: 3px solid var(--exam-primary);
}

.exam-correction--visible {
    display: block;
}

.exam-correction__info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.exam-correction__icon {
    width: 28px;
    height: 28px;
    background: var(--exam-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
    cursor: pointer;
    transition: transform 0.2s;
}

.exam-correction__icon:hover {
    transform: scale(1.1);
}

.exam-correction__description {
    display: none;
    flex: 1;
    font-size: 14px;
    line-height: 1.6;
    color: var(--exam-text-muted);
}

.exam-correction__description--visible {
    display: block;
}

/* Footer actions */
.exam-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: var(--exam-bg-darker);
    border-top: 1px solid var(--exam-border);
    flex-shrink: 0;
}

.exam-footer__quit {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: transparent;
    border: 1px solid var(--exam-border);
    border-radius: 6px;
    color: var(--exam-text-muted);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.exam-footer__quit:hover {
    border-color: var(--exam-danger);
    color: var(--exam-danger);
}

.exam-footer__actions {
    display: flex;
    gap: 15px;
}

.exam-btn--validate {
    background: var(--exam-warning);
    color: #000;
}

.exam-btn--validate:hover {
    background: #e67e22;
}

.exam-btn--validate:disabled,
.exam-btn--next:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.exam-btn--next {
    background: var(--exam-success);
    color: #fff;
}

.exam-btn--next:hover:not(:disabled) {
    background: #219a52;
}

/* ==========================================================================
   ÉTAPE 3 : RÉSULTATS
   ========================================================================== */
.exam-results {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 40px;
    text-align: center;
    overflow-y: auto;
}

.exam-results__icon {
    font-size: 80px;
    margin-bottom: 20px;
}

.exam-results__title {
    font-size: 32px;
    font-weight: 700;
    margin: 0 0 30px;
}

.exam-results__score {
    margin-bottom: 20px;
}

.exam-results__score-value {
    font-size: 72px;
    font-weight: 700;
    color: var(--exam-primary);
}

.exam-results__score-total {
    font-size: 36px;
    color: var(--exam-text-muted);
}

.exam-results__percentage {
    font-size: 24px;
    color: var(--exam-text-muted);
    margin-bottom: 30px;
}

.exam-results__status {
    padding: 15px 30px;
    border-radius: 8px;
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 30px;
}

.exam-results__status--success {
    background: rgba(39, 174, 96, 0.2);
    color: var(--exam-success);
    border: 2px solid var(--exam-success);
}

.exam-results__status--failure {
    background: rgba(231, 76, 60, 0.2);
    color: var(--exam-danger);
    border: 2px solid var(--exam-danger);
}

/* Stats détaillées */
.exam-results__stats {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-bottom: 30px;
}

.exam-results__stat {
    text-align: center;
    padding: 15px 25px;
    background: var(--exam-bg-card);
    border-radius: 8px;
}

.exam-results__stat-value {
    display: block;
    font-size: 28px;
    font-weight: 700;
}

.exam-results__stat-value--correct {
    color: var(--exam-success);
}

.exam-results__stat-value--wrong {
    color: var(--exam-danger);
}

.exam-results__stat-value--ignored {
    color: var(--exam-warning);
}

.exam-results__stat-label {
    font-size: 12px;
    color: var(--exam-text-muted);
    text-transform: uppercase;
}

/* Grille questions (mode apprentissage) */
.exam-results__grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    max-width: 600px;
    margin-bottom: 30px;
}

.exam-results__question {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
}

.exam-results__question--correct {
    background: var(--exam-success);
    color: #fff;
}

.exam-results__question--wrong {
    background: var(--exam-danger);
    color: #fff;
}

.exam-results__question--ignored {
    background: var(--exam-warning);
    color: #000;
}

.exam-results__legend {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 30px;
    font-size: 13px;
    color: var(--exam-text-muted);
}

.exam-results__legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.exam-results__legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 3px;
}

.exam-results__legend-dot--correct {
    background: var(--exam-success);
}

.exam-results__legend-dot--wrong {
    background: var(--exam-danger);
}

.exam-results__legend-dot--ignored {
    background: var(--exam-warning);
}

.exam-results__actions {
    display: flex;
    gap: 15px;
}

/* ==========================================================================
   MODAL CONFIRMATION
   ========================================================================== */
.exam-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 100000;
    align-items: center;
    justify-content: center;
}

.exam-modal--visible {
    display: flex;
}

.exam-modal__content {
    background: var(--exam-bg-card);
    padding: 40px;
    border-radius: var(--exam-radius);
    text-align: center;
    max-width: 400px;
}

.exam-modal__icon {
    font-size: 48px;
    margin-bottom: 20px;
}

.exam-modal__title {
    font-size: 20px;
    font-weight: 600;
    margin: 0 0 15px;
}

.exam-modal__text {
    color: var(--exam-text-muted);
    margin-bottom: 25px;
    font-size: 14px;
}

.exam-modal__actions {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.exam-modal__btn--cancel {
    background: var(--exam-bg-darker);
    color: var(--exam-text);
    border: 1px solid var(--exam-border);
}

.exam-modal__btn--confirm {
    background: var(--exam-danger);
    color: #fff;
}

.exam-modal__btn--login {
    background: var(--exam-primary);
    color: #fff;
}

.exam-modal__btn--login:hover {
    background: #2980b9;
}

/* ==========================================================================
   AUDIO HIDDEN
   ========================================================================== */
.exam-audio {
    display: none;
}

/* ==========================================================================
   LOADING STATE
   ========================================================================== */
.exam-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 20px;
}

.exam-loading__spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--exam-border);
    border-top-color: var(--exam-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */
@media (max-width: 768px) {
    .exam-presentation {
        padding: 20px;
    }
    
    .exam-presentation__title {
        font-size: 28px;
    }
    
    .exam-presentation__info {
        padding: 20px;
    }
    
    .exam-presentation__stats {
        gap: 20px;
    }
    
    .exam-header {
        padding: 10px 15px;
        flex-wrap: wrap;
        gap: 10px;
    }
    
    .exam-header__left {
        order: 1;
    }
    
    .exam-header__center {
        order: 3;
        width: 100%;
    }
    
    .exam-header__right {
        order: 2;
    }
    
    .exam-question {
        padding: 20px;
    }
    
    .exam-question__head {
        font-size: 18px;
    }
    
    .exam-answers--inline {
        flex-direction: column;
        gap: 12px;
    }
    
    .exam-footer {
        padding: 15px;
    }
    
    .exam-btn {
        padding: 14px 24px;
        font-size: 14px;
    }
    
    .exam-results {
        padding: 20px;
    }
    
    .exam-results__score-value {
        font-size: 56px;
    }
    
    .exam-results__actions {
        flex-direction: column;
        width: 100%;
    }
    
    .exam-results__stats {
        flex-wrap: wrap;
    }
}

@media (max-width: 480px) {
    .exam-timer {
        width: 50px;
        height: 50px;
    }
    
    .exam-timer__text {
        font-size: 14px;
    }
    
    .exam-answer {
        padding: 12px 15px;
    }
    
    .exam-answer__text {
        font-size: 14px;
    }
    
    .exam-results__grid {
        gap: 6px;
    }
    
    .exam-results__question {
        width: 35px;
        height: 35px;
        font-size: 12px;
    }
}
