/* ===========================
   BASE & RESET
   =========================== */
* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

/* ===========================
   CONTENEUR FORMULAIRE
   =========================== */
.ri-form-wrap {
    max-width: 900px;
    margin: 40px auto;
    padding: 0;
    background: transparent; /* 🔥 MODIFIÉ de #fff à transparent */
    border-radius: 0; /* 🔥 MODIFIÉ de 12px à 0 */
    box-shadow: none; /* 🔥 SUPPRIMÉ l'ombre */
    overflow: visible; /* 🔥 MODIFIÉ de hidden à visible */
}

.ri-form-wrap h2 {
    margin: 0 0 24px 0; /* 🔥 AJOUTÉ margin-bottom 24px */
    padding: 24px 30px;
    font-size: 1.5rem;
    color: #fff;
    background: #00b0ed;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    border-radius: 12px; /* 🔥 MODIFIÉ : 4 coins arrondis au lieu de seulement top */
    box-shadow: 0 2px 12px rgba(0, 176, 237, 0.3); /* 🔥 AJOUTÉ ombre sur header */
}

.ri-form-wrap form {
    padding: 30px;
    background: transparent; /* 🔥 AJOUTÉ pour clarté */
}

/* ===========================
   BOUTON DASHBOARD (Header)
   =========================== */
.ri-dashboard-btn {
    background: rgba(255,255,255,0.2);
    backdrop-filter: blur(10px);
    color: #fff;
    padding: 8px 16px;
    border-radius: 8px;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.3s;
    border: 1px solid rgba(255,255,255,0.3);
}

.ri-dashboard-btn:hover {
    background: rgba(255,255,255,0.3);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

/* ===========================
   CADRES DE SECTION
   =========================== */
.ri-doc-cadre {
    background: #ccc;
    border: 1px solid #e9ecef;
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 24px;
    transition: all 0.3s;
}

.ri-doc-cadre:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

/* ===========================
   LABELS & INPUTS
   =========================== */
.ri-form-wrap label {
    display: block;
    margin-bottom: 16px;
    font-weight: 600;
    font-size: 0.9rem;
    color: #495057;
}

.ri-form-wrap input,
.ri-form-wrap select,
.ri-form-wrap textarea {
    width: 100%;
    padding: 12px 16px;
    margin-top: 6px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 0.95rem;
    background: #fff;
    transition: all 0.3s;
    font-family: inherit;
}

.ri-form-wrap input:focus,
.ri-form-wrap select:focus,
.ri-form-wrap textarea:focus {
    outline: none;
    border-color: #00b0ed;
    box-shadow: 0 0 0 3px rgba(0, 176, 237, 0.1);
}

.ri-form-wrap input[readonly] {
    background: #e9ecef;
    color: #6c757d;
    cursor: not-allowed;
    border-color: #dee2e6;
}

.ri-form-wrap textarea {
    resize: vertical;
    min-height: 100px;
}

/* ===========================
   ROW (2 colonnes)
   =========================== */
.ri-row {
    display: flex;
    gap: 16px;
    margin-bottom: 0;
}

.ri-row label {
    flex: 1;
}

/* ===========================
   BOUTONS PRINCIPAUX
   =========================== */
.ri-form-wrap button {
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: 600;
    background: #00b0ed;
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 2px 8px rgba(0, 176, 237, 0.3);
}

.ri-form-wrap button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 176, 237, 0.4);
}

.ri-form-wrap button:active {
    transform: translateY(0);
}

/* Boutons secondaires (Précédent) */
#ri-prev-step2,
#ri-prev-step3 {
    background: #6c757d;
    box-shadow: 0 2px 8px rgba(108, 117, 125, 0.3);
}

#ri-prev-step2:hover,
#ri-prev-step3:hover {
    background: #5a6268;
    box-shadow: 0 4px 16px rgba(108, 117, 125, 0.4);
}

/* Bouton Sauvegarder */
#ri-save-step1,
#ri-save-step2 {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    box-shadow: 0 2px 8px rgba(17, 153, 142, 0.3);
}

#ri-save-step1:hover,
#ri-save-step2:hover {
    box-shadow: 0 4px 16px rgba(17, 153, 142, 0.4);
}

