/* WCAG Accessibility Plugin - Charte Jaune/Or et Violet/Bleu */

:root {
    --wcag-gold: #D4AF37;
    --wcag-gold-light: #f9e339;
    --wcag-purple: #5B4E96;
    --wcag-purple-dark: #4A3E7E;
    --wcag-blue: #6B7DB8;
    --wcag-text-dark: #2C2C2C;
    --wcag-text-light: #FFFFFF;
}

/* Widget container - isolation complète */
#wcag-accessibility-widget {
    position: relative;
    z-index: 999999;
    isolation: isolate;
	display:contents;
    will-change: transform;
    transform: translateZ(0);
}

/* Bouton d'ouverture fixe en bas de l'écran */
.wcag-toggle-btn {
    position: fixed !important;
    bottom: 45px !important;
    left: 20px !important;
    background: linear-gradient(135deg, var(--wcag-gold) 0%, var(--wcag-gold-light) 100%) !important;
    color: var(--wcag-purple-dark) !important;
    border: none !important;
    border-radius: 0 15px !important;
    padding: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 10px !important;
    font-size: 16px !important;
    font-weight: 700 !important;
    cursor: pointer !important;
    box-shadow: 0 8px 25px rgba(212, 175, 55, 0.4) !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    z-index: 999998 !important;
    direction: rtl !important;
    isolation: isolate !important;
    will-change: transform !important;
    transform: translateZ(0) !important;
    opacity: 1 !important;
    visibility: visible !important;
    width: 2.4em !important;
    height: 2.4em !important;
}

/* Cacher le texte du bouton */
.wcag-btn-text {
    display: none !important;
}

.wcag-toggle-btn:hover {
    transform: translateY(-3px) !important;
    box-shadow: 0 12px 35px rgba(212, 175, 55, 0.5) !important;
    background: linear-gradient(135deg, var(--wcag-gold-light) 0%, var(--wcag-gold) 100%) !important;
}

.wcag-toggle-btn svg {
    width: 1.5em !important;
    height: 1.5em !important;
}

.wcag-btn-text {
    font-family: 'Cairo', 'Segoe UI', sans-serif;
}

/* Panel d'accessibilité */
.wcag-panel {
    position: fixed;
    bottom: 20px;
    left: 20px;
    width: 420px;
    max-height: 85vh;
    background: #FFFFFF;
    border-radius: 20px;
    box-shadow: 0 15px 50px rgba(91, 78, 150, 0.3);
    z-index: 999999;
    display: none;
    flex-direction: column;
    overflow: hidden;
    direction: rtl;
    font-family: 'Cairo', 'Segoe UI', sans-serif;
    isolation: isolate;
    will-change: transform;
    transform: translateZ(0);
}

.wcag-panel.active {
    display: flex;
    animation: slideInUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

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

/* Header du panel */
.wcag-panel-header {
    background: linear-gradient(135deg, var(--wcag-purple) 0%, var(--wcag-purple-dark) 100%);
    color: white;
    padding: 20px;
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
}

.wcag-panel-title {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    flex: 1;
}

.wcag-close-btn,
.wcag-reset-btn,
.wcag-hide-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 18px;
}

.wcag-close-btn:hover,
.wcag-reset-btn:hover,
.wcag-hide-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

/* Contenu du panel */
.wcag-panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.wcag-panel-content::-webkit-scrollbar {
    width: 8px;
}

.wcag-panel-content::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.wcag-panel-content::-webkit-scrollbar-thumb {
    background: var(--wcag-gold);
    border-radius: 10px;
}

.wcag-panel-content::-webkit-scrollbar-thumb:hover {
    background: var(--wcag-purple);
}

/* Sections */
.wcag-section {
    margin-bottom: 25px;
}

.wcag-section-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--wcag-purple-dark);
    margin: 0 0 15px 0;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--wcag-gold);
}

/* Grille de contrôles */
.wcag-controls-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

/* Contrôle individuel */
.wcag-control {
    background: #F8F9FA;
    border-radius: 12px;
    padding: 15px;
    grid-column: span 2;
}

