/**
 * WCAG 2.1 Level AA Accessibility Enhancements
 * Version: 1.0.0
 * Date: 2025-10-19
 *
 * Implements accessibility fixes recommended by WCAG audit:
 * - Focus indicators for keyboard navigation (WCAG 2.4.7, 1.4.11)
 * - Improved button contrast (WCAG 1.4.3)
 * - Larger touch targets for desktop close buttons (WCAG 2.5.5)
 */

/* ==========================================================================
   1. FOCUS INDICATORS - WCAG 2.4.7 & 1.4.11
   ========================================================================== */

/**
 * Visible focus indicators for all booking form inputs
 * Ensures keyboard users can see which element has focus
 */
.kupbilet input:focus,
.kupbilet select:focus,
.kupbilet button:focus {
    outline: 3px solid #0066cc;
    outline-offset: 2px;
}

/**
 * Focus indicator for Selectric dropdown plugin
 * Applied when the custom dropdown is focused
 */
.kupbilet .selectric:focus-within,
.kupbilet .selectric-wrapper:focus-within .selectric {
    outline: 3px solid #0066cc;
    outline-offset: 2px;
}

/**
 * Focus indicators for datepicker inputs
 */
.kupbilet input.datepicker:focus {
    outline: 3px solid #0066cc;
    outline-offset: 2px;
}

/**
 * Focus indicators for close buttons (desktop)
 * White outline for better visibility on red background
 */
.kupbilet-closepowrotne:focus {
    outline: 3px solid #fff;
    outline-offset: 2px;
}

/**
 * Focus indicators for mobile close buttons
 */
.kupbilet-mobile-powrotne-close:focus,
.kupbilet-mobile-powrotnecargo-close:focus {
    outline: 3px solid #fff;
    outline-offset: 2px;
}

/**
 * Focus indicators for mobile booking form close button
 */
.kupbilet-mobile .kupbilet-mobile-close:focus {
    outline: 3px solid #fff;
    outline-offset: 2px;
}

/* ==========================================================================
   2. BUTTON CONTRAST IMPROVEMENT - WCAG 1.4.3
   ========================================================================== */

/**
 * Darken submit button background for better contrast
 * OLD: #e31e25 (ratio ~4.1:1 - borderline)
 * NEW: #cc1a20 (ratio ~4.9:1 - passes WCAG AA)
 */
.kupbilet button {
    background-color: #cc1a20 !important;
}

/**
 * Darken mobile close buttons for better contrast
 * Applied to all mobile form close buttons
 */
.kupbilet-mobile-powrotne-close,
.kupbilet-mobile-powrotnecargo-close {
    background-color: #cc1a20 !important;
}

/**
 * Darken desktop close button for better contrast
 */
.kupbilet-closepowrotne {
    background-color: #cc1a20 !important;
}

/**
 * Update hover state to maintain visual consistency
 */
.kupbilet-closepowrotne:hover {
    background-color: #e94b51 !important;
}

/* ==========================================================================
   3. CLOSE BUTTON POSITIONING - Inside Selectric Element (RIGHT side)
   ========================================================================== */

/**
 * Close button positioned INSIDE .selectric element on RIGHT side
 * The close button class (.kupbilet-closepowrotne) is unique to return trip connection dropdown
 * Size: 38x38px to match selectric height exactly
 * Positioned after the dropdown arrow button
 * Uses flexbox for perfect centering of icon
 */
.selectric .kupbilet-closepowrotne {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    position: absolute !important;
    right: 0 !important;
    top: 0 !important;
    width: 38px !important;
    height: 38px !important;  /* Match selectric height exactly */
    font-size: 18px !important;
    color: #fff !important;  /* White × icon */
    z-index: 11 !important;  /* Above dropdown arrow (z-index: 10) */
    border-radius: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    /* Red background inherited from .kupbilet-closepowrotne base rule (line 96-98) */
    border-left: 1px solid #ddd !important;  /* Visual separator from dropdown */
}

