/**
 * WCAG 2.1 Level AA Accessibility Fixes
 * 
 * This file addresses critical accessibility violations in the VR-ImmoService theme
 * Focus: WCAG 2.4.7 (Focus Visible), 2.1.1 (Keyboard), 1.3.1 (Info and Relationships)
 * 
 * Last Updated: 2025-08-17
 */

/* ================================================
   FOCUS INDICATORS - WCAG 2.4.7 Level AA
   ================================================ */

/* Override all outline:none declarations with proper focus indicators */

/* Navigation Focus Indicators */
.uk-nav-navbar > li > a:focus,
.uk-navbar-nav > li > a:focus,
.uk-nav-side > li > a:focus,
.uk-nav-dropdown > li > a:focus,
.uk-nav-offcanvas > li > a:focus {
    outline: 2px solid #0066B3 !important;
    outline-offset: 2px !important;
    background-color: rgba(0, 102, 179, 0.1) !important;
}

/* Button Focus Indicators */
.uk-button:focus,
.btn:focus,
.btn.btn-primary:focus,
.uk-button.uk-button-primary:focus,
button.immomakler-submit.btn.btn-primary:focus,
.immomakler .btn-default:focus,
.dropdown-toggle:focus,
li.immo-single-kaufpreis .uk-button:focus,
.uk-button-group .uk-button:focus,
.uk-button-group .uk-button-primary:focus {
    outline: 2px solid #0066B3 !important;
    outline-offset: 2px !important;
    box-shadow: 0 0 0 3px rgba(0, 102, 179, 0.3) !important;
}

/* Form Field Focus Indicators */
.nf-form-content .list-select-wrap .nf-field-element > div:focus,
.nf-form-content input:not([type=button]):focus,
.nf-form-content textarea:focus,
.object-request .nf-form-content .list-select-wrap .nf-field-element > div:focus,
.object-request .nf-form-content input:not([type=button]):focus,
.object-request .nf-form-content textarea:focus,
.uk-form select:focus,
.uk-form textarea:focus,
.uk-form input:not([type]):focus,
.uk-form input[type="text"]:focus,
.uk-form input[type="password"]:focus,
.uk-form input[type="datetime"]:focus,
.uk-form input[type="datetime-local"]:focus,
.uk-form input[type="date"]:focus,
.uk-form input[type="month"]:focus,
.uk-form input[type="time"]:focus,
.uk-form input[type="week"]:focus,
.uk-form input[type="number"]:focus,
.uk-form input[type="email"]:focus,
.uk-form input[type="url"]:focus,
.uk-form input[type="search"]:focus,
.uk-form input[type="tel"]:focus,
.uk-form input[type="color"]:focus {
    outline: 2px solid #0066B3 !important;
    outline-offset: 1px !important;
    border-color: #0066B3 !important;
    box-shadow: 0 0 0 3px rgba(0, 102, 179, 0.2) !important;
}

/* Link Focus Indicators */
.immomakler a:focus,
.large-list a:focus,
.immomakler-archive .property-title a:focus,
.immomakler-archive .orderby-switch a:focus,
.expose-button:focus,
.immo-single-title .uk-panel .uk-button:focus,
a.text-link:focus,
.uk-slideshow a.text-link:focus,
.search-for-id .input-group-btn .btn:focus,
.panel-header-right a:focus {
    outline: 2px solid #0066B3 !important;
    outline-offset: 2px !important;
    text-decoration: underline !important;
}

/* Specific Component Focus Indicators */
.team-hover-img .wk-popover-toggle:focus,
.uk-slidenav:focus,
.page-id-80 a.uk-slidenav:focus,
.immomakler-single .uk-overlay-background .uk-button:focus {
    outline: 3px solid #ffffff !important;
    outline-offset: 2px !important;
    box-shadow: 0 0 0 1px #0066B3, 0 0 0 4px rgba(0, 102, 179, 0.3) !important;
}

/* Bootstrap Select Focus Indicators */
.bootstrap-select.btn-group .dropdown-menu li a span.text:focus,
.bootstrap-select.btn-group .dropdown-menu li:focus,
.bootstrap-select.btn-group .dropdown-menu li a:focus {
    outline: 2px solid #0066B3 !important;
    outline-offset: 1px !important;
    background-color: rgba(0, 102, 179, 0.1) !important;
}

