/* ========================================
   Widget d'Accessibilité WCAG 2.1 AA
   ======================================== */

/* Bouton flottant d'accessibilité */
.accessibility-button {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #e42125 0%, #c41e22 100%);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(228, 33, 37, 0.4);
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    animation: pulse-accessibility 2s infinite;
    isolation: isolate;
    filter: none !important;
}

.accessibility-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(228, 33, 37, 0.6);
}

.accessibility-button svg {
    width: 30px;
    height: 30px;
    fill: white;
}

/* Animation pulse */
@keyframes pulse-accessibility {
    0%, 100% {
        box-shadow: 0 4px 12px rgba(228, 33, 37, 0.4);
    }
    50% {
        box-shadow: 0 4px 20px rgba(228, 33, 37, 0.7);
    }
}

/* Support RTL */
[dir="rtl"] .accessibility-button {
    right: auto;
    left: 20px;
}

/* Panneau d'accessibilité */
.accessibility-panel {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 320px;
    max-height: 80vh;
    background: #f8f9fa !important;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15) !important;
    border: 2px solid #1a237e !important;
    z-index: 999999;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: all 0.3s ease;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    isolation: isolate;
    filter: none !important;
}

.accessibility-panel.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

[dir="rtl"] .accessibility-panel {
    right: auto;
    left: 20px;
}

/* Header du panneau */
.accessibility-header {
    background: #1a237e !important;
    color: #FFFFFF !important;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 3px solid #1a237e !important;
}

.accessibility-header h3 {
    margin: 0;
    font-size: 18px;
	color:#ffffff;
    font-weight: 600;
}

.accessibility-close {
    background: transparent;
    border: none;
    color:#ffffff;
    font-size: 24px;
    cursor: pointer;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s;
}

.accessibility-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Corps du panneau */
.accessibility-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

/* Groupes de contrôles */
.accessibility-group {
    margin-bottom: 25px;
}

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

.accessibility-group-title {
    font-size: 14px;
    font-weight: 600;
    color: #2c3e50 !important;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.accessibility-group-title svg {
    width: 18px;
    height: 18px;
    fill: #e42125;
}

/* Contrôles */
.accessibility-control {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    background: white !important;
    border-radius: 8px;
    margin-bottom: 8px;
    transition: background 0.2s, border-color 0.2s, box-shadow 0.2s;
    border: 1px solid #e9ecef !important;
}

.accessibility-control:hover {
    background: #fff !important;
    border-color: #e42125 !important;
    box-shadow: 0 2px 8px rgba(228, 33, 37, 0.1) !important;
}

.accessibility-control-label {
    font-size: 14px;
    color: #2c3e50 !important;
    flex: 1;
    font-weight: 500;
}

/* Boutons de contrôle */
.accessibility-control-buttons {
    display: flex;
    gap: 8px;
}

.accessibility-btn {
    background: #f8f9fa !important;
    border: 1px solid #dee2e6 !important;
    color: #2c3e50 !important;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.2s;
    min-width: 40px;
}

.accessibility-btn:hover {
    background: #e42125 !important;
    color: white !important;
    border-color: #e42125 !important;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(228, 33, 37, 0.2) !important;
}

.accessibility-btn.active {
    background: #e42125 !important;
    color: white !important;
    border-color: #e42125 !important;
    box-shadow: 0 2px 4px rgba(228, 33, 37, 0.3) !important;
}

/* Toggle switch */
.accessibility-toggle {
    position: relative;
    width: 50px;
    height: 26px;
    background: #ccc;
    border-radius: 13px;
    cursor: pointer;
    transition: background 0.3s;
}

.accessibility-toggle::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    transition: transform 0.3s;
}

.accessibility-toggle.active {
    background: #e42125;
}

.accessibility-toggle.active::after {
    transform: translateX(24px);
}

[dir="rtl"] .accessibility-toggle.active::after {
    transform: translateX(-24px);
}

