/**
 * Employer Autocomplete CSS
 * Styling for the employer autocomplete component
 */

.umm-employer-container {
    position: relative !important;
    width: 100%;
}

/* Ensure any parent that needs it has relative positioning */
.umm-form-group {
    position: relative !important;
}

input.umm-employer-autocomplete {
    padding-right: 30px !important;
    /* Add space for loading indicator */
}

/* Portal-specific dropdown styling */
body>.umm-employer-suggestions-portal {
    position: fixed !important;
    max-height: 250px !important;
    overflow-y: auto !important;
    background-color: #fff !important;
    border: 1px solid #ddd !important;
    border-radius: 4px !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
    z-index: 9999999 !important;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    margin: 0 !important;
    padding: 0 !important;
    list-style: none !important;
    transition: opacity 0.2s ease !important;
}

/* Dropdown styling - using only .umm-employer-suggestions class for consistency */
.umm-employer-suggestions {
    position: absolute !important;
    top: 100% !important;
    left: 0 !important;
    width: 100% !important;
    max-height: 250px !important;
    overflow-y: auto !important;
    background-color: #fff !important;
    border: 1px solid #ddd !important;
    border-top: none !important;
    border-radius: 0 0 4px 4px !important;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1) !important;
    z-index: 1000001 !important;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    margin: 0 !important;
    padding: 0 !important;
    list-style: none !important;
}

.umm-employer-suggestion {
    padding: 8px 12px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.umm-employer-suggestion:hover {
    background-color: #f5f5f5;
}

.umm-employer-suggestion.active {
    background-color: #e9f1fd;
}

.umm-employer-suggestion.umm-add-new {
    border-top: 1px solid #eee;
    color: #0073aa;
    font-weight: 500;
}

.umm-employer-details {
    /* slightly smaller detail text to visually separate it from the main label */
    font-size: calc(var(--umm-font-size-base) * 0.9) !important;
    color: #666 !important;
    margin-top: 2px;
}

/* Keyboard navigation indicators */
.umm-employer-suggestion:focus {
    outline: none;
    background-color: #e9f1fd;
}

/* Loading indicator */
.umm-employer-loading {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    border: 2px solid rgba(0, 115, 170, 0.2);
    border-radius: 50%;
    border-top-color: #0073aa;
    animation: umm-spin 0.8s linear infinite;
}

@keyframes umm-spin {
    to {
        transform: translateY(-50%) rotate(360deg);
    }
}

/* Selected employer badge */
.umm-employer-selected {
    background-color: #e9f1fd;
    border: 1px solid #bcdffb;
    border-radius: 3px;
    padding: 2px 6px;
    margin-top: 5px;
    display: inline-block;
    font-size: 0.9em;
}

/* Match highlighting */
.umm-highlight {
    font-weight: bold;
    background-color: rgba(255, 255, 0, 0.2);
}

/* Locked employer-dependent fields (address, county, locality)
   Applied when an existing employer is selected from the DB.
   pointer-events:none prevents mouse/touch interaction;
   readonly / tabindex=-1 (set via JS) prevent keyboard editing. */
.umm-employer-field-locked {
    background-color: #f5f5f5 !important;
    color: #888 !important;
    cursor: not-allowed !important;
    opacity: 0.8;
    border-color: #ddd !important;
    pointer-events: none;
    user-select: none;
}

/* Dropdown item styles - using only .umm-employer-suggestions class */
.umm-employer-suggestions .umm-employer-suggestion,
.umm-employer-suggestions-portal .umm-employer-suggestion {
    padding: 8px 12px;
    cursor: pointer;
    margin: 0;
}

.umm-employer-suggestions .umm-employer-suggestion:hover,
.umm-employer-suggestions .umm-employer-suggestion.active,
.umm-employer-suggestions-portal .umm-employer-suggestion:hover,
.umm-employer-suggestions-portal .umm-employer-suggestion.active {
    background-color: #f0f0f0;
}

.umm-employer-suggestions .umm-employer-suggestion .umm-highlight,
.umm-employer-suggestions-portal .umm-employer-suggestion .umm-highlight {
    font-weight: bold;
}

.umm-employer-suggestions .umm-employer-suggestion .umm-employer-details,
.umm-employer-suggestions-portal .umm-employer-suggestion .umm-employer-details {
    font-size: 0.9em;
    color: #666;
    margin-left: 5px;
}

/* Ensure dropdown is visible regardless of parent overflow settings */
body .umm-employer-suggestions {
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    z-index: 1000001 !important;
    /* Extremely high z-index */
}

/* Body-level styles for when employer dropdown is showing */
body.umm-showing-employer-dropdown {
    overflow: hidden !important;
    position: relative !important;
}

body.umm-showing-employer-dropdown .umm-employer-suggestions-portal {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Hide regular dropdown when portal is active */
body.umm-showing-employer-dropdown .umm-employer-suggestions {
    display: none !important;
}

/* Hide absolute dropdown when portal is active */
body.umm-showing-employer-dropdown .umm-employer-suggestions-absolute {
    display: none !important;
}

/* Prevent scroll on mobile devices as well */
@media (max-width: 768px) {
    body.umm-showing-employer-dropdown {
        position: fixed !important;
        width: 100% !important;
        height: 100% !important;
        overflow: hidden !important;
    }
}

/* Ensure absolute positioned dropdown has proper styling */
.umm-employer-suggestions-absolute {
    position: absolute !important;
    z-index: 1000001 !important;
}

.umm-employer-suggestions-absolute .umm-employer-suggestions {
    position: static !important;
    box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2) !important;
    border: 2px solid #0073aa !important;
}

/* Ensure portal dropdown is always visible and properly styled */
.umm-employer-suggestions-portal {
    position: fixed !important;
    z-index: 9999999 !important;
    background-color: #fff !important;
    border: 1px solid #ddd !important;
    border-radius: 4px !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2) !important;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    margin: 0 !important;
    padding: 0 !important;
    max-height: 250px !important;
    overflow-y: auto !important;
    transition: opacity 0.2s ease !important;
    /* Ensure it's above all other elements */
    pointer-events: auto !important;
    /* Allow smooth scrolling within the dropdown */
    -webkit-overflow-scrolling: touch !important;
    /* Ensure consistent appearance */
    box-sizing: border-box !important;
    /* Prevent text selection issues */
    user-select: none !important;
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
}

