/* CSS Global de Accesibilidad Universal */

/* 1. Definición de Variables CSS de Accesibilidad por Defecto */
:root {
    --acc-font-size-multiplier: 1.0;
    --acc-letter-spacing: normal;
    --acc-word-spacing: normal;
    --acc-line-height: normal;
    --acc-font-family: inherit;
    --acc-filter: none;
    --acc-cursor: default;
}

/* 2. Temas de Accesibilidad */

/* Alto Contraste (Amarillo sobre Negro) */
:root[data-acc-theme="high-contrast"] {
    --acc-filter: none;
    background-color: #000000 !important;
    color: #ffff00 !important;
}
:root[data-acc-theme="high-contrast"] body,
:root[data-acc-theme="high-contrast"] div,
:root[data-acc-theme="high-contrast"] section,
:root[data-acc-theme="high-contrast"] header,
:root[data-acc-theme="high-contrast"] footer,
:root[data-acc-theme="high-contrast"] table,
:root[data-acc-theme="high-contrast"] tr,
:root[data-acc-theme="high-contrast"] td,
:root[data-acc-theme="high-contrast"] th,
:root[data-acc-theme="high-contrast"] h1,
:root[data-acc-theme="high-contrast"] h2,
:root[data-acc-theme="high-contrast"] h3,
:root[data-acc-theme="high-contrast"] h4,
:root[data-acc-theme="high-contrast"] h5,
:root[data-acc-theme="high-contrast"] h6,
:root[data-acc-theme="high-contrast"] p,
:root[data-acc-theme="high-contrast"] span,
:root[data-acc-theme="high-contrast"] a,
:root[data-acc-theme="high-contrast"] label,
:root[data-acc-theme="high-contrast"] input,
:root[data-acc-theme="high-contrast"] select,
:root[data-acc-theme="high-contrast"] textarea,
:root[data-acc-theme="high-contrast"] button,
:root[data-acc-theme="high-contrast"] li,
:root[data-acc-theme="high-contrast"] i {
    background-color: #000000 !important;
    color: #ffff00 !important;
    border-color: #ffff00 !important;
    text-shadow: none !important;
    box-shadow: none !important;
}
:root[data-acc-theme="high-contrast"] a:hover,
:root[data-acc-theme="high-contrast"] button:hover {
    background-color: #ffff00 !important;
    color: #000000 !important;
    text-decoration: underline !important;
}

/* Monocromático (Escala de Grises) */
:root[data-acc-theme="monochrome"] {
    --acc-filter: grayscale(100%) !important;
}
:root[data-acc-theme="monochrome"] body {
    filter: var(--acc-filter);
}

/* Colores Invertidos */
:root[data-acc-theme="inverted"] {
    --acc-filter: invert(100%) hue-rotate(180deg) !important;
}
:root[data-acc-theme="inverted"] body {
    filter: var(--acc-filter);
}
/* Evitar invertir imágenes, videos o mapas */
:root[data-acc-theme="inverted"] img,
:root[data-acc-theme="inverted"] video,
:root[data-acc-theme="inverted"] iframe,
:root[data-acc-theme="inverted"] .gmnoprint,
:root[data-acc-theme="inverted"] [style*="background-image"] {
    filter: invert(100%) hue-rotate(180deg) !important;
}

/* Contraste Suave / Filtro de Lectura Cálido (Cataratas/Fatiga Visual) */
:root[data-acc-theme="warm"] {
    --acc-filter: sepia(50%) contrast(110%) brightness(95%) !important;
}
:root[data-acc-theme="warm"] body {
    filter: var(--acc-filter);
}

/* Protanopía (Filtro Rojo-Verde Dalónico) */
:root[data-acc-theme="protanopia"] {
    filter: url('#protanopia-filter') !important;
}

/* 3. Modificaciones de Tipografía y Espaciado */
body.acc-dyslexic-font {
    --acc-font-family: 'OpenDyslexic', 'Comic Sans MS', sans-serif !important;
    font-family: var(--acc-font-family) !important;
}

