/**
 * IMA Auto-complete Styles
 *
 * Bootstrap 5 compliant styling for auto-complete component
 *
 * @package IMA_Network
 * @since 1.0.0
 */

/* Wrapper positioning */
.ima-autocomplete-wrapper {
    position: relative;
    width: 100%;
}

/* Input field - styled to match form-select with dropdown chevron */
.ima-autocomplete-input {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 16px 12px;
    padding-right: 2.25rem;
    cursor: pointer;
}

/* Dropdown menu - Bootstrap dropdown styling */
.ima-autocomplete-dropdown {
    /* Inherits Bootstrap .dropdown-menu styles */
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(0, 0, 0, 0.15);
}

.ima-autocomplete-dropdown.show {
    display: block !important;
}

/* Dropdown items - Bootstrap dropdown-item styling */
.ima-autocomplete-dropdown .dropdown-item {
    cursor: pointer;
    white-space: normal;
    word-wrap: break-word;
    padding: 0.5rem 1rem;
}

.ima-autocomplete-dropdown .dropdown-item:hover {
    background-color: var(--bs-dropdown-link-hover-bg, #f8f9fa);
    color: var(--bs-dropdown-link-hover-color, #1e2125);
}

.ima-autocomplete-dropdown .dropdown-item.active {
    background-color: var(--bs-primary, #0d6efd);
    color: #fff;
}

/* Loading state (optional future enhancement) */
.ima-autocomplete-wrapper.loading .ima-autocomplete-input {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Ccircle cx='10' cy='10' r='8' fill='none' stroke='%23999' stroke-width='2' stroke-dasharray='12.56' transform='rotate(0 10 10)'%3E%3CanimateTransform attributeName='transform' type='rotate' from='0 10 10' to='360 10 10' dur='1s' repeatCount='indefinite'/%3E%3C/circle%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 1rem 1rem;
}

/* Focus state - Bootstrap form-control focus */
.ima-autocomplete-input:focus {
    /* Inherits Bootstrap focus styles */
}

/* Clear button (optional future enhancement) */
.ima-autocomplete-wrapper .clear-btn {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    font-size: 1.25rem;
    line-height: 1;
    padding: 0.25rem;
    display: none;
}

.ima-autocomplete-wrapper .clear-btn:hover {
    color: #333;
}

.ima-autocomplete-input:not([value=""]) ~ .clear-btn {
    display: block;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .ima-autocomplete-dropdown {
        max-height: 250px !important;
    }

    .ima-autocomplete-dropdown .dropdown-item {
        padding: 0.5rem 0.75rem;
        font-size: 0.9rem;
    }
}

@media (max-width: 576px) {
    .ima-autocomplete-dropdown {
        max-height: 200px !important;
    }

    .ima-autocomplete-dropdown .dropdown-item {
        padding: 0.4rem 0.6rem;
        font-size: 0.85rem;
    }
}

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