/* Bouton Clear signature */
#ri-clear-sign {
    background: #dc3545;
    box-shadow: 0 2px 8px rgba(220, 53, 69, 0.3);
    padding: 12px 20px;
}

#ri-clear-sign:hover {
    background: #c82333;
    box-shadow: 0 4px 16px rgba(220, 53, 69, 0.4);
}

/* ===========================
   ÉQUIPEMENTS (Boutons tags)
   =========================== */
.ri-equipements-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: center; /* 🔥 AJOUTÉ */
    gap: 10px;
    margin: 16px 0;
}

.equip-btn {
    padding: 10px 18px;
    border: 2px solid #e9ecef;
    border-radius: 24px;
    background: #fff;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    color: #495057;
    transition: all 0.3s;
    user-select: none;
}

.equip-btn:hover {
    border-color: #00b0ed;
    background: #f8f9ff;
    transform: translateY(-2px);
}

.equip-btn.selected {
    background: #00b0ed;
    color: #fff;
    border-color: #00b0ed;
    box-shadow: 0 2px 8px rgba(0, 176, 237, 0.3);
}

#equip-autre-input {
    flex: 1;
    min-width: 200px;
    margin-top: 0;
}

/* Tags sélectionnés */
#equipements-list {
    display: flex;
    flex-wrap: wrap;
    justify-content: center; /* 🔥 AJOUTÉ */
    gap: 8px;
    margin-top: 12px;
    min-height: 32px;
}

.equip-tag {
    display: inline-flex;
    align-items: center;
    padding: 6px 14px;
    background: #00b0ed;
    color: #fff;
    border-radius: 16px;
    font-size: 0.85rem;
    font-weight: 500;
    box-shadow: 0 2px 4px rgba(0, 176, 237, 0.2);
}

/* ===========================
   TABLEAU SITE INFO
   =========================== */
.site-info-wrapper {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 16px 0;
}

#site-info {
    width: 100%;
    min-width: 500px;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.75rem;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

#site-info thead {
    background: #00b0ed;
    color: #fff;
}

/* 🔥 SOLUTION : Plus de spécificité */
#site-info thead tr th {
    padding: 8px 6px !important;
    font-weight: 600 !important;
    font-size: 0.7rem !important;
    text-align: center !important; /* 🔥 FORCÉ */
    vertical-align: middle !important;
    border: none !important;
}

#site-info tbody tr td {
    padding: 8px 6px !important;
    text-align: center !important; /* 🔥 FORCÉ */
    vertical-align: middle !important;
    border: none !important;
    border-top: 1px solid #e9ecef !important;
    font-weight: 500 !important;
    font-size: 0.75rem !important;
}

/* ===========================
   SWITCH EXCLUSION
   =========================== */
.ri-switch-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 20px;
    background: #ffffff; /* 🔥 MODIFIÉ de #fff3cd à #fff */
    border: 2px solid #e9ecef; /* 🔥 MODIFIÉ de #ffc107 à #e9ecef */
    border-radius: 12px;
    margin: 20px 0;
    transition: all 0.3s;
}

.ri-switch-wrapper:has(input:checked) {
    background: #f8d7da; /* ✅ Rouge quand activé */
    border-color: #dc3545;
}

.ri-switch-labels {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.ri-switch-labels span {
    font-weight: 600;
    font-size: 0.95rem;
    color: #495057;
}

.ri-switch-note {
    font-size: 0.8rem;
    font-style: italic;
    color: #6c757d;
}

.switch {
    position: relative;
    display: inline-block;
    width: 56px;
    height: 30px;
    flex-shrink: 0;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .3s;
    border-radius: 30px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 22px;
    width: 22px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.switch input:checked + .slider {
    background-color: #dc3545;
}

.switch input:checked + .slider:before {
    transform: translateX(26px);
}

/* ===========================
   DROPZONE PHOTOS
   =========================== */
#ri-dropzone {
    border: 3px dashed #dee2e6;
    border-radius: 12px;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    background: #f8f9fa;
    transition: all 0.3s;
    color: #6c757d;
    font-weight: 500;
    margin: 16px 0;
}

#ri-dropzone:hover {
    border-color: #00b0ed;
    background: #f8f9ff;
    color: #00b0ed;
}

