/**
 * BullTech Accessibility Styles
 * WCAG 2.2 AA Compliance
 */

/* ========================================
   SKIP LINKS & SCREEN READER CONTENT
   ======================================== */

.skip-link,
.screen-reader-text {
    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;
}

.skip-link:focus,
.screen-reader-text:focus {
    position: absolute !important;
    top: 0 !important;
    left: 6px !important;
    width: auto !important;
    height: auto !important;
    padding: 8px 16px !important;
    margin: 0 !important;
    background-color: #ffffff !important;
    color: #000000 !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    text-decoration: none !important;
    border: 2px solid #005fcc !important;
    border-radius: 4px !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3) !important;
    z-index: 100000 !important;
    clip: unset !important;
    white-space: normal !important;
}

.skip-link:hover:focus {
    background-color: #005fcc !important;
    color: #ffffff !important;
}

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

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

/* High-contrast focus indicators */
*:focus {
    outline: 3px solid #005fcc !important;
    outline-offset: 2px !important;
    box-shadow: 0 0 0 1px #ffffff, 0 0 0 4px #005fcc !important;
}

/* Button focus states */
.elementor-button:focus,
.btn:focus,
button:focus,
input[type="submit"]:focus,
input[type="button"]:focus,
.wp-block-button__link:focus {
    outline: 3px solid #ffffff !important;
    outline-offset: 2px !important;
    box-shadow: 0 0 0 1px #005fcc, 0 0 0 4px #ffffff !important;
}

/* Link focus states */
a:focus {
    outline: 2px solid #005fcc !important;
    outline-offset: 2px !important;
    text-decoration: underline !important;
}

/* Form element focus states */
input:focus,
textarea:focus,
select:focus,
.StripeElement--focus {
    outline: 2px solid #005fcc !important;
    outline-offset: 1px !important;
    border-color: #005fcc !important;
}

/* ========================================
   TOUCH TARGET SIZES (48x48px minimum)
   ======================================== */

/* Ensure all interactive elements meet 48x48px minimum */
a,
button,
input[type="button"],
input[type="submit"],
input[type="reset"],
input[type="checkbox"],
input[type="radio"],
select,
.elementor-button,
.btn,
.wp-block-button__link,
[role="button"],
[role="link"],
[tabindex]:not([tabindex="-1"]) {
    min-height: 48px !important;
    min-width: 48px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 12px 16px !important;
}

/* Exceptions for text links within paragraphs */
p a,
li a,
.elementor-text-editor a {
    min-height: auto !important;
    min-width: auto !important;
    display: inline !important;
    padding: 2px 4px !important;
}

/* Checkbox and radio specific sizing */
input[type="checkbox"],
input[type="radio"] {
    width: 20px !important;
    height: 20px !important;
    min-width: 48px !important;
    min-height: 48px !important;
    padding: 14px !important;
    cursor: pointer !important;
}

/* Mobile touch target adjustments */
@media (max-width: 768px) {
    /* Increase touch targets on mobile */
    .elementor-button,
    .btn,
    button,
    input[type="submit"],
    input[type="button"],
    .wp-block-button__link {
        min-height: 52px !important;
        padding: 14px 18px !important;
    }
    
    /* Navigation menu items */
    .elementor-nav-menu a {
        min-height: 48px !important;
        padding: 12px 16px !important;
    }
}

/* ========================================
   COLOR CONTRAST (4.5:1 minimum)
   ======================================== */

/* Ensure high contrast text */
.low-contrast-fix {
    color: #1a1a1a !important;
    background-color: #ffffff !important;
}

/* Link contrast improvements */
a {
    color: #005fcc !important;
    text-decoration: underline !important;
}

a:hover,
a:focus {
    color: #003d7a !important;
    text-decoration: underline !important;
}

/* Button contrast improvements */
.elementor-button,
.btn-primary {
    background-color: #005fcc !important;
    color: #ffffff !important;
    border-color: #005fcc !important;
}

.elementor-button:hover,
.btn-primary:hover {
    background-color: #003d7a !important;
    border-color: #003d7a !important;
    color: #ffffff !important;
}

/* Form input contrast */
input,
textarea,
select {
    background-color: #ffffff !important;
    color: #1a1a1a !important;
    border: 2px solid #666666 !important;
}

input:focus,
textarea:focus,
select:focus {
    border-color: #005fcc !important;
    color: #1a1a1a !important;
}

/* Error state colors with sufficient contrast */
.error,
.invalid,
.StripeElement--invalid {
    border-color: #cc0000 !important;
    color: #cc0000 !important;
}

.error-message {
    color: #cc0000 !important;
    background-color: #ffe6e6 !important;
    padding: 8px 12px !important;
    border-radius: 4px !important;
}

/* Success state colors */
.success {
    color: #006600 !important;
    background-color: #e6ffe6 !important;
}

/* ========================================
   MEGA MENU ACCESSIBILITY
   ======================================== */

/* Mega menu aria states */
.mega-menu-item[aria-expanded="true"] .bt-mega-panel {
    display: block !important;
}