/* Slider and Interactive Elements */
.noUi-horizontal .noUi-handle:focus {
    outline: 2px solid #0066B3 !important;
    outline-offset: 2px !important;
    box-shadow: 0 0 0 4px rgba(0, 102, 179, 0.3) !important;
}

/* Complex Components */
.immomakler-flexslider ul.slides li:focus,
.immomakler-archive .immomakler-boxed .property .absolute-link:focus + .property-container,
.links-hidden .uk-panel .uk-grid.uk-float-right:focus {
    outline: 2px solid #0066B3 !important;
    outline-offset: 2px !important;
}

/* Sticky Sidebar Focus */
.tm-block-sticky-sidebar:focus,
.tm-block-sticky-sidebar li:focus a {
    outline: 2px solid #0066B3 !important;
    outline-offset: 2px !important;
}

/* Property Categories Focus */
.immo-categories .uk-panel-title:focus,
.immo-categories .uk-overlay-hover:focus .uk-panel-title,
.header-boxes .uk-panel:focus {
    outline: 2px solid #0066B3 !important;
    outline-offset: 2px !important;
    background-color: rgba(0, 102, 179, 0.1) !important;
}

/* Tab Navigation Focus */
.uk-tab > li > a:focus,
.uk-tab > li:not(.uk-active) > a:focus,
.uk-tab-bottom > li:not(.uk-active) > a:focus,
.uk-tab-left > li:not(.uk-active) > a:focus,
.uk-tab-right > li:not(.uk-active) > a:focus {
    outline: 2px solid #0066B3 !important;
    outline-offset: 2px !important;
}

/* Pagination Focus */
.uk-pagination > li > a:focus {
    outline: 2px solid #0066B3 !important;
    outline-offset: 2px !important;
}

/* Subnav Focus */
.uk-subnav > * > :focus,
.uk-subnav-pill > * > :focus {
    outline: 2px solid #0066B3 !important;
    outline-offset: 2px !important;
}

/* Navbar Brand and Toggle Focus */
.uk-navbar-brand:focus,
.uk-navbar-toggle:focus {
    outline: 2px solid #0066B3 !important;
    outline-offset: 2px !important;
}

/* Thumbnail Navigation Focus */
.uk-thumbnav > * > :focus > img {
    outline: 2px solid #0066B3 !important;
    outline-offset: 2px !important;
}

/* ================================================
   SKIP NAVIGATION - WCAG 2.4.1 Level A
   ================================================ */

/* Skip to main content link */
.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: 999999;
    padding: 8px 16px;
    background: #0066B3;
    color: white;
    text-decoration: none;
    font-weight: bold;
}

.skip-link:focus {
    left: 6px;
    top: 6px;
    outline: 2px solid #ffffff !important;
    outline-offset: 2px !important;
}

/* ================================================
   SCREEN READER IMPROVEMENTS - WCAG 1.3.1 Level A
   ================================================ */

/* Screen reader only text */
.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;
}

/* Screen reader only focusable */
.sr-only:focus {
    position: static !important;
    width: auto !important;
    height: auto !important;
    padding: 0.25rem 0.5rem !important;
    margin: 0 !important;
    overflow: visible !important;
    clip: auto !important;
    white-space: normal !important;
    background: #0066B3 !important;
    color: white !important;
    outline: 2px solid #ffffff !important;
    outline-offset: 2px !important;
}

/* ================================================
   HIGH CONTRAST MODE SUPPORT - WCAG 1.4.11 Level AA
   ================================================ */

@media (prefers-contrast: high) {
    .uk-button:focus,
    .btn:focus,
    input:focus,
    textarea:focus,
    select:focus,
    a:focus {
        outline: 3px solid currentColor !important;
        outline-offset: 2px !important;
    }
}

/* ================================================
   REDUCED MOTION SUPPORT - WCAG 2.3.3 Level AAA
   ================================================ */

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ================================================
   COLOR CONTRAST IMPROVEMENTS - WCAG 1.4.3 Level AA
   ================================================ */

/* Ensure sufficient contrast for interactive elements */
.uk-nav-navbar > li > a:focus,
.uk-navbar-nav > li > a:focus {
    color: #003366 !important; /* Darker blue for better contrast */
}