.wcag-control-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--wcag-text-dark);
    margin-bottom: 10px;
}

/* Contrôles de taille */
.wcag-size-controls {
    display: flex;
    gap: 8px;
    justify-content: space-between;
}

.wcag-size-btn {
    flex: 1;
    background: white;
    border: 2px solid var(--wcag-purple);
    color: var(--wcag-purple);
    border-radius: 8px;
    padding: 10px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
}

.wcag-size-btn:hover {
    background: var(--wcag-purple);
    color: white;
    transform: translateY(-2px);
}

.wcag-size-btn.active {
    background: linear-gradient(135deg, var(--wcag-gold) 0%, var(--wcag-gold-light) 100%);
    border-color: var(--wcag-gold);
    color: var(--wcag-purple-dark);
}

.wcag-size-icon {
    display: block;
}

/* Boutons de fonctionnalités */
.wcag-feature-btn {
    background: white;
    border: 2px solid #E9ECEF;
    border-radius: 12px;
    padding: 15px 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: center;
}

.wcag-feature-btn:hover {
    border-color: var(--wcag-gold);
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.1) 0%, rgba(249, 227, 57, 0.1) 100%);
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(212, 175, 55, 0.2);
}

.wcag-feature-btn.active {
    background: linear-gradient(135deg, var(--wcag-gold) 0%, var(--wcag-gold-light) 100%);
    border-color: var(--wcag-gold);
    color: var(--wcag-purple-dark);
}

.wcag-feature-icon {
    width: 28px;
    height: 28px;
    color: var(--wcag-purple);
    transition: color 0.3s ease;
}

.wcag-feature-btn.active .wcag-feature-icon {
    color: var(--wcag-purple-dark);
}

.wcag-feature-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--wcag-text-dark);
}

/* Footer */
.wcag-panel-footer {
    background: #F8F9FA;
    padding: 15px 20px;
    text-align: center;
    border-top: 1px solid #E9ECEF;
}

.wcag-powered-by {
    font-size: 12px;
    color: #6C757D;
}

.wcag-powered-by strong {
    color: var(--wcag-purple);
}

/* Responsive */
@media (max-width: 768px) {
    .wcag-toggle-btn {
        bottom: 15px;
        left: 15px;
        padding: 10px 20px;
        font-size: 14px;
    }
    
    .wcag-btn-text {
        display: none;
    }
    
    .wcag-panel {
        width: calc(100vw - 30px);
        max-width: 380px;
        bottom: 15px;
        left: 15px;
    }
    
    .wcag-controls-grid {
        grid-template-columns: 1fr;
    }
    
    .wcag-feature-btn {
        padding: 12px 10px;
    }
}

@media (max-width: 480px) {
    .wcag-panel {
        width: calc(100vw - 20px);
        left: 10px;
        bottom: 10px;
        max-height: 80vh;
    }
    
    .wcag-panel-content {
        padding: 15px;
    }
    
    .wcag-section {
        margin-bottom: 20px;
    }
}

/* Classes d'accessibilité appliquées au body */

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

body.wcag-text-normal,
body.wcag-text-normal * {
    font-size: 16px !important;
}

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

body.wcag-text-xlarge,
body.wcag-text-xlarge * {
    font-size: 20px !important;
}

/* Espacement des lettres */
body.wcag-spacing-normal {
    letter-spacing: normal !important;
}

body.wcag-spacing-medium * {
    letter-spacing: 0.05em !important;
}

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

/* Contraste élevé - Appliquer uniquement aux éléments de contenu, pas au body */
/* Cela évite de cacher les éléments position:fixed comme le widget et scroll-to-top */