/* Bouton de réinitialisation */
.accessibility-reset {
    width: 100%;
    background: white !important;
    color: #6c757d !important;
    border: 1px solid #dee2e6 !important;
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    margin-top: 15px;
    transition: all 0.2s;
}

.accessibility-reset:hover {
    background: #6c757d !important;
    color: white !important;
    border-color: #6c757d !important;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(108, 117, 125, 0.2) !important;
}

/* Scrollbar personnalisée */
.accessibility-body::-webkit-scrollbar {
    width: 6px;
}

.accessibility-body::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.accessibility-body::-webkit-scrollbar-thumb {
    background: #e42125;
    border-radius: 3px;
}

.accessibility-body::-webkit-scrollbar-thumb:hover {
    background: #c41e22;
}

/* ========================================
   Classes d'accessibilité appliquées
   ======================================== */

/* Taille du texte */
body.text-size-small {
    font-size: 12px !important;
}

body.text-size-small p,
body.text-size-small span,
body.text-size-small div,
body.text-size-small a,
body.text-size-small li,
body.text-size-small td,
body.text-size-small th,
body.text-size-small label,
body.text-size-small input,
body.text-size-small textarea {
    font-size: 12px !important;
}

body.text-size-large {
    font-size: 18px !important;
}

body.text-size-large p,
body.text-size-large span,
body.text-size-large div,
body.text-size-large a,
body.text-size-large li,
body.text-size-large td,
body.text-size-large th,
body.text-size-large label,
body.text-size-large input,
body.text-size-large textarea {
    font-size: 18px !important;
}

body.text-size-xlarge {
    font-size: 24px !important;
}

body.text-size-xlarge p,
body.text-size-xlarge span,
body.text-size-xlarge div,
body.text-size-xlarge a,
body.text-size-xlarge li,
body.text-size-xlarge td,
body.text-size-xlarge th,
body.text-size-xlarge label,
body.text-size-xlarge input,
body.text-size-xlarge textarea {
    font-size: 24px !important;
}

/* Titres proportionnels */
body.text-size-small h1 { font-size: 24px !important; }
body.text-size-small h2 { font-size: 20px !important; }
body.text-size-small h3 { font-size: 18px !important; }
body.text-size-small h4 { font-size: 16px !important; }
body.text-size-small h5 { font-size: 14px !important; }
body.text-size-small h6 { font-size: 12px !important; }

body.text-size-large h1 { font-size: 36px !important; }
body.text-size-large h2 { font-size: 30px !important; }
body.text-size-large h3 { font-size: 26px !important; }
body.text-size-large h4 { font-size: 22px !important; }
body.text-size-large h5 { font-size: 20px !important; }
body.text-size-large h6 { font-size: 18px !important; }

body.text-size-xlarge h1 { font-size: 48px !important; }
body.text-size-xlarge h2 { font-size: 40px !important; }
body.text-size-xlarge h3 { font-size: 34px !important; }
body.text-size-xlarge h4 { font-size: 28px !important; }
body.text-size-xlarge h5 { font-size: 26px !important; }
body.text-size-xlarge h6 { font-size: 24px !important; }

/* Exceptions - Ne pas modifier le widget d'accessibilité */
body.text-size-small .accessibility-widget,
body.text-size-small .accessibility-widget *,
body.text-size-large .accessibility-widget,
body.text-size-large .accessibility-widget *,
body.text-size-xlarge .accessibility-widget,
body.text-size-xlarge .accessibility-widget * {
    font-size: inherit !important;
}

/* Garder les boutons à une taille raisonnable */
body.text-size-small button:not(.accessibility-widget button),
body.text-size-large button:not(.accessibility-widget button),
body.text-size-xlarge button:not(.accessibility-widget button) {
    font-size: 14px !important;
}

/* Espacement des lignes */
body.line-height-medium * {
    line-height: 1.8 !important;
}

body.line-height-large * {
    line-height: 2.2 !important;
}

/* Espacement des lettres */
body.letter-spacing-medium * {
    letter-spacing: 0.05em !important;
}

body.letter-spacing-large * {
    letter-spacing: 0.1em !important;
}

