/**
 * PTNG Accessibility Styles
 * Enhanced accessibility styles for better keyboard navigation and screen reader support
 * Version 1.0.0
 */

/* Skip link for keyboard users */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--bs-primary);
    color: white;
    padding: 8px;
    z-index: 9999;
    transition: top 0.3s;
}

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

/* Enhanced focus styles for keyboard navigation */
body.keyboard-user :focus {
    outline: 3px solid var(--bs-primary) !important;
    outline-offset: 3px !important;
    box-shadow: none !important;
}

body.keyboard-user .btn:focus,
body.keyboard-user .nav-link:focus {
    outline: 3px solid var(--bs-primary) !important;
    outline-offset: 3px !important;
    box-shadow: none !important;
}

/* Ensure color contrast in dark mode */
body.dark-mode .form-control:focus {
    border-color: #7eb4ff;
    box-shadow: 0 0 0 0.25rem rgba(126, 180, 255, 0.25);
}

body.dark-mode .form-check-input:checked {
    background-color: #4d94ff;
    border-color: #4d94ff;
}

/* Screen reader only class */
.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;
}

/* Make the aria-live region available to screen readers but hidden visually */
#aria-live-region {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Ensure form validation messages are accessible */
.was-validated .form-control:invalid:focus,
.form-control.is-invalid:focus {
    border-color: #dc3545;
    box-shadow: 0 0 0 0.25rem rgba(220, 53, 69, 0.25);
}

.was-validated .form-control:valid:focus,
.form-control.is-valid:focus {
    border-color: #198754;
    box-shadow: 0 0 0 0.25rem rgba(25, 135, 84, 0.25);
}

/* High contrast focus indicators for dark mode */
body.dark-mode.keyboard-user :focus {
    outline-color: #ffcc00 !important;
}

/* Make sure disabled buttons have sufficient contrast */
.btn:disabled,
.btn.disabled {
    opacity: 0.65;
}

body.dark-mode .btn:disabled,
body.dark-mode .btn.disabled {
    background-color: #444;
    border-color: #555;
    color: #aaa;
}

/* Ensure contrast ratios on all text elements */
body.dark-mode {
    --accessible-text-color: #f0f0f0;
    --accessible-muted-color: #c0c0c0;
}

body.dark-mode .text-muted {
    color: var(--accessible-muted-color) !important;
}

/* Enhanced focus for tab navigation */
.focus-visible {
    outline: 3px solid var(--bs-primary);
    outline-offset: 3px;
}

/* Ensure sufficient spacing for touch targets */
.nav-link,
.btn {
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Improve table accessibility */
.table {
    caption-side: top;
}

.table caption {
    padding: 0.5rem;
    font-weight: bold;
    color: inherit;
}

/* Ensure modal focus handling */
.modal-dialog:focus {
    outline: none;
}

/* Links should be underlined for accessibility */
main a:not(.btn):not(.nav-link) {
    text-decoration: underline;
}

main a:not(.btn):not(.nav-link):hover {
    text-decoration: none;
}

/* Improve form control accessibility */
.form-control::placeholder {
    opacity: 0.7;
}

body.dark-mode .form-control::placeholder {
    color: #aaa;
}

/* Ensure form field groups have proper spacing */
.form-group,
.mb-3 {
    margin-bottom: 1.5rem !important;
}

/* Improve contrast of input fields in dark mode */
body.dark-mode .form-control,
body.dark-mode .form-select {
    background-color: #333;
    border-color: #555;
    color: #fff;
}

body.dark-mode .form-control:focus,
body.dark-mode .form-select:focus {
    background-color: #3a3a3a;
}
