/*
 * VoyagerDaterange Accessibility Styles
 * WCAG 2.2 Compliant Styling for Date Range Picker
 * 
 * This CSS file provides comprehensive accessibility support for the VoyagerDaterange
 * component, ensuring WCAG 2.2 AA/AAA compliance across all interactive elements.
 * 
 * Features:
 * - Screen reader announcements and live regions
 * - High contrast mode support (Windows and prefers-contrast)
 * - Reduced motion preferences (prefers-reduced-motion)
 * - Dark mode support (prefers-color-scheme: dark)
 * - Touch target size compliance (44px minimum)
 * - Focus indicators with proper contrast ratios
 * - Error message styling with WCAG color requirements
 * - Keyboard navigation visual feedback
 * - Print accessibility styles
 * 
 * Enqueued automatically when:
 * - voyager-daterange script is used (booking panels)
 * - voyager-inline-booking block is rendered
 * 
 * WCAG 2.2 Success Criteria Addressed:
 * - 1.3.1 Info and Relationships
 * - 1.4.3 Contrast (Minimum)
 * - 1.4.11 Non-text Contrast
 * - 2.1.1 Keyboard
 * - 2.4.7 Focus Visible
 * - 3.3.1 Error Identification
 * - 4.1.2 Name, Role, Value
 * - 4.1.3 Status Messages
 */

/* 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;
}

/* Live Region for Screen Reader Announcements */
.datepicker-live-region {
    position: absolute;
    left: -10000px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* Error Styling with WCAG Color Contrast */
.datepicker-error {
    color: #d63384; /* WCAG AA compliant error red */
    font-size: 0.875em;
    margin-top: 0.25rem;
    display: block;
}

/* Input Error State */
.datepicker-input.has-error {
    border-color: #d63384;
    box-shadow: 0 0 0 0.2rem rgba(214, 51, 132, 0.25);
}

.datepicker-input.has-error:focus {
    border-color: #d63384;
    box-shadow: 0 0 0 0.2rem rgba(214, 51, 132, 0.5);
    outline: none;
}

/* Focus Management */
.datepicker-input:focus {
    outline: 2px solid #0066cc;
    outline-offset: 2px;
    border-color: #0066cc;
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .datepicker-input {
        border: 2px solid;
        background: Window;
        color: WindowText;
    }
    
    .datepicker-input:focus {
        outline: 3px solid Highlight;
        outline-offset: 2px;
    }
    
    .datepicker-error {
        color: WindowText;
        background: Window;
        border: 1px solid WindowText;
        padding: 0.25rem;
    }
    
    .datepicker-input.has-error {
        border: 2px solid WindowText;
        background: Window;
    }
}

/* Windows High Contrast Mode */
.high-contrast-mode .datepicker-input {
    border: 2px solid;
    background: window;
    color: windowtext;
}

.high-contrast-mode .datepicker-input:focus {
    outline: 3px solid highlight;
    outline-offset: 2px;
}

.high-contrast-mode .datepicker-error {
    color: windowtext;
    background: window;
    border: 1px solid windowtext;
    padding: 0.25rem;
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    .datepicker-input,
    .datepicker-card,
    .datepicker-error {
        transition: none !important;
        animation: none !important;
    }
    
    /* Ensure calendar animations are disabled */
    .datepicker-picker,
    .datepicker-picker * {
        transition: none !important;
        animation: none !important;
    }
}

/* Enhanced Focus Indicators */
.datepicker-input[aria-expanded="true"] {
    border-color: #0066cc;
    box-shadow: 0 0 0 0.2rem rgba(0, 102, 204, 0.25);
}

/* Help Text Styling */
.datepicker-help {
    font-size: 0.875em;
    color: #6c757d;
    margin-top: 0.25rem;
    display: block;
}

/* Dark Mode Support - Only apply when explicitly enabled */
@media (prefers-color-scheme: dark) {
    /* Only apply dark mode styles when parent has dark mode class or data attribute */
    .voyager-dark-mode .datepicker-input,
    .dark-mode .datepicker-input,
    [data-theme="dark"] .datepicker-input,
    body.dark .datepicker-input {
        background: #212529;
        border-color: #495057;
        color: #f8f9fa;
    }
    
    .voyager-dark-mode .datepicker-input:focus,
    .dark-mode .datepicker-input:focus,
    [data-theme="dark"] .datepicker-input:focus,
    body.dark .datepicker-input:focus {
        border-color: #66b3ff;
        box-shadow: 0 0 0 0.2rem rgba(102, 179, 255, 0.25);
    }
    
    .voyager-dark-mode .datepicker-error,
    .dark-mode .datepicker-error,
    [data-theme="dark"] .datepicker-error,
    body.dark .datepicker-error {
        color: #ff6b9d;
    }
    
    .voyager-dark-mode .datepicker-help,
    .dark-mode .datepicker-help,
    [data-theme="dark"] .datepicker-help,
    body.dark .datepicker-help {
        color: #adb5bd;
    }
}

/* Alternative: Manual dark mode without media query dependency */
.voyager-daterange-dark .datepicker-input,
.datepicker-input[data-theme="dark"] {
    background: #212529;
    border-color: #495057;
    color: #f8f9fa;
}

.voyager-daterange-dark .datepicker-input:focus,
.datepicker-input[data-theme="dark"]:focus {
    border-color: #66b3ff;
    box-shadow: 0 0 0 0.2rem rgba(102, 179, 255, 0.25);
}



/* Calendar Button Accessibility */
.datepicker-toggle-button {
    min-height: 44px;
    min-width: 44px;
    border: 1px solid #ced4da;
    background: #f8f9fa;
    color: #212529;
    cursor: pointer;
    padding: 0.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.datepicker-toggle-button:focus {
    outline: 2px solid #0066cc;
    outline-offset: 2px;
}

.datepicker-toggle-button:hover {
    background: #e9ecef;
}

.datepicker-toggle-button[aria-pressed="true"] {
    background: #0066cc;
    color: white;
}

/* Status Messages */
.datepicker-status {
    font-weight: 500;
    margin-top: 0.5rem;
}

.datepicker-status.success {
    color: #198754;
}

.datepicker-status.error {
    color: #d63384;
}

.datepicker-status.info {
    color: #0dcaf0;
}

/* Keyboard Navigation Indicators */
.datepicker-input[data-keyboard-focused="true"] {
    box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.5);
}

/* Skip Link for Calendar Navigation */
.datepicker-skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: #000;
    color: #fff;
    padding: 8px;
    z-index: 1000;
    text-decoration: none;
    border-radius: 4px;
}