/* ================================================
   KEYBOARD NAVIGATION IMPROVEMENTS - WCAG 2.1.1 Level A
   ================================================ */

/* Ensure all interactive elements are keyboard accessible */
[tabindex="-1"]:focus {
    outline: none !important;
}

/* Make sure custom elements can receive focus */
.immomakler-archive .property,
.property-container {
    position: relative;
}

.immomakler-archive .property .absolute-link {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
    text-indent: -9999px;
    background: transparent;
}

.immomakler-archive .property .absolute-link:focus {
    text-indent: 0;
    background: rgba(0, 102, 179, 0.1) !important;
    color: #0066B3 !important;
    font-size: 0.875rem !important;
    padding: 0.5rem !important;
    text-align: center !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.immomakler-archive .property .absolute-link:focus::before {
    content: "Objekt ansehen: ";
    font-weight: bold;
}

/* ================================================
   FORM IMPROVEMENTS - WCAG 1.3.1, 3.3.1, 3.3.2 Level A
   ================================================ */

/* Ensure form error states are clearly visible */
.nf-error-field {
    border-color: #d32f2f !important;
    background-color: #ffebee !important;
}

.nf-error-field:focus {
    outline: 2px solid #d32f2f !important;
    outline-offset: 2px !important;
    box-shadow: 0 0 0 3px rgba(211, 47, 47, 0.3) !important;
}

/* Required field indicators */
.nf-field-element[aria-required="true"] label::after,
.required-field::after {
    content: " *";
    color: #d32f2f;
    font-weight: bold;
}

/* ================================================
   PRINT ACCESSIBILITY - WCAG 1.4.13 Level AA
   ================================================ */

@media print {
    .skip-link,
    .sr-only:not(:focus) {
        display: none !important;
    }
    
    /* Ensure all text has sufficient contrast when printed */
    * {
        color: #000000 !important;
        background: transparent !important;
    }
    
    a[href]:after {
        content: " (" attr(href) ")";
        font-size: 0.8em;
    }
}

/* ================================================
   PA11Y SPECIFIC FIXES - WCAG 2.1 Level AA
   ================================================ */

/* Fix obsolete center tags replacement */
.text-center {
    text-align: center !important;
}

/* Ensure logo links have minimum touch target */
.tm-logo,
.tm-logo-small {
    min-height: 44px;
    min-width: 44px;
    display: inline-block;
}

/* Fix property image links styling */
.immolist-item-image-link {
    display: block;
    position: relative;
}

.immolist-item-image-link::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: transparent;
}

/* Improve form field visibility */
select[name="objektart"],
select[name="ort"],
input[name="objektnr_extern"] {
    border: 1px solid #ccc;
    padding: 8px;
    background: white;
}

select[name="objektart"]:focus,
select[name="ort"]:focus,
input[name="objektnr_extern"]:focus {
    outline: 2px solid #005fcc;
    outline-offset: 2px;
    border-color: #005fcc;
}

/* Fix navigation elements without content */
/* Navigation button fixes - but preserve original dotnav styles */
.uk-slidenav:empty::before {
    content: '';
    display: inline-block;
    width: 16px;
    height: 16px;
    background: currentColor;
}

/* Removed - was interfering with original theme styles */

.uk-slidenav-previous:empty::before {
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath d='M10 2l-6 6 6 6z'/%3E%3C/svg%3E");
}

.uk-slidenav-next:empty::before {
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath d='M6 2l6 6-6 6z'/%3E%3C/svg%3E");
}

/* Ensure pagination dots are visible and accessible */
/* Only add accessibility improvements without breaking original styles */
/* Let the theme.css handle the visual styling */

/* Just ensure dots are keyboard accessible */
.uk-dotnav > * > *:focus {
    outline: 2px solid #005fcc;
    outline-offset: 2px;
}

/* Ensure proper ARIA labels for screen readers */
.uk-dotnav > * > *:empty::after {
    content: attr(aria-label);
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
}

/* Fix duplicate ID visibility issues */
[id*="pvc_stats"]:not(:first-of-type) {
    display: none;
}

/* Improve visibility of required field indicators */
.required-indicator {
    color: #d9534f;
    font-weight: bold;
}

/* Ensure all interactive elements have proper focus states */
a:not([href]):focus,
[role="button"]:focus {
    outline: 2px solid #005fcc;
    outline-offset: 2px;
}