/* =========================================
           Variables & Reset
           ========================================= */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* =========================================
           Masquer toutes les scrollbars (design pro)
           ========================================= */
.sim-app-container *,
.sim-intro-screen,
.sim-results-screen,
.sim-loading-screen,
.sim-sidebar-left,
.sim-sidebar-right,
.sim-main,
.task-prompt {
    scrollbar-width: none;
    /* Firefox */
    -ms-overflow-style: none;
    /* IE / Edge */
}

.sim-app-container *::-webkit-scrollbar,
.sim-intro-screen::-webkit-scrollbar,
.sim-results-screen::-webkit-scrollbar,
.sim-loading-screen::-webkit-scrollbar,
.sim-sidebar-left::-webkit-scrollbar,
.sim-sidebar-right::-webkit-scrollbar,
.sim-main::-webkit-scrollbar,
.task-prompt::-webkit-scrollbar {
    display: none;
    /* Chrome / Safari / Opera */
}

.sim-app-container {
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 13px;
    height: 90vh;
    min-height: 600px;
    max-height: 900px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    color: #1a2332;
    position: relative;
    margin: 20px auto;
    width: 95%;
    max-width: 1280px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.1);
}

@media (max-width: 1024px) {
    body.simulator-active-mobile {
        overflow: hidden !important;
        touch-action: pan-y;
    }

    body.simulator-active-mobile #masthead,
    body.simulator-active-mobile .site-header,
    body.simulator-active-mobile .main-header-bar,
    body.simulator-active-mobile .elementor-location-header,
    body.simulator-active-mobile .hfe-header {
        display: none !important;
        pointer-events: none !important;
    }

    body.simulator-active-mobile .sim-app-container {
        position: fixed !important;
        inset: 0 !important;
        width: 100vw !important;
        height: 100svh !important;
        min-height: 100svh !important;
        max-height: none !important;
        z-index: 2147483647 !important;
        isolation: isolate !important;
        pointer-events: auto !important;
        background: #f8fafc !important;
        overflow-y: auto !important;
        margin: 0 !important;
        border: 0 !important;
        border-radius: 0 !important;
    }
}

/* Correction mobile : pas de hauteurs fixes */
@media (max-width: 1024px) {
    .sim-app-container {
        height: auto;
        min-height: 100svh;
        max-height: none;
        border-radius: 4px;
        margin: 0;
        border: none;
        overflow: visible;
    }
}

/* =========================================
           Écran d'Introduction
           ========================================= */
.sim-intro-screen {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #f8fafc;
    z-index: 50;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    animation: simFadeIn 0.5s ease;
}

@keyframes simFadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.intro-header {
    background: linear-gradient(150deg, #1e3a8a 0%, #1d4ed8 50%, #3b82f6 100%);
    color: #ffffff;
    padding: 24px 20px;
    text-align: center;
    position: relative;
}

.intro-back {
    position: absolute;
    top: 20px;
    left: 20px;
    color: white;
    font-size: 1.5rem;
    opacity: 0.8;
    transition: all 0.2s;
    text-decoration: none;
    -webkit-touch-callout: none;
    user-select: none;
}

.intro-back:hover {
    opacity: 1;
    transform: translateX(-3px);
}

.intro-header h1 {
    font-size: clamp(1.8rem, 4vw, 2.2rem);
    font-weight: 800;
    margin-bottom: 6px;
    color: #ffffff !important;
}

.intro-header p {
    font-size: 1rem;
    opacity: 0.95;
    color: #ffffff !important;
}

.intro-body {
    padding: 10px 20px 20px 20px;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    flex: 1;
}

.intro-duration {
    background: rgba(255, 255, 255, 0.15);
    padding: 8px 20px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.9rem;
    color: #ffffff;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 1.5px solid rgba(255, 255, 255, 0.5);
    margin-top: 16px;
    backdrop-filter: blur(4px);
    letter-spacing: 0.02em;
}

.intro-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 30px;
}

.intro-card {
    background: white;
    border-radius: 4px;
    padding: 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
    border: 1px solid #e2e8f0;
    border-left: 4px solid transparent;
    transition: transform 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.intro-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.06);
}

.intro-card.c1 {
    border-left-color: #3b82f6;
}

.intro-card.c2 {
    border-left-color: #a855f7;
}

.intro-card.c3 {
    border-left-color: #10b981;
}

