/* ===== CONTAINER PRINCIPAL QCM ===== */
.qcm-container {
    font-family: 'Tahoma', Arial, sans-serif;
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
    background-color: #ffffff;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 217, 255, 0.12);
    border: 1px solid rgba(0, 217, 255, 0.25);
    position: relative;
}

/* Container des options QCM */
.qcm-options-container {
    display: grid;
    gap: 15px;
    margin: 20px 0;
}

/* ===== STYLES DES OPTIONS ===== */
.interactif-option {
    display: flex;
    align-items: center;
    padding: 15px 20px;
    background: linear-gradient(135deg, #ffffff 0%, #f8fcff 100%);
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 15px;
    font-weight: 500;
    color: #1e293b;
    position: relative;
    overflow: hidden;
    user-select: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    min-height: 60px;
}

/* Label conteneur */
.option-label {
    display: flex;
    align-items: center;
    width: 100%;
    cursor: pointer;
    gap: 12px;
    position: relative;
}

/* ===== INPUTS CHECKBOX ET RADIO ===== */
.option-input[type="checkbox"],
.option-input[type="radio"] {
    position: relative;
    width: 20px;
    height: 20px;
    cursor: pointer;
    margin: 0;
    flex-shrink: 0;
    accent-color: #00d9ff;
    transform: scale(1.1);
    transition: all 0.3s ease;
}

.option-input[type="checkbox"]:focus,
.option-input[type="radio"]:focus {
    outline: 3px solid rgba(0, 217, 255, 0.4);
    outline-offset: 2px;
    box-shadow: 0 0 0 6px rgba(0, 217, 255, 0.15);
}

/* ===== CUSTOM CHECKBOX/RADIO STYLES ===== */
.custom-checkbox,
.custom-radio {
    width: 20px;
    height: 20px;
    border: 2px solid #cbd5e1;
    background: linear-gradient(135deg, #ffffff 0%, #f8fcff 100%);
    cursor: pointer;
    transition: all 0.3s ease;
    flex-shrink: 0;
    pointer-events: none;
    z-index: 1;
}

.custom-checkbox {
    border-radius: 5px;
}

.custom-radio {
    border-radius: 50%;
}

/* États des custom inputs */
.custom-checkbox::after,
.custom-radio::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    transition: transform 0.2s ease;
}

.custom-checkbox::after {
    width: 6px;
    height: 10px;
    border: 2px solid #ffffff;
    border-top: none;
    border-left: none;
    transform: translate(-50%, -60%) rotate(45deg) scale(0);
}

.custom-radio::after {
    width: 8px;
    height: 8px;
    background: #ffffff;
    border-radius: 50%;
}

/* ===== TEXTE DES OPTIONS ===== */
.option-text {
    flex-grow: 1;
    color: #334155;
    line-height: 1.5;
    font-weight: 500;
    text-align: inherit;
    word-wrap: break-word;
    hyphens: auto;
}

/* ===== ÉTATS HOVER (Desktop uniquement) ===== */
@media (hover: hover) and (pointer: fine) {
    .interactif-option:hover {
        border-color: #00d9ff;
        transform: translateY(-2px);
        box-shadow: 0 8px 25px rgba(0, 217, 255, 0.2);
        background: linear-gradient(135deg, #ffffff 0%, #e0f7ff 100%);
    }

    .interactif-option:hover .custom-checkbox,
    .interactif-option:hover .custom-radio {
        border-color: #00d9ff;
        box-shadow: 0 0 0 4px rgba(0, 217, 255, 0.15);
        background: linear-gradient(135deg, #ffffff 0%, #cff4ff 100%);
    }

    .interactif-option:hover .option-input {
        filter: drop-shadow(0 2px 8px rgba(0, 217, 255, 0.3));
    }

    .interactif-option:hover .option-text {
        color: #0f172a;
    }

    /* Effet de brillance sur hover */
    .interactif-option::before {
        content: "";
        position: absolute;
        top: 0;
        left: -100%;
        width: 100%;
        height: 100%;
        background: linear-gradient(90deg, transparent, rgba(0, 217, 255, 0.2), transparent);
        transition: all 0.8s ease;
        pointer-events: none;
        z-index: 0;
    }

    .interactif-option:hover::before {
        left: 100%;
    }
}

/* ===== ÉTAT SÉLECTIONNÉ ===== */
.interactif-option.interactif-selected {
    background: linear-gradient(135deg, rgba(0, 217, 255, 0.08) 0%, rgba(0, 217, 255, 0.15) 100%);
    border-color: #00d9ff;
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(0, 217, 255, 0.25);
}

.interactif-option.interactif-selected .custom-checkbox,
.interactif-option.interactif-selected .custom-radio {
    background: linear-gradient(135deg, #00d9ff 0%, #33e3ff 100%);
    border-color: #00d9ff;
    box-shadow: 0 0 0 4px rgba(0, 217, 255, 0.2);
}

.interactif-option.interactif-selected .custom-checkbox::after {
    transform: translate(-50%, -60%) rotate(45deg) scale(1);
}

.interactif-option.interactif-selected .custom-radio::after {
    transform: translate(-50%, -50%) scale(1);
}

.interactif-option.interactif-selected .option-text {
    color: #0c4a6e;
    font-weight: 600;
}

/* ===== ÉTATS CORRECT/INCORRECT ===== */
.interactif-option.interactif-correct {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.08) 0%, rgba(34, 197, 94, 0.15) 100%);
    border-color: #22c55e;
    color: #15803d;
    animation: correctPulse 0.6s ease-out;
}

.interactif-option.interactif-correct .custom-checkbox,
.interactif-option.interactif-correct .custom-radio {
    background: linear-gradient(135deg, #22c55e 0%, #4ade80 100%);
    border-color: #22c55e;
}

.interactif-option.interactif-correct .option-text {
    color: #15803d;
    font-weight: 600;
}

.interactif-option.interactif-incorrect {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.08) 0%, rgba(239, 68, 68, 0.15) 100%);
    border-color: #ef4444;
    color: #991b1b;
    animation: incorrectShake 0.6s ease-in-out;
}

.interactif-option.interactif-incorrect .custom-checkbox,
.interactif-option.interactif-incorrect .custom-radio {
    background: linear-gradient(135deg, #ef4444 0%, #f87171 100%);
    border-color: #ef4444;
}

.interactif-option.interactif-incorrect .option-text {
    color: #991b1b;
    font-weight: 600;
}

/* ===== SUPPORT RTL ===== */
[dir="rtl"] .qcm-container,
.qcm-container[style*="direction: rtl"] {
    direction: rtl;
    text-align: right;
}

[dir="rtl"] .interactif-option,
.interactif-option[style*="direction: rtl"] {
    direction: rtl;
    text-align: right;
}

[dir="rtl"] .option-label,
.option-label[dir="rtl"] {
    direction: rtl;
    justify-content: flex-start;
}

[dir="rtl"] .option-text,
.option-text[dir="rtl"] {
    text-align: right;
    direction: rtl;
}

/* Positionnement des inputs en RTL */
.custom-checkbox.rtl,
.custom-radio.rtl {
    right: 0;
    left: auto;
}

.option-input[style*="margin-left: 8px"] {
    margin-left: 8px;
    margin-right: 0;
}

/* ===== ÉTATS DISABLED ===== */
.interactif-option input:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

.interactif-option:has(input:disabled) {
    cursor: not-allowed;
    opacity: 0.7;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
}

/* ===== ANIMATIONS ===== */
@keyframes correctPulse {
    0% { 
        transform: scale(1); 
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.4); 
    }
    50% { 
        transform: scale(1.02); 
        box-shadow: 0 0 0 12px rgba(34, 197, 94, 0.1); 
    }
    100% { 
        transform: scale(1); 
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); 
    }
}