/* Appliquer le contraste uniquement aux éléments de contenu */
body.wcag-high-contrast main,
body.wcag-high-contrast article,
body.wcag-high-contrast section:not(.wcag-panel):not(#wcag-accessibility-widget),
body.wcag-high-contrast div:not(.wcag-panel):not(#wcag-accessibility-widget):not([class*="scroll"]):not([class*="back-to-top"]),
body.wcag-high-contrast p,
body.wcag-high-contrast h1,
body.wcag-high-contrast h2,
body.wcag-high-contrast h3,
body.wcag-high-contrast h4,
body.wcag-high-contrast h5,
body.wcag-high-contrast h6 {
    filter: contrast(1.5) !important;
}

/* Le widget et les éléments fixes restent normaux */
body.wcag-high-contrast #wcag-accessibility-widget,
body.wcag-high-contrast #wcag-accessibility-widget *,
body.wcag-high-contrast #wcag-panel,
body.wcag-high-contrast #wcag-panel *,
body.wcag-high-contrast #wcag-toggle-btn,
body.wcag-high-contrast #wcag-toggle-btn *,
body.wcag-high-contrast [class*="scroll"],
body.wcag-high-contrast [class*="back-to-top"],
body.wcag-high-contrast .scroll-to-top,
body.wcag-high-contrast .back-to-top {
    filter: none !important;
}

/* Mode sombre */
body.wcag-dark-mode {
    background: #1a1a1a !important;
    color: #ffffff !important;
}

body.wcag-dark-mode * {
    background-color: #1a1a1a !important;
    color: #ffffff !important;
    border-color: #444 !important;
}

/* IMPORTANT: Le widget doit TOUJOURS rester visible */
/* Forcer les couleurs du widget avec priorité maximale */
body.wcag-dark-mode #wcag-accessibility-widget {
    background-color: transparent !important;
    filter: none !important;
}

body.wcag-dark-mode #wcag-panel {
    background: #FFFFFF !important;
    color: #2C2C2C !important;
    border: 2px solid #D4AF37 !important;
}

body.wcag-dark-mode #wcag-panel * {
    background-color: transparent !important;
    color: inherit !important;
}

body.wcag-dark-mode #wcag-toggle-btn {
    background: linear-gradient(135deg, #D4AF37 0%, #f9e339 100%) !important;
    color: #4A3E7E !important;
    display: flex !important;
    opacity: 1 !important;
    visibility: visible !important;
}

body.wcag-dark-mode #wcag-toggle-btn * {
    color: #4A3E7E !important;
    background: transparent !important;
}