.intro-card .badge {
    width: 32px;
    height: 32px;
    border-radius: 4px;
    background: #eff6ff;
    color: #2563eb;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    margin: 0 auto 10px;
    font-size: 1rem;
}

.intro-card.c2 .badge {
    background: #faf5ff;
    color: #a855f7;
}

.intro-card.c3 .badge {
    background: #ecfdf5;
    color: #10b981;
}

.intro-card h3 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.intro-card p {
    color: #64748b;
    font-size: 0.85rem;
}

.intro-start-box {
    background: white;
    border-radius: 4px;
    padding: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.04);
    border: 1px solid #e2e8f0;
}

.info-essais {
    color: #3b82f6;
    font-weight: 600;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-bottom: 16px;
}

.info-essais-link {
    color: #2563eb;
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 3px;
    transition: color 0.2s;
}

.info-essais-link:hover {
    color: #1d4ed8;
}

.beta-notice {
    display: flex;
    align-items: center;
    gap: 16px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    padding: 16px;
    margin-bottom: 20px;
    text-align: left;
    border-radius: 4px;
    position: relative;
    overflow: hidden;
}

.beta-notice::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: #2563eb;
}

.beta-notice i {
    color: #2563eb;
    font-size: 1.25rem;
    flex-shrink: 0;
    background: white;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.1);
}

.beta-notice strong {
    display: block;
    color: #1e3a8a;
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 2px;
}

.beta-notice p {
    color: #3b82f6;
    font-size: 0.85rem;
    line-height: 1.5;
    margin: 0;
}

.btn-start-exam {
    background: #2563eb;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 4px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s;
    box-shadow: 0 4px 10px rgba(37, 99, 235, 0.2);
}

.btn-start-exam:hover {
    background: #1d4ed8;
    transform: translateY(-1px);
}

/* =========================================
           Espace de Travail (Workspace)
           ========================================= */
.sim-workspace {
    display: flex;
    flex-direction: column;
    height: 100%;
}

@media (max-width: 1024px) {
    .sim-workspace {
        height: auto;
        min-height: 100svh;
    }
}

/* --- Header --- */
.sim-header {
    height: 70px;
    background: #ffffff;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    flex-shrink: 0;
    z-index: 10;
}

.sim-header-left {
    display: flex;
    align-items: center;
    gap: 20px;
    min-width: 200px;
}

.sim-back {
    color: #64748b;
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
    -webkit-touch-callout: none;
    user-select: none;
}

.sim-back:hover {
    color: #0f172a;
}

.sim-title {
    font-size: 0.85rem;
    font-weight: 800;
    color: #1a2332;
    line-height: 1.2;
}

.sim-subtitle {
    font-size: 0.68rem;
    color: #64748b;
}

.sim-timer {
    background: #eff6ff;
    color: #2563eb;
    padding: 5px 16px;
    border-radius: 4px;
    font-weight: 800;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 6px;
    border: 1px solid #bfdbfe;
    transition: all 0.3s;
}

.sim-header-right {
    min-width: 200px;
}

/* --- Layout --- */
.sim-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

@media (max-width: 1024px) {
    .sim-body {
        overflow: visible;
    }
}

/* --- Sidebars --- */
.sim-sidebar-left,
.sim-sidebar-right {
    background: #ffffff;
    width: 320px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 24px;
}

.sim-sidebar-left {
    border-right: 1px solid #e2e8f0;
}

.sim-sidebar-right {
    border-left: 1px solid #e2e8f0;
    width: 280px;
}

