/**
 * Estilos da Barra de Acessibilidade Avançada
 * IPDSA Core Plugin
 * @since 1.5.0
 */

/* ============================================
   CONTROLES INLINE PARA HEADER (SHORTCODE)
   ============================================ */

.ipdsa-accessibility-inline-controls {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    padding: 0;
}

.ipdsa-a11y-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 6px 10px;
    margin: 0;
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 4px;
    color: #005d86;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
    line-height: 1;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.ipdsa-a11y-btn:hover {
    background: #f5f5f5;
    border-color: rgba(0, 0, 0, 0.2);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

.ipdsa-a11y-btn:focus {
    outline: 2px solid #f89b1e;
    outline-offset: 2px;
}

.ipdsa-a11y-btn:active {
    transform: scale(0.96);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Botão A+ - maior */
.ipdsa-a11y-increase {
    font-size: 17px;
}

/* Botão A- - menor */
.ipdsa-a11y-decrease {
    font-size: 13px;
}

/* Botão A (reset) - tamanho padrão */
.ipdsa-a11y-reset {
    font-size: 15px;
}

/* Botão de contraste */
.ipdsa-a11y-contrast {
    padding: 8px 10px;
    min-width: 38px;
}

.ipdsa-a11y-contrast svg {
    display: block;
    width: 20px;
    height: 20px;
}

.ipdsa-a11y-contrast[aria-pressed="true"] {
    background: #000000;
    border-color: #000000;
    color: #ffffff;
}

/* ============================================
   MODO DE ESCALA DE FONTE - SOBRESCREVE TODOS OS TAMANHOS
   ============================================ */

/*
 * Quando a escala está ativa, força todos os elementos com font-size
 * definido em pixels a recalcularem baseado na escala do root
 */

/* Força elementos inline e de bloco a respeitarem a escala */
.ipdsa-font-scaled body,
.ipdsa-font-scaled body * {
    /* Remove font-size fixo em pixels e força uso de valores relativos */
}

/* Força todos os elementos com classes específicas a escalarem */
.ipdsa-font-scaled .noticia-titulo,
.ipdsa-font-scaled .noticia-link,
.ipdsa-font-scaled .destaque-resumo,
.ipdsa-font-scaled .servico-titulo,
.ipdsa-font-scaled h1,
.ipdsa-font-scaled h2,
.ipdsa-font-scaled h3,
.ipdsa-font-scaled h4,
.ipdsa-font-scaled h5,
.ipdsa-font-scaled h6,
.ipdsa-font-scaled p,
.ipdsa-font-scaled a,
.ipdsa-font-scaled span,
.ipdsa-font-scaled div,
.ipdsa-font-scaled li,
.ipdsa-font-scaled button,
.ipdsa-font-scaled input,
.ipdsa-font-scaled textarea,
.ipdsa-font-scaled label,
.ipdsa-font-scaled td,
.ipdsa-font-scaled th {
    /* Nenhum estilo aqui - o JavaScript aplica zoom no html que escala tudo */
}

/* ============================================
   VARIÁVEIS CSS PARA MODO DE ALTO CONTRASTE
   ============================================ */

:root {
    --ipdsa-a11y-primary: #005d86;
    --ipdsa-a11y-accent: #f89b1e;
    --ipdsa-a11y-bg: #ffffff;
    --ipdsa-a11y-text: #333333;
    --ipdsa-a11y-border: #dddddd;
    --ipdsa-a11y-shadow: rgba(0, 0, 0, 0.15);
}

/* ============================================
   MODO DE ALTO CONTRASTE
   ============================================ */

.ipdsa-high-contrast-mode {
    --ipdsa-a11y-primary: #000000;
    --ipdsa-a11y-accent: #000000;
    --ipdsa-a11y-bg: #FFFFFF;
    --ipdsa-a11y-text: #000000;
    --ipdsa-a11y-border: #000000;
    --ipdsa-a11y-shadow: rgba(0, 0, 0, 0.5);
}

.ipdsa-high-contrast-mode body {
    background: #FFFFFF !important;
    color: #000000 !important;
}

.ipdsa-high-contrast-mode a {
    color: #0000EE !important;
    text-decoration: underline !important;
}

.ipdsa-high-contrast-mode a:visited {
    color: #551A8B !important;
}

.ipdsa-high-contrast-mode button,
.ipdsa-high-contrast-mode input,
.ipdsa-high-contrast-mode select,
.ipdsa-high-contrast-mode textarea {
    border: 2px solid #000000 !important;
    background: #FFFFFF !important;
    color: #000000 !important;
}

.ipdsa-high-contrast-mode h1,
.ipdsa-high-contrast-mode h2,
.ipdsa-high-contrast-mode h3,
.ipdsa-high-contrast-mode h4,
.ipdsa-high-contrast-mode h5,
.ipdsa-high-contrast-mode h6 {
    color: #000000 !important;
}

.ipdsa-high-contrast-mode p,
.ipdsa-high-contrast-mode li,
.ipdsa-high-contrast-mode span,
.ipdsa-high-contrast-mode div {
    color: #000000 !important;
}

.ipdsa-high-contrast-mode img {
    filter: contrast(1.2) brightness(1.1);
}

/* ============================================
   CONTAINER PRINCIPAL DA BARRA
   ============================================ */

.ipdsa-accessibility-toolbar {
    position: fixed;
    top: 50%;
    right: 0;
    transform: translateY(-50%);
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

/* ============================================
   BOTÃO DE TOGGLE (VISÍVEL POR PADRÃO)
   ============================================ */

.ipdsa-accessibility-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--ipdsa-a11y-primary);
    color: #ffffff;
    border: none;
    border-radius: 8px 0 0 8px;
    cursor: pointer;
    box-shadow: -2px 2px 8px var(--ipdsa-a11y-shadow);
    transition: all 0.3s ease;
    font-size: 14px;
    font-weight: 600;
    min-height: 48px;
}

.ipdsa-accessibility-toggle:hover {
    background: var(--ipdsa-a11y-accent);
    transform: translateX(-4px);
}

.ipdsa-accessibility-toggle:focus {
    outline: 3px solid var(--ipdsa-a11y-accent);
    outline-offset: 2px;
}

.ipdsa-accessibility-toggle svg {
    flex-shrink: 0;
}

.ipdsa-accessibility-toggle-text {
    white-space: nowrap;
}

/* ============================================
   PAINEL DE CONTROLES
   ============================================ */

.ipdsa-accessibility-panel {
    position: absolute;
    top: 0;
    right: 100%;
    width: 320px;
    max-height: 90vh;
    background: var(--ipdsa-a11y-bg);
    border: 2px solid var(--ipdsa-a11y-border);
    border-radius: 8px;
    box-shadow: -4px 0 16px var(--ipdsa-a11y-shadow);
    opacity: 0;
    visibility: hidden;
    transform: translateX(20px);
    transition: all 0.3s ease;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.ipdsa-accessibility-toolbar.open .ipdsa-accessibility-panel {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
}

/* ============================================
   HEADER DO PAINEL
   ============================================ */

.ipdsa-accessibility-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: var(--ipdsa-a11y-primary);
    color: #ffffff;
    border-bottom: 2px solid var(--ipdsa-a11y-border);
}

.ipdsa-accessibility-title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #ffffff;
}