/* Sections du panel */
body.wcag-dark-mode .wcag-panel-header {
    background: linear-gradient(135deg, #5B4E96 0%, #6B7DB8 100%) !important;
    color: #FFFFFF !important;
}

body.wcag-dark-mode .wcag-panel-header * {
    color: #FFFFFF !important;
}

body.wcag-dark-mode .wcag-section-title {
    color: #4A3E7E !important;
}

body.wcag-dark-mode .wcag-feature-btn {
    background: #f8f9fa !important;
    color: #2C2C2C !important;
}

body.wcag-dark-mode .wcag-feature-btn.active {
    background: linear-gradient(135deg, #D4AF37 0%, #f9e339 100%) !important;
    color: #4A3E7E !important;
}

/* Inverser les couleurs - Appliquer uniquement aux éléments de contenu, pas au body */
/* Cela évite de cacher les éléments position:fixed */

/* Appliquer l'inversion uniquement aux éléments de contenu */
body.wcag-invert-colors main,
body.wcag-invert-colors article,
body.wcag-invert-colors section:not(.wcag-panel):not(#wcag-accessibility-widget),
body.wcag-invert-colors div:not(.wcag-panel):not(#wcag-accessibility-widget):not([class*="scroll"]):not([class*="back-to-top"]),
body.wcag-invert-colors header:not(.wcag-panel-header),
body.wcag-invert-colors footer {
    filter: invert(1) hue-rotate(180deg) !important;
}

/* Le widget et les éléments fixes restent normaux */
body.wcag-invert-colors #wcag-accessibility-widget,
body.wcag-invert-colors #wcag-accessibility-widget *,
body.wcag-invert-colors #wcag-panel,
body.wcag-invert-colors #wcag-panel *,
body.wcag-invert-colors #wcag-toggle-btn,
body.wcag-invert-colors #wcag-toggle-btn *,
body.wcag-invert-colors [class*="scroll"],
body.wcag-invert-colors [class*="back-to-top"],
body.wcag-invert-colors .scroll-to-top,
body.wcag-invert-colors .back-to-top {
    filter: none !important;
}

/* Niveaux de gris - Appliquer uniquement aux éléments de contenu, pas au body */
/* Cela évite de cacher les éléments position:fixed */

/* Appliquer le grayscale uniquement aux éléments de contenu */
body.wcag-grayscale main,
body.wcag-grayscale article,
body.wcag-grayscale section:not(.wcag-panel):not(#wcag-accessibility-widget),
body.wcag-grayscale div:not(.wcag-panel):not(#wcag-accessibility-widget):not([class*="scroll"]):not([class*="back-to-top"]),
body.wcag-grayscale header:not(.wcag-panel-header),
body.wcag-grayscale footer,
body.wcag-grayscale img {
    filter: grayscale(100%) !important;
}

/* Le widget et les éléments fixes restent en couleur */
body.wcag-grayscale #wcag-accessibility-widget,
body.wcag-grayscale #wcag-accessibility-widget *,
body.wcag-grayscale #wcag-panel,
body.wcag-grayscale #wcag-panel *,
body.wcag-grayscale #wcag-toggle-btn,
body.wcag-grayscale #wcag-toggle-btn *,
body.wcag-grayscale [class*="scroll"],
body.wcag-grayscale [class*="back-to-top"],
body.wcag-grayscale .scroll-to-top,
body.wcag-grayscale .back-to-top {
    filter: none !important;
}

/* Surligner les liens */
body.wcag-highlight-links a {
    background: var(--wcag-gold) !important;
    color: var(--wcag-purple-dark) !important;
    padding: 2px 6px !important;
    border-radius: 4px !important;
    text-decoration: underline !important;
}

/* Curseur large */
body.wcag-big-cursor,
body.wcag-big-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 d="M4 4 L4 28 L12 20 L16 28 L20 26 L16 18 L28 18 Z" fill="black" stroke="white" stroke-width="2"/></svg>') 4 4, auto !important;
}

/* Masquer les images */
body.wcag-hide-images img {
    opacity: 0 !important;
    visibility: hidden !important;
}

/* Guide de lecture - bandes horizontales qui suivent le curseur */
#wcag-reading-guide-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 99998;
    display: none;
}

body.wcag-reading-guide #wcag-reading-guide-overlay {
    display: block;
}

#wcag-reading-guide-top {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    background: rgba(0, 0, 0, 0.7);
    transition: height 0.1s ease;
}

#wcag-reading-guide-bottom {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(0, 0, 0, 0.7);
    transition: height 0.1s ease;
}

/* Garder le widget au-dessus du guide de lecture */
body.wcag-reading-guide #wcag-panel {
    z-index: 999999 !important;
}

body.wcag-reading-guide #wcag-toggle-btn {
    z-index: 999999 !important;
}

/* Masque de focus - cercle qui suit le curseur */
body.wcag-focus-mask {
    position: relative;
}

body.wcag-focus-mask::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(
            circle 150px at var(--mouse-x, 50%) var(--mouse-y, 50%),
            transparent 0%,
            transparent 100%,
            rgba(0, 0, 0, 0.85) 100%
        );
    pointer-events: none;
    z-index: 99998;
    transition: background 0.1s ease;
}

/* Fallback pour navigateurs sans support de var() dans radial-gradient */
body.wcag-focus-mask::after {
    content: '';
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 300px;
    height: 300px;
    border-radius: 50%;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.85);
    pointer-events: none;
    z-index: 99998;
}

/* Garder le widget au-dessus du masque */
body.wcag-focus-mask #wcag-panel {
    z-index: 999999 !important;
}

body.wcag-focus-mask #wcag-toggle-btn {
    z-index: 999999 !important;
}
