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

/* ==== Mobile Debug Panel ==== */
#mobileDebugPanel .debug-info { color: #0ff; }
#mobileDebugPanel .debug-success { color: #0f0; }
#mobileDebugPanel .debug-error { color: #f00; }
#mobileDebugPanel .debug-warning { color: #ff0; }

/* ==== Couleurs & typographie ==== */
:root{
    --primary:#3498db;
    --primary-dark:#2980b9;
    --bg-grad:#f0f4ff;
    --bg-card:#fff;
    --text:#333;
    --muted:#777;
    --accent:#2c3e50;
}
body{
    font-family:-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                 Helvetica, Arial, sans-serif;
    background:linear-gradient(135deg,var(--bg-grad),#e6e9ff);
    color:var(--text);
    min-height:100vh;
    display:flex;
    align-items:center;
    justify-content:center;
    padding:2rem;
    /* Mobile touch optimization */
    -webkit-tap-highlight-color: rgba(52, 152, 219, 0.3);
    -webkit-touch-callout: none;
    font-size: 16px; /* Prevents iOS zoom on input focus */
}

/* ==== Conteneur principal ==== */
.wrapper{
    max-width:900px;
    width:100%;
    background:var(--bg-card);
    border-radius:12px;
    box-shadow:0 8px 24px rgba(0,0,0,.1);
    padding:2.5rem 2rem;
}

/* ==== Titres ==== */
h1{font-size:2.2rem;margin-bottom:.5rem;color:var(--accent);}
h2{font-size:1.6rem;margin:1rem 0 .5rem;color:var(--accent);}
h3{font-size:1.3rem;margin:.5rem 0;color:var(--accent);}

/* ==== Boutons ==== */
.btn{
    display:inline-block;
    background:var(--primary);
    color:#fff;
    text-decoration:none;
    padding:.8rem 1.5rem;
    border-radius:4px;
    font-weight:600;
    cursor:pointer;
    border:none;
    font-size:1rem;
    /* Mobile touch target minimum 44x44px */
    min-height:44px;
    min-width:44px;
    touch-action:manipulation; /* Prevents double-tap zoom */
    user-select:none;
    -webkit-user-select:none;
}
.btn:hover{background:var(--primary-dark);}
.btn:active{transform:scale(0.98);}

/* ==== Formulaires ==== */
input, select, textarea{
    width:100%;
    padding:.6rem;
    margin:.4rem 0 1rem;
    border:1px solid #ccc;
    border-radius:4px;
    font-size:1rem;
}
label{font-weight:500;}

/* ==== Card de quiz ==== */
.quiz-card{
    background:#fafafa;
    border:1px solid #e0e0e0;
    border-radius:8px;
    padding:1.2rem;
    margin-bottom:1rem;
}
.quiz-card h3{margin-top:0;}

/* ==== Password Requirements ==== */
.password-requirements {
    margin: 0.5rem 0 1rem 0;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 6px;
    border-left: 4px solid var(--primary);
}

.password-requirements p {
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--accent);
}

.password-requirements ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.password-requirements li {
    padding: 0.2rem 0;
    font-size: 0.9rem;
    position: relative;
    padding-left: 1.5rem;
}

.password-requirements li::before {
    content: "✗";
    position: absolute;
    left: 0;
    color: #e74c3c;
    font-weight: bold;
}

.password-requirements li.valid::before {
    content: "✓";
    color: #27ae60;
}

.password-requirements li.valid {
    color: #27ae60;
}

.password-requirements li.invalid {
    color: #e74c3c;
}

/* ==== Profile Page Styles ==== */
.profile-section {
    margin-bottom: 2.5rem;
    padding: 1.5rem;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.profile-section h2 {
    margin-top: 0;
    margin-bottom: 1.5rem;
    color: var(--accent);
    border-bottom: 2px solid var(--primary);
    padding-bottom: 0.5rem;
}

.status-card {
    background: white;
    padding: 1.5rem;
    border-radius: 6px;
    border: 1px solid #dee2e6;
}

.status-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #f1f3f4;
}

.status-item:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.status-label {
    font-weight: 600;
    color: var(--text);
}

.status-value {
    font-weight: 500;
}

.status-paid {
    color: #28a745;
    font-weight: 600;
}

.status-unpaid {
    color: #dc3545;
    font-weight: 600;
}

.profile-form {
    background: white;
    padding: 1.5rem;
    border-radius: 6px;
    border: 1px solid #dee2e6;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text);
}