body.acc-custom-spacing {
    --acc-letter-spacing: 0.12em !important;
    --acc-word-spacing: 0.16em !important;
    --acc-line-height: 1.8 !important;
}

body.acc-custom-spacing *,
body.acc-dyslexic-font * {
    font-family: var(--acc-font-family);
    letter-spacing: var(--acc-letter-spacing);
    word-spacing: var(--acc-word-spacing);
    line-height: var(--acc-line-height);
}

/* Escala de texto */
body.acc-text-zoom-110 { --acc-font-size-multiplier: 1.1; }
body.acc-text-zoom-120 { --acc-font-size-multiplier: 1.2; }
body.acc-text-zoom-130 { --acc-font-size-multiplier: 1.3; }
body.acc-text-zoom-140 { --acc-font-size-multiplier: 1.4; }
body.acc-text-zoom-150 { --acc-font-size-multiplier: 1.5; }

body[class*="acc-text-zoom-"] {
    font-size: calc(1rem * var(--acc-font-size-multiplier)) !important;
}
body[class*="acc-text-zoom-"] h1 { font-size: calc(2.5rem * var(--acc-font-size-multiplier)) !important; }
body[class*="acc-text-zoom-"] h2 { font-size: calc(2rem * var(--acc-font-size-multiplier)) !important; }
body[class*="acc-text-zoom-"] h3 { font-size: calc(1.75rem * var(--acc-font-size-multiplier)) !important; }
body[class*="acc-text-zoom-"] p, 
body[class*="acc-text-zoom-"] span, 
body[class*="acc-text-zoom-"] label,
body[class*="acc-text-zoom-"] input,
body[class*="acc-text-zoom-"] td,
body[class*="acc-text-zoom-"] th,
body[class*="acc-text-zoom-"] a,
body[class*="acc-text-zoom-"] li {
    font-size: calc(1rem * var(--acc-font-size-multiplier)) !important;
}

/* 4. Foco Visual de Navegación Mejorado */
:root[data-acc-focus-ring="enhanced"] *:focus {
    outline: 4px solid #f29c12 !important;
    outline-offset: 4px !important;
    box-shadow: 0 0 0 8px rgba(242, 156, 18, 0.4) !important;
    z-index: 99999 !important;
}

/* Cursor Grande */
body.acc-large-cursor {
    --acc-cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 48 48"><polygon points="0,0 32,22 18,24 28,42 22,44 12,28 4,32" fill="white" stroke="black" stroke-width="3"/></svg>'), auto !important;
    cursor: var(--acc-cursor) !important;
}
body.acc-large-cursor a,
body.acc-large-cursor button,
body.acc-large-cursor select,
body.acc-large-cursor input,
body.acc-large-cursor [role="button"] {
    cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 48 48"><polygon points="0,0 32,22 18,24 28,42 22,44 12,28 4,32" fill="%23FFCC00" stroke="black" stroke-width="3"/></svg>'), pointer !important;
}

/* Desactivar Animaciones */
:root[data-acc-animations="disabled"] *,
:root[data-acc-animations="disabled"] *::before,
:root[data-acc-animations="disabled"] *::after {
    animation-duration: 0.001s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001s !important;
    scroll-behavior: auto !important;
}

/* 5. Utilidades y Widgets de Lectura (TDAH y Concentración) */

/* Regla de lectura */
.acc-reading-ruler {
    position: fixed;
    left: 0;
    width: 100%;
    height: 40px;
    background-color: rgba(255, 235, 59, 0.25);
    border-top: 2px solid #fbc02d;
    border-bottom: 2px solid #fbc02d;
    pointer-events: none;
    z-index: 999998;
    display: none;
    transform: translateY(-50%);
}

/* Máscara de lectura */
.acc-reading-mask-top,
.acc-reading-mask-bottom {
    position: fixed;
    left: 0;
    width: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    pointer-events: none;
    z-index: 999997;
    display: none;
}
.acc-reading-mask-top {
    top: 0;
}
.acc-reading-mask-bottom {
    bottom: 0;
}

