/**
 * AllofPan Accessibility Plugin - Frontend CSS
 * Barra de accesibilidad flotante WCAG 2.1 AA
 *
 * Usa CSS Custom Properties (variables) para que los colores
 * sean configurables desde el panel de WordPress sin tocar este archivo.
 *
 * @package AllofPan_Accessibility
 * @version 1.0.0
 */

/* Fuente Montserrat desde Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700&display=swap');

/* ===================================
   1. VARIABLES / TOKENS DE DISEÑO
   =================================== */
:root {
    /* ---- Colores sólidos de marca P.A.N. Colombia ---- */
    --aop-bg: #02225A;
    /* Azul único PAN */
    --aop-bg-dark: #02225A;
    /* Mismo azul para cabecera/pie */
    --aop-bg-panel: #02225A;
    /* Panel principal */
    --aop-icon: #ffffff;
    /* Texto e iconos: blanco puro */
    --aop-accent: #FFB800;
    /* Amarillo dorado PAN */
    --aop-accent-text: #02225A;
    /* Texto oscuro sobre fondo amarillo */
    --aop-border: #02225A;
    /* Borde, mismo azul */
    --aop-shadow: 0 4px 16px rgba(2, 34, 90, 0.4);
    --aop-radius: 14px;
    --aop-radius-sm: 8px;
    --aop-transition: 0.22s cubic-bezier(0.4, 0, 0.2, 1);
    --aop-font: 'Montserrat', -apple-system, BlinkMacSystemFont, sans-serif;
    --aop-width: 268px;
    --aop-z: 99999;
}

/* ===================================
   2. SKIP LINK (WCAG 2.4.1)
   =================================== */
.aop-skip-link {
    position: absolute;
    top: -100px;
    left: 16px;
    z-index: calc(var(--aop-z) + 1);
    background: var(--aop-accent);
    color: #fff !important;
    font-family: var(--aop-font);
    font-size: 14px;
    font-weight: 600;
    padding: 10px 20px;
    border-radius: 0 0 var(--aop-radius-sm) var(--aop-radius-sm);
    text-decoration: none !important;
    transition: top var(--aop-transition);
    box-shadow: var(--aop-shadow);
}

.aop-skip-link:focus {
    top: 0;
    outline: 3px solid #fff;
    outline-offset: 2px;
}

/* ===================================
   3. BARRA PRINCIPAL FLOTANTE
   Fija en la esquina inferior, al mismo nivel que los widgets
   =================================== */
.aop-toolbar {
    position: fixed !important;
    bottom: 20px;
    /* Mismo nivel que el círculo amarillo */
    top: auto;
    transform: none;
    z-index: var(--aop-z);
    font-family: var(--aop-font);
    display: flex;
    align-items: center;
    gap: 0;
    pointer-events: auto;
}

.aop-toolbar--right {
    right: 20px;
    flex-direction: row-reverse;
}

.aop-toolbar--left {
    left: 12px;
    /* Pequeño margen del borde */
    flex-direction: row;
}

/* ===================================
   4. BOTÓN DE APERTURA (TOGGLE) - CIRCULAR
   =================================== */
.aop-toolbar__toggle {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    width: 52px;
    height: 52px;
    /* Igual al ancho = círculo perfecto */
    background: var(--aop-bg);
    color: var(--aop-icon);
    border: 2px solid #FFF;
    /* Borde completo en el círculo */
    cursor: pointer;
    border-radius: 50%;
    /* Siempre circular */
    box-shadow: var(--aop-shadow);
    transition: background var(--aop-transition), transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
    padding: 0;
    animation: aop-pulse 3s ease-in-out infinite;
    position: relative;
    overflow: visible;
}

/* Animación de pulso */
@keyframes aop-pulse {

    0%,
    100% {
        box-shadow: var(--aop-shadow);
    }

    50% {
        box-shadow: var(--aop-shadow), 0 0 0 5px rgba(255, 184, 0, 0.2);
    }
}

/* En ambos lados siempre es círculo */
.aop-toolbar--right .aop-toolbar__toggle,
.aop-toolbar--left .aop-toolbar__toggle {
    border-radius: 50%;
}

/* HOVER: amarillo sólido PAN, mantiene el círculo, sin sombra */
.aop-toolbar__toggle:hover {
    background: var(--aop-accent);
    /* Amarillo PAN */
    color: var(--aop-accent-text);
    /* Texto azul oscuro */
    border-radius: 50% !important;
    /* Sigue siendo círculo */
    transform: scale(1.12);
    box-shadow: none;
    animation: none;
    border-color: var(--aop-accent);
}

/* Hover igual en ambos lados */
.aop-toolbar--right .aop-toolbar__toggle:hover,
.aop-toolbar--left .aop-toolbar__toggle:hover {
    transform: scale(1.12);
    border-radius: 50% !important;
}

