/* ============================================
   Sistema de Agendamento SEE-PB
   Acessibilidade - Lei nº 13146 (LBI)
   WCAG 2.1 AA Compliance
   ============================================ */

/* ============================================
   Skip Links - Navegacao por Teclado
   ============================================ */
.skip-link {
    position: absolute;
    top: -100px;
    left: 0;
    background: #1e40af;
    color: #ffffff;
    padding: 12px 24px;
    z-index: 9999;
    font-weight: 600;
    text-decoration: none;
    border-radius: 0 0 8px 0;
    transition: top 0.3s ease;
}

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

/* ============================================
   Correcoes de Contraste - WCAG 2.1 AA
   Minimo 4.5:1 para texto normal
   Minimo 3:1 para texto grande (18px+ ou 14px bold)
   ============================================ */

/* text-gray-400 em dark mode: #9ca3af sobre #171717 = 4.04:1 (FALHA)
   Corrigido para text-gray-300: #d1d5db sobre #171717 = 8.59:1 (OK) */
.dark .text-gray-400,
.dark .dark\:text-gray-400 {
    color: #d1d5db !important; /* gray-300 */
}

/* text-gray-500 em dark mode: #6b7280 sobre #171717 = 2.77:1 (FALHA)
   Corrigido para: #9ca3af sobre #171717 = 4.04:1 -> usar #a1a1aa = 4.52:1 */
.dark .text-gray-500,
.dark .dark\:text-gray-500 {
    color: #a1a1aa !important; /* zinc-400 */
}

/* text-indigo-200/300 em dark mode - baixo contraste */
.dark .text-indigo-200 {
    color: #c7d2fe !important; /* indigo-200 OK */
}

.dark .text-indigo-300 {
    color: #a5b4fc !important; /* indigo-300 - verificar contexto */
}

/* Textos em backgrounds claros (light mode) */
.text-gray-400 {
    color: #6b7280 !important; /* gray-500 para melhor contraste */
}

/* ============================================
   Placeholders - Contraste melhorado
   ============================================ */
.dark ::placeholder {
    color: #a1a1aa !important;
    opacity: 1;
}

::placeholder {
    color: #6b7280 !important;
    opacity: 1;
}

/* ============================================
   Labels e Textos de Ajuda
   ============================================ */
.dark .fi-fo-field-wrp-helper-text,
.dark .fi-input-wrp-label {
    color: #d1d5db !important;
}

.dark .fi-sidebar-group-label {
    color: #d1d5db !important;
}

/* ============================================
   Links - Contraste e Identificacao
   Sublinhado apenas em links dentro de texto corrido
   ============================================ */
a {
    text-decoration-skip-ink: auto;
}

/* Links dentro de paragrafos e conteudo editorial */
p a,
.prose a,
.content a,
article p a {
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
}

p a:hover,
.prose a:hover,
.content a:hover,
article p a:hover {
    text-decoration-thickness: 2px;
}

/* ============================================
   Focus Visible - Indicadores claros
   ============================================ */
*:focus-visible {
    outline: 3px solid #6366f1 !important;
    outline-offset: 2px !important;
}

.dark *:focus-visible {
    outline-color: #818cf8 !important;
}

/* Botoes com focus mais visivel */
button:focus-visible,
[role="button"]:focus-visible,
input[type="submit"]:focus-visible,
input[type="button"]:focus-visible {
    outline: 3px solid #6366f1 !important;
    outline-offset: 2px !important;
    box-shadow: 0 0 0 6px rgba(99, 102, 241, 0.25) !important;
}

/* ============================================
   Tabelas - Melhorias de acessibilidade
   ============================================ */
.dark .fi-ta-header-cell {
    color: #e5e7eb !important; /* gray-200 */
}

.dark .fi-ta-cell {
    color: #f3f4f6 !important; /* gray-100 */
}

/* ============================================
   Formularios - Mensagens de erro
   ============================================ */
.fi-fo-field-wrp-error-message {
    color: #dc2626 !important; /* red-600 - alto contraste */
    font-weight: 500;
}

.dark .fi-fo-field-wrp-error-message {
    color: #f87171 !important; /* red-400 */
}

/* ============================================
   Badges e Status - Contraste garantido
   ============================================ */
.dark .text-green-300 {
    color: #86efac !important;
}

.dark .text-blue-300 {
    color: #93c5fd !important;
}

.dark .text-amber-200,
.dark .text-amber-300 {
    color: #fde68a !important;
}

.dark .text-amber-400 {
    color: #fbbf24 !important;
}

/* ============================================
   Modo Alto Contraste (Ativado via classe)
   ============================================ */
.high-contrast {
    --contrast-text: #000000;
    --contrast-bg: #ffffff;
    --contrast-border: #000000;
    --contrast-link: #0000ee;
    --contrast-focus: #ff6600;
}

.high-contrast.dark {
    --contrast-text: #ffffff;
    --contrast-bg: #000000;
    --contrast-border: #ffffff;
    --contrast-link: #ffff00;
    --contrast-focus: #00ffff;
}

.high-contrast * {
    border-color: var(--contrast-border) !important;
}

.high-contrast body,
.high-contrast .fi-body {
    background: var(--contrast-bg) !important;
    color: var(--contrast-text) !important;
}