.mega-menu-item[aria-expanded="false"] .bt-mega-panel {
    display: none !important;
}

/* Keyboard navigation for mega menu */
.mega-menu-item > a:focus + .bt-mega-panel,
.bt-mega-panel:focus-within {
    display: block !important;
}

/* Mega menu focus trapping */
.bt-mega-panel {
    position: relative;
}

.bt-mega-panel::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: -1;
}

/* Navigation accessibility */
nav[role="navigation"] {
    position: relative;
}

nav ul {
    list-style: none !important;
    margin: 0 !important;
    padding: 0 !important;
}

nav li {
    position: relative;
}

nav a {
    display: block;
    text-decoration: none;
    padding: 12px 16px;
    min-height: 48px;
}

/* ========================================
   FORM ACCESSIBILITY ENHANCEMENTS
   ======================================== */

/* Required field indicators */
.required::after {
    content: " *";
    color: #cc0000 !important;
    font-weight: bold;
}

/* Form field grouping */
fieldset {
    border: 2px solid #666666 !important;
    padding: 16px !important;
    margin: 16px 0 !important;
    border-radius: 4px !important;
}

legend {
    font-weight: 600 !important;
    color: #1a1a1a !important;
    padding: 0 8px !important;
}

/* Label positioning and styling */
label {
    display: block !important;
    font-weight: 600 !important;
    color: #1a1a1a !important;
    margin-bottom: 4px !important;
}

.form-row label {
    cursor: pointer !important;
}

/* Help text styling */
.form-help,
.description,
[id$="-description"] {
    font-size: 14px !important;
    color: #666666 !important;
    margin-top: 4px !important;
    line-height: 1.4 !important;
}

/* ========================================
   MODAL/DIALOG ACCESSIBILITY
   ======================================== */

/* Modal focus management */
.modal[aria-hidden="true"] {
    display: none !important;
}

.modal[aria-hidden="false"] {
    display: flex !important;
}

.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7) !important;
    z-index: 9998;
}

.modal-content {
    background-color: #ffffff !important;
    color: #1a1a1a !important;
    border: 2px solid #005fcc !important;
    border-radius: 4px !important;
    max-width: 90% !important;
    max-height: 90% !important;
    overflow-y: auto !important;
    z-index: 9999;
    position: relative;
}

.modal-close {
    position: absolute !important;
    top: 8px !important;
    right: 8px !important;
    width: 44px !important;
    height: 44px !important;
    background-color: transparent !important;
    border: 2px solid #666666 !important;
    border-radius: 4px !important;
    cursor: pointer !important;
    font-size: 18px !important;
    line-height: 1 !important;
}

/* ========================================
   TABLE ACCESSIBILITY
   ======================================== */

table {
    border-collapse: collapse !important;
    width: 100% !important;
    margin: 16px 0 !important;
}

th,
td {
    border: 1px solid #666666 !important;
    padding: 12px !important;
    text-align: left !important;
}

th {
    background-color: #f5f5f5 !important;
    color: #1a1a1a !important;
    font-weight: 600 !important;
}

caption {
    font-weight: 600 !important;
    color: #1a1a1a !important;
    text-align: left !important;
    margin-bottom: 8px !important;
}

/* ========================================
   MEDIA ACCESSIBILITY
   ======================================== */

/* Ensure all images have proper alt text styling */
img[alt=""],
img:not([alt]) {
    border: 2px solid #cc0000 !important;
}

/* Video controls accessibility */
video:focus,
audio:focus {
    outline: 3px solid #005fcc !important;
    outline-offset: 2px !important;
}

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

@media print {
    /* Ensure skip links are hidden in print */
    .skip-link,
    .screen-reader-text {
        display: none !important;
    }
    
    /* Print-friendly focus indicators */
    *:focus {
        outline: 2px solid #000000 !important;
        box-shadow: none !important;
    }
    
    /* Ensure sufficient contrast in print */
    * {
        color: #000000 !important;
        background-color: transparent !important;
    }
    
    a {
        text-decoration: underline !important;
    }
}

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

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

@media (prefers-contrast: high) {
    * {
        border-color: #000000 !important;
    }
    
    .elementor-button,
    button,
    input[type="submit"] {
        background-color: #000000 !important;
        color: #ffffff !important;
        border: 2px solid #000000 !important;
    }
    
    a {
        color: #0000ff !important;
        text-decoration: underline !important;
    }
    
    a:visited {
        color: #800080 !important;
    }
}

/* ========================================
   DARK MODE ACCESSIBILITY
   ======================================== */

@media (prefers-color-scheme: dark) {
    /* Maintain accessibility in dark mode */
    .skip-link:focus,
    .screen-reader-text:focus {
        background-color: #1a1a1a !important;
        color: #ffffff !important;
        border-color: #66b3ff !important;
    }
    
    *:focus {
        outline-color: #66b3ff !important;
        box-shadow: 0 0 0 1px #1a1a1a, 0 0 0 4px #66b3ff !important;
    }
}