.ipdsa-accessibility-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    background: transparent;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    color: #ffffff;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ipdsa-accessibility-close:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.6);
}

.ipdsa-accessibility-close:focus {
    outline: 2px solid #ffffff;
    outline-offset: 2px;
}

/* ============================================
   CONTEÚDO DO PAINEL
   ============================================ */

.ipdsa-accessibility-content {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}

/* ============================================
   GRUPOS DE CONTROLES
   ============================================ */

.ipdsa-accessibility-group {
    margin-bottom: 24px;
}

.ipdsa-accessibility-group:last-child {
    margin-bottom: 0;
}

.ipdsa-accessibility-label {
    display: block;
    margin-bottom: 12px;
    font-size: 13px;
    font-weight: 600;
    color: var(--ipdsa-a11y-text);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ============================================
   CONTROLES DE FONTE
   ============================================ */

.ipdsa-accessibility-font-controls {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.ipdsa-accessibility-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 10px 16px;
    background: #ffffff;
    border: 2px solid var(--ipdsa-a11y-border);
    border-radius: 6px;
    color: var(--ipdsa-a11y-text);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ipdsa-accessibility-btn:hover {
    background: var(--ipdsa-a11y-primary);
    border-color: var(--ipdsa-a11y-primary);
    color: #ffffff;
}

.ipdsa-accessibility-btn:focus {
    outline: 3px solid var(--ipdsa-a11y-accent);
    outline-offset: 2px;
}

.ipdsa-accessibility-btn.active {
    background: var(--ipdsa-a11y-primary);
    border-color: var(--ipdsa-a11y-primary);
    color: #ffffff;
}

.ipdsa-accessibility-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.ipdsa-accessibility-btn.disabled:hover {
    background: #ffffff;
    border-color: var(--ipdsa-a11y-border);
    color: var(--ipdsa-a11y-text);
}

/* Botões de fonte com tamanhos diferentes */
.ipdsa-btn-font-decrease .ipdsa-btn-text {
    font-size: 12px;
}

.ipdsa-btn-font-reset .ipdsa-btn-text {
    font-size: 14px;
}

.ipdsa-btn-font-increase .ipdsa-btn-text {
    font-size: 16px;
}

/* ============================================
   INDICADOR DE ESCALA DE FONTE
   ============================================ */

.ipdsa-font-scale-indicator {
    text-align: center;
    padding: 8px;
    background: #f5f5f5;
    border-radius: 4px;
    font-size: 12px;
    color: #666;
}

.ipdsa-scale-value {
    font-weight: 600;
    color: var(--ipdsa-a11y-primary);
}

/* ============================================
   BOTÕES DE BLOCO (LARGURA TOTAL)
   ============================================ */

.ipdsa-btn-block {
    width: 100%;
}

.ipdsa-btn-contrast {
    background: #ffffff;
}

.ipdsa-btn-contrast.active {
    background: #000000;
    border-color: #000000;
    color: #ffffff;
}

.ipdsa-btn-reset {
    background: #f5f5f5;
    border-color: #cccccc;
    color: #666666;
}

.ipdsa-btn-reset:hover {
    background: #e74c3c;
    border-color: #e74c3c;
    color: #ffffff;
}

/* ============================================
   SCREEN READER ONLY
   ============================================ */

.ipdsa-accessibility-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;
}

/* ============================================
   SUPORTE A PREFERÊNCIAS DO SISTEMA
   ============================================ */

@media (prefers-reduced-motion: reduce) {
    .ipdsa-accessibility-toolbar,
    .ipdsa-accessibility-toggle,
    .ipdsa-accessibility-panel,
    .ipdsa-accessibility-btn {
        transition: none;
        animation: none;
    }
}

/* ============================================
   RESPONSIVIDADE - TABLET
   ============================================ */

@media (max-width: 991px) {
    .ipdsa-accessibility-toolbar {
        top: auto;
        bottom: 20px;
        right: 20px;
        transform: none;
    }

    .ipdsa-accessibility-panel {
        bottom: 100%;
        top: auto;
        right: 0;
        margin-bottom: 12px;
    }

    .ipdsa-accessibility-toolbar.open .ipdsa-accessibility-panel {
        transform: translateY(0);
    }
}

/* ============================================
   RESPONSIVIDADE - MOBILE
   ============================================ */

@media (max-width: 767px) {
    .ipdsa-accessibility-toolbar {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
    }

    .ipdsa-accessibility-toggle {
        width: 100%;
        justify-content: center;
        border-radius: 0;
        padding: 14px 20px;
    }

    .ipdsa-accessibility-panel {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        top: auto;
        width: 100%;
        max-height: 80vh;
        border-radius: 16px 16px 0 0;
        transform: translateY(100%);
        margin: 0;
    }

    .ipdsa-accessibility-toolbar.open .ipdsa-accessibility-panel {
        transform: translateY(0);
    }

    .ipdsa-accessibility-content {
        max-height: calc(80vh - 64px);
    }

    .ipdsa-accessibility-font-controls {
        flex-direction: row;
    }

    .ipdsa-accessibility-btn {
        min-height: 48px;
    }
}

@media (max-width: 480px) {
    .ipdsa-accessibility-toggle-text {
        font-size: 12px;
    }

    .ipdsa-accessibility-panel {
        max-height: 90vh;
    }

    .ipdsa-accessibility-content {
        padding: 16px;
        max-height: calc(90vh - 64px);
    }

    .ipdsa-accessibility-group {
        margin-bottom: 20px;
    }
}

/* ============================================
   MODO DE ALTO CONTRASTE - AJUSTES NA BARRA
   ============================================ */

.ipdsa-high-contrast-mode .ipdsa-accessibility-toolbar {
    border: 3px solid #000000;
}

.ipdsa-high-contrast-mode .ipdsa-accessibility-toggle {
    background: #000000 !important;
    color: #FFFFFF !important;
    border: 2px solid #FFFFFF !important;
}

.ipdsa-high-contrast-mode .ipdsa-accessibility-panel {
    background: #FFFFFF !important;
    border: 3px solid #000000 !important;
}

.ipdsa-high-contrast-mode .ipdsa-accessibility-header {
    background: #000000 !important;
    color: #FFFFFF !important;
    border-bottom: 3px solid #000000 !important;
}

.ipdsa-high-contrast-mode .ipdsa-accessibility-btn {
    background: #FFFFFF !important;
    border: 2px solid #000000 !important;
    color: #000000 !important;
}

.ipdsa-high-contrast-mode .ipdsa-accessibility-btn:hover,
.ipdsa-high-contrast-mode .ipdsa-accessibility-btn.active {
    background: #000000 !important;
    color: #FFFFFF !important;
}

.ipdsa-high-contrast-mode .ipdsa-font-scale-indicator {
    background: #EFEFEF !important;
    border: 2px solid #000000 !important;
    color: #000000 !important;
}

/* ============================================
   ANIMAÇÕES SUTIS
   ============================================ */

@keyframes ipdsa-fade-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ipdsa-accessibility-toolbar.open .ipdsa-accessibility-group {
    animation: ipdsa-fade-in 0.3s ease forwards;
}

.ipdsa-accessibility-toolbar.open .ipdsa-accessibility-group:nth-child(1) {
    animation-delay: 0.05s;
}

.ipdsa-accessibility-toolbar.open .ipdsa-accessibility-group:nth-child(2) {
    animation-delay: 0.1s;
}

.ipdsa-accessibility-toolbar.open .ipdsa-accessibility-group:nth-child(3) {
    animation-delay: 0.15s;
}

/* Desabilita animações se usuário preferir movimento reduzido */
@media (prefers-reduced-motion: reduce) {
    .ipdsa-accessibility-toolbar.open .ipdsa-accessibility-group {
        animation: none;
    }
}