/* Contraste élevé - Appliquer uniquement au contenu principal */
body.high-contrast .page-wrapper,
body.high-contrast .main-content {
    filter: contrast(150%) !important;
}

body.high-contrast * {
    border-color: #000 !important;
}

/* Exclure le widget du contraste élevé */
body.high-contrast .accessibility-widget,
body.high-contrast .accessibility-widget * {
    filter: none !important;
    border-color: inherit !important;
}

/* Contraste inversé - Appliquer uniquement au contenu principal */
body.invert-colors .page-wrapper,
body.invert-colors .main-content {
    filter: invert(1) hue-rotate(180deg) !important;
}

/* Exclure le widget de l'inversion */
body.invert-colors .accessibility-widget,
body.invert-colors .accessibility-widget * {
    filter: none !important;
}

/* Niveaux de gris - Appliquer uniquement au contenu principal */
body.grayscale .page-wrapper,
body.grayscale .main-content {
    filter: grayscale(100%) !important;
}

/* Exclure le widget du grayscale */
body.grayscale .accessibility-widget,
body.grayscale .accessibility-widget * {
    filter: none !important;
}

/* Modes daltonisme - Appliquer uniquement au contenu principal */
body.protanopia .page-wrapper,
body.protanopia .main-content {
    filter: url('#protanopia-filter') !important;
}

body.deuteranopia .page-wrapper,
body.deuteranopia .main-content {
    filter: url('#deuteranopia-filter') !important;
}

body.tritanopia .page-wrapper,
body.tritanopia .main-content {
    filter: url('#tritanopia-filter') !important;
}

/* Exclure le widget des filtres daltonisme */
body.protanopia .accessibility-widget,
body.protanopia .accessibility-widget *,
body.deuteranopia .accessibility-widget,
body.deuteranopia .accessibility-widget *,
body.tritanopia .accessibility-widget,
body.tritanopia .accessibility-widget * {
    filter: none !important;
}

/* Arrêter les animations */
body.no-animations * {
    animation: none !important;
    transition: none !important;
}

/* Curseur large */
body.large-cursor,
body.large-cursor * {
    cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32"><path fill="black" stroke="white" stroke-width="2" d="M2 2 L2 28 L10 20 L15 28 L18 27 L13 19 L22 19 Z"/></svg>') 0 0, auto !important;
}

/* Guide de lecture */
body.reading-guide {
    position: relative;
}

.reading-guide-line {
    position: fixed;
    left: 0;
    right: 0;
    height: 2px;
    background: #e42125;
    pointer-events: none;
    z-index: 9997;
    box-shadow: 0 0 10px rgba(228, 33, 37, 0.5);
}

/* Responsive */
@media (max-width: 768px) {
    .accessibility-panel {
        width: calc(100% - 40px);
        max-width: 320px;
    }
    
    .accessibility-button {
        width: 50px;
        height: 50px;
    }
    
    .accessibility-button svg {
        width: 24px;
        height: 24px;
    }
}

/* Mode sombre */
@media (prefers-color-scheme: dark) {
    .accessibility-panel {
        background: #2d3748;
        border-color: #e42125;
    }
    
    .accessibility-body {
        color: #e2e8f0;
    }
    
    .accessibility-control {
        background: #1a202c;
        border-color: #4a5568;
    }
    
    .accessibility-control:hover {
        background: #2d3748;
        border-color: #e42125;
    }
    
    .accessibility-control-label {
        color: #e2e8f0;
    }
    
    .accessibility-group-title {
        color: #e2e8f0;
    }
    
    .accessibility-btn {
        background: #1a202c;
        color: #e2e8f0;
        border-color: #4a5568;
    }
    
    .accessibility-btn:hover,
    .accessibility-btn.active {
        background: #e42125;
        color: white;
        border-color: #e42125;
    }
    
    .accessibility-reset {
        background: #1a202c;
        color: #e2e8f0;
        border-color: #4a5568;
    }
    
    .accessibility-reset:hover {
        background: #6c757d;
        color: white;
        border-color: #6c757d;
    }
}
