/**
 * Estilos de Acessibilidade - WCAG 2.1 AA
 * Twins Sports - E-commerce
 * 
 * Garante contraste adequado e elementos acessíveis
 */

/* ============================================
   CORES ACESSÍVEIS (WCAG 2.1 AA)
   ============================================ */

:root {
    /* Cores Primárias */
    --color-primary: #dc2626;
    --color-primary-hover: #b91c1c;
    --color-primary-dark: #991b1b;
    
    /* Backgrounds */
    --bg-dark: #0a0a0a;
    --bg-card: #1a1a1a;
    --bg-input: #0a0a0a;
    --bg-hover: #111111;
    
    /* Textos (contraste garantido) */
    --text-primary: #ffffff;      /* 21:1 com #0a0a0a */
    --text-secondary: #e5e5e5;    /* 18:1 com #0a0a0a */
    --text-muted: #a3a3a3;        /* 7.5:1 com #0a0a0a */
    --text-disabled: #666666;     /* 4.8:1 com #0a0a0a */
    
    /* Estados */
    --color-success: #22c55e;     /* 4.8:1 com #0a0a0a */
    --color-success-bg: rgba(34, 197, 94, 0.15);
    --color-error: #ef4444;       /* 5.2:1 com #0a0a0a */
    --color-error-bg: rgba(239, 68, 68, 0.15);
    --color-warning: #f59e0b;      /* 4.9:1 com #0a0a0a */
    --color-warning-bg: rgba(245, 158, 11, 0.15);
    --color-info: #3b82f6;        /* 5.1:1 com #0a0a0a */
    --color-info-bg: rgba(59, 130, 246, 0.15);
    
    /* Bordas */
    --border-default: #333333;    /* 3.2:1 com #0a0a0a */
    --border-focus: #dc2626;
    --border-error: #ef4444;
    
    /* Links */
    --link-color: #dc2626;
    --link-hover: #b91c1c;
}

/* ============================================
   ELEMENTOS DE FORMULÁRIO ACESSÍVEIS
   ============================================ */

/* Labels obrigatórios */
label {
    color: var(--text-primary);
    font-weight: 600;
    display: block;
    margin-bottom: 8px;
}

label .required {
    color: var(--color-error);
    margin-left: 4px;
    font-weight: 700;
}

/* Inputs acessíveis */
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="time"],
textarea,
select {
    background: var(--bg-input);
    border: 2px solid var(--border-default);
    color: var(--text-primary);
    padding: 12px 15px;
    border-radius: 8px;
    font-size: 1em;
    font-family: inherit;
    width: 100%;
    transition: all 0.3s ease;
}

input:focus,
textarea:focus,
select:focus {
    outline: 3px solid var(--border-focus);
    outline-offset: 2px;
    border-color: var(--border-focus);
    background: var(--bg-hover);
}

input:invalid:not(:focus):not(:placeholder-shown),
textarea:invalid:not(:focus):not(:placeholder-shown) {
    border-color: var(--border-error);
}

input[aria-invalid="true"],
textarea[aria-invalid="true"] {
    border-color: var(--border-error);
    background: var(--color-error-bg);
}

/* Placeholders acessíveis */
input::placeholder,
textarea::placeholder {
    color: var(--text-muted);
    opacity: 1;
}

/* Mensagens de erro */
.form-error {
    color: var(--color-error);
    font-size: 0.9em;
    margin-top: 8px;
    display: block;
    font-weight: 500;
}

.form-error::before {
    content: '⚠ ';
    margin-right: 4px;
}

/* Mensagens de sucesso */
.form-success {
    color: var(--color-success);
    font-size: 0.9em;
    margin-top: 8px;
    display: block;
    font-weight: 500;
}

.form-success::before {
    content: '✓ ';
    margin-right: 4px;
}

/* Botões acessíveis */
button,
.btn-primary,
.btn-secondary,
a[role="button"] {
    min-height: 44px;
    min-width: 44px;
    padding: 12px 24px;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
    border: 2px solid transparent;
}

button:focus-visible,
.btn-primary:focus-visible,
.btn-secondary:focus-visible,
a[role="button"]:focus-visible {
    outline: 3px solid var(--border-focus);
    outline-offset: 3px;
}

/* Botão primário */
.btn-primary,
button[type="submit"] {
    background: var(--color-primary);
    color: var(--text-primary);
    border-color: var(--color-primary);
}

.btn-primary:hover:not(:disabled),
button[type="submit"]:hover:not(:disabled) {
    background: var(--color-primary-hover);
    border-color: var(--color-primary-hover);
}

.btn-primary:disabled,
button[type="submit"]:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Botão secundário */
.btn-secondary {
    background: transparent;
    color: var(--text-primary);
    border-color: var(--border-default);
}