/* Add subtle backdrop when dropdown is showing to indicate scroll is disabled */
body.umm-showing-employer-dropdown::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.01);
    z-index: 9999998;
    pointer-events: none;
}

/* Ensure portal suggestions follow same hover behavior */
.umm-employer-suggestions-portal .umm-employer-suggestion {
    padding: 8px 12px !important;
    cursor: pointer !important;
    margin: 0 !important;
    transition: background-color 0.2s ease !important;
}

.umm-employer-suggestions-portal .umm-employer-suggestion:hover,
.umm-employer-suggestions-portal .umm-employer-suggestion.active {
    background-color: #f0f0f0 !important;
}

.umm-employer-suggestions-portal .umm-employer-suggestion:first-child {
    border-radius: 4px 4px 0 0 !important;
}

.umm-employer-suggestions-portal .umm-employer-suggestion:last-child {
    border-radius: 0 0 4px 4px !important;
}

/* Extra high-specificity rules to ensure dropdown visibility */
html body div.umm-form-group .umm-employer-suggestions,
html body div.umm-employer-container .umm-employer-suggestions,
html body form .umm-employer-suggestions {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    z-index: 1000002 !important;
    pointer-events: auto !important;
}

/* Special styling for IE11 (just in case) */
@media all and (-ms-high-contrast: none),
(-ms-high-contrast: active) {
    body>.umm-employer-suggestions-portal {
        display: block !important;
        visibility: visible !important;
    }
}

/* Form-specific scroll lock when employer dropdown is active */
body.umm-showing-employer-dropdown .umm-modal,
body.umm-showing-employer-dropdown .umm-form-container,
body.umm-showing-employer-dropdown .modal-body,
body.umm-showing-employer-dropdown .dialog-content {
    overflow: hidden !important;
}

/* Ensure form containers maintain their height when scroll is locked */
body.umm-showing-employer-dropdown .umm-form-container {
    height: auto !important;
    max-height: none !important;
}

/* Prevent scrolling on common form dialog containers */
body.umm-showing-employer-dropdown .wp-dialog,
body.umm-showing-employer-dropdown .ui-dialog-content,
body.umm-showing-employer-dropdown .mfp-content {
    overflow: hidden !important;
}