/**
 * ACCESSIBILITY IMPROVEMENTS - PROLEITE AGRO
 * Melhorias de acessibilidade seguindo WCAG 2.1 AA
 */

/* Skip Links */
.skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: #0e602f;
    color: white;
    padding: 8px;
    text-decoration: none;
    border-radius: 4px;
    z-index: 10000;
    font-weight: 600;
    transition: top 0.3s ease;
}

.skip-link:focus {
    top: 6px;
    outline: 3px solid #F3B007;
    outline-offset: 2px;
}

/* Screen Reader Only Content */
.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;
}

/* Focus Indicators - Melhorados */
*:focus {
    outline: 3px solid #F3B007;
    outline-offset: 2px;
    transition: outline 0.2s ease;
}

/* Focus visível para elementos interativos */
button:focus,
a:focus,
input:focus,
select:focus,
textarea:focus,
[tabindex]:focus {
    outline: 3px solid #F3B007;
    outline-offset: 2px;
    box-shadow: 0 0 0 6px rgba(243, 176, 7, 0.2);
}

/* Remover outline padrão mas manter para teclado */
button:focus:not(:focus-visible) {
    outline: none;
    box-shadow: none;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 3px solid #F3B007;
    outline-offset: 2px;
    box-shadow: 0 0 0 6px rgba(243, 176, 7, 0.2);
}

/* Melhor contraste para texto */
.low-contrast {
    color: #555555; /* Melhor que #777 */
}

/* Estados de botões mais acessíveis */
button[aria-pressed="true"] {
    background-color: #0e602f;
    color: white;
    border: 2px solid #F3B007;
}

button[aria-pressed="false"] {
    background-color: transparent;
    color: #0e602f;
    border: 2px solid #0e602f;
}

/* Indicadores visuais para estados */
[aria-expanded="true"]::after {
    content: " (expandido)";
    color: #0e602f;
    font-size: 0.8em;
}

[aria-expanded="false"]::after {
    content: " (recolhido)";
    color: #666;
    font-size: 0.8em;
}

/* Melhorar contraste de links */
a {
    color: #0e602f;
    text-decoration: underline;
}

a:hover,
a:focus {
    color: #F3B007;
    text-decoration: underline;
    text-decoration-thickness: 2px;
}

/* Estados de loading acessíveis */
.loading::after {
    content: "Carregando...";
    position: absolute;
    left: -9999px;
}

/* Melhor indicação de elementos obrigatórios */
[aria-required="true"]::after,
.required::after {
    content: " *";
    color: #d32f2f;
    font-weight: bold;
}

/* Indicadores de erro mais visíveis */
[aria-invalid="true"] {
    border: 2px solid #d32f2f !important;
    background-color: #ffeaea;
}

.error-message {
    color: #d32f2f;
    font-size: 0.9em;
    margin-top: 4px;
    display: flex;
    align-items: center;
}

.error-message::before {
    content: "⚠️";
    margin-right: 4px;
}

/* Melhor feedback para formulários */
.success-message {
    color: #0e602f;
    font-size: 0.9em;
    margin-top: 4px;
    display: flex;
    align-items: center;
}

.success-message::before {
    content: "✅";
    margin-right: 4px;
}

/* Navegação por teclado melhorada */
.keyboard-navigation {
    border: 2px dashed #F3B007;
    background-color: rgba(243, 176, 7, 0.1);
}

/* Indicador de página atual na navegação */
[aria-current="page"] {
    background-color: #0e602f;
    color: white;
    font-weight: bold;
}

/* Melhor contraste para botões secundários */
.btn-outline,
.btn-secondary {
    border: 2px solid #0e602f;
    color: #0e602f;
    background-color: white;
}

.btn-outline:hover,
.btn-secondary:hover {
    background-color: #0e602f;
    color: white;
}

/* Tooltips acessíveis */
[title]:hover::after {
    content: attr(title);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    z-index: 1000;
}

/* Melhor indicação de links externos */
a[target="_blank"]::after {
    content: " (abre em nova aba)";
    font-size: 0.8em;
    color: #666;
}

/* Remove indicação de nova aba para o link do Patrick Lima */
a[href*="patricklima_dev"]::after {
    content: none;
}

/* Indicadores de progresso acessíveis */
.progress-bar {
    background-color: #f0f0f0;
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.progress-fill {
    background-color: #0e602f;
    height: 100%;
    transition: width 0.3s ease;
}

.progress-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #333;
    font-weight: bold;
    mix-blend-mode: difference;
}

/* Melhorar acessibilidade de modais */
.modal[aria-hidden="true"] {
    display: none;
}

.modal[aria-hidden="false"] {
    display: flex;
}

/* Foco dentro de modais */
.modal-content:focus {
    outline: none;
}

/* Texto mais legível */
.text-small {
    font-size: 0.9em;
    line-height: 1.5;
}

/* Espaçamento melhorado para touch */
.touch-target {
    min-height: 44px;
    min-width: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Indicadores de estado para elementos interativos */
.interactive-element {
    cursor: pointer;
    transition: all 0.2s ease;
}

.interactive-element:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.interactive-element:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Responsividade para texto */
@media (max-width: 768px) {
    .skip-link {
        font-size: 16px;
        padding: 12px;
    }
    
    /* Aumentar área de toque em mobile */
    .touch-target {
        min-height: 48px;
        min-width: 48px;
    }
    
    /* Melhor contraste em telas pequenas */
    body {
        font-size: 16px;
        line-height: 1.6;
    }
}

/* Modo escuro acessível */
@media (prefers-color-scheme: dark) {
    .auto-dark {
        background-color: #1a1a1a;
        color: #ffffff;
    }
    
    .auto-dark a {
        color: #66bb6a;
    }
    
    .auto-dark button {
        background-color: #333;
        color: white;
        border-color: #66bb6a;
    }
}

/* Redução de movimento para usuários sensíveis */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Alto contraste */
@media (prefers-contrast: high) {
    * {
        border-color: #000 !important;
    }
    
    a {
        text-decoration: underline !important;
        text-decoration-thickness: 2px !important;
    }
    
    button {
        border: 3px solid #000 !important;
    }
}
