/*
 * Accessibility CSS for PrayReps
 * 
 * Provides styles for accessibility features including:
 * - Skip links
 * - Screen reader only content
 * - Focus indicators
 * - High contrast support
 * - RTL language support
 */

/* Skip Links */
.skip-links {
    position: absolute;
    top: -40px;
    left: 6px;
    z-index: 1000;
}

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

.skip-link:focus {
    top: 0;
}

/* 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:focus,
.sr-only-focusable:active {
    position: static !important;
    width: auto !important;
    height: auto !important;
    padding: inherit !important;
    margin: inherit !important;
    overflow: visible !important;
    clip: auto !important;
    white-space: normal !important;
}

.visually-hidden-focusable {
    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;
}

.visually-hidden-focusable:focus {
    position: static !important;
    width: auto !important;
    height: auto !important;
    padding: 0.25rem 0.5rem !important;
    margin: inherit !important;
    overflow: visible !important;
    clip: auto !important;
    white-space: normal !important;
    background-color: #007bff !important;
    color: #fff !important;
    text-decoration: none !important;
    border-radius: 0.25rem !important;
}

/* Enhanced Focus Indicators */
.focus-visible,
*:focus-visible {
    outline: 2px solid #007bff !important;
    outline-offset: 2px !important;
    box-shadow: 0 0 0 4px rgba(0, 123, 255, 0.25) !important;
}

/* Remove default focus outline for mouse users */
*:focus:not(:focus-visible) {
    outline: none !important;
    box-shadow: none !important;
}

/* Enhanced focus for interactive elements */
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
    outline: 2px solid #007bff !important;
    outline-offset: 2px !important;
    box-shadow: 0 0 0 4px rgba(0, 123, 255, 0.25) !important;
}

/* Focus for custom interactive elements */
.btn:focus-visible,
.form-control:focus-visible,
.form-select:focus-visible {
    border-color: #007bff !important;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25) !important;
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .btn {
        border: 2px solid currentColor !important;
    }
    
    .card {
        border: 2px solid currentColor !important;
    }
    
    .alert {
        border: 2px solid currentColor !important;
    }
    
    .table th,
    .table td {
        border: 1px solid currentColor !important;
    }
}

/* Reduced Motion Support */
@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;
    }
    
    .collapse {
        transition: none !important;
    }
    
    .fade {
        transition: none !important;
    }
}

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

[dir="rtl"] .breadcrumb-item + .breadcrumb-item::before {
    float: left;
    padding-right: 0;
    padding-left: 0.5rem;
    content: "\\";
}

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

[dir="rtl"] .navbar-nav .dropdown-menu {
    right: 0;
    left: auto;
}

[dir="rtl"] .pagination {
    direction: rtl;
}

[dir="rtl"] .carousel-control-prev {
    right: 0;
    left: auto;
}

[dir="rtl"] .carousel-control-next {
    right: auto;
    left: 0;
}

/* Language Direction Utilities */
.ltr {
    direction: ltr;
    text-align: left;
}

.rtl {
    direction: rtl;
    text-align: right;
}

/* Accessible Form Styling */
.form-label {
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.form-label.required::after {
    content: " *";
    color: #dc3545;
    font-weight: bold;
}

.form-text {
    font-size: 0.875em;
    color: #6c757d;
    margin-top: 0.25rem;
}

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

.was-validated .form-control:invalid,
.form-control.is-invalid {
    border-color: #dc3545;
    padding-right: calc(1.5em + 0.75rem);
    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);
}

/* Accessible Table Styling */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

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

.table th[aria-sort] {
    cursor: pointer;
    user-select: none;
}

.table th[aria-sort="ascending"]::after {
    content: " ↑";
    color: #007bff;
}

.table th[aria-sort="descending"]::after {
    content: " ↓";
    color: #007bff;
}

.table th[aria-sort="none"]::after {
    content: " ↕";
    color: #6c757d;
    opacity: 0.5;
}

/* Accessible Navigation */
.navbar-nav .nav-link[aria-current="page"] {
    font-weight: 600;
    color: #007bff !important;
}

.breadcrumb-item.active {
    font-weight: 600;
}

/* Accessible Alerts and Status Messages */
.alert {
    border-left: 4px solid transparent;
}

.alert-success {
    border-left-color: #28a745;
}

.alert-info {
    border-left-color: #17a2b8;
}

.alert-warning {
    border-left-color: #ffc107;
}

.alert-danger {
    border-left-color: #dc3545;
}

.alert-icon {
    font-weight: bold;
    margin-right: 0.5rem;
}

[dir="rtl"] .alert-icon {
    margin-right: 0;
    margin-left: 0.5rem;
}

/* Loading States */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading-overlay .spinner-border {
    width: 3rem;
    height: 3rem;
}

/* Progress Indicators */
.progress {
    background-color: #e9ecef;
    border-radius: 0.25rem;
    overflow: hidden;
}

.progress-bar {
    transition: width 0.6s ease;
}

@media (prefers-reduced-motion: reduce) {
    .progress-bar {
        transition: none;
    }
}

/* Keyboard Navigation Helpers */
.keyboard-navigation-active *:focus {
    outline: 2px solid #007bff !important;
    outline-offset: 2px !important;
}

/* Print Styles */
@media print {
    .skip-links,
    .sr-only,
    .visually-hidden-focusable {
        display: none !important;
    }
    
    .no-print {
        display: none !important;
    }
    
    a[href]:after {
        content: " (" attr(href) ")";
    }
    
    abbr[title]:after {
        content: " (" attr(title) ")";
    }
}

/* Color Contrast Utilities */
.text-contrast-high {
    color: #000 !important;
    background-color: #fff !important;
}

.bg-contrast-high {
    background-color: #000 !important;
    color: #fff !important;
}

/* Language Switcher */
.language-switcher {
    position: relative;
}

.language-switcher .dropdown-menu {
    min-width: 200px;
}

.language-switcher .dropdown-item {
    padding: 0.5rem 1rem;
}

.language-switcher .dropdown-item.active {
    background-color: #007bff;
    color: #fff;
}

.language-switcher .dropdown-item:hover {
    background-color: #f8f9fa;
}

/* Multilingual Content */
.multilingual-content {
    position: relative;
}

.multilingual-content .language-indicator {
    font-size: 0.75em;
    color: #6c757d;
    font-weight: normal;
    margin-left: 0.5rem;
}

[dir="rtl"] .multilingual-content .language-indicator {
    margin-left: 0;
    margin-right: 0.5rem;
}

/* Form Field Groups */
.form-field-group {
    margin-bottom: 1.5rem;
}

.form-field-group .form-label {
    display: block;
    margin-bottom: 0.5rem;
}

.form-field-group .form-control {
    margin-bottom: 0.25rem;
}

.form-field-group .form-text {
    margin-top: 0.25rem;
}

/* Responsive Text Sizing */
@media (max-width: 576px) {
    .responsive-text {
        font-size: 0.9rem;
    }
}

/* Touch Target Sizing */
@media (pointer: coarse) {
    .btn,
    .form-control,
    .form-select,
    a {
        min-height: 44px;
        min-width: 44px;
    }
    
    .btn-sm {
        min-height: 38px;
        min-width: 38px;
    }
    
    .btn-lg {
        min-height: 48px;
        min-width: 48px;
    }
}