/**
 * BOOKING ACCESSIBILITY ENHANCEMENTS
 * 
 * Modern accessibility patterns and assistive technology support
 * Depends on: booking-base.css
 * 
 * Version: 1.0
 * Last Updated: 2025-01-06
 */

/* ==========================================================================
   SCREEN READER SUPPORT
   ========================================================================== */

.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: inherit !important;
    border: inherit !important;
}

/* Live regions for dynamic content */
.booking-live-region {
    position: absolute;
    left: -10000px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* ==========================================================================
   FOCUS MANAGEMENT
   ========================================================================== */

/* Enhanced focus styles */
.booking-focus-ring:focus-visible {
    outline: 3px solid var(--booking-primary);
    outline-offset: 2px;
    border-radius: var(--booking-radius-sm);
    box-shadow: 0 0 0 1px var(--booking-white), 
                0 0 0 4px var(--booking-primary);
}

/* Focus within containers */
.booking-form-section:focus-within {
    box-shadow: var(--booking-elevation-2), 
                0 0 0 2px var(--booking-primary-light);
}

/* Skip links */
.skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: var(--booking-primary);
    color: var(--booking-white);
    padding: var(--booking-space-sm) var(--booking-space-lg);
    border-radius: var(--booking-radius-md);
    text-decoration: none;
    font-weight: var(--booking-font-semibold);
    z-index: var(--booking-z-toast);
    transition: top var(--booking-transition-fast);
}

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

/* Focus trap */
.booking-focus-trap {
    outline: none;
}

/* Keyboard navigation indicators */
[data-whatintent="keyboard"] .booking-btn:focus,
[data-whatintent="keyboard"] .booking-input:focus,
[data-whatintent="keyboard"] .flatpickr-day:focus {
    outline: 2px solid var(--booking-primary);
    outline-offset: 2px;
}

/* ==========================================================================
   HIGH CONTRAST MODE SUPPORT
   ========================================================================== */

@media (prefers-contrast: high) {
    :root {
        --booking-border: #000000;
        --booking-text-muted: var(--booking-text-secondary);
        --booking-shadow-sm: 0 2px 4px 0 rgba(0, 0, 0, 0.3);
        --booking-shadow-md: 0 4px 8px -1px rgba(0, 0, 0, 0.4);
    }
    
    [data-theme="dark"] {
        --booking-border: #ffffff;
        --booking-text-muted: var(--booking-text-secondary);
    }
    
    /* Enhanced borders for better visibility */
    .booking-card,
    .booking-form-section,
    .property-section {
        border-width: 2px;
    }
    
    .booking-btn {
        border: 2px solid;
        font-weight: var(--booking-font-bold);
    }
    
    /* High contrast text */
    .booking-text-muted {
        color: var(--booking-text-secondary);
    }
}

/* ==========================================================================
   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;
    }
    
    /* Remove transforms that cause motion */
    .booking-btn:hover,
    .gallery-image:hover,
    .property-section:hover,
    .booking-card:hover {
        transform: none !important;
    }
    
    /* Keep focus indicators */
    .booking-focus-ring:focus-visible {
        transition: box-shadow 0.15s ease-out !important;
    }
}

/* ==========================================================================
   COLOR PREFERENCE SUPPORT
   ========================================================================== */

/* Respect user's color preferences */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) {
        color-scheme: dark;
    }
}

@media (prefers-color-scheme: light) {
    :root:not([data-theme]) {
        color-scheme: light;
    }
}

/* ==========================================================================
   TOUCH TARGET SIZES
   ========================================================================== */

/* Ensure minimum 44px touch targets */
.booking-btn,
.guest-counter-btn,
.gallery-thumbnail,
.flatpickr-day,
input[type="checkbox"],
input[type="radio"] {
    min-width: 44px;
    min-height: 44px;
}

/* Exception for desktop-only interactions */
@media (pointer: fine) {
    .booking-btn-xs,
    .booking-btn-sm {
        min-width: auto;
        min-height: auto;
    }
}

/* ==========================================================================
   ARIA SUPPORT ENHANCEMENTS
   ========================================================================== */