.form-group input {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #e9ecef;
    border-radius: 4px;
    font-size: 1rem;
    transition: border-color 0.2s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary);
}

.cgu-acceptance {
    margin: 1.5rem 0;
    padding: 1rem;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 5px;
}

.cgu-acceptance input[type="checkbox"] {
    width: auto;
    margin-right: 0.5rem;
    margin-bottom: 0;
}

.cgu-acceptance label {
    margin-bottom: 0;
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    font-size: 0.9rem;
    line-height: 1.4;
}

.cgu-acceptance a {
    color: var(--primary);
    text-decoration: none;
}

.cgu-acceptance a:hover {
    text-decoration: underline;
}

.legal-info {
    background: #f8f9fa;
    padding: 1.5rem;
    border-radius: 6px;
    border: 1px solid #dee2e6;
}

.legal-info p {
    margin-bottom: 1rem;
}

.legal-info p:last-child {
    margin-bottom: 0;
}

.info-text {
    font-size: 0.9rem;
    color: #6c757d;
    font-style: italic;
    margin-top: 1rem;
}

.form-group input:disabled {
    background-color: #f8f9fa;
    color: #6c757d;
    cursor: not-allowed;
}

.subscription-notice {
    text-align: center;
    background: #fff3cd;
    border: 2px solid #ffc107;
    border-radius: 8px;
    padding: 2rem;
    margin: 2rem 0;
}

.subscription-notice h2 {
    color: #856404;
    margin-bottom: 1rem;
}

.subscription-notice p {
    color: #856404;
    margin-bottom: 1.5rem;
    font-size: 1.1rem;
}

.btn-subscribe {
    background: #28a745;
    color: white;
    font-size: 1.1rem;
    padding: 1rem 2rem;
}

.btn-subscribe:hover {
    background: #218838;
}

.training-options.disabled {
    opacity: 0.5;
    pointer-events: none;
}

.training-card.disabled {
    background: #f8f9fa;
    color: #6c757d;
    cursor: not-allowed;
    opacity: 0.6;
}

.training-card.disabled:hover {
    transform: none;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #545b62;
}

.selected-mode-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.custom-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.btn-reset {
    font-size: 0.9rem;
    padding: 0.5rem 1rem;
}

/* Mode-specific button styles */
.btn-apesanteur {
    background: linear-gradient(135deg, #27ae60 0%, #2ecc71 100%) !important;
    border: none !important;
    box-shadow: 0 4px 15px rgba(39, 174, 96, 0.4);
    color: white !important;
}

.btn-apesanteur:hover {
    background: linear-gradient(135deg, #229954 0%, #27ae60 100%) !important;
    box-shadow: 0 6px 20px rgba(39, 174, 96, 0.6);
    transform: translateY(-2px);
}

.btn-gravity {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%) !important;
    border: none !important;
    box-shadow: 0 4px 15px rgba(231, 76, 60, 0.4);
    color: white !important;
}

.btn-gravity:hover {
    background: linear-gradient(135deg, #cb4335 0%, #a93226 100%) !important;
    box-shadow: 0 6px 20px rgba(231, 76, 60, 0.6);
    transform: translateY(-2px);
}

.btn-personnalise {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%) !important;
    border: none !important;
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.4);
    color: white !important;
}