/* Alerta Visual de Pantalla (Destello) */
.acc-screen-flash {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(180, 20, 20, 0.35);
    pointer-events: none;
    z-index: 999999;
    animation: flashAnimation 0.6s ease-out 2;
}

@keyframes flashAnimation {
    0% { opacity: 0; }
    50% { opacity: 1; }
    100% { opacity: 0; }
}

/* Clase de simplificación para ocultar distractores */
.acc-simplified-mode .app-menu,
.acc-simplified-mode header #page-header-search-dropdown,
.acc-simplified-mode .fade-logo-container,
.acc-simplified-mode .breadcrumb-item,
.acc-simplified-mode footer {
    display: none !important;
}
.acc-simplified-mode .main-content {
    margin-left: 0 !important;
    padding: 20px !important;
}

/* 6. Widget Flotante de Accesibilidad Universal */
.acc-widget-trigger {
    position: fixed;
    bottom: 120px;
    right: 25px;
    width: 65px;
    height: 65px;
    border-radius: 50%;
    background: linear-gradient(135deg, #761c3f, #A0354A);
    color: #ffffff;
    border: 2px solid #ffffff;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    z-index: 999995;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 30px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.acc-widget-trigger:hover,
.acc-widget-trigger:focus {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
    outline: none;
}

/* Panel Desplizable de Accesibilidad */
.acc-panel {
    position: fixed;
    top: 0;
    right: -420px;
    width: 400px;
    height: 100vh;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(10px);
    box-shadow: -5px 0 25px rgba(0, 0, 0, 0.25);
    z-index: 999996;
    transition: right 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
    color: #333333;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    border-left: 1px solid rgba(0, 0, 0, 0.1);
}

.acc-panel.open {
    right: 0;
}

.acc-panel-header {
    background-color: #761c3f;
    color: #ffffff;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #A0354A;
}

.acc-panel-header h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #ffffff !important;
}

.acc-close-btn {
    background: none;
    border: none;
    color: #ffffff;
    font-size: 24px;
    cursor: pointer;
}

.acc-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.acc-section-title {
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #761c3f;
    margin-top: 15px;
    margin-bottom: 10px;
    border-bottom: 1px solid rgba(118, 28, 63, 0.2);
    padding-bottom: 4px;
}

/* Tarjetas de Perfiles de Discapacidad */
.acc-profiles-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}

.acc-profile-card {
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    padding: 12px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.acc-profile-card i {
    font-size: 22px;
    color: #b38e5d;
}

.acc-profile-card span {
    font-size: 12px;
    font-weight: 600;
    color: #555555;
}

.acc-profile-card:hover {
    border-color: #761c3f;
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
}

.acc-profile-card.active {
    background: rgba(118, 28, 63, 0.05);
    border-color: #761c3f;
}

.acc-profile-card.active i {
    color: #761c3f;
}

/* Interruptores y Ajustes */
.acc-setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.acc-setting-label {
    font-size: 13.5px;
    font-weight: 500;
    color: #444444;
}

.acc-setting-control {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Selectores de Opciones Múltiples */
.acc-options-group {
    display: flex;
    background: #eeeeee;
    border-radius: 6px;
    padding: 2px;
    width: 100%;
    margin-top: 5px;
}

.acc-option-btn {
    flex: 1;
    background: none;
    border: none;
    padding: 6px 4px;
    font-size: 11px;
    font-weight: 600;
    color: #666666;
    border-radius: 4px;
    cursor: pointer;
    text-align: center;
}

.acc-option-btn.active {
    background: #ffffff;
    color: #761c3f;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.10);
}

/* Botones del Panel */
.acc-panel-footer {
    padding: 20px;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    display: flex;
    gap: 10px;
}

.acc-btn {
    flex: 1;
    padding: 10px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    text-align: center;
}

.acc-btn-reset {
    background-color: #e0e0e0;
    color: #444444;
}

.acc-btn-reset:hover {
    background-color: #d0d0d0;
}

.acc-btn-save {
    background-color: #761c3f;
    color: #ffffff;
}

.acc-btn-save:hover {
    background-color: #611532;
}

/* Ocultar elementos visualmente para lectores de pantalla */
.acc-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