.aop-toolbar__toggle:focus-visible {
    outline: 3px solid var(--aop-accent);
    outline-offset: 3px;
}

/* El ícono SVG crece un poco al hacer hover */
.aop-toolbar__toggle svg {
    flex-shrink: 0;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), color 0.3s ease;
    color: #ffffff;
    /* Icono blanco en estado normal */
}

.aop-toolbar__toggle:hover svg {
    transform: scale(1.15) rotate(-5deg);
    color: var(--aop-accent-text);
    /* Icono oscuro sobre fondo amarillo */
}

/* ===================================
   5. PANEL DESPLEGABLE
   =================================== */
.aop-toolbar__panel {
    width: var(--aop-width);
    max-height: 90vh;
    overflow-y: auto;
    overflow-x: hidden;
    background: var(--aop-bg-panel);
    /* Azul sólido PAN */
    color: var(--aop-icon);
    border-radius: var(--aop-radius);
    box-shadow: var(--aop-shadow);
    border: 2px solid var(--aop-border);
    /* Borde sólido */
    padding: 0;
    animation: aop-slide-in var(--aop-transition) forwards;
    scrollbar-width: thin;
    scrollbar-color: var(--aop-accent) var(--aop-bg-dark);
}

.aop-toolbar--right .aop-toolbar__panel {
    margin-right: 8px;
    transform-origin: right center;
}

.aop-toolbar--left .aop-toolbar__panel {
    margin-left: 8px;
    transform-origin: left center;
}

@keyframes aop-slide-in {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.aop-toolbar__panel::-webkit-scrollbar {
    width: 4px;
}

.aop-toolbar__panel::-webkit-scrollbar-track {
    background: transparent;
}

.aop-toolbar__panel::-webkit-scrollbar-thumb {
    background: var(--aop-accent);
    border-radius: 4px;
}

/* Panel oculto */
.aop-toolbar__panel[hidden] {
    display: none !important;
}

/* ===================================
   6. CABECERA DEL PANEL
   =================================== */
.aop-toolbar__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px 12px;
    background: #02225A;
    /* Azul sólido */
    border-bottom: 2px solid var(--aop-accent);
    /* Línea amarilla separadora */
    position: sticky;
    top: 0;
}

.aop-toolbar__title {
    font-size: 16px;
    /* +2px */
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #ffffff;
    /* Blanco puro */
    opacity: 1;
}

.aop-toolbar__close {
    background: none;
    border: none;
    color: var(--aop-icon);
    font-size: 16px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--aop-radius-sm);
    opacity: 0.6;
    transition: opacity var(--aop-transition), background var(--aop-transition);
    line-height: 1;
}

.aop-toolbar__close:hover {
    opacity: 1;
    background: #FFB800;
    color: #02225A;
    border-radius: 4px;
}

.aop-toolbar__close:focus-visible {
    outline: 3px solid var(--aop-accent);
    outline-offset: 2px;
    opacity: 1;
}

/* ===================================
   7. SECCIONES INTERNAS
   =================================== */
.aop-section {
    padding: 14px 16px;
    border-bottom: 1px solid var(--aop-border);
}

.aop-section:last-of-type {
    border-bottom: none;
}

.aop-section__label {
    font-size: 13px;
    /* +2px (de 9px a 11px) */
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #ffffff;
    /* Blanco puro */
    opacity: 0.7;
    margin: 0 0 10px;
}

/* ===================================
   8. BOTONES DE ACCIÓN
   =================================== */
.aop-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: #02225A;
    /* Azul sólido */
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--aop-radius-sm);
    padding: 8px 12px;
    font-size: 13px;
    font-family: var(--aop-font);
    font-weight: 500;
    cursor: pointer;
    transition:
        background var(--aop-transition),
        border-color var(--aop-transition),
        border-radius 0.25s ease,
        color var(--aop-transition),
        transform var(--aop-transition);
    white-space: nowrap;
}

/* Hover: amarillo sólido, sin sombra */
.aop-btn:hover {
    background: var(--aop-accent);
    /* Amarillo PAN */
    border-color: var(--aop-accent);
    border-radius: 20px;
    color: var(--aop-accent-text);
    /* Texto azul sobre amarillo */
    box-shadow: none;
    transform: translateY(-1px);
}

.aop-btn:focus-visible {
    outline: 3px solid var(--aop-accent);
    outline-offset: 2px;
    border-radius: 20px;
}

.aop-btn:active {
    transform: scale(0.97) translateY(0);
    border-radius: var(--aop-radius-sm);
}

/* Estado activo: amarillo con texto azul */
.aop-btn--active,
.aop-btn[aria-pressed="true"],
.aop-btn[aria-checked="true"] {
    background: var(--aop-accent) !important;
    border-color: var(--aop-accent) !important;
    color: var(--aop-accent-text) !important;
}

