/**
 * Accessibility - WCAG 2.1 AA Compliance
 * Focus states, keyboard navigation, screen readers
 */

/* ============================================ */
/* KEYBOARD NAVIGATION - FOCUS VISIBLE */
/* ============================================ */

/* Focus visible para todos os elementos interativos */
*:focus-visible {
    outline: 3px solid #fbbf24;
    outline-offset: 3px;
    border-radius: 4px;
}

/* Botões - focus destacado */
.btn:focus-visible,
button:focus-visible {
    outline: 3px solid #fbbf24;
    outline-offset: 4px;
    box-shadow: 0 0 0 6px rgba(251, 191, 36, 0.2);
}

/* Links - focus com underline */
a:focus-visible {
    outline: 2px solid #fbbf24;
    outline-offset: 2px;
    text-decoration: underline;
}

/* Inputs e selects - focus com borda */
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 3px solid #5f249f;
    outline-offset: 2px;
    border-color: #5f249f;
}

/* ============================================ */
/* SKIP TO CONTENT */
/* ============================================ */

.skip-to-content {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translate(-50%, -150%);
    background: var(--primary);
    color: white;
    padding: 16px 32px;
    text-decoration: none;
    z-index: 10000;
    font-weight: 700;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s ease;
    text-align: center;
    font-size: 1rem;
    white-space: nowrap;
}

.skip-to-content:focus {
    transform: translate(-50%, 0);
    outline: 3px solid #fbbf24;
    outline-offset: 3px;
}

/* ============================================ */
/* MINIMUM TOUCH TARGET SIZE (44x44px) */
/* ============================================ */

@media (max-width: 768px) {
    .btn,
    button,
    a.btn,
    input[type="submit"],
    input[type="button"] {
        min-height: 44px;
        min-width: 44px;
        padding: 12px 20px;
    }

    /* Links no texto - área clicável maior */
    a:not(.btn) {
        display: inline-block;
        padding: 4px 0;
    }
}

/* ============================================ */
/* PREFERS REDUCED MOTION */
/* ============================================ */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ============================================ */
/* SCREEN READER ONLY */
/* ============================================ */

.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;
}

/* ============================================ */
/* HIGH CONTRAST MODE */
/* ============================================ */

@media (prefers-contrast: high) {
    /* Aumentar contraste de botões */
    .btn-primary {
        background: #000000;
        color: #ffffff;
        border: 2px solid #ffffff;
    }

    .btn-secondary {
        background: #ffffff;
        color: #000000;
        border: 2px solid #000000;
    }

    /* Bordas mais visíveis */
    input,
    select,
    textarea {
        border: 2px solid #000000;
    }

    /* Links mais visíveis */
    a {
        text-decoration: underline;
        font-weight: 700;
    }
}

/* ============================================ */
/* ARIA LIVE REGIONS */
/* ============================================ */

[aria-live="polite"],
[aria-live="assertive"] {
    position: relative;
}

/* Indicador visual para status messages */
[role="status"],
[role="alert"] {
    padding: 16px;
    border-radius: 8px;
    margin: 16px 0;
}

[role="status"] {
    background: rgba(16, 185, 129, 0.1);
    border-left: 4px solid #10b981;
}

[role="alert"] {
    background: rgba(239, 68, 68, 0.1);
    border-left: 4px solid #ef4444;
}

/* ============================================ */
/* FOCUS TRAP (para modals) */
/* ============================================ */

.modal:focus-within {
    outline: none;
}

.modal-content:focus {
    outline: 3px solid #fbbf24;
    outline-offset: -3px;
}

/* ============================================ */
/* ACCESSIBLE COLORS - WCAG AA */
/* ============================================ */

/* Garantir contraste mínimo 4.5:1 */
.text-light-on-dark {
    color: #ffffff;
    background: #1f2937; /* 15.5:1 ratio */
}

.text-dark-on-light {
    color: #1f2937;
    background: #ffffff; /* 15.5:1 ratio */
}

/* Links com contraste suficiente */
a.link-light {
    color: #fbbf24; /* 1.9:1 on white - needs dark background */
}

a.link-dark {
    color: #5f249f; /* 6.7:1 on white - PASS */
}

/* ============================================ */
/* ERROR STATES ACESSÍVEIS */
/* ============================================ */

.input-error {
    border: 2px solid #ef4444 !important;
    background: rgba(239, 68, 68, 0.05);
}

.input-error:focus-visible {
    outline-color: #ef4444;
}

.error-message {
    color: #dc2626;
    font-size: 0.875rem;
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.error-message::before {
    content: "⚠";
    font-size: 1rem;
}

/* ============================================ */
/* LOADING STATES ACESSÍVEIS */
/* ============================================ */

.loading {
    position: relative;
    pointer-events: none;
    opacity: 0.6;
}

.loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 3px solid #5f249f;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============================================ */
/* TOOLTIPS ACESSÍVEIS */
/* ============================================ */

[data-tooltip] {
    position: relative;
}

[data-tooltip]:hover::after,
[data-tooltip]:focus-visible::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 8px 12px;
    background: #1f2937;
    color: white;
    font-size: 0.875rem;
    border-radius: 6px;
    white-space: nowrap;
    margin-bottom: 8px;
    z-index: 1000;
}

[data-tooltip]:hover::before,
[data-tooltip]:focus-visible::before {
    content: "";
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: #1f2937;
    margin-bottom: 2px;
}