/**
 * Mobile close buttons positioned inside .selectric (RIGHT side)
 * The button classes are unique to return trip connection dropdowns
 * Same pattern as desktop but with larger font size
 */
.selectric .kupbilet-mobile-powrotne-close,
.selectric .kupbilet-mobile-powrotnecargo-close {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    position: absolute !important;
    right: 0 !important;
    top: 0 !important;
    width: 38px !important;
    height: 38px !important;  /* Match selectric height exactly */
    font-size: 24px !important;
    color: #fff !important;  /* White × icon */
    z-index: 11 !important;
    border-radius: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    /* Red background inherited from mobile close button base rules (lines 88-91, 155-169) */
    border-left: 1px solid #ddd !important;
}

/**
 * Push dropdown arrow button to the left of close button
 * Original position: right: 0
 * New position: right: 38px (makes room for 38px close button)
 * Uses sibling selector ~ to only affect selectric with close button
 */
.selectric .kupbilet-closepowrotne ~ .button,
.selectric .kupbilet-mobile-powrotne-close ~ .button,
.selectric .kupbilet-mobile-powrotnecargo-close ~ .button {
    right: 38px !important;
}

/**
 * Adjust label to make room for BOTH buttons (dropdown + close)
 * Original margin-right: 38px (for dropdown arrow only)
 * New margin-right: 76px (38px dropdown + 38px close button)
 * Uses sibling selector ~ to only affect selectric with close button
 */
.selectric .kupbilet-closepowrotne ~ .label,
.selectric .kupbilet-mobile-powrotne-close ~ .label,
.selectric .kupbilet-mobile-powrotnecargo-close ~ .label {
    margin-right: 76px !important;  /* 38px (dropdown) + 38px (close button) */
}

/* ==========================================================================
   4. ERROR HANDLING SUPPORT - WCAG 3.3.1 & 3.3.3
   ========================================================================== */

/**
 * Styles for error messages
 * To be used with aria-live regions for screen reader announcements
 */
.kupbilet .error-message {
    color: #cc1a20;
    font-size: 14px;
    margin-top: 5px;
    display: block;
}

/**
 * Error state for form inputs
 * Applied when aria-invalid="true"
 */
.kupbilet input[aria-invalid="true"],
.kupbilet select[aria-invalid="true"] {
    border-color: #cc1a20 !important;
    border-width: 2px;
}

/**
 * Error icon support (optional)
 */
.kupbilet .error-message::before {
    content: "⚠ ";
    font-weight: 700;
}

/* ==========================================================================
   5. RESPONSIVE ADJUSTMENTS
   ========================================================================== */

/**
 * No responsive adjustments needed
 * Close buttons are positioned absolutely within their parent containers
 * and automatically adapt to different screen sizes
 */

/* ==========================================================================
   6. HIGH CONTRAST MODE SUPPORT
   ========================================================================== */

/**
 * Ensure focus indicators are visible in Windows High Contrast Mode
 */
@media (prefers-contrast: high) {
    .kupbilet input:focus,
    .kupbilet select:focus,
    .kupbilet button:focus,
    .kupbilet .selectric:focus-within {
        outline: 3px solid currentColor;
        outline-offset: 2px;
    }
}

/* ==========================================================================
   7. REDUCED MOTION SUPPORT - WCAG 2.3.3
   ========================================================================== */

/**
 * Respect user's motion preferences
 * Disables animations for users who prefer reduced motion
 */
@media (prefers-reduced-motion: reduce) {
    .kupbilet button,
    .kupbilet-closepowrotne,
    .kupbilet .selectric,
    .kupbilet input {
        -webkit-transition: none !important;
        transition: none !important;
    }
}

/* ==========================================================================
   END OF ACCESSIBILITY ENHANCEMENTS
   ========================================================================== */