#ri-dropzone-previews {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 16px;
}

.ri-photo-preview {
    position: relative;
    width: 140px;
    height: 140px;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: all 0.3s;
}

.ri-photo-preview:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

.ri-photo-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ri-remove-photo {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    box-shadow: 0 2px 8px rgba(220, 53, 69, 0.4);
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ri-remove-photo:hover {
    background: #c82333;
    transform: scale(1.1);
}

/* ===========================
   SIGNATURE CANVAS
   =========================== */
canvas#ri-signature {
    display: block;
    width: 100% !important;
    height: 200px;
    border: 2px solid #e9ecef;
    background: #fff;
    border-radius: 12px;
    cursor: crosshair;
    margin-top: 8px;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.05);
}

/* ===========================
   RÉCAPITULATIF (Step 3)
   =========================== */
.ri-doc-cadre[style*="background:#f0f8ff"] {
    /*background: linear-gradient(135deg, #e3f2fd 0%, #f3e5f5 100%) !important;*/
    background: #ccc !important;
    border: 2px solid #00b0ed !important;
    padding: 20px !important; /* 🔥 RÉDUIT */
}

.ri-doc-cadre h3 {
    margin: 0 0 16px 0; /* 🔥 RÉDUIT de 20px à 16px */
    font-size: 1.1rem; /* 🔥 RÉDUIT de 1.3rem à 1.1rem */
    color: #1d3557;
    font-weight: 700;
}

.ri-doc-cadre table {
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    font-size: 0.85rem; /* 🔥 AJOUTÉ */
}

.ri-doc-cadre table td {
    padding: 10px 12px; /* 🔥 RÉDUIT de 8px à 10px vertical, augmenté horizontal */
    border-bottom: 1px solid #ddd;
    font-size: 0.85rem; /* 🔥 AJOUTÉ */
    line-height: 1.5; /* 🔥 AJOUTÉ pour aération */
}

.ri-doc-cadre table td:first-child {
    background: #f8f9fa;
    color: #495057;
    font-weight: 600;
    width: 180px; /* 🔥 AJOUTÉ pour largeur fixe label */
    font-size: 0.8rem; /* 🔥 AJOUTÉ - encore plus petit pour labels */
}

.ri-doc-cadre table td:last-child {
    text-align: left; /* 🔥 AJOUTÉ pour meilleure lecture */
}

.ri-doc-cadre table tr:last-child td {
    border-bottom: none; /* 🔥 AJOUTÉ - retire bordure dernière ligne */
}

/* Note en bas du récap */
.ri-doc-cadre p[style*="text-align:center"] {
    font-size: 0.8rem !important; /* 🔥 AJOUTÉ */
    margin-top: 12px !important; /* 🔥 RÉDUIT */
    padding-top: 12px; /* 🔥 AJOUTÉ */
    border-top: 1px solid #e9ecef; /* 🔥 AJOUTÉ */
}

/* ===========================
   MESSAGE SUCCESS/ERROR
   =========================== */
#ri-message {
    margin-top: 20px;
    padding: 16px 20px;
    border-radius: 8px;
    font-weight: 600;
    text-align: center;
}

/* Bouton PDF */
.ri-btn-pdf,
#ri-download-pdf-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    margin-top: 16px;
    background: linear-gradient(135deg, #ff416c 0%, #ff4b2b 100%);
    color: #fff;
    text-decoration: none;
    font-weight: 600;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(255, 65, 108, 0.3);
    transition: all 0.3s;
    font-size: 1rem;
}

.ri-btn-pdf:hover,
#ri-download-pdf-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 65, 108, 0.4);
    text-decoration: none;
    color: #fff;
}

.ri-btn-pdf::before {
    content: "📄";
    margin-right: 8px;
    font-size: 1.2rem;
}

/* ===========================
   RESPONSIVE
   =========================== */