@keyframes incorrectShake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-4px); }
    20%, 40%, 60%, 80% { transform: translateX(4px); }
}

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

/* Animation d'apparition progressive */
.interactif-option {
    animation: fadeInUp 0.5s ease-out both;
}

.interactif-option:nth-child(1) { animation-delay: 0.1s; }
.interactif-option:nth-child(2) { animation-delay: 0.2s; }
.interactif-option:nth-child(3) { animation-delay: 0.3s; }
.interactif-option:nth-child(4) { animation-delay: 0.4s; }
.interactif-option:nth-child(5) { animation-delay: 0.5s; }

/* S'assurer que le contenu reste au-dessus */
.option-label {
    position: relative;
    z-index: 2;
}

/* ===== SUPPORT POUR ANCIENS NAVIGATEURS ===== */
@supports not (accent-color: #00d9ff) {
    .option-input[type="checkbox"],
    .option-input[type="radio"] {
        opacity: 0;
        position: absolute;
        pointer-events: none;
    }
    
    .custom-checkbox,
    .custom-radio {
        position: relative;
        pointer-events: all;
        display: block;
    }
}

/* ===== RESPONSIVE DESIGN OPTIMISÉ ===== */

/* Tablettes et petits écrans */
@media (max-width: 768px) {
    .qcm-container {
        padding: 16px;
        margin: 10px;
        border-radius: 10px;
        max-width: calc(100vw - 20px);
    }
    
    .qcm-options-container {
        gap: 12px;
        margin: 16px 0;
    }
    
    .interactif-option {
        padding: 14px 16px;
        font-size: 14px;
        gap: 10px;
        min-height: 56px;
        border-radius: 8px;
    }
    
    .option-input[type="checkbox"],
    .option-input[type="radio"],
    .custom-checkbox,
    .custom-radio {
        width: 20px;
        height: 20px;
    }
    
    .option-text {
        font-size: 14px;
        line-height: 1.4;
    }
    
    /* Touch targets plus larges */
    .interactif-option {
        -webkit-tap-highlight-color: rgba(0, 217, 255, 0.1);
        touch-action: manipulation;
    }
}