.btn-secondary:hover:not(:disabled) {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

/* Links acessíveis */
a {
    color: var(--link-color);
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 3px;
    transition: all 0.2s ease;
}

a:hover,
a:focus {
    color: var(--link-hover);
    text-decoration-thickness: 3px;
}

a:focus-visible {
    outline: 3px solid var(--border-focus);
    outline-offset: 3px;
    border-radius: 4px;
}

/* ============================================
   MENSAGENS FLASH ACESSÍVEIS
   ============================================ */

.flash-message[role="alert"],
.flash-message[role="status"] {
    position: relative;
    padding-left: 45px;
}

.flash-message[role="alert"]::before,
.flash-message[role="status"]::before {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.2em;
    font-weight: 900;
}

.flash-success[role="status"]::before {
    content: '✓';
}

.flash-error[role="alert"]::before {
    content: '✗';
}

.flash-warning[role="alert"]::before {
    content: '⚠';
}

.flash-info[role="status"]::before {
    content: 'ℹ';
}

/* ============================================
   TABS E NAVEGAÇÃO ACESSÍVEIS
   ============================================ */

[role="tablist"] {
    display: flex;
    gap: 10px;
    border-bottom: 2px solid var(--border-default);
    margin-bottom: 20px;
}

[role="tab"] {
    padding: 12px 20px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    transition: all 0.3s ease;
}

[role="tab"]:hover {
    color: var(--text-primary);
}

[role="tab"][aria-selected="true"] {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
    font-weight: 700;
}

[role="tab"]:focus-visible {
    outline: 3px solid var(--border-focus);
    outline-offset: 3px;
    border-radius: 4px;
}

[role="tabpanel"] {
    padding: 20px 0;
}

[role="tabpanel"][aria-hidden="true"] {
    display: none;
}

/* ============================================
   DROPDOWNS E MENUS ACESSÍVEIS
   ============================================ */

[role="menu"],
[role="menubar"] {
    list-style: none;
    padding: 0;
    margin: 0;
}

[role="menuitem"] {
    padding: 12px 20px;
    color: var(--text-primary);
    cursor: pointer;
    display: block;
    text-decoration: none;
    transition: all 0.2s ease;
}

[role="menuitem"]:hover,
[role="menuitem"]:focus {
    background: var(--bg-hover);
    color: var(--color-primary);
}

[role="menuitem"]:focus-visible {
    outline: 3px solid var(--border-focus);
    outline-offset: -3px;
}

/* ============================================
   MODAIS ACESSÍVEIS
   ============================================ */

[role="dialog"] {
    background: var(--bg-card);
    border: 2px solid var(--border-default);
    border-radius: 12px;
    padding: 30px;
    max-width: 90vw;
    max-height: 90vh;
    overflow-y: auto;
}

[role="dialog"]:focus {
    outline: none;
}

[role="dialog"] [role="heading"] {
    margin-top: 0;
    margin-bottom: 20px;
}

/* Overlay de modal */
[role="dialog"]::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: -1;
}

/* ============================================
   SKIP LINKS
   ============================================ */

.skip-link {
    position: absolute;
    top: -100px;
    left: 0;
    background: var(--color-primary);
    color: var(--text-primary);
    padding: 12px 20px;
    text-decoration: none;
    z-index: 10000;
    font-weight: 700;
    border-radius: 0 0 8px 0;
}

.skip-link:focus {
    top: 0;
    outline: 3px solid var(--text-primary);
    outline-offset: 3px;
}

/* ============================================
   INDICADORES DE FOCO VISÍVEL
   ============================================ */

*:focus-visible {
    outline: 3px solid var(--border-focus);
    outline-offset: 2px;
    border-radius: 4px;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline-width: 3px;
    outline-style: solid;
    outline-color: var(--border-focus);
}

/* Remover outline padrão do navegador */
*:focus:not(:focus-visible) {
    outline: none;
}

/* ============================================
   TEXTO ALTERNATIVO PARA ÍCONES
   ============================================ */

.icon-only {
    position: relative;
}

.icon-only::after {
    content: attr(aria-label);
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* ============================================
   CONTRASTE DE CORES GARANTIDO
   ============================================ */

/* Texto sobre fundo escuro */
body,
.admin-body {
    background: var(--bg-dark);
    color: var(--text-primary);
}

/* Texto sobre cards */
.admin-card,
.checkout-card {
    background: var(--bg-card);
    color: var(--text-primary);
}

/* Texto muted */
.text-muted,
small,
.secondary-text {
    color: var(--text-muted);
}

/* Links sempre visíveis */
a {
    color: var(--link-color);
}

a:visited {
    color: var(--link-hover);
}

/* Botões com contraste garantido */
.btn-primary {
    background: var(--color-primary);
    color: var(--text-primary);
}

.btn-secondary {
    color: var(--text-primary);
    border-color: var(--border-default);
}

/* ============================================
   MELHORIAS DE LEITURA
   ============================================ */

/* Tamanho mínimo de fonte */
body {
    font-size: 16px;
    line-height: 1.6;
}

/* Espaçamento adequado */
p, li {
    margin-bottom: 1em;
}

/* Texto justificado não recomendado para acessibilidade */
p {
    text-align: left;
}

/* ============================================
   COMPATIBILIDADE COM LEITORES DE TELA
   ============================================ */

/* Esconder elementos decorativos */
.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;
}

/* Mostrar apenas para leitores de tela */
.sr-only-focusable:focus {
    position: static;
    width: auto;
    height: auto;
    padding: inherit;
    margin: inherit;
    overflow: visible;
    clip: auto;
    white-space: normal;
}

/* ============================================
   RESPONSIVIDADE E ACESSIBILIDADE
   ============================================ */

@media (max-width: 768px) {
    /* Áreas de toque maiores em mobile */
    button,
    a,
    input[type="checkbox"],
    input[type="radio"],
    label {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Texto legível em mobile */
    body {
        font-size: 16px; /* Não reduzir abaixo de 16px */
    }
}

/* ============================================
   ANIMAÇÕES E REDUÇÃO DE MOVIMENTO
   ============================================ */

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

/* ============================================
   ALTO CONTRASTE (OPCIONAL)
   ============================================ */

@media (prefers-contrast: high) {
    :root {
        --text-primary: #ffffff;
        --text-secondary: #ffffff;
        --border-default: #666666;
        --border-focus: #ffffff;
    }
    
    button,
    .btn-primary {
        border: 3px solid var(--text-primary);
    }
}