@media (max-width: 768px) {
    .ri-form-wrap {
        margin: 20px;
        border-radius: 0; /* 🔥 AJUSTÉ */
    }

    .ri-form-wrap h2 {
        padding: 20px;
        font-size: 1.3rem;
        flex-direction: column;
        gap: 12px;
        text-align: center;
        border-radius: 12px; /* 🔥 MODIFIÉ : garde 4 coins arrondis sur mobile */
        margin-bottom: 20px; /* 🔥 AJOUTÉ */
    }

    .ri-form-wrap form {
        padding: 20px;
    }

    .ri-doc-cadre {
        padding: 16px;
    }

    .ri-row {
        flex-direction: column;
        gap: 0;
    }

    .equip-btn {
        flex: 1 1 calc(50% - 5px);
        min-width: 0;
    }

    #equip-autre-input {
        min-width: 100%;
    }

    .ri-switch-wrapper {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    #site-info {
        font-size: 0.7rem; /* 🔥 ENCORE PLUS PETIT sur mobile */
    }

    #site-info th,
    #site-info td {
        padding: 6px 4px; /* 🔥 AJUSTÉ */
    }

    .ri-photo-preview {
        width: calc(50% - 6px);
        height: 120px;
    }

    /* Récap plus compact sur mobile */
    .ri-doc-cadre table td {
        padding: 8px 10px; /* 🔥 AJOUTÉ */
        font-size: 0.8rem; /* 🔥 AJOUTÉ */
    }

    .ri-doc-cadre table td:first-child {
        font-size: 0.75rem; /* 🔥 AJOUTÉ */
    }
}

@media (max-width: 480px) {
    .ri-form-wrap {
        margin: 10px;
    }

    .ri-form-wrap h2 {
        font-size: 1.1rem;
        padding: 16px;
        margin-bottom: 16px; /* 🔥 AJOUTÉ */
    }

    .ri-form-wrap button {
        width: 100%;
        margin-bottom: 8px;
    }

    .equip-btn {
        flex: 1 1 100%;
    }

    .ri-photo-preview {
        width: 100%;
        height: 140px;
    }
}

/* ===========================
   FOOTER NAVIGATION (Steps)
   =========================== */
.ri-step-footer {
    background: #00b0ed;
    border-radius: 12px;
    padding: 20px 30px;
    margin-top: 24px;
    box-shadow: 0 2px 12px rgba(0, 176, 237, 0.3);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.ri-step-footer-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    flex: 1;
    align-items: center;
}

.ri-step-footer-links {
    display: flex;
    gap: 10px;
    align-items: center;
}

.ri-step-footer button,
.ri-step-footer .ri-dashboard-btn,
.ri-step-footer .ri-new-form-btn {
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    border: none;
    height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.ri-step-footer button {
    background: rgba(255,255,255,0.95);
    color: #00b0ed;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.ri-step-footer button:hover {
    background: #fff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.ri-step-footer .ri-new-form-btn {
    background: rgba(255,255,255,0.2);
    backdrop-filter: blur(10px);
    color: #fff;
    text-decoration: none;
    border: 1px solid rgba(255,255,255,0.3);
}

.ri-step-footer .ri-new-form-btn:hover {
    background: rgba(255,255,255,0.3);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.ri-step-footer .ri-dashboard-btn {
    background: rgba(255,255,255,0.2);
    backdrop-filter: blur(10px);
    color: #fff;
    text-decoration: none;
    border: 1px solid rgba(255,255,255,0.3);
}

.ri-step-footer .ri-dashboard-btn:hover {
    background: rgba(255,255,255,0.3);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

/* Boutons spécifiques dans le footer */
.ri-step-footer #ri-prev-step2,
.ri-step-footer #ri-prev-step3 {
    background: rgba(255, 255, 255, 0.95);
    color: #00b0ed;
    border: 1px solid rgba(255,255,255,0.3);
}

.ri-step-footer #ri-prev-step2:hover,
.ri-step-footer #ri-prev-step3:hover {
    background: rgba(255, 255, 255, 0.95);
}

.ri-step-footer #ri-save-step1,
.ri-step-footer #ri-save-step2 {
    background: #663399;
    color: #fff;
}

.ri-step-footer #ri-save-step1:hover,
.ri-step-footer #ri-save-step2:hover {
    background: #9966ff;
}

.ri-step-footer #ri-clear-sign {
    background: rgba(220, 53, 69, 0.95);
    color: #fff;
}