/* Smartphones */
@media (max-width: 480px) {
    .qcm-container {
        padding: 12px;
        margin: 8px;
        border-radius: 8px;
        max-width: calc(100vw - 16px);
    }
    
    .qcm-options-container {
        gap: 10px;
        margin: 12px 0;
    }
    
    .interactif-option {
        padding: 12px 14px;
        font-size: 13px;
        gap: 8px;
        min-height: 52px;
        border-radius: 6px;
        align-items: flex-start;
    }
    
    .option-input[type="checkbox"],
    .option-input[type="radio"],
    .custom-checkbox,
    .custom-radio {
        width: 18px;
        height: 18px;
        margin-top: 2px;
        flex-shrink: 0;
    }
    
    .custom-checkbox::after {
        width: 5px;
        height: 8px;
    }
    
    .custom-radio::after {
        width: 6px;
        height: 6px;
    }
    
    .option-text {
        font-size: 13px;
        line-height: 1.3;
        flex: 1;
        word-break: break-word;
    }
}

/* Très petits écrans */
@media (max-width: 360px) {
    .qcm-container {
        padding: 10px;
        margin: 5px;
    }
    
    .interactif-option {
        padding: 10px 12px;
        font-size: 12px;
        min-height: 48px;
    }
    
    .option-text {
        font-size: 12px;
        line-height: 1.2;
    }
    
    .option-input[type="checkbox"],
    .option-input[type="radio"],
    .custom-checkbox,
    .custom-radio {
        width: 16px;
        height: 16px;
    }
    
    .custom-checkbox::after {
        width: 4px;
        height: 7px;
    }
    
    .custom-radio::after {
        width: 5px;
        height: 5px;
    }
}