.sidebar-title {
    font-size: 0.8rem;
    font-weight: 800;
    color: #1a2332;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* --- Navigation Gauche --- */
.sim-task-btn {
    width: 100%;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    padding: 12px 16px;
    text-align: left;
    margin-bottom: 10px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    color: #475569;
}

.sim-task-btn:hover {
    border-color: #cbd5e1;
    background: #f8fafc;
}

.sim-task-btn.active {
    background: #2563eb;
    border-color: #2563eb;
    color: white;
    box-shadow: 0 10px 20px rgba(37, 99, 235, 0.15);
}

.sim-task-btn .task-name {
    font-weight: 700;
    font-size: 0.78rem;
    margin-bottom: 3px;
}

.sim-task-btn .task-desc {
    font-size: 0.65rem;
    opacity: 0.8;
    margin-bottom: 8px;
}

.task-progress {
    height: 6px;
    background: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
}

.sim-task-btn.active .task-progress {
    background: rgba(255, 255, 255, 0.2);
}

.progress-fill {
    height: 100%;
    background: #f59e0b;
    /* Orange si incomplet, Vert si complet (géré en JS) */
    width: 0%;
    transition: width 0.3s, background-color 0.3s;
}

.sim-warning {
    margin-top: auto;
    background: #fffbeb;
    border: 1px solid #fde68a;
    padding: 12px;
    border-radius: 4px;
    color: #b45309;
    font-size: 0.68rem;
    line-height: 1.4;
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

/* --- Main Content (Centre) --- */
.sim-main {
    flex: 1;
    overflow-y: auto;
    padding: 30px;
    display: flex;
    flex-direction: column;
    animation: simFadeIn 0.5s ease;
}

.task-content {
    display: none;
    flex-direction: column;
    height: 100%;
    animation: simSlideIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.task-content.active {
    display: flex;
}

@keyframes simSlideIn {
    from {
        opacity: 0;
        transform: translateX(10px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@media (max-width: 1024px) {
    .task-content {
        height: auto;
    }
}

.task-header-box {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.02);
}

.task-header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.btn-masquer {
    background: #f1f5f9;
    border: none;
    color: #475569;
    padding: 8px 16px;
    border-radius: 4px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.btn-masquer:hover {
    background: #e2e8f0;
    color: #0f172a;
}

.task-badge {
    width: 34px;
    height: 34px;
    background: #2563eb;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.task-header-text h2 {
    font-size: 0.95rem;
    font-weight: 800;
    color: #1a2332;
    margin-bottom: 3px;
}

.task-header-text p {
    font-size: 0.72rem;
    color: #64748b;
}

.task-instructions {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.02);
}

.task-instructions p {
    color: #475569;
    font-size: 0.75rem;
    line-height: 1.6;
    margin-bottom: 12px;
}

.task-prompt {
    background: #f8fafc;
    border-left: 4px solid #2563eb;
    padding: 12px 16px;
    font-weight: 600;
    font-size: 0.78rem;
    color: #1a2332;
    border-radius: 0 6px 6px 0;
    line-height: 1.55;
    width: 100%;
    max-width: none;
    white-space: normal;
    word-break: normal;
    overflow-wrap: normal;
    text-wrap: pretty;
}

.doc-box,
.doc-box p,
.doc-box div {
    white-space: normal !important;
    word-break: normal !important;
    overflow-wrap: normal !important;
    text-wrap: pretty;
}

/* Slider pour les documents (Tâche 3) */
.task-prompt:has(.tcf-doc-block) {
    background: transparent;
    border-left: none;
    padding: 0;
    padding-bottom: 5px;
    /* Pour la zone de défilement */
    white-space: nowrap;
    overflow-x: auto;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    /* Firefox */
}

.task-prompt:has(.tcf-doc-block)::-webkit-scrollbar {
    display: none;
    /* Chrome/Safari */
}

.task-prompt:has(.tcf-doc-block) .tcf-task-title-center {
    white-space: normal;
    display: block;
    margin-bottom: 15px;
}

.task-prompt .tcf-doc-block {
    display: inline-block;
    vertical-align: top;
    white-space: normal;
    /* Annule le nowrap pour le texte à l'intérieur */
    width: 85%;
    max-width: 400px;
    margin-right: 12px;
    margin-bottom: 4px;
}

.task-prompt .tcf-doc-block:last-child {
    margin-right: 0;
}

/* Éditeur de texte */
.sim-editor-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: 4px;
    transition: all 0.2s;
    overflow: hidden;
    min-height: 300px;
}

.sim-editor-wrap:focus-within {
    border-color: #3b82f6;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
}

.sim-editor-wrap textarea {
    flex: 1;
    width: 100%;
    border: none;
    padding: 16px;
    font-family: inherit;
    font-size: 0.82rem;
    color: #1a2332;
    resize: none;
    outline: none;
    line-height: 1.65;
}

.task-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    flex-shrink: 0;
    /* Empêche le footer d'être écrasé */
}

.word-counter-display {
    font-weight: 700;
    color: #475569;
    font-size: 0.72rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.count-val {
    color: #f59e0b;
    font-size: 0.88rem;
    transition: color 0.3s;
}

.count-val.success {
    color: #10b981;
}

.count-val.error {
    color: #ef4444;
}

.mini-progress {
    width: 120px;
    height: 6px;
    background: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
}

.task-controls {
    display: flex;
    gap: 8px;
}

.btn-nav-task {
    background: white;
    border: 1px solid #cbd5e1;
    color: #475569;
    width: 40px;
    height: 40px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-nav-task:hover:not(:disabled) {
    background: #f1f5f9;
    color: #0f172a;
}

.btn-nav-task:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-nav-task.primary {
    background: #2563eb;
    border-color: #2563eb;
    color: white;
}

.btn-nav-task.primary:hover:not(:disabled) {
    background: #1d4ed8;
}

/* --- Outils (Droite) --- */
.tools-section {
    margin-bottom: 30px;
}

.tools-section h4 {
    font-size: 0.95rem;
    font-weight: 800;
    color: #0f172a;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid #e2e8f0;
}

.char-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.char-grid button {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    padding: 10px 0;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.2s;
    color: #334155;
    font-family: inherit;
}

.char-grid button:hover {
    background: #eff6ff;
    border-color: #3b82f6;
    color: #2563eb;
}

.prog-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: #475569;
    font-weight: 600;
    margin-bottom: 6px;
    margin-top: 16px;
}

.right-prog-bar {
    height: 6px;
    background: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
}

.btn-terminer {
    background: #f59e0b;
    color: white;
    border: none;
    padding: 12px;
    border-radius: 4px;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    width: 100%;
    margin-top: auto;
    transition: all 0.2s;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
}

.btn-terminer:hover {
    background: #d97706;
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(245, 158, 11, 0.2);
}

/* --- Modal Terminer --- */
.sim-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    z-index: 2147483647;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.sim-modal {
    background: white;
    border-radius: 4px;
    width: 90%;
    max-width: 450px;
    max-height: calc(100svh - 32px);
    margin: auto;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    animation: modalFadeIn 0.3s ease-out;
    overflow: auto;
}

body.sim-modal-open,
body.sim-modal-open .sim-app-container,
.sim-app-container.modal-open {
    overflow: hidden !important;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid #e2e8f0;
}

.modal-header h3 {
    font-size: 1.15rem;
    font-weight: 800;
    color: #0f172a;
}

.modal-close {
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 1.2rem;
    cursor: pointer;
}

.modal-close:hover {
    color: #0f172a;
}

.modal-body {
    padding: 24px;
    color: #475569;
    font-size: 0.95rem;
    line-height: 1.5;
}

.modal-footer {
    padding: 16px 24px;
    background: #f8fafc;
    display: flex;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 12px;
    border-top: 1px solid #e2e8f0;
}

.btn-modal-cancel {
    background: white;
    border: 1px solid #cbd5e1;
    color: #475569;
    padding: 10px 16px;
    border-radius: 4px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-modal-cancel:hover {
    background: #f1f5f9;
}

.btn-modal-confirm {
    background: #f59e0b;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.btn-modal-confirm:hover {
    background: #d97706;
}

@media (max-width: 480px) {
    .sim-modal-overlay {
        align-items: center;
        padding: 12px;
    }

    .sim-modal {
        width: 100%;
        max-height: calc(100svh - 24px);
    }

    .modal-header,
    .modal-body,
    .modal-footer {
        padding-left: 16px;
        padding-right: 16px;
    }

    .modal-footer {
        display: grid;
        grid-template-columns: 1fr;
        gap: 10px;
        padding-top: 14px;
        padding-bottom: 16px;
    }

    .btn-modal-cancel,
    .btn-modal-confirm {
        width: 100%;
        min-height: 48px;
        margin: 0;
        padding: 0 16px;
        border-radius: 6px;
        font-size: 0.88rem;
        line-height: 1.2;
        justify-content: center;
        text-align: center;
        box-sizing: border-box;
    }

    .btn-modal-cancel {
        order: 1;
        background: #ffffff;
        border: 1px solid #dbe3ef;
        color: #334155;
    }

    .btn-modal-confirm {
        order: 2;
        background: #f59e0b;
        box-shadow: 0 8px 18px rgba(245, 158, 11, 0.22);
    }
}

/* --- Loading Screen --- */
.sim-loading-screen {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #f8fafc;
    z-index: 60;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 20px;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 6px solid #e2e8f0;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 24px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.sim-loading-screen h2 {
    font-size: 1.5rem;
    color: #0f172a;
    margin-bottom: 12px;
    font-weight: 800;
}

.sim-loading-screen p {
    color: #64748b;
    max-width: 400px;
    line-height: 1.5;
    margin-bottom: 30px;
}

.loading-astuce {
    background: #eff6ff;
    color: #1d4ed8;
    padding: 16px 24px;
    border-radius: 4px;
    font-size: 0.9rem;
    max-width: 500px;
}

/* --- Results Screen --- */
.sim-results-screen {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #f8fafc;
    z-index: 70;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.results-header {
    background: linear-gradient(150deg, #1e3a8a 0%, #1d4ed8 50%, #3b82f6 100%);
    color: white;
    padding: 40px 20px 80px;
    text-align: center;
}

.results-header h1 {
    color: #ffffff !important;
    font-size: 2rem;
    font-weight: 800;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

.badge-result {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.2);
    padding: 6px 16px;
    border-radius: 4px;
    font-size: 0.9rem;
    margin-bottom: 16px;
}

.results-header h1 {
    font-size: 2rem;
    font-weight: 800;
}

.results-content {
    max-width: 900px;
    margin: -50px auto 40px;
    padding: 0 20px;
    width: 100%;
}

@media (max-width: 1024px) {
    .results-content {
        padding: 0 10px;
    }

    .stats-card {
        padding: 16px;
    }

    .task-review-card {
        padding: 16px 10px;
    }

    .results-actions {
        padding: 0 4px;
    }
}

.stats-card {
    background: white;
    border-radius: 4px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 30px;
    margin-bottom: 24px;
    border: 1px solid #e2e8f0;
    transition: transform 0.3s ease;
}

.stats-card:hover {
    transform: translateY(-5px);
}

.stat-item {
    flex: 1;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-divider {
    width: 1px;
    height: 60px;
    background: #e2e8f0;
}

.stat-label {
    font-size: 0.9rem;
    color: #64748b;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 2.5rem;
    font-weight: 800;
    color: #0f172a;
    line-height: 1;
    margin-bottom: 4px;
}

.stat-sub {
    font-size: 0.85rem;
    color: #94a3b8;
}

.stat-badge {
    font-size: 2rem;
    font-weight: 800;
    padding: 4px 16px;
    border-radius: 4px;
    line-height: 1;
    margin-bottom: 4px;
}

.text-red {
    color: #ef4444;
}

.text-blue {
    color: #3b82f6;
}

.stat-badge.text-red {
    background: #fef2f2;
    color: #ef4444;
    border: 1px solid #fecaca;
}

.results-warning {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #ef4444;
    padding: 20px;
    border-radius: 4px;
    font-size: 0.95rem;
    line-height: 1.5;
    margin-bottom: 24px;
    text-align: center;
}

.results-actions {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-bottom: 40px;
}

.btn-outline {
    background: white;
    border: 1px solid #cbd5e1;
    color: #475569;
    padding: 12px 24px;
    border-radius: 4px;
    font-weight: 600;
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.btn-outline:hover {
    background: #f8fafc;
    color: #0f172a;
}

.btn-primary {
    background: #3b82f6;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 4px;
    font-weight: 600;
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.btn-primary:hover {
    background: #2563eb;
}

.task-review-card {
    background: white;
    border-radius: 4px;
    border: 1px solid #e2e8f0;
    padding: 30px;
    margin-bottom: 24px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.02);
    transition: all 0.3s;
}

.task-review-card:hover {
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.08);
    border-color: #cbd5e1;
}

.review-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid #f1f5f9;
}

.review-title h3 {
    font-size: 1.25rem;
    font-weight: 800;
    color: #0f172a;
    margin-bottom: 8px;
}

.review-title p {
    font-size: 0.9rem;
    color: #64748b;
    line-height: 1.5;
}

.review-docs {
    display: grid;
    grid-template-columns: 1fr;
    gap: 18px;
    margin-top: 16px;
}

.review-docs[hidden] {
    display: none !important;
}

.review-doc[hidden] {
    display: none !important;
}

.review-doc {
    background: #f8fafc;
    border: 1px solid #dbe3ef;
    border-left: 6px solid #6366f1;
    border-radius: 8px;
    padding: 18px 22px;
    color: #1e293b;
    font-size: 1rem;
    line-height: 1.65;
    box-shadow: 0 2px 10px rgba(15, 23, 42, 0.03);
}

.review-doc-contre {
    border-left-color: #f59e0b;
    background: #fffbeb;
}

.review-doc-label {
    color: #4f46e5;
    font-weight: 800;
    font-size: 0.95rem;
    margin-bottom: 10px;
}

.review-doc-label-contre {
    color: #d97706;
}

.review-doc p,
.review-doc div {
    margin: 0;
}

.review-score {
    font-size: 1.5rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 12px;
}

.badge-mini {
    font-size: 0.85rem;
    padding: 2px 8px;
    border-radius: 4px;
    border: 1px solid currentColor;
}

.feedback-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 24px;
}

.feedback-box {
    padding: 20px;
    border-radius: 12px;
    font-size: 0.9rem;
    line-height: 1.5;
}

.feedback-box.positive {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #166534;
}

.feedback-box.negative {
    background: #fffbeb;
    border: 1px solid #fde68a;
    color: #92400e;
}

.feedback-box h4 {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    font-size: 1rem;
    font-weight: 700;
}

.feedback-box ul {
    padding-left: 20px;
}

.feedback-box li {
    margin-bottom: 8px;
}

.accordion {
    border-top: 1px solid #e2e8f0;
}

.accordion-item {
    border-bottom: 1px solid #e2e8f0;
}

.accordion-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    font-size: 0.95rem;
    font-weight: 600;
    color: #475569;
    cursor: pointer;
    margin-bottom: 4px;
    transition: all 0.2s;
}

.accordion-header:hover {
    background: #f1f5f9;
    color: #0f172a;
    border-color: #cbd5e1;
}

.accordion-header.open {
    background: #eff6ff;
    color: #1d4ed8;
    border-color: #bfdbfe;
}

.accordion-content {
    display: none;
    padding: 0 0 20px 0;
    color: #475569;
    font-size: 0.95rem;
    line-height: 1.6;
}

.user-text {
    white-space: pre-wrap;
    font-family: 'Courier New', Courier, monospace;
    background: #f8fafc;
    padding: 16px;
    border-radius: 4px;
}

/* =========================================
           Responsive Tablette & Mobile
           ========================================= */
@media (max-width: 1024px) {

    /* --- Results page --- */
    .stats-card {
        flex-direction: column;
        gap: 24px;
        padding: 20px;
    }

    .stat-divider {
        width: 100%;
        height: 1px;
    }

    .feedback-grid {
        grid-template-columns: 1fr;
    }

    .review-header {
        flex-direction: column;
        gap: 16px;
    }

    .review-doc {
        padding: 14px 16px;
        font-size: 0.9rem;
        line-height: 1.6;
    }

    .results-actions {
        flex-direction: column;
    }

    .btn-outline,
    .btn-primary {
        width: 100%;
        justify-content: center;
    }

    /* --- Main layout stacks vertically --- */
    .sim-body {
        flex-direction: column;
    }

    /* --- Header --- */
    .sim-header {
        height: auto;
        min-height: 60px;
        padding: 10px 16px;
        flex-wrap: wrap;
        gap: 8px;
        position: sticky;
        top: 0;
        z-index: 20;
        background: #fff;
    }

    .sim-header-left {
        min-width: 0;
        gap: 10px;
    }

    .sim-header-right {
        display: none;
    }

    .sim-title {
        font-size: 0.95rem;
    }

    .sim-timer {
        font-size: 0.95rem;
        padding: 6px 14px;
    }

    /* --- Left nav becomes horizontal strip --- */
    .sim-sidebar-left {
        width: 100%;
        height: auto;
        padding: 8px 10px;
        border-right: none;
        border-bottom: 1px solid #e2e8f0;
        overflow: visible;
    }

    .sidebar-title {
        display: none;
    }

    .sim-task-nav {
        display: flex;
        gap: 10px;
        overflow-x: auto;
        padding-bottom: 4px;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .sim-task-nav::-webkit-scrollbar {
        display: none;
    }

    .sim-task-btn {
        min-width: 160px;
        flex-shrink: 0;
        margin-bottom: 0;
        padding: 12px;
    }

    .sim-task-btn .task-name {
        font-size: 0.9rem;
    }

    .sim-task-btn .task-desc {
        font-size: 0.75rem;
    }

    .sim-warning {
        display: none;
    }

    /* --- Main editor area --- */
    .sim-main {
        overflow-y: visible;
        padding: 10px 8px;
        flex: none;
        display: block;
        order: 2;
        width: 100%;
        min-width: 0;
    }

    .task-content.active {
        display: block;
        height: auto;
        min-height: 0;
    }

    .sim-editor-wrap {
        display: flex;
        overflow: visible;
        flex: none;
        min-height: 300px;
        margin-bottom: 12px;
    }

    .sim-editor-wrap textarea {
        display: block;
        flex: none;
        height: clamp(220px, 38svh, 360px);
        min-height: 220px;
        width: 100%;
        padding: 16px;
        resize: none;
    }

    .task-footer {
        padding: 12px 16px;
        flex-shrink: 0;
        width: 100%;
        box-sizing: border-box;
        position: relative;
        z-index: 1;
        gap: 12px;
    }

    .task-controls {
        flex-shrink: 0;
    }

    .word-counter-display {
        flex: 1;
        min-width: 0;
        overflow: hidden;
    }

    .task-header-box {
        flex-wrap: wrap;
        gap: 8px;
        padding: 10px 8px;
    }

    .task-instructions {
        padding: 10px 8px;
    }

    .task-instructions p {
        font-size: 0.88rem;
    }

    .task-prompt {
        font-size: 0.88rem;
    }

    /* --- Right sidebar (tools) becomes horizontal strip --- */
    .sim-sidebar-right {
        width: 100%;
        border-left: none;
        border-top: 1px solid #e2e8f0;
        height: auto;
        padding: 10px 8px;
        flex-shrink: 0;
        order: 3;
    }

    .btn-terminer {
        margin-top: 16px;
    }

    .char-grid {
        grid-template-columns: repeat(7, 1fr);
    }

    .tools-section {
        margin-bottom: 16px;
    }

    /* --- Task 3 Slider --- */
    .docs-container {
        display: flex;
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        grid-template-columns: none;
        gap: 12px;
        padding-bottom: 8px;
        -webkit-overflow-scrolling: touch;
    }

    .doc-slide,
    .doc-card {
        flex: 0 0 85%;
        scroll-snap-align: start;
    }

    .docs-container::-webkit-scrollbar {
        height: 4px;
    }

    .docs-container::-webkit-scrollbar-thumb {
        background: #cbd5e1;
        border-radius: 4px;
    }
}

@media (max-width: 600px) {
    .char-grid {
        grid-template-columns: repeat(5, 1fr);
    }

    .sim-header {
        padding: 8px 12px;
    }

    .sim-timer {
        font-size: 0.9rem;
        padding: 5px 12px;
    }

    .sim-task-btn {
        min-width: 140px;
    }

    .task-badge {
        width: 36px;
        height: 36px;
        font-size: 1rem;
    }

    .task-header-text h2 {
        font-size: 1.05rem;
    }

    .task-header-box {
        align-items: flex-start;
    }

    .btn-masquer {
        margin-left: auto;
        min-height: 40px;
    }

    .task-instructions {
        margin-bottom: 12px;
    }

    .sim-editor-wrap {
        min-height: 320px;
    }

    .sim-editor-wrap textarea {
        height: 230px;
        min-height: 230px;
    }

    .task-footer {
        align-items: stretch;
        flex-direction: column;
        padding: 12px;
    }

    .word-counter-display {
        width: 100%;
        flex-wrap: wrap;
        justify-content: space-between;
        gap: 8px;
    }

    .mini-progress {
        width: 100%;
        flex: 0 0 100%;
    }

    .task-controls {
        width: 100%;
        justify-content: space-between;
    }

    .btn-nav-task {
        flex: 1 1 0;
        max-width: none;
    }

    .intro-header {
        padding: 20px 16px;
    }

    .intro-header h1 {
        font-size: 1.4rem;
    }

    .intro-body {
        padding: 16px;
    }

    .intro-cards {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .intro-card {
        flex-direction: row;
        text-align: left;
        padding: 12px 16px;
    }

    .intro-card .badge {
        margin: 0 12px 0 0;
    }

    .intro-card-text {
        display: flex;
        flex-direction: column;
    }

    .btn-start-exam {
        width: 100%;
        justify-content: center;
    }
}

/* Nettoyage des blocs vides qui peuvent rester dans les documents de la tache 3 */
.doc-box .task-prompt,
.doc-box .task-prompt:empty,
.doc-box p:empty,
.doc-box div:empty {
    display: none !important;
}