.ri-step-footer #ri-clear-sign:hover {
    background: rgba(220, 53, 69, 1);
}

/* ===========================
   ADMIN DASHBOARD BUTTONS
   =========================== */
.ri-dashboard-buttons {
    text-align: center;
    margin: 0;
    padding: 0;
}

.ri-dashboard-buttons button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 8px !important;
    padding: 12px 24px !important;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: 8px;
    border: none;
    background: #00b0ed;
    color: #fff;
    transition: all 0.3s;
    box-shadow: 0 2px 8px rgba(0, 176, 237, 0.3);
}

.ri-dashboard-buttons button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 176, 237, 0.4);
}

/* ===========================
   ADMIN SITES TABLE
   =========================== */
#ri-sites-table th,
#ri-sites-table td {
    text-align: center;
    padding: 12px 8px;
}

#ri-sites-table th:nth-child(2),
#ri-sites-table td:nth-child(2) {
    text-align: left;
}

/* ========================================
 * BOUTON CORRECTION ON/OFF
 * ======================================== */
.ri-correction-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ri-correction-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
}

.ri-correction-btn:active {
    transform: translateY(0);
}

/* 🔴 État OFF (GRIS) */
.ri-correction-btn[data-enabled="false"] {
    background: #333;
}

.ri-correction-btn[data-enabled="false"]:hover {
    background: #5a6268;
}

/* 🟢 État ON (VERT) */
.ri-correction-btn[data-enabled="true"] {
    background: #0F3D19;
}

.ri-correction-btn[data-enabled="true"]:hover {
    background: #218838;
}

.ri-correction-icon {
    font-size: 16px;
    line-height: 1;
}

.ri-correction-text {
    font-size: 13px;
}

/* Animation rotation icône lors du clic */
.ri-correction-btn.toggling .ri-correction-icon {
    animation: spin 0.5s ease;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ========================================
 * INDICATEUR D'ÉTAT DISCRET
 * ======================================== */
.ri-correction-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    color: #666;
    transition: all 0.3s ease;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #6c757d;
    transition: all 0.3s ease;
}