/* ===== INDICATEUR DE SÉLECTION MULTIPLE ===== */
.qcm-container[data-multiple="true"] .interactif-option::after {
    content: "✓";
    position: absolute;
    top: 8px;
    right: 8px;
    color: #00d9ff;
    font-weight: bold;
    font-size: 12px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.qcm-container[data-multiple="true"] .interactif-option.interactif-selected::after {
    opacity: 1;
}

[dir="rtl"] .qcm-container[data-multiple="true"] .interactif-option::after {
    right: auto;
    left: 8px;
}

/* Mobile adjustments pour l'indicateur */
@media (max-width: 480px) {
    .qcm-container[data-multiple="true"] .interactif-option::after {
        top: 6px;
        right: 6px;
        font-size: 11px;
    }
    
    [dir="rtl"] .qcm-container[data-multiple="true"] .interactif-option::after {
        right: auto;
        left: 6px;
    }
}

/* ===== THÉORÈMES - STYLES MOBILE OPTIMISÉS ===== */

.qcm-theorem-container {
    margin: 20px 0;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.12);
    border: 1px solid rgba(99, 102, 241, 0.25);
    background: linear-gradient(135deg, #faf5ff 0%, #f3e8ff 100%);
    transition: all 0.3s ease;
}

.theorem-button {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 16px 22px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.12) 0%, rgba(129, 140, 248, 0.08) 100%);
    border: none;
    border-radius: 12px 12px 0 0;
    color: #4c1d95;
    font-weight: 600;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: left;
    position: relative;
    overflow: hidden;
    -webkit-tap-highlight-color: rgba(99, 102, 241, 0.1);
    touch-action: manipulation;
}

.theorem-button svg {
    width: 20px;
    height: 20px;
    transition: transform 0.3s ease;
    flex-shrink: 0;
    color: #6366f1;
}

.theorem-button[aria-expanded="true"] svg {
    transform: rotate(180deg);
}