.high-contrast a {
    color: var(--contrast-link) !important;
}

.high-contrast *:focus-visible {
    outline-color: var(--contrast-focus) !important;
    outline-width: 4px !important;
}

.high-contrast .fi-section,
.high-contrast .fi-card {
    background: var(--contrast-bg) !important;
    border: 2px solid var(--contrast-border) !important;
}

.high-contrast button,
.high-contrast .fi-btn {
    border: 2px solid var(--contrast-border) !important;
}

/* ============================================
   Tamanho de Fonte Ajustavel
   ============================================ */
.font-size-large {
    font-size: 112.5% !important; /* 18px base */
}

.font-size-larger {
    font-size: 125% !important; /* 20px base */
}

.font-size-largest {
    font-size: 150% !important; /* 24px base */
}

/* ============================================
   Reducao de Movimento (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;
    }
}

/* Classe para desativar animacoes manualmente */
.reduce-motion *,
.reduce-motion *::before,
.reduce-motion *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
}

/* ============================================
   Imagens e Midias
   ============================================ */
img:not([alt]) {
    outline: 4px dashed #dc2626 !important;
}

/* ============================================
   Espacamento para Legibilidade
   ============================================ */
.increased-spacing {
    letter-spacing: 0.05em;
    word-spacing: 0.1em;
    line-height: 1.8;
}

.increased-spacing p,
.increased-spacing li {
    margin-bottom: 1.5em;
}

/* ============================================
   Cursor para elementos interativos
   ============================================ */
button,
[role="button"],
a,
input[type="submit"],
input[type="button"],
input[type="checkbox"],
input[type="radio"],
select,
label[for] {
    cursor: pointer;
}

button:disabled,
[aria-disabled="true"] {
    cursor: not-allowed;
}

/* ============================================
   Correcoes especificas do projeto
   ============================================ */

/* Dashboard - texto de estatisticas */
.dark .text-sm.text-gray-400 {
    color: #d1d5db !important;
}

/* Sidebar - textos de grupos */
.dark .fi-sidebar-group-label {
    color: #d1d5db !important;
}

/* Icones em sidebar */
.dark .fi-sidebar-group-icon,
.dark .fi-sidebar-item-icon {
    color: #a1a1aa !important;
}

.dark .fi-sidebar-item:hover .fi-sidebar-item-icon,
.dark .fi-sidebar-item.fi-active .fi-sidebar-item-icon {
    color: #ffffff !important;
}

/* Calendario - legenda */
.dark .text-xs.text-white {
    color: #ffffff !important;
}

/* User menu */
.dark .fi-user-menu .text-gray-400 {
    color: #d1d5db !important;
}

/* Global search placeholder */
.dark .fi-global-search-no-results-message {
    color: #d1d5db !important;
}

/* Header subheading */
.dark .fi-header-subheading {
    color: #d1d5db !important;
}

/* Modal e formularios */
.dark .fi-modal .text-gray-400,
.dark .fi-modal .text-gray-500 {
    color: #d1d5db !important;
}

/* Topbar items inativos */
.dark .fi-topbar-item:not(.fi-active) {
    color: #d1d5db !important;
}

/* Breadcrumbs */
.dark .fi-breadcrumbs-item {
    color: #a1a1aa !important;
}

.dark .fi-breadcrumbs-item:hover {
    color: #ffffff !important;
}

/* ============================================
   Painel de Acessibilidade (Widget Flutuante)
   ============================================ */
.accessibility-panel {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 9998;
}

.accessibility-toggle {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4f46e5, #6366f1);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(79, 70, 229, 0.4);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.accessibility-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(79, 70, 229, 0.5);
}

.accessibility-toggle:focus-visible {
    outline: 3px solid #fbbf24;
    outline-offset: 3px;
}

.accessibility-toggle svg {
    width: 28px;
    height: 28px;
}

.accessibility-menu {
    position: absolute;
    bottom: 70px;
    left: 0;
    background: white;
    border-radius: 16px;
    padding: 16px;
    min-width: 280px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    display: none;
}

.accessibility-menu.active {
    display: block;
}

.dark .accessibility-menu {
    background: #262626;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.accessibility-menu h3 {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 16px;
    color: #1f2937;
}

.dark .accessibility-menu h3 {
    color: #f3f4f6;
}

.accessibility-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    border-radius: 10px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.accessibility-option:hover {
    background: #f3f4f6;
}

.dark .accessibility-option:hover {
    background: rgba(255, 255, 255, 0.1);
}

.accessibility-option label {
    font-size: 0.875rem;
    font-weight: 500;
    color: #374151;
    cursor: pointer;
}

.dark .accessibility-option label {
    color: #e5e7eb;
}

.accessibility-option input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: #6366f1;
}

/* ============================================
   Anuncio para Leitores de Tela
   ============================================ */
.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;
}

.sr-only-focusable:focus {
    position: static;
    width: auto;
    height: auto;
    padding: inherit;
    margin: inherit;
    overflow: visible;
    clip: auto;
    white-space: normal;
}

/* Live region para anuncios */
[role="status"],
[role="alert"],
[aria-live] {
    position: relative;
}