.status-text {
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* 🔵 États du point coloré */
.ri-correction-status.idle .status-dot {
    background: #6c757d; /* Gris */
}

.ri-correction-status.waiting .status-dot {
    background: #ffc107; /* Jaune */
    animation: pulse-dot 1.5s infinite;
}

.ri-correction-status.correcting .status-dot {
    background: #17a2b8; /* Bleu */
    animation: pulse-dot 0.8s infinite;
}

.ri-correction-status.corrected .status-dot {
    background: #28a745; /* Vert */
}

.ri-correction-status.no-changes .status-dot {
    background: #6c757d; /* Gris */
}

@keyframes pulse-dot {
    0%, 100% { 
        opacity: 1; 
        transform: scale(1); 
    }
    50% { 
        opacity: 0.5; 
        transform: scale(1.3); 
    }
}

/* Cacher l'indicateur si correction désactivée */
.ri-correction-status.hidden {
    opacity: 0;
    pointer-events: none;
    display: none;
}

/* Animation de correction appliquée sur textarea */
.text-corrected {
    animation: highlight-correction 1s ease;
}

@keyframes highlight-correction {
    0%, 100% { background-color: transparent; }
    50% { background-color: #d4edda; }
}

.text-correcting {
    opacity: 0.7;
    transition: opacity 0.3s ease;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.text-correcting {
    opacity: 0.6;
    transition: opacity 0.3s;
}

.text-corrected {
    animation: flashGreen 1s;
}

@keyframes flashGreen {
    0%, 100% { background-color: transparent; }
    50% { background-color: #d4edda; }
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.text-correcting {
    opacity: 0.6;
    border: 2px solid #17a2b8;
    transition: all 0.3s;
}

.text-corrected {
    animation: flashGreen 1s;
}

@keyframes flashGreen {
    0%, 100% { 
        background-color: transparent;
        border-color: #ccc;
    }
    50% { 
        background-color: #d4edda;
        border-color: #28a745;
    }
}

/* ========================================
 * STYLES CSS (à ajouter dans votre CSS)
 * ======================================== */
const styles = `
/* Modal */
.ri-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
}

.ri-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

.ri-modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    width: 90%;
    max-width: 700px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        transform: translate(-50%, -60%);
        opacity: 0;
    }
    to {
        transform: translate(-50%, -50%);
        opacity: 1;
    }
}

.ri-modal-header {
    padding: 20px 25px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ri-modal-header h3 {
    margin: 0;
    font-size: 18px;
    color: #333;
}

.ri-modal-close {
    background: none;
    border: none;
    font-size: 28px;
    color: #999;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s;
}

.ri-modal-close:hover {
    background: #f5f5f5;
    color: #333;
}

.ri-modal-body {
    padding: 25px;
    overflow-y: auto;
    flex: 1;
}

.ri-correction-section {
    margin-bottom: 20px;
}

.ri-correction-label {
    display: block;
    font-weight: 600;
    margin-bottom: 10px;
    color: #333;
    font-size: 14px;
}

.ri-text-display {
    background: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 15px;
    min-height: 100px;
    line-height: 1.6;
    font-family: inherit;
    font-size: 14px;
    color: #333;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.ri-error {
    background: #fee;
    color: #c00;
    border-bottom: 2px solid #f00;
    padding: 2px 0;
    cursor: help;
    position: relative;
}

.ri-error:hover {
    background: #fdd;
}

#ri-corrected-text {
    width: 100%;
    padding: 15px;
    border: 2px solid #28a745;
    border-radius: 6px;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.6;
    resize: vertical;
    transition: border-color 0.3s;
}

#ri-corrected-text:focus {
    outline: none;
    border-color: #1e7e34;
    box-shadow: 0 0 0 3px rgba(40, 167, 69, 0.1);
}

.ri-correction-hint {
    margin-top: 8px;
    font-size: 12px;
    color: #666;
    font-style: italic;
}

.ri-loader {
    text-align: center;
    padding: 40px 20px;
}

.ri-spinner {
    width: 40px;
    height: 40px;
    margin: 0 auto 15px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #0073aa;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.ri-success-message {
    text-align: center;
    padding: 30px;
    font-size: 18px;
    color: #28a745;
    font-weight: 600;
}

.ri-modal-footer {
    padding: 20px 25px;
    border-top: 1px solid #e0e0e0;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.ri-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.ri-btn-secondary {
    background: #6c757d;
    color: #fff;
}

.ri-btn-secondary:hover {
    background: #5a6268;
}

.ri-btn-primary {
    background: #28a745;
    color: #fff;
}

.ri-btn-primary:hover {
    background: #218838;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.3);
}

body.ri-modal-open {
    overflow: hidden;
}

/* Animation texte corrigé */
.text-corrected {
    animation: flashGreen 1s;
}

@keyframes flashGreen {
    0%, 100% { 
        background-color: transparent;
        border-color: #ccc;
    }
    50% { 
        background-color: #d4edda;
        border-color: #28a745;
    }
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ========================================
 * CORRECTION CSS MODAL
 * ======================================== */

.ri-modal-content {
    position: fixed; /* 🔥 Changé de absolute à fixed */
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    width: 90%;
    max-width: 700px;
    max-height: 90vh; /* 🔥 Augmenté de 85vh à 90vh */
    display: flex;
    flex-direction: column;
    animation: modalSlideIn 0.3s ease;
    z-index: 10001; /* 🔥 Ajouté pour être au-dessus de l'overlay */
}

.ri-modal-body {
    padding: 25px;
    overflow-y: auto;
    flex: 1;
    min-height: 200px; /* 🔥 Ajouté pour garantir une hauteur minimum */
}

.ri-modal-footer {
    padding: 20px 25px;
    border-top: 1px solid #e0e0e0;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    flex-shrink: 0; /* 🔥 Empêche le footer de rétrécir */
}

/* ========================================
 * 🔥 EFFETS VISUELS CORRECTION AUTO
 * ======================================== */

/* Champ avec correction active (halo + bordure animée) */
textarea.correction-active {
    position: relative;
    border: 2px solid #4CAF50 !important;
    box-shadow: 0 0 15px rgba(76, 175, 80, 0.4),
                inset 0 0 10px rgba(76, 175, 80, 0.1);
    background: linear-gradient(to bottom, #f0fff4 0%, #ffffff 100%);
    transition: all 0.3s ease;
}

/* Animation au focus */
textarea.correction-active.correction-focused {
    box-shadow: 0 0 25px rgba(76, 175, 80, 0.6),
                inset 0 0 15px rgba(76, 175, 80, 0.2);
    border-color: #45a049 !important;
}

/* Animation de pulsation */
@keyframes pulse-glow {
    0% {
        box-shadow: 0 0 5px rgba(76, 175, 80, 0.2);
    }
    50% {
        box-shadow: 0 0 25px rgba(76, 175, 80, 0.8);
    }
    100% {
        box-shadow: 0 0 15px rgba(76, 175, 80, 0.4);
    }
}

/* Badge "Correction active" */
textarea.correction-active::before {
    content: '✏️ Correction auto active';
    position: absolute;
    top: -25px;
    right: 0;
    background: #4CAF50;
    color: white;
    padding: 3px 8px;
    border-radius: 4px 4px 0 0;
    font-size: 11px;
    font-weight: 600;
    z-index: 10;
    box-shadow: 0 -2px 5px rgba(0,0,0,0.1);
}

/* Animation du badge */
textarea.correction-active::before {
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        transform: translateY(-10px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Quand une correction est appliquée */
textarea.text-corrected {
    animation: flash-success 1s ease;
}

@keyframes flash-success {
    0%, 100% {
        background: white;
    }
    50% {
        background: #c8e6c9;
    }
}

/* Bouton toggle avec animation */
.ri-correction-btn.toggling {
    animation: rotate-scale 0.5s ease;
}

@keyframes rotate-scale {
    0% {
        transform: scale(1) rotate(0deg);
    }
    50% {
        transform: scale(1.2) rotate(180deg);
    }
    100% {
        transform: scale(1) rotate(360deg);
    }
}

/* Fautes surlignées dans le modal */
.ri-error {
    background-color: #ffebee;
    border-bottom: 2px wavy #f44336;
    padding: 2px 0;
    cursor: help;
}

.ri-error:hover {
    background-color: #ffcdd2;
}

/* ========================================
 * 🪄 BADGE CORRECTEUR AUTO
 * À ajouter dans votre CSS (style.css ou ri-style.css)
 * ======================================== */

@keyframes fadeInBadge {
    from {
        opacity: 0;
        transform: translateX(-10px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

.ri-correction-badge {
    display: inline-block;
    margin-left: 8px;
    padding: 3px 8px;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: #fff;
    font-size: 11px;
    font-weight: 500;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(16, 185, 129, 0.3);
    animation: fadeInBadge 0.4s ease;
    vertical-align: middle;
    white-space: nowrap;
}

/* Effet hover subtil */
.ri-correction-badge:hover {
    box-shadow: 0 3px 6px rgba(16, 185, 129, 0.3);
    transform: translateY(-1px);
    transition: all 0.2s ease;
}

/* Version mobile plus compacte */
@media (max-width: 768px) {
    .ri-correction-badge {
        font-size: 10px;
        padding: 2px 6px;
        margin-left: 6px;
    }
}

/* Animation de pulsation optionnelle (si vous voulez attirer l'attention) */
@keyframes badgePulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.ri-correction-badge.pulse {
    animation: badgePulse 2s ease-in-out infinite;
}

/* ========================================
 * 🎨 AMÉLIORATIONS VISUELLES GLOBALES
 * ======================================== */

@media (max-width: 768px) {
    
    /* Container du tableau */
    .wrap table.widefat {
        margin-top: 20px !important;
        border-radius: 12px !important;
        overflow: hidden !important;
        box-shadow: 0 2px 8px rgba(0,0,0,0.08) !important;
    }
    
    /* Séparateurs entre lignes plus discrets */
    .wrap table.widefat tbody tr + tr {
        border-top: 1px solid #f0f0f0 !important;
    }
    
    /* Dernier élément sans bordure */
    .wrap table.widefat tbody tr:last-child {
        border-bottom: none !important;
    }
    
    /* Animation au tap */
    .wrap table.widefat tbody td:last-child a:active,
    .wrap table.widefat tbody td:last-child button:active {
        transform: scale(0.95) !important;
    }
}