.theorem-content {
    padding: 0;
    max-height: 0;
    overflow: hidden;
    background: linear-gradient(135deg, #ffffff 0%, #fefbff 100%);
    border-radius: 0 0 12px 12px;
    transition: all 0.4s ease;
    font-size: 14px;
    line-height: 1.6;
    color: #475569;
}

.theorem-content.show {
    padding: 22px;
    max-height: 500px;
    overflow-y: auto;
    border-top: 1px solid rgba(99, 102, 241, 0.2);
}

.theorem-content strong {
    color: #4c1d95;
    font-weight: 600;
    display: block;
    margin-bottom: 12px;
    font-size: 15px;
    position: relative;
    padding-left: 12px;
}

.theorem-content strong::before {
    content: "";
    position: absolute;
    left: 0;
    top: 2px;
    width: 3px;
    height: 16px;
    background: linear-gradient(180deg, #6366f1 0%, #8b5cf6 100%);
    border-radius: 2px;
}

.theorem-content p {
    margin: 0 0 14px 0;
    color: #334155;
}

.theorem-content p:last-child {
    margin-bottom: 0;
}

/* ===== RESPONSIVE DESIGN POUR THÉORÈMES ===== */
@media (max-width: 768px) {
    .qcm-theorem-container {
        margin: 16px 0;
        border-radius: 10px;
    }
    
    .theorem-button {
        padding: 14px 18px;
        font-size: 15px;
        border-radius: 10px 10px 0 0;
        gap: 12px;
    }
    
    .theorem-button svg {
        width: 18px;
        height: 18px;
    }
    
    .theorem-content.show {
        padding: 18px;
        max-height: 400px;
    }
    
    .theorem-content strong {
        font-size: 14px;
        padding-left: 10px;
    }
    
    .theorem-content strong::before {
        width: 2px;
        height: 14px;
    }
    
    .theorem-content {
        font-size: 13px;
        line-height: 1.5;
    }
}

@media (max-width: 480px) {
    .qcm-theorem-container {
        margin: 12px 0;
        border-radius: 8px;
    }
    
    .theorem-button {
        padding: 12px 16px;
        font-size: 14px;
        border-radius: 8px 8px 0 0;
        gap: 10px;
        min-height: 48px;
    }
    
    .theorem-button svg {
        width: 16px;
        height: 16px;
    }
    
    .theorem-content.show {
        padding: 16px;
        max-height: 300px;
    }
    
    .theorem-content strong {
        font-size: 13px;
        padding-left: 8px;
        margin-bottom: 10px;
    }
    
    .theorem-content strong::before {
        width: 2px;
        height: 12px;
    }
    
    .theorem-content {
        font-size: 12px;
        line-height: 1.4;
    }
    
    .theorem-content p {
        margin-bottom: 12px;
    }
    
    .theorem-content ul, 
    .theorem-content ol {
        padding-left: 20px;
        margin: 12px 0;
    }
    
    [dir="rtl"] .theorem-content ul,
    [dir="rtl"] .theorem-content ol {
        padding-right: 20px;
        padding-left: 0;
    }
}

@media (max-width: 360px) {
    .theorem-button {
        padding: 10px 14px;
        font-size: 13px;
    }
    
    .theorem-content.show {
        padding: 14px;
    }
    
    .theorem-content {
        font-size: 11px;
    }
}

/* ===== SUPPORT RTL POUR THÉORÈMES ===== */
[dir="rtl"] .theorem-button,
.theorem-button[dir="rtl"] {
    text-align: right;
    direction: rtl;
}

[dir="rtl"] .theorem-content,
.theorem-content[dir="rtl"] {
    direction: rtl;
    text-align: right;
}

[dir="rtl"] .theorem-content strong,
.theorem-content[dir="rtl"] strong {
    padding-left: 0;
    padding-right: 12px;
}

[dir="rtl"] .theorem-content strong::before,
.theorem-content[dir="rtl"] strong::before {
    left: auto;
    right: 0;
}

[dir="rtl"] .theorem-button svg,
.theorem-button[dir="rtl"] svg {
    transform: scaleX(-1);
}

[dir="rtl"] .theorem-button[aria-expanded="true"] svg,
.theorem-button[dir="rtl"][aria-expanded="true"] svg {
    transform: scaleX(-1) rotate(180deg);
}

/* Mobile RTL adjustments */
@media (max-width: 480px) {
    [dir="rtl"] .theorem-content strong,
    .theorem-content[dir="rtl"] strong {
        padding-right: 8px;
    }
}

/* ===== ACCESSIBILITÉ ===== */
@media (prefers-reduced-motion: reduce) {
    .interactif-option,
    .custom-checkbox,
    .custom-radio,
    .theorem-content,
    .theorem-button svg {
        animation: none;
        transition: none;
    }
}

.theorem-button:focus:not(:focus-visible) {
    outline: none;
}

.theorem-button:focus-visible {
    outline: 3px solid rgba(99, 102, 241, 0.5);
    outline-offset: -2px;
}

/* Focus trap pour navigation clavier */
.interactif-option:focus-within {
    outline: 3px solid rgba(0, 217, 255, 0.5);
    outline-offset: 2px;
}

/* Amélioration de la lisibilité en arabe */
.option-text[dir="rtl"],
.theorem-content[dir="rtl"] {
    font-family: 'Tahoma', 'Arial Unicode MS', Arial, sans-serif;
    font-weight: 500;
    line-height: 1.6;
}

/* ===== AMÉLIORATIONS VISUELLES ===== */
.qcm-container::before {
    content: "";
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(45deg, #00d9ff, #33e3ff, #00d9ff);
    border-radius: 14px;
    z-index: -1;
    opacity: 0;
    transition: opacity 0.3s ease;
}

/* Style d'impression */
@media print {
    .qcm-container,
    .qcm-theorem-container {
        box-shadow: none;
        border: 2px solid #00d9ff;
        page-break-inside: avoid;
        margin: 10px 0;
    }
    
    .theorem-button {
        display: none;
    }
    
    .theorem-content {
        max-height: none;
        display: block;
        padding: 16px;
        border-top: 2px solid #6366f1;
        background: #ffffff;
    }
    
    .interactif-option {
        transform: none;
        box-shadow: none;
        border: 1px solid #00d9ff;
    }
}