/* ===== STRUCTURE DU WIDGET ===== */
.accessibility-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
}

.accessibility-toggle {
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: #007bff;
    color: white;
    border: none;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

.accessibility-panel {
    display: none;
    position: absolute;
    bottom: 70px;
    right: 0;
    width: 380px !important;
    max-height: 80vh !important;
    background-color: white;
    border-radius: 10px;
    box-shadow: 0 2px 20px rgba(0,0,0,0.2);
    padding: 20px !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
}

.accessibility-widget.open .accessibility-panel {
    display: block;
}

/* Style pour la barre de défilement */
.accessibility-panel::-webkit-scrollbar {
    width: 8px !important;
}

.accessibility-panel::-webkit-scrollbar-thumb {
    background-color: #ccc !important;
    border-radius: 10px !important;
}

.accessibility-panel::-webkit-scrollbar-track {
    background-color: #f5f5f5 !important;
}

/* ===== ÉLÉMENTS DE L'INTERFACE ===== */
.accessibility-panel h3 {
    font-size: 20px !important;
    margin-top: 5px !important;
    margin-bottom: 15px !important;
    padding-bottom: 10px !important;
    text-align: center;
    border-bottom: 1px solid #eee;
}

.option {
    display: flex !important;
    flex-wrap: wrap !important;
    justify-content: center !important;
    gap: 10px !important;
    margin-bottom: 10px !important;
}

.option label {
    width: 100% !important;
    text-align: center !important;
    font-size: 16px !important;
    font-weight: bold !important;
    color: #495057 !important;
}

/* ===== STYLES DES BOUTONS ===== */
.btn-small {
    padding: 5px 10px;
    margin-right: 5px;
    border: 1px solid #ddd;
    background-color: #f9f9f9;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
}

.btn-small:hover {
    background-color: #eee;
    transform: translateY(-2px);
}

/* Style pour les boutons isolés */
.accessibility-isolated .btn-small {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    height: 90px !important;
    width: 90px !important;
    margin: 5px !important;
    padding: 5px !important;
    text-align: center !important;
    position: relative !important;
    font-size: 12px !important;
    line-height: 1.2 !important;
}

/* Style pour les boutons actifs */
.accessibility-panel .btn-small.active {
    background-color: #007bff !important;
    color: white !important;
    border-color: #0069d9 !important;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25) !important;
}

/* ===== STYLES DES ICÔNES ===== */
/* Style pour les icônes emoji */
.accessibility-btn-icon {
    display: block !important;
    font-size: 24px !important;
    height: 36px !important;
    margin: 0 auto 8px auto !important;
    line-height: 36px !important;
    text-align: center !important;
}

/* Assurer que les icônes restent visibles même en mode sombre */
html.dark-mode .accessibility-panel .accessibility-btn-icon {
    filter: none !important;
}

/* ===== MODES D'ACCESSIBILITÉ ===== */
/* Mode sombre */
html.dark-mode *:not(.accessibility-isolated):not(.accessibility-isolated *) {
    background-color: #222 !important;
    color: #f5f5f5 !important;
    border-color: #555 !important;
}

html.dark-mode .accessibility-panel h3 {
    color: #333 !important;
    background-color: white !important;
    border-bottom-color: #eee !important;
}

html.dark-mode input,
html.dark-mode textarea {
    background-color: #333 !important;
}

/* Mode contraste élevé */
html.high-contrast-mode *:not(.accessibility-isolated):not(.accessibility-isolated *) {
    background-color: white !important;
    color: black !important;
    border-color: black !important;
}

/* Mode daltonisme */
html.deuteranopia-mode {
    filter: grayscale(0.5) sepia(0.2) !important;
}

html.protanopia-mode {
    filter: hue-rotate(-30deg) saturate(0.8) !important;
}

html.tritanopia-mode {
    filter: hue-rotate(90deg) saturate(0.8) !important;
}

/* Mode texte large */
body.wide-text-spacing *:not(.accessibility-isolated):not(.accessibility-isolated *) {
    line-height: 1.8 !important;
    letter-spacing: 0.12em !important;
    word-spacing: 0.16em !important;
}

body.wide-text-spacing p,
body.wide-text-spacing li:not(.accessibility-isolated):not(.accessibility-isolated *) {
    margin-bottom: 1.5em !important;
}

/* Police lisible */
body.readable-font *:not(.fas):not(.fab):not(.far):not(.fa):not([class*="fa-"]):not(.accessibility-isolated):not(.accessibility-isolated *) {
    font-family: Verdana, sans-serif !important;
    text-transform: none !important;
}

/* Combinaison Police lisible + espacement large */
body.wide-text-spacing.readable-font *:not(.fas):not(.fab):not(.far):not(.fa):not([class*="fa-"]):not(.accessibility-isolated):not(.accessibility-isolated *) {
    font-family: Verdana, sans-serif !important;
    line-height: 1.8 !important;
    letter-spacing: 0.12em !important;
    word-spacing: 0.16em !important;
}

/* Gestion des liens surlignés */
body.highlight-links a,
body.highlight-links button,
body.highlight-links input[type="button"],
body.highlight-links input[type="submit"],
body.highlight-links .btn {
    position: relative !important;
    background-color: #ffeb3ba1 !important;
    box-shadow: 0 0 0 2px #ff6b6b !important;
    z-index: 1 !important;
}

body.highlight-links a::after,
body.highlight-links button::after,
body.highlight-links input[type="button"]::after,
body.highlight-links input[type="submit"]::after,
body.highlight-links .btn::after {
    content: "" !important;
    position: absolute !important;
    top: -2px !important;
    left: -2px !important;
    right: -2px !important;
    bottom: -2px !important;
    background-color: #ffeb3ba1 !important;
    border: 1px solid #ff6b6b !important;
    border-radius: inherit !important;
    z-index: -1 !important;
    pointer-events: none !important;
}

body.highlight-links a:hover,
body.highlight-links button:hover,
body.highlight-links input[type="button"]:hover,
body.highlight-links input[type="submit"]:hover,
body.highlight-links .btn:hover {
    background-color: #ffeb3ba1 !important;
    box-shadow: 0 0 0 3px rgba(255, 107, 107, 0.5) !important;
}

/* === Icônes utilisateur : comportement par défaut et pour chaque mode === */

/* Valeur par défaut (mode normal) : icône blanche (.icon-dark) visible, icône noire (.icon-light) masquée */
.icon-dark.user  { display: inline-block !important; }
.icon-light.user { display: none !important; }
.user-name { color: #fff !important; transition: color .18s ease-in-out; }

/* Hover/focus en mode normal : swap → afficher icône noire et nom noir */
.dropdown-toggle:hover .icon-light.user,
.dropdown-toggle:focus-visible .icon-light.user {
    display: inline-block !important;
}
.dropdown-toggle:hover .icon-dark.user,
.dropdown-toggle:focus-visible .icon-dark.user {
    display: none !important;
}
.dropdown-toggle:hover .user-name,
.dropdown-toggle:focus-visible .user-name {
    color: #000 !important;
}

/* DARK MODE : garder icône blanche par défaut et au hover (pas de swap) */
html.dark-mode .icon-dark.user  { display: inline-block !important; }
html.dark-mode .icon-light.user { display: none !important; }
html.dark-mode .dropdown-toggle:hover .icon-dark.user,
html.dark-mode .dropdown-toggle:focus-visible .icon-dark.user {
    display: inline-block !important;
}
html.dark-mode .dropdown-toggle:hover .icon-light.user,
html.dark-mode .dropdown-toggle:focus-visible .icon-light.user {
    display: none !important;
}
html.dark-mode .user-name,
html.dark-mode .dropdown-toggle:hover .user-name,
html.dark-mode .dropdown-toggle:focus-visible .user-name {
    color: #fff !important;
}

/* HIGH CONTRAST : icône noire (.icon-light) visible par défaut et au hover (contraste maximal) */
html.high-contrast-mode .icon-light.user { display: inline-block !important; }
html.high-contrast-mode .icon-dark.user  { display: none !important; }
html.high-contrast-mode .dropdown-toggle:hover .icon-light.user,
html.high-contrast-mode .dropdown-toggle:focus-visible .icon-light.user {
    display: inline-block !important;
}
html.high-contrast-mode .dropdown-toggle:hover .icon-dark.user,
html.high-contrast-mode .dropdown-toggle:focus-visible .icon-dark.user {
    display: none !important;
}
html.high-contrast-mode .user-name,
html.high-contrast-mode .dropdown-toggle:hover .user-name,
html.high-contrast-mode .dropdown-toggle:focus-visible .user-name {
    color: #000 !important;
}

/* ===== NAVBAR EN MODE SOMBRE ===== */
html.dark-mode .navbar-toggler {
    border-color: rgba(255, 255, 255, 0.5) !important;
    background-color: rgba(255, 255, 255, 0.1) !important;
}

html.dark-mode .navbar-toggler-icon {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%28255, 255, 255, 0.75%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e") !important;
}

html.dark-mode .navbar-toggler:hover {
    background-color: rgba(255, 255, 255, 0.2) !important;
}

/* ===== GRAND CURSEUR PERSONNALISÉ ===== */
body.large-cursor,
body.large-cursor a,
body.large-cursor button,
body.large-cursor input,
body.large-cursor textarea,
body.large-cursor select,
body.large-cursor [role="button"],
body.large-cursor [tabindex],
body.large-cursor label,
body.large-cursor .btn,
body.large-cursor .clickable,
body.large-cursor *[onclick] {
    cursor: none !important;
}

.custom-cursor {
    position: fixed;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: rgba(255,255,255,0.5);
    border: 2px solid #000;
    pointer-events: none;
    z-index: 9999;
    transform: translate(-50%, -50%);
    transition: transform 0.1s ease-out, width 0.2s, height 0.2s;
}

body.large-cursor:active .custom-cursor {
    transform: translate(-50%, -50%) scale(0.8);
    background-color: rgba(0,123,255,0.3);
    border-color: #0069d9;
}

body.large-cursor a:hover ~ .custom-cursor,
body.large-cursor button:hover ~ .custom-cursor,
body.large-cursor input:hover ~ .custom-cursor {
    width: 45px;
    height: 45px;
    border-color: #007bff;
}

.custom-cursor.clickable-target {
    background-color: rgba(0,123,255,0.2);
    border-color: #007bff;
    width: 45px;
    height: 45px;
}

.custom-cursor.clicking {
    transform: translate(-50%, -50%) scale(0.8);
    background-color: rgba(0,123,255,0.4);
    border-width: 3px;
}

/* ===== MODE LECTURE AU SURVOL ===== */
body.hover-reading-mode {
    cursor: help !important;
}

body.hover-reading-mode *:hover {
    outline: 2px dashed #ff6b6b !important;
}

/* ===== STYLES SPÉCIFIQUES POUR LES BOUTONS DE MODE ===== */
[data-action="high-contrast"].active {
    background-color: #000 !important;
    color: white !important;
}

[data-action="dark-mode"].active {
    background-color: #343a40 !important;
    color: #f8f9fa !important;
}

[data-action="highlight-links"].active {
    border-left: 3px solid #ff6b6b !important;
}

[data-action="readable-font"].active {
    font-family: Arial, sans-serif !important;
}

/* Mode sans animation */
body.no-animations * {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
}

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

/* Masque supérieur avec bordure inférieure */
body.reading-guide::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: calc(var(--guide-position, 50vh) - 25px);
    background-color: rgba(0, 0, 0, 0.7) !important;
    border-bottom: 2px solid #ffeb3b !important; /* Bordure inférieure */
    pointer-events: none;
    z-index: 9998;
    transition: height 0.1s ease;
}

/* Masque inférieur avec bordure supérieure */
body.reading-guide::after {
    content: "";
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(100vh - var(--guide-position, 50vh) - 25px);
    background-color: rgba(0, 0, 0, 0.7) !important;
    border-top: 2px solid #ffeb3b !important; /* Bordure supérieure */
    pointer-events: none;
    z-index: 9998;
    transition: height 0.1s ease;
}

/* Amélioration des performances */
.reading-highlight-borders {
    will-change: transform;
    position: fixed;
    left: 0;
    right: 0;
    height: 50px;
    z-index: 9999;
    pointer-events: none;
}

/* Règles spécifiques pour le mode contraste élevé */
html.high-contrast-mode body.reading-guide::before {
    background-color: rgba(0, 0, 0, 0.8) !important;
    border-bottom: 3px solid #ffeb3b !important; /* Bordure plus visible en contraste élevé */
}

html.high-contrast-mode body.reading-guide::after {
    background-color: rgba(0, 0, 0, 0.8) !important;
    border-top: 3px solid #ffeb3b !important; /* Bordure plus visible en contraste élevé */
}

/* Règles spécifiques pour le mode sombre */
html.dark-mode body.reading-guide::before {
    background-color: rgba(0, 0, 0, 0.8) !important;
    border-bottom: 2px solid #ffeb3b !important;
}

html.dark-mode body.reading-guide::after {
    background-color: rgba(0, 0, 0, 0.8) !important;
    border-top: 2px solid #ffeb3b !important;
}

/* Garantir que l'élément reading-highlight-borders reste transparent */
html.high-contrast-mode body.reading-guide .reading-highlight-borders,
html.dark-mode body.reading-guide .reading-highlight-borders {
    background: transparent !important;
    background-color: transparent !important;
    border: none !important;
    border-top: none !important;
    border-bottom: none !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    opacity: 0 !important;
}

/* Animation au survol du bouton d'accessibilité */
.accessibility-toggle {
    transition: transform 0.3s ease, box-shadow 0.3s ease, background-color 0.3s ease !important;
}

.accessibility-toggle:hover {
    transform: scale(1.1) !important;
    box-shadow: 0 4px 15px rgba(0, 123, 255, 0.4) !important;
    background-color: #0069d9 !important;
    animation: pulse 2s infinite !important;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(0, 123, 255, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(0, 123, 255, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(0, 123, 255, 0);
    }
}

/* Assurer que l'animation fonctionne en mode sombre et contraste élevé */
html.dark-mode .accessibility-toggle:hover,
html.high-contrast-mode .accessibility-toggle:hover {
    animation: pulse 2s infinite !important;
}

/* Désactiver l'animation si l'utilisateur préfère réduire les mouvements */
@media (prefers-reduced-motion: reduce) {
    .accessibility-toggle:hover {
        transform: scale(1.05) !important;
        animation: none !important;
    }
}

/* Mode sans images */
html.no-background-images *:not(.accessibility-widget *) {
    background-image: none !important;
}

img.disabled-image {
    border: 1px dashed #999 !important;
    background-color: #f0f0f0 !important;
    padding: 8px !important;
    box-sizing: border-box !important;
    min-width: 24px !important;
    min-height: 24px !important;
    position: relative !important;
}

/* Pour compatibilité avec le mode sombre */
html.dark-mode img.disabled-image {
    background-color: #333 !important;
    border-color: #666 !important;
}

html.dark-mode,
html.dark-mode body {
    background-color: #121212 !important;
    color: #e6eef8 !important;
    background-image: none !important;
}
html.high-contrast-mode,
html.high-contrast-mode body {
    background-color: #ffffff !important;
    color: #000000 !important;
    background-image: none !important;
}
