/**
 * OriginStep Accessibility Styles
 * Enhances visual accessibility and screen reader support
 */

/* Skip link styles */
.skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    z-index: 9999;
    padding: 8px 16px;
    background: #000;
    color: #fff;
    text-decoration: none;
    border-radius: 4px;
    font-weight: bold;
    transition: top 0.3s;
}

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

/* Screen reader only content */
.sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

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

/* High contrast mode */
.high-contrast {
    filter: contrast(150%) brightness(110%);
}

.high-contrast .card {
    border: 2px solid #fff !important;
    background: #000 !important;
    color: #fff !important;
}

.high-contrast .btn {
    border: 2px solid #fff !important;
    font-weight: bold !important;
}

.high-contrast .text-muted {
    color: #ccc !important;
}

/* Focus indicators */
*:focus {
    outline: 3px solid #ffd700;
    outline-offset: 2px;
}

.btn:focus,
.form-control:focus,
.form-select:focus {
    box-shadow: 0 0 0 0.25rem rgba(255, 215, 0, 0.5);
    border-color: #ffd700;
}

/* Card accessibility enhancements */
.card[tabindex="0"]:hover,
.card[tabindex="0"]:focus {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
}

/* Button accessibility */
button:disabled,
.btn:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

/* Form accessibility */
.form-control:invalid {
    border-color: #dc3545;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' width='12' height='12' fill='none' stroke='%23dc3545'%3e%3ccircle cx='6' cy='6' r='4.5'/%3e%3cpath d='m5.8 3.6h.4L6 6.5z'/%3e%3ccircle cx='6' cy='8.2' r='.6' fill='%23dc3545' stroke='none'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right calc(0.375em + 0.1875rem) center;
    background-size: calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
}

.form-control:valid {
    border-color: #198754;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'%3e%3cpath fill='%23198754' d='m2.3 6.73.94-.94 1.46-1.46.94-.94L6.7 2.3 5.76 1.36 4.3 2.82l-.94.94-1.46 1.46L.9 6.22z'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right calc(0.375em + 0.1875rem) center;
    background-size: calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
}

/* Required field indicators */
.form-label[for] .required::after {
    content: " *";
    color: #dc3545;
    font-weight: bold;
}

/* Error message styles */
.invalid-feedback {
    display: block;
    width: 100%;
    margin-top: 0.25rem;
    font-size: 0.875em;
    color: #dc3545;
}

/* Loading indicators */
.loading {
    position: relative;
}

.loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #333;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Progress bar accessibility */
.progress {
    background-color: #e9ecef;
    border-radius: 0.375rem;
    height: 1rem;
    overflow: hidden;
}

.progress-bar {
    transition: width 0.6s ease;
    background-color: #0d6efd;
    color: #fff;
    text-align: center;
    white-space: nowrap;
    font-size: 0.75rem;
    line-height: 1rem;
}

/* Modal accessibility */
.modal-backdrop {
    background-color: rgba(0, 0, 0, 0.7);
}

.modal {
    outline: none;
}

.modal-dialog {
    margin: 1.75rem auto;
}

.modal-content {
    border: 2px solid #dee2e6;
    border-radius: 0.5rem;
}

/* Navigation accessibility */
.navbar-nav .nav-link:focus {
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 0.25rem;
}

/* Table accessibility */
.table th,
.table td {
    border-top: 1px solid #dee2e6;
    padding: 0.75rem;
    vertical-align: top;
}

.table thead th {
    border-bottom: 2px solid #dee2e6;
    font-weight: bold;
}

/* Responsive font sizes */
@media (max-width: 576px) {
    html {
        font-size: 14px;
    }
}

@media (max-width: 768px) {
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }
}

/* Print styles */
@media print {
    .skip-link,
    .navbar,
    .btn,
    #language-selector,
    [class*="position-fixed"] {
        display: none !important;
    }
    
    .card {
        border: 1px solid #000 !important;
        box-shadow: none !important;
    }
    
    a[href]:after {
        content: " (" attr(href) ")";
        font-size: 0.8em;
        color: #666;
    }
}

/* Reduced motion preferences */
@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;
    }
}

/* Color contrast improvements */
.text-muted {
    color: #8a8a8a !important;
}

.card-text,
.small {
    color: #666 !important;
}

/* Interactive element sizing for touch */
@media (max-width: 768px) {
    .btn {
        min-height: 44px;
        padding: 0.5rem 1rem;
    }
    
    .nav-link {
        min-height: 44px;
        display: flex;
        align-items: center;
        padding: 0.75rem 1rem;
    }
    
    .form-control,
    .form-select {
        min-height: 44px;
        padding: 0.75rem 0.75rem;
    }
}

/* Language direction support */
[dir="rtl"] {
    text-align: right;
}

[dir="rtl"] .me-1,
[dir="rtl"] .me-2,
[dir="rtl"] .me-3 {
    margin-right: 0;
    margin-left: 0.25rem;
}

[dir="rtl"] .ms-auto {
    margin-left: 0;
    margin-right: auto;
}

/* Dark mode accessibility improvements */
@media (prefers-color-scheme: dark) {
    .card {
        background-color: #343a40;
        border-color: #495057;
    }
    
    .text-muted {
        color: #adb5bd !important;
    }
}

/* Focus management for screen readers */
.visually-hidden-focusable:not(:focus):not(:focus-within) {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* Accessibility panel specific styles */
#accessibility-panel {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

#accessibility-panel .form-select,
#accessibility-panel .btn {
    font-size: 0.875rem;
}

#accessibility-panel .btn:focus {
    box-shadow: 0 0 0 2px #ffd700;
}

/* Smooth animations for panel content */
#accessibility-content {
    transition: all 0.3s ease;
}

/* High contrast mode enhancements for accessibility panel */
.high-contrast #accessibility-panel {
    background: #000 !important;
    border-color: #fff !important;
}

.high-contrast #accessibility-panel .text-light {
    color: #fff !important;
}

.high-contrast #accessibility-panel .btn-outline-warning,
.high-contrast #accessibility-panel .btn-outline-info {
    color: #fff !important;
    border-color: #fff !important;
}

.high-contrast #accessibility-panel .btn-outline-warning:hover,
.high-contrast #accessibility-panel .btn-outline-info:hover {
    background-color: #fff !important;
    color: #000 !important;
}

/* Panel header styling */
#accessibility-panel .btn-link {
    color: #ffd700 !important;
    text-decoration: none;
    font-weight: bold;
}