.btn-personnalise:hover {
    background: linear-gradient(135deg, var(--primary-dark) 0%, #1f4e79 100%) !important;
    box-shadow: 0 6px 20px rgba(52, 152, 219, 0.6);
    transform: translateY(-2px);
}

/* Mode-specific header styles */
.mode-apesanteur h2 {
    color: #27ae60;
    text-shadow: 0 2px 4px rgba(39, 174, 96, 0.3);
}

.mode-gravity h2 {
    color: #e74c3c;
    text-shadow: 0 2px 4px rgba(231, 76, 60, 0.3);
}

.mode-trou-noir h2 {
    color: #2c2c2c;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.mode-personnalise h2 {
    color: var(--primary);
    text-shadow: 0 2px 4px rgba(52, 152, 219, 0.3);
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #e9ecef;
}

.header div {
    display: flex;
    gap: 1rem;
}


/* ==== Training Menu (Burger Menu) ==== */
.training-menu {
    text-align: center;
    margin-bottom: 2rem;
}

.training-menu h2 {
    margin-bottom: 2rem;
    color: var(--accent);
    font-size: 1.8rem;
}

.training-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.training-card {
    color: white;
    border: 3px solid transparent;
    border-radius: 16px;
    padding: 2.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.training-card:hover {
    transform: translateY(-5px);
}

.training-card:nth-child(1) {
    background: linear-gradient(135deg, #27ae60 0%, #2ecc71 100%);
    border-color: #27ae60;
    box-shadow: 0 6px 15px rgba(39, 174, 96, 0.4);
}

.training-card:nth-child(1):hover {
    box-shadow: 0 12px 25px rgba(39, 174, 96, 0.6);
}

.training-card:nth-child(2) {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    border-color: #e74c3c;
    box-shadow: 0 6px 15px rgba(231, 76, 60, 0.4);
}

.training-card:nth-child(2):hover {
    box-shadow: 0 12px 25px rgba(231, 76, 60, 0.6);
}

.training-card:nth-child(3) {
    background: linear-gradient(135deg, #2c2c2c 0%, #000000 100%);
    border-color: #333333;
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.7);
}

.training-card:nth-child(3):hover {
    box-shadow: 0 12px 25px rgba(0, 0, 0, 0.9);
}

.training-card:nth-child(4) {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-color: var(--primary);
    box-shadow: 0 6px 15px rgba(52, 152, 219, 0.4);
}

.training-card:nth-child(4):hover {
    box-shadow: 0 12px 25px rgba(52, 152, 219, 0.6);
}

.training-card h3 {
    margin: 0 0 1rem 0;
    color: white;
    font-size: 1.4rem;
    font-weight: 600;
}

.training-card p {
    color: rgba(255, 255, 255, 0.9);
    line-height: 1.5;
    margin: 0;
}

/* ==== Configuration Panel ==== */
#configPanel {
    animation: slideInUp 0.4s ease;
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.config-container {
    max-width: 600px;
    margin: 0 auto;
}

.btn-back {
    background: transparent;
    color: var(--primary);
    border: 2px solid var(--primary);
    margin-bottom: 2rem;
    padding: 0.8rem 1.5rem;
}

.btn-back:hover {
    background: var(--primary);
    color: white;
}

.selected-mode-header {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 12px;
    border-left: 4px solid var(--primary);
}

.mode-icon-large {
    font-size: 3rem;
}

.selected-mode-header h2 {
    margin: 0;
    color: var(--accent);
    font-size: 1.6rem;
}

.selected-mode-header p {
    margin: 0.5rem 0 0 0;
    color: var(--muted);
    line-height: 1.4;
}

.config-section {
    margin-bottom: 2rem;
}

.config-section h3 {
    margin: 0 0 1rem 0;
    color: var(--accent);
    font-size: 1.3rem;
}

/* ==== Type Boxes (Selectable QCM Types) ==== */
.type-boxes {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.type-box {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.5rem;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: white;
}

.type-box:hover {
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(52, 152, 219, 0.15);
}

.type-box.selected {
    border-color: var(--primary);
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.2);
}

.type-icon {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: bold;
}

.type-info {
    display: flex;
    flex-direction: column;
}

.type-title {
    font-weight: 600;
    color: var(--accent);
    font-size: 1.1rem;
}

.type-desc {
    color: var(--muted);
    font-size: 0.9rem;
}

/* ==== Subject Dropdown ==== */
.subject-dropdown {
    position: relative;
}

.dropdown-btn {
    width: 100%;
    padding: 1rem 1.5rem;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    background: white;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.dropdown-btn:hover {
    border-color: var(--primary);
}

.dropdown-btn.active {
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(52, 152, 219, 0.15);
}

.dropdown-arrow {
    transition: transform 0.3s ease;
}

.dropdown-btn.active .dropdown-arrow {
    transform: rotate(180deg);
}

.dropdown-content {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 2px solid var(--primary);
    border-top: none;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 100;
    max-height: 300px;
    overflow-y: auto;
    display: none;
}

.dropdown-content.show {
    display: block;
}

.dropdown-item {
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    transition: background 0.2s ease;
}

.dropdown-item:hover {
    background: #f8f9fa;
}

.dropdown-item input[type="checkbox"] {
    width: auto;
    margin: 0;
}

.dropdown-item label {
    margin: 0;
    cursor: pointer;
    flex: 1;
}

.dropdown-separator {
    height: 1px;
    background: #e9ecef;
    margin: 0.5rem 0;
}

/* ==== Start Button ==== */
.btn-start {
    width: 100%;
    padding: 1.2rem 2rem;
    font-size: 1.2rem;
    font-weight: 600;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    border: none;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.btn-start:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(52, 152, 219, 0.3);
}

.btn-danger.btn-start {
    background: linear-gradient(135deg, #2c2c2c 0%, #000000 100%) !important;
    border: none !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.6);
    color: white !important;
}

.btn-danger.btn-start:hover {
    background: linear-gradient(135deg, #4a1c1c 0%, #2d1212 100%) !important;
    box-shadow: 0 6px 20px rgba(74, 28, 28, 0.7);
    transform: translateY(-2px);
}

/* ==== Custom Settings (Mode Personnalisé) ==== */
.custom-options {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    border: 1px solid #dee2e6;
}

.option-group {
    margin-bottom: 2rem;
}

.option-group:last-child {
    margin-bottom: 0;
}

.option-group label {
    display: block;
    font-weight: 600;
    color: var(--accent);
    margin-bottom: 0.8rem;
    font-size: 1.1rem;
}

.question-input {
    width: 100%;
    max-width: 150px;
    padding: 0.75rem;
    border: 2px solid #e9ecef;
    border-radius: 6px;
    font-size: 1rem;
    transition: border-color 0.3s;
}

.question-input:focus {
    outline: none;
    border-color: var(--primary);
}

.input-with-help {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.input-inline-help {
    font-size: 0.8rem;
    color: var(--muted);
    font-style: italic;
    white-space: nowrap;
}

.timer-options {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 400;
    background: #f8f9fa;
}

.radio-label:hover {
    border-color: var(--primary);
    background: #f0f8ff;
}

.radio-label input[type="radio"] {
    width: auto;
    margin: 0;
    transform: scale(1.2);
}

.radio-label.active {
    border-color: var(--primary);
    background: #e3f2fd;
}

.time-input {
    width: 80px;
    padding: 0.4rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 0.9rem;
    margin: 0 0.5rem;
}

.time-input:disabled {
    background: #f5f5f5;
    color: #999;
}

.time-input:focus {
    outline: none;
    border-color: var(--primary);
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .form-row {
        grid-template-columns: 1fr;
    }

    .header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    .header div {
        justify-content: center;
    }
}

/* ==== Password Reset Styles ==== */
.forgot-password-link {
    color: #3498db;
    text-decoration: none;
    font-size: 0.9rem;
}

.forgot-password-link:hover {
    text-decoration: underline;
}

.form-description {
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 5px;
    border-left: 4px solid #3498db;
    margin-bottom: 1.5rem;
    color: #555;
    font-size: 0.95rem;
    line-height: 1.4;
}

.user-info {
    margin-bottom: 1rem;
}

.password-requirements {
    margin-top: 0.5rem;
    color: #666;
    font-size: 0.85rem;
}

.message {
    padding: 1rem;
    border-radius: 5px;
    margin: 1rem 0;
}

.message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.message.info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

.message h3 {
    margin: 0 0 0.5rem 0;
    font-size: 1.1rem;
}

.message p {
    margin: 0.5rem 0;
    line-height: 1.4;
}

/* ==== Footer ==== */
.footer{margin-top:2rem;font-size:.85rem;color:var(--muted);text-align:center;}

/* ==== QCM Interface Styles ==== */

/* Container principal de la question */
.question-container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 2rem;
    position: relative;
}

/* Contrôles en haut de la question */
.question-top-controls {
    margin-bottom: 1.5rem;
    display: flex;
    justify-content: flex-start;
}

.btn-back-question {
    background: transparent;
    color: var(--primary);
    border: 2px solid var(--primary);
    padding: 0.6rem 1.2rem;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

.btn-back-question:hover {
    background: var(--primary);
    color: white;
}

/* Header de la question */
.question-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 12px;
    border-left: 4px solid var(--primary);
}

.question-progress {
    flex: 1;
}

.question-number {
    font-weight: 600;
    color: var(--accent);
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    display: block;
}

.progress-bar {
    width: 200px;
    height: 8px;
    background: #e9ecef;
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary) 0%, var(--primary-dark) 100%);
    transition: width 0.3s ease;
}

.question-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.question-subject {
    padding: 0.4rem 0.8rem;
    background: #28a745; /* Green for subjects */
    color: white;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
}

.question-type {
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
}

.type-a {
    background: #007bff; /* Blue for Type A */
    color: white;
}

.type-k,
.type-kprim {
    background: #ff8c00; /* Orange for K-Prim */
    color: white;
}

/* Timer */
.timer-display {
    font-family: 'Courier New', monospace;
    font-size: 1.4rem;
    font-weight: bold;
    color: var(--accent);
    padding: 0.5rem 1rem;
    background: white;
    border-radius: 8px;
    border: 2px solid #e9ecef;
    min-width: 80px;
    text-align: center;
}

.timer-warning {
    color: #f39c12 !important;
    border-color: #f39c12 !important;
}

.timer-danger {
    color: #e74c3c !important;
    border-color: #e74c3c !important;
    animation: pulse 1s infinite;
}

.timer-overtime {
    color: white !important;
    background-color: #e74c3c !important;
    border-color: #e74c3c !important;
    animation: none;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* Titre de la question */
.question-title {
    font-size: 1.6rem;
    color: var(--accent);
    margin-bottom: 1.5rem;
    text-align: center;
    line-height: 1.4;
}

/* Énoncé */
.question-enonce {
    background: white;
    padding: 2rem;
    border-radius: 12px;
    border: 1px solid #e9ecef;
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

.question-enonce p {
    font-size: 1.1rem;
    margin-bottom: 1rem;
}

.question-image {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 1rem 0;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

/* Instructions */
.question-instructions {
    text-align: center;
    margin-bottom: 2rem;
    padding: 1rem;
    background: #e3f2fd;
    border-radius: 8px;
    border-left: 4px solid var(--primary);
}

.question-instructions p {
    margin: 0;
    font-size: 1rem;
    color: var(--accent);
}

/* Grille des réponses 2x2 */
.answers-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

/* Carte de réponse */
.answer-card {
    background: white;
    border: 3px solid #e9ecef;
    border-radius: 12px;
    padding: 1.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    min-height: 120px;
    display: flex;
    flex-direction: column;
    /* Mobile touch optimization */
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.answer-card:hover {
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.15);
    transform: translateY(-2px);
}

.answer-card:active {
    transform: scale(0.98);
}

.answer-card.selected {
    border-color: var(--primary);
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.3);
}

/* États de correction */
.answer-card.correct {
    border-color: #27ae60 !important;
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%) !important;
}

.answer-card.incorrect {
    border-color: #e74c3c !important;
    background: linear-gradient(135deg, #f8d7da 0%, #f5c6cb 100%) !important;
}

.answer-card.correct-unselected {
    border-color: #27ae60 !important;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%) !important;
    border-style: dashed !important;
}

/* Lettre de la réponse */
.answer-letter {
    position: absolute;
    top: -10px;
    left: 15px;
    background: var(--primary);
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.1rem;
}

.answer-card.correct .answer-letter {
    background: #27ae60;
}

.answer-card.incorrect .answer-letter {
    background: #e74c3c;
}

.answer-card.correct-unselected .answer-letter {
    background: #27ae60;
}

/* Contenu de la réponse */
.answer-content {
    flex: 1;
    padding-top: 0.5rem;
}

.answer-content p {
    margin: 0;
    font-size: 1rem;
    line-height: 1.5;
    color: var(--text);
}

.answer-image {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    margin: 0.5rem 0;
}

/* Indicateur de sélection */
.answer-indicator {
    position: absolute;
    top: 15px;
    right: 15px;
    font-size: 1.5rem;
    color: var(--primary);
    font-weight: bold;
}

.answer-card.selected .answer-indicator {
    color: var(--primary);
}

/* Answer indicator colors for correction display */
.answer-card.correct .answer-indicator {
    color: #27ae60; /* Green for correct selected answers */
}

.answer-card.correct-unselected .answer-indicator {
    color: #27ae60; /* Green for correct unselected answers */
}

.answer-card.incorrect .answer-indicator {
    color: #e74c3c; /* Red for incorrect selected answers */
}

/* Answer correction styling */
.answer-correction {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid #e9ecef;
    font-size: 0.9rem;
    color: #2c3e50;
    line-height: 1.4;
}

/* Make answer text grey when correction is shown */
.answer-card.correct .answer-content p,
.answer-card.incorrect .answer-content p,
.answer-card.correct-unselected .answer-content p {
    color: #7f8c8d;
}

/* Zone de correction */
.correction-zone {
    background: #f8f9fa;
    border: 2px solid #dee2e6;
    border-radius: 12px;
    padding: 2rem;
    margin: 2rem 0;
    border-left: 4px solid #28a745;
}

.correction-zone h3 {
    color: #28a745;
    margin-top: 0;
    margin-bottom: 1.5rem;
    font-size: 1.4rem;
}

.correction-content p {
    margin-bottom: 1rem;
    line-height: 1.6;
}

.explanation {
    background: white;
    padding: 1rem;
    border-radius: 8px;
    border-left: 4px solid #17a2b8;
    font-style: italic;
}

.correction-image {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 1rem 0;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

/* User watermark system */
.user-watermark {
    position: absolute;
    font-size: 2rem;
    font-weight: bold;
    color: rgba(52, 152, 219, 0.08);
    text-transform: uppercase;
    letter-spacing: 3px;
    white-space: nowrap;
    pointer-events: none;
    z-index: 1;
    /* Prevent selection and copying */
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Watermark positioning - anti-tampering layout */
.user-watermark.pos-0 { transform: rotate(-45deg); }
.user-watermark.pos-0.w1 { top: 8%; left: 15%; }
.user-watermark.pos-0.w2 { top: 45%; right: 20%; }
.user-watermark.pos-0.w3 { top: 75%; left: 60%; }
.user-watermark.pos-0.w4 { top: 25%; left: 75%; }
.user-watermark.pos-0.w5 { top: 60%; right: 10%; }
.user-watermark.pos-0.w6 { bottom: 15%; left: 35%; }

.user-watermark.pos-1 { transform: rotate(45deg); }
.user-watermark.pos-1.w1 { top: 20%; right: 25%; }
.user-watermark.pos-1.w2 { top: 55%; left: 10%; }
.user-watermark.pos-1.w3 { bottom: 30%; right: 15%; }
.user-watermark.pos-1.w4 { top: 35%; left: 70%; }
.user-watermark.pos-1.w5 { bottom: 10%; left: 50%; }
.user-watermark.pos-1.w6 { top: 80%; right: 45%; }

.user-watermark.pos-2 { transform: rotate(-30deg); }
.user-watermark.pos-2.w1 { top: 15%; left: 40%; }
.user-watermark.pos-2.w2 { top: 65%; right: 30%; }
.user-watermark.pos-2.w3 { top: 40%; left: 5%; }
.user-watermark.pos-2.w4 { bottom: 25%; left: 80%; }
.user-watermark.pos-2.w5 { top: 85%; left: 25%; }
.user-watermark.pos-2.w6 { top: 30%; right: 5%; }

.user-watermark.pos-3 { transform: rotate(30deg); }
.user-watermark.pos-3.w1 { top: 12%; left: 65%; }
.user-watermark.pos-3.w2 { top: 50%; right: 35%; }
.user-watermark.pos-3.w3 { bottom: 20%; left: 20%; }
.user-watermark.pos-3.w4 { top: 70%; left: 85%; }
.user-watermark.pos-3.w5 { top: 35%; right: 10%; }
.user-watermark.pos-3.w6 { bottom: 45%; right: 60%; }

.user-watermark.pos-4 { transform: rotate(-60deg); }
.user-watermark.pos-4.w1 { top: 25%; left: 30%; }
.user-watermark.pos-4.w2 { bottom: 35%; right: 20%; }
.user-watermark.pos-4.w3 { top: 60%; left: 80%; }
.user-watermark.pos-4.w4 { top: 10%; right: 40%; }
.user-watermark.pos-4.w5 { bottom: 15%; left: 65%; }
.user-watermark.pos-4.w6 { top: 85%; right: 15%; }

.user-watermark.pos-5 { transform: rotate(0deg); }
.user-watermark.pos-5.w1 { top: 18%; left: 55%; }
.user-watermark.pos-5.w2 { top: 65%; right: 25%; }
.user-watermark.pos-5.w3 { bottom: 30%; left: 15%; }
.user-watermark.pos-5.w4 { top: 45%; left: 85%; }
.user-watermark.pos-5.w5 { top: 80%; right: 50%; }
.user-watermark.pos-5.w6 { top: 30%; left: 8%; }

.user-watermark.pos-6 { transform: rotate(-45deg); }
.user-watermark.pos-6.w1 { top: 22%; right: 30%; }
.user-watermark.pos-6.w2 { bottom: 40%; left: 45%; }
.user-watermark.pos-6.w3 { top: 70%; left: 15%; }
.user-watermark.pos-6.w4 { top: 50%; right: 8%; }
.user-watermark.pos-6.w5 { bottom: 10%; right: 70%; }
.user-watermark.pos-6.w6 { top: 15%; left: 75%; }

.user-watermark.pos-7 { transform: rotate(45deg); }
.user-watermark.pos-7.w1 { top: 28%; left: 20%; }
.user-watermark.pos-7.w2 { bottom: 25%; right: 35%; }
.user-watermark.pos-7.w3 { top: 75%; right: 10%; }
.user-watermark.pos-7.w4 { top: 10%; left: 85%; }
.user-watermark.pos-7.w5 { bottom: 50%; left: 60%; }
.user-watermark.pos-7.w6 { top: 55%; right: 55%; }

/* Ensure content stays above watermarks */
.question-container {
    position: relative;
    z-index: 2;
}

/* Images dans les questions */
.question-image,
.answer-image,
.correction-image {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 10px 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    display: block;
}

.answer-image {
    max-width: 150px;
    max-height: 100px;
    object-fit: contain;
    margin: 5px auto;
}

.question-image {
    max-height: 300px;
    margin: 15px auto;
}

.correction-image {
    max-height: 250px;
    margin: 15px auto;
}

/* Preview d'images dans l'admin */
.image-preview {
    margin: 10px 0;
    padding: 10px;
    border: 1px dashed #ccc;
    border-radius: 4px;
    min-height: 40px;
    background: #f9f9f9;
}

.image-preview img {
    display: block;
    margin: 0 auto 10px auto;
    border-radius: 4px;
}

.image-preview .btn {
    padding: 2px 8px;
    font-size: 12px;
}

.uploading {
    text-align: center;
    color: #666;
    font-style: italic;
}

/* Résultats de session */
.session-results {
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem;
}

.results-header {
    text-align: center;
    margin-bottom: 3rem;
}

.results-header h2 {
    color: var(--accent);
    margin-bottom: 1rem;
}

.results-score {
    font-size: 4rem;
    font-weight: bold;
    width: 200px;
    height: 200px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    margin: 1rem auto;
}

.results-score.good {
    background: #28a745; /* Green for >80% */
}

.results-score.average {
    background: #ff8c00; /* Orange for 50-80% */
}

.results-score.poor {
    background: #dc3545; /* Red for <50% */
}

/* Statistiques */
.results-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1.5rem;
    margin-bottom: 3rem;
}

.stat-card {
    background: white;
    padding: 1.5rem;
    border-radius: 12px;
    text-align: center;
    border: 1px solid #e9ecef;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.stat-number {
    font-size: 2rem;
    font-weight: bold;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.stat-label {
    font-size: 0.9rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Résumé des questions */
.questions-summary {
    background: white;
    border-radius: 12px;
    border: 1px solid #e9ecef;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.question-summary-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #e9ecef;
    cursor: pointer;
    transition: background 0.2s ease;
}

.question-summary-item:hover {
    background: #f8f9fa;
}

.question-summary-item:last-child {
    border-bottom: none;
}

.question-summary-item.correct {
    border-left: 4px solid #27ae60;
}

.question-summary-item.incorrect {
    border-left: 4px solid #e74c3c;
}

.question-summary-title {
    flex: 1;
    font-weight: 500;
    color: var(--text);
}

.question-summary-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.result-icon {
    font-size: 1.2rem;
    font-weight: bold;
}

.question-summary-item.correct .result-icon {
    color: #27ae60;
}

.question-summary-item.incorrect .result-icon {
    color: #e74c3c;
}

.time-spent {
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    color: var(--muted);
    background: #f8f9fa;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
}

/* Actions de résultats */
.results-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 2rem;
}

.results-actions .btn {
    padding: 0.8rem 1.5rem;
    font-weight: 600;
}

/* Messages d'erreur */
.error-message {
    text-align: center;
    padding: 3rem 2rem;
    background: #f8d7da;
    border: 2px solid #f5c6cb;
    border-radius: 12px;
    color: #721c24;
}

.error-message h3 {
    color: #721c24;
    margin-bottom: 1rem;
}

/* Contrôles de question centrés */
.question-controls {
    text-align: center;
    margin: 2rem 0;
    padding: 1rem 0;
}

/* Bouton suivant centré */
.btn-next {
    padding: 1rem 2rem;
    font-size: 1.1rem;
    font-weight: 600;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border: none;
    border-radius: 8px;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.3);
    min-width: 200px;
}

.btn-next:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(52, 152, 219, 0.4);
}

.btn-next:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    background: #95a5a6;
}

/* Report problem button */
.btn-report {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    font-weight: 400;
    background: #95a5a6;
    border: none;
    border-radius: 6px;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
    margin-top: 1rem;
}

.btn-report:hover {
    background: #7f8c8d;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

/* Modal overlay */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal .modal-content {
    position: relative;
    animation: modalSlideIn 0.3s ease-out;
}

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

/* Compatibilité avec l'ancien bouton fixe pour les résultats */
#nextBtn:not(.btn-next) {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    padding: 1rem 2rem;
    font-size: 1.1rem;
    font-weight: 600;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border: none;
    border-radius: 50px;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.3);
    z-index: 100;
}

#nextBtn:not(.btn-next):hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(52, 152, 219, 0.4);
}

#nextBtn:not(.btn-next):disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Modal de détail des questions */
.question-detail-modal {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.modal-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 1.5rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.4rem;
}

.modal-header .btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.modal-header .btn:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
}

.question-detail-content {
    padding: 2rem;
}

/* Badges de résultat */
.question-result-badge {
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
}

.question-result-badge.correct {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.question-result-badge.incorrect {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.question-time-spent {
    padding: 0.4rem 0.8rem;
    background: #f8f9fa;
    border-radius: 20px;
    font-size: 0.9rem;
    font-family: 'Courier New', monospace;
    color: var(--muted);
}

/* Responsivité */
@media (max-width: 768px) {
    .question-container {
        padding: 1rem;
    }

    .question-header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    .question-meta {
        justify-content: center;
    }

    .progress-bar {
        width: 150px;
    }

    .answers-grid {
        grid-template-columns: 1fr;
        grid-template-rows: auto;
        gap: 1rem;
    }

    .answer-card {
        min-height: 100px;
        padding: 1rem;
    }

    .results-stats {
        grid-template-columns: repeat(2, 1fr);
    }

    .results-actions {
        flex-direction: column;
    }

    .results-actions .btn {
        width: 100%;
    }

    .btn-next {
        width: 100%;
        margin: 2rem 0;
        min-width: auto;
    }

    .question-controls {
        margin: 1.5rem 0;
        padding: 0.5rem 0;
    }

    .question-top-controls {
        margin-bottom: 1rem;
    }

    .btn-back-question {
        padding: 0.5rem 1rem;
        font-size: 0.8rem;
    }

    #nextBtn:not(.btn-next) {
        position: static;
        width: 100%;
        margin: 2rem 0;
        border-radius: 8px;
    }

    /* Modal responsive */
    .modal-header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
        padding: 1rem;
    }

    .question-detail-content {
        padding: 1rem;
    }

    .question-result-badge,
    .question-time-spent {
        font-size: 0.8rem;
        padding: 0.3rem 0.6rem;
    }
}

@media (max-width: 480px) {
    body {
        padding: 0.5rem;
        font-size: 16px;
    }

    .wrapper {
        padding: 1rem;
        border-radius: 8px;
    }

    h1 {
        font-size: 1.5rem;
    }

    h2 {
        font-size: 1.3rem;
    }

    h3 {
        font-size: 1.1rem;
    }

    .question-title {
        font-size: 1.3rem;
    }

    .question-enonce {
        padding: 1rem;
        font-size: 1rem;
        line-height: 1.6;
    }

    /* Ensure MathJax renders at readable size */
    .question-enonce mjx-container,
    .answer-content mjx-container,
    .correction-zone mjx-container {
        font-size: 1.1em !important;
    }

    .answer-card {
        padding: 1rem;
        min-height: 80px;
    }

    .answer-content {
        font-size: 1rem;
        line-height: 1.5;
    }

    .answer-letter {
        width: 28px;
        height: 28px;
        font-size: 1rem;
    }

    .answer-indicator {
        font-size: 1.3rem;
    }

    .results-score {
        font-size: 2.5rem;
        width: 120px;
        height: 120px;
    }

    .results-stats {
        grid-template-columns: 1fr;
    }

    .btn {
        padding: 0.9rem 1.2rem;
        font-size: 1rem;
        width: 100%;
    }

    /* Ensure all inputs are 16px to prevent iOS zoom */
    input, select, textarea {
        font-size: 16px;
    }
}