/* Status indicators */
[aria-expanded="true"] .dropdown-icon {
    transform: rotate(180deg);
}

[aria-selected="true"] {
    background: var(--booking-primary-bg);
    color: var(--booking-primary);
}

[aria-invalid="true"] {
    border-color: var(--booking-error);
    background: var(--booking-error-bg);
}

[aria-disabled="true"] {
    opacity: 0.6;
    pointer-events: none;
}

/* Progress indicators */
[role="progressbar"] {
    position: relative;
    overflow: hidden;
}

[role="progressbar"]::before {
    content: attr(aria-valuetext);
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: var(--booking-text-sm);
    font-weight: var(--booking-font-medium);
    color: var(--booking-text-primary);
    z-index: 1;
}

/* ==========================================================================
   LOADING STATES ACCESSIBILITY
   ========================================================================== */

.booking-loading {
    position: relative;
}

.booking-loading::after {
    content: "";
    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: 1;
}

.booking-loading[aria-live="polite"]::before {
    content: "Loading...";
    position: absolute;
    left: -10000px;
    top: auto;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* ==========================================================================
   ERROR STATE ACCESSIBILITY
   ========================================================================== */

.booking-error-state {
    border: 2px solid var(--booking-error);
    background: var(--booking-error-bg);
}

.booking-error-message {
    display: flex;
    align-items: flex-start;
    gap: var(--booking-space-sm);
    color: var(--booking-error);
    font-size: var(--booking-text-sm);
    margin-top: var(--booking-space-sm);
}

.booking-error-icon {
    flex-shrink: 0;
    margin-top: 2px;
}

/* ==========================================================================
   KEYBOARD NAVIGATION ENHANCEMENTS
   ========================================================================== */

/* Tab order visual indicators */
.booking-tabindex-indicator {
    position: relative;
}

.booking-tabindex-indicator[tabindex]:focus::before {
    content: attr(tabindex);
    position: absolute;
    top: -8px;
    right: -8px;
    background: var(--booking-primary);
    color: var(--booking-white);
    width: 20px;
    height: 20px;
    border-radius: 50%;
    font-size: var(--booking-text-xs);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: var(--booking-font-bold);
    z-index: var(--booking-z-tooltip);
}

/* Modal focus management */
.booking-modal[aria-modal="true"] {
    isolation: isolate;
}

/* ==========================================================================
   PRINT ACCESSIBILITY
   ========================================================================== */

@media print {
    /* Ensure sufficient contrast for printing */
    .booking-text-muted {
        color: #000 !important;
    }
    
    /* Show URLs for links */
    a[href^="http"]:after {
        content: " (" attr(href) ")";
        font-size: var(--booking-text-xs);
        color: #666;
    }
    
    /* Ensure form values are visible */
    input,
    textarea,
    select {
        border: 1px solid #000 !important;
        background: white !important;
        color: #000 !important;
    }
}

/* ==========================================================================
   RESPONSIVE ACCESSIBILITY
   ========================================================================== */

@media (max-width: 768px) {
    /* Larger touch targets on mobile */
    .booking-btn,
    .booking-input,
    .flatpickr-day {
        min-height: 48px;
    }
    
    /* Better spacing for easier navigation */
    .booking-form-group {
        margin-bottom: var(--booking-space-xl);
    }
}

/* ==========================================================================
   ASSISTIVE TECHNOLOGY SUPPORT
   ========================================================================== */

/* Windows High Contrast Mode */
@media screen and (-ms-high-contrast: active) {
    .booking-btn {
        border: 2px solid;
    }
    
    .booking-focus-ring:focus {
        outline: 2px solid;
    }
}

/* Forced colors mode */
@media (forced-colors: active) {
    .booking-btn {
        forced-color-adjust: none;
        border: 2px solid ButtonText;
        background: ButtonFace;
        color: ButtonText;
    }
    
    .booking-btn:hover {
        background: Highlight;
        color: HighlightText;
    }
    
    .booking-focus-ring:focus {
        outline: 2px solid Highlight;
    }
}