.datepicker-skip-link:focus {
    top: 6px;
}

/* Responsive Design Considerations */
@media (max-width: 768px) {
    .datepicker-input {
        font-size: 16px; /* Prevents zoom on iOS */
    }
}

/* Print Styles */
@media print {
    .datepicker-error,
    .datepicker-help,
    .datepicker-toggle-button {
        display: none;
    }
    
    .datepicker-input {
        border: 1px solid #000;
        background: transparent;
        color: #000;
    }
}

/* Loading State Accessibility */
.datepicker-loading {
    position: relative;
}

.datepicker-loading::after {
    content: "";
    position: absolute;
    top: 50%;
    right: 10px;
    width: 16px;
    height: 16px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #0066cc;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    transform: translateY(-50%);
}

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

/* Disable loading animation for reduced motion */
@media (prefers-reduced-motion: reduce) {
    .datepicker-loading::after {
        animation: none;
        border-top-color: transparent;
    }
}

/* Tooltip Accessibility */
.datepicker-tooltip {
    position: absolute;
    z-index: 1000;
    background: #000;
    color: #fff;
    padding: 0.5rem;
    border-radius: 4px;
    font-size: 0.875em;
    max-width: 250px;
    word-wrap: break-word;
}

.datepicker-tooltip[aria-hidden="true"] {
    display: none;
}

/* Calendar Popup Accessibility */
.datepicker-picker {
    border: 2px solid #0066cc;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    background: white;
    z-index: 1050;
}

.datepicker-picker:focus-within {
    border-color: #004499;
}

/* Focus trap for calendar */
.datepicker-picker .focus-trap-start,
.datepicker-picker .focus-trap-end {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}
