/* Accessibility Widget (Peona) Styles */

.accessibility-widget {
    position: relative;
    font-family: 'Nunito', sans-serif;
    margin-right: 0;
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.accessibility-btn {
    width: 48px;
    height: 48px;
    background: var(--accent, #ff9f1c);
    color: #ffffff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
    aspect-ratio: 1 / 1;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s ease, background-color 0.2s;
    box-shadow: 0 4px 15px rgba(255, 159, 28, 0.4);
    animation: a11y-pulse 2.5s infinite;
}

.accessibility-btn:hover {
    background-color: #e68a00;
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(255, 159, 28, 0.6);
}

.dark-mode .accessibility-btn:hover {
    background-color: #e68a00;
}

.accessibility-btn svg {
    width: 26px;
    height: 26px;
    fill: currentColor;
    opacity: 1;
}

@keyframes a11y-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(255, 159, 28, 0.7);
    }
    70% {
        box-shadow: 0 0 0 12px rgba(255, 159, 28, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(255, 159, 28, 0);
    }
}

.accessibility-menu {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 320px;
    max-width: calc(100vw - 24px);
    background-color: var(--bg-main, #ffffff);
    color: var(--text-main, #333333);
    border-radius: 12px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    padding: 15px;
    display: none; /* Hidden by default */
    flex-direction: column;
    gap: 10px;
    border: 1px solid var(--border-color, #eaeaea);
    z-index: 100000;
    box-sizing: border-box;
}

.accessibility-menu.active {
    display: flex;
    animation: fadeIn 0.3s ease;
}

.accessibility-menu h4 {
    margin: 0 0 10px 0;
    font-size: 16px;
    text-align: center;
    border-bottom: 1px solid var(--border-color, #eaeaea);
    padding-bottom: 8px;
    color: var(--text-main, #333);
}

.accessibility-option {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    font-size: 14px;
}

.accessibility-option label {
    cursor: pointer;
}

/* Toggle Switch Styles */
.a11y-toggle {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 20px;
}

.a11y-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.a11y-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 20px;
}

.a11y-slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .a11y-slider {
    background-color: var(--accent, #ff9f1c);
}

input:checked + .a11y-slider:before {
    transform: translateX(20px);
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* GLOBAL DYSLEXIC FONT */
body.dyslexic-mode, body.dyslexic-mode * {
    font-family: 'Comic Neue', 'Comic Sans MS', cursive, sans-serif !important;
}

/* Custom layout for a11y dropdown options and controls */
.accessibility-menu {
    width: 320px;
    max-width: calc(100vw - 24px);
    max-height: 450px;
    overflow-y: auto;
}

.a11y-select-control {
    width: 130px;
    padding: 5px 8px;
    border-radius: 6px;
    border: 1.5px solid var(--border-color, #eaeaea);
    font-size: 13px;
    font-family: inherit;
    background: var(--bg-main, #fff);
    color: var(--text-main, #333);
    outline: none;
    cursor: pointer;
}

.a11y-actions {
    display: flex;
    gap: 10px;
    margin-top: 15px;
    padding-top: 10px;
    border-top: 1px solid var(--border-color, #eaeaea);
}

.a11y-btn-save {
    flex: 1;
    background: var(--accent, #ff9f1c);
    color: #fff;
    border: none;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 700;
    font-size: 13px;
    transition: background 0.2s;
}

.a11y-btn-save:hover {
    background: #e68a00;
}

.a11y-btn-cancel {
    background: #dfe6e9;
    color: #2d3436;
    border: none;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 700;
    font-size: 13px;
    transition: background 0.2s;
}

.a11y-btn-cancel:hover {
    background: #b2bec3;
}

body.dark-mode .accessibility-menu {
    background-color: #131a26 !important;
    color: #f1f5f9 !important;
    border-color: #1e293b !important;
}

body.dark-mode .accessibility-menu h4,
body.dark-mode .a11y-actions {
    border-color: #1e293b !important;
}

body.dark-mode .a11y-select-control {
    background-color: #0b0f19 !important;
    color: #fff !important;
    border-color: #1e293b !important;
}

body.dark-mode .a11y-btn-cancel {
    background: #334155;
    color: #f1f5f9;
}

body.dark-mode .a11y-btn-cancel:hover {
    background: #475569;
}

/* HIGH CONTRAST MODE */
body.high-contrast {
    background: #000000 !important;
    background-color: #000000 !important;
    color: #ffff00 !important;
}

body.high-contrast main,
body.high-contrast header,
body.high-contrast footer {
    background-color: #000000 !important;
}

body.high-contrast .accessibility-menu {
    background-color: #000000 !important;
    border: 2px solid #ffff00 !important;
    color: #ffff00 !important;
    box-shadow: 0 0 20px rgba(255, 255, 0, 0.4) !important;
}

body.high-contrast .accessibility-menu h4 {
    color: #ffff00 !important;
    border-bottom: 2px solid #ffff00 !important;
}

body.high-contrast .accessibility-option label {
    color: #ffff00 !important;
}

body.high-contrast .a11y-select-control {
    background-color: #000000 !important;
    color: #ffff00 !important;
    border: 2px solid #ffff00 !important;
}

body.high-contrast .a11y-slider {
    background-color: #222222 !important;
    border: 1px solid #ffff00 !important;
}

body.high-contrast input:checked + .a11y-slider {
    background-color: #ffff00 !important;
}

body.high-contrast input:checked + .a11y-slider:before {
    background-color: #000000 !important;
}

body.high-contrast input:not(:checked) + .a11y-slider:before {
    background-color: #ffff00 !important;
}

body.high-contrast .card,
body.high-contrast .hero-section,
body.high-contrast .faq-item,
body.high-contrast .support-form,
body.high-contrast .contact-info-card,
body.high-contrast .section-card,
body.high-contrast .perfil-card,
body.high-contrast .thread-card,
body.high-contrast .thread-card-detail,
body.high-contrast .comment-card,
body.high-contrast .danger-zone,
body.high-contrast .auth-card,
body.high-contrast .beto-hero,
body.high-contrast .wiki-hero,
body.high-contrast .stat,
body.high-contrast .skin-card,
body.high-contrast .mvv-card,
body.high-contrast .history-card,
body.high-contrast .team-card,
body.high-contrast .music-player-card,
body.high-contrast .problem-stat,
body.high-contrast .nivel,
body.high-contrast .level-item,
body.high-contrast .soporte-card,
body.high-contrast .islas,
body.high-contrast .custom-list li {
    background-color: #0c0c0c !important;
    border: 2px solid #ffff00 !important;
    color: #ffff00 !important;
    box-shadow: none !important;
}

body.high-contrast h1,
body.high-contrast h2,
body.high-contrast h3,
body.high-contrast h4,
body.high-contrast h5,
body.high-contrast h6 {
    color: #ffffff !important;
    border-color: #ffff00 !important;
}

body.high-contrast p,
body.high-contrast span:not(.a11y-slider):not(.level-num),
body.high-contrast strong,
body.high-contrast b,
body.high-contrast li,
body.high-contrast label,
body.high-contrast td,
body.high-contrast th,
body.high-contrast i {
    color: #ffff00 !important;
}

body.high-contrast a:not(.btn):not(.main-nav a):not(.dropdown-item):not(.perfil-nav a) {
    color: #00ffff !important;
    text-decoration: underline !important;
}

body.high-contrast .btn-primary {
    background-color: #ffff00 !important;
    color: #000000 !important;
    border: 2px solid #ffff00 !important;
    font-weight: 900 !important;
}

body.high-contrast .btn-primary:hover {
    background-color: #ffe600 !important;
    box-shadow: 0 0 15px rgba(255, 255, 0, 0.6) !important;
}

body.high-contrast .btn-secondary,
body.high-contrast .btn-outline {
    background-color: #000000 !important;
    color: #ffff00 !important;
    border: 2px solid #ffff00 !important;
}

body.high-contrast .btn-secondary:hover,
body.high-contrast .btn-outline:hover {
    background-color: #ffff00 !important;
    color: #000000 !important;
}

body.high-contrast .main-nav {
    background-color: #000000 !important;
    border: 2px solid #ffff00 !important;
}

body.high-contrast .main-nav a {
    color: #ffff00 !important;
}

body.high-contrast .main-nav a:hover,
body.high-contrast .main-nav a.active {
    background-color: #ffff00 !important;
    color: #000000 !important;
    font-weight: 800 !important;
}

body.high-contrast input:not(#lexica-chat-input),
body.high-contrast select,
body.high-contrast textarea:not(#lexica-chat-widget textarea) {
    background-color: #000000 !important;
    color: #ffff00 !important;
    border: 2px solid #ffff00 !important;
}

body.high-contrast footer {
    border-top: 2px solid #ffff00 !important;
}

body.high-contrast img:not(#lexica-chat-widget img) {
    filter: contrast(1.2) brightness(0.9);
}

/* Responsive Adjustments for Accessibility Widget */
@media (max-width: 768px) {
    .accessibility-widget {
        margin-right: 0 !important;
        flex-shrink: 0 !important;
    }

    .accessibility-btn {
        width: 40px !important;
        height: 40px !important;
        flex-shrink: 0 !important;
    }

    .accessibility-btn svg {
        width: 20px !important;
        height: 20px !important;
    }

    .accessibility-menu {
        position: fixed !important;
        top: 70px !important;
        right: 14px !important;
        left: auto !important;
        width: min(320px, calc(100vw - 28px)) !important;
        max-width: calc(100vw - 28px) !important;
        max-height: calc(100vh - 85px) !important;
        overflow-y: auto !important;
        box-sizing: border-box !important;
        z-index: 100000 !important;
    }
}

@media (max-width: 480px) {
    .accessibility-widget {
        margin-right: 0 !important;
        flex-shrink: 0 !important;
    }

    .accessibility-btn {
        width: 36px !important;
        height: 36px !important;
        padding: 0 !important;
        flex-shrink: 0 !important;
    }

    .accessibility-btn svg {
        width: 18px !important;
        height: 18px !important;
    }

    .accessibility-menu {
        position: fixed !important;
        top: 58px !important;
        left: 8px !important;
        right: 8px !important;
        width: auto !important;
        max-width: none !important;
        max-height: calc(100vh - 70px) !important;
        overflow-y: auto !important;
        box-sizing: border-box !important;
        padding: 12px 10px !important;
        z-index: 100000 !important;
    }

    .accessibility-menu h4 {
        font-size: 14px;
        margin-bottom: 6px;
        padding-bottom: 6px;
    }

    .accessibility-option {
        padding: 6px 0;
        font-size: 13px;
    }

    .a11y-select-control {
        max-width: 46%;
        min-width: 90px;
        font-size: 12px;
        padding: 4px 6px;
    }

    .a11y-actions {
        margin-top: 8px;
        padding-top: 8px;
        gap: 6px;
    }

    .a11y-btn-save,
    .a11y-btn-cancel {
        padding: 6px 8px;
        font-size: 12px;
    }
}

@media (max-width: 360px) {
    .accessibility-menu {
        left: 4px !important;
        right: 4px !important;
        padding: 10px 8px !important;
    }

    .accessibility-option {
        font-size: 12px;
    }

    .a11y-select-control {
        max-width: 44%;
        min-width: 80px;
        font-size: 11px;
    }
}