/* ===================================
   9. GRUPO DE BOTONES (CONTRASTE)
   =================================== */
.aop-btn-group {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.aop-btn-group .aop-btn {
    flex: 1;
    flex-direction: column;
    gap: 4px;
    padding: 10px 6px;
    font-size: 11px;
    min-width: 0;
}

/* ===================================
   10. CONTROLES DE FUENTE
   =================================== */
.aop-font-controls {
    display: flex;
    align-items: center;
    gap: 6px;
}

.aop-btn--font {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    font-weight: 700;
    font-size: 14px;
}

.aop-font-indicator {
    flex: 1;
    text-align: center;
    font-size: 16px;
    /* +2px */
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: #ffffff;
    /* Blanco */
    min-width: 48px;
}

.aop-btn--reset-font {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    padding: 0;
    opacity: 0.6;
}

.aop-btn--reset-font:hover {
    opacity: 1;
}

/* ===================================
   11. BOTÓN TOGGLE (SWITCH)
   =================================== */
.aop-btn--toggle {
    width: 100%;
    justify-content: flex-start;
    padding: 10px 14px;
    gap: 10px;
}

.aop-btn__text {
    flex: 1;
    text-align: left;
    font-size: 13px;
    /* +2px */
    color: #ffffff;
    /* Blanco puro */
    font-weight: 500;
}

/* ===================================
   12. HINT TTS
   =================================== */
.aop-tts-hint {
    font-size: 11px;
    opacity: 0.6;
    margin: 8px 0 0;
    padding: 6px 10px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: var(--aop-radius-sm);
    border-left: 2px solid var(--aop-accent);
    line-height: 1.4;
}

/* ===================================
   13. PIE DEL PANEL
   =================================== */
.aop-toolbar__footer {
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.2);
    border-top: 1px solid var(--aop-border);
}

.aop-btn--reset-all {
    width: 100%;
    padding: 9px 14px;
    font-size: 12px;
    opacity: 0.7;
    background: transparent;
}

.aop-btn--reset-all:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.08);
}

/* ===================================
   14. SCREEN READER ONLY
   =================================== */
.aop-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* ===================================
   15. MODOS DE CONTRASTE
   =================================== */

/* MODO OSCURO
   - Se aplica a <html> para que la barra quede fuera del filtro.
   - Solo invert(1) SIN hue-rotate → evita el efecto marrón
     que causa hue-rotate en colores azul oscuro (#02225A).
   - Las imágenes y vídeos se re-invierten para verse naturales.
*/
html.aop-contrast--dark {
    filter: invert(1);
}

html.aop-contrast--dark img,
html.aop-contrast--dark video,
html.aop-contrast--dark iframe,
html.aop-contrast--dark canvas,
html.aop-contrast--dark svg image,
html.aop-contrast--dark [style*="background-image"] {
    filter: invert(1);
}

/* La barra de accesibilidad se auto-corrige para mantener
   sus colores propios (doble invert = sin efecto) */
html.aop-contrast--dark #aop-accessibility-toolbar {
    filter: invert(1);
}



/* ===================================
   16. SUBRAYADO DE ENLACES
   =================================== */
body.aop-underline-links a {
    text-decoration: underline !important;
    text-underline-offset: 3px !important;
    text-decoration-thickness: 2px !important;
}

/* ===================================
   17. RESALTE DE ENFOQUE MEJORADO
   =================================== */
body.aop-enhanced-focus *:focus,
body.aop-enhanced-focus *:focus-visible {
    outline: 3px solid var(--aop-accent) !important;
    outline-offset: 4px !important;
    border-radius: 3px;
    box-shadow: 0 0 0 6px var(--aop-accent-light) !important;
}

/* ===================================
   18. RESPONSIVE: OCULTAR EN MÓVIL
       si el panel se desborda
   =================================== */
@media (max-width: 360px) {
    .aop-toolbar__panel {
        --aop-width: 220px;
    }
}

/* ===================================
   19. REDUCCIÓN DE MOVIMIENTO
   =================================== */
@media (prefers-reduced-motion: reduce) {
    .aop-toolbar__panel {
        animation: none;
    }

    .aop-btn,
    .aop-toolbar__toggle {
        transition: none;
    }
}

/* ===================================
   OVERRIDES DE USUARIO
   Botón circular: borde completo alrededor
   =================================== */
.aop-toolbar__toggle {
    border: 2px solid #FFF !important;
    border-radius: 50% !important;
    width: 46px !important;
    height: 46px !important;
    left: 7px;
}

@keyframes aop-pulse {

    0%,
    50%,
    100% {
        box-shadow: none !important;
    }
}