/**
 * Mega Autocomplete - v1.0.1
 * Bootstrap 4.6.2 & RTL Compliant
 */

/* --- Wrapper for the Input --- */
.mega-autocomplete-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

/* --- Results Dropdown --- */
.autocomplete-results {
    position: absolute;
    /* BS4 RTL Compatibility: use right/left instead of inset-inline */
    right: 0;
    left: 0;
    top: 100%;
    margin-top: 10px;
    background: #ffffff;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1), 0 5px 15px rgba(0, 0, 0, 0.05);
    overflow-y: auto;
    max-height: 720px;
    display: none; 
    z-index: 9999;
    text-align: right; /* Force RTL text alignment */
}

/* --- Individual Result Item --- */
.autocomplete-item {
    padding: 12px 16px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid #f1f5f9;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s ease;
    color: #1e293b;
    text-decoration: none !important;
}

.autocomplete-item:last-child {
    border-bottom: none;
}

.autocomplete-item:hover, .autocomplete-item.active {
    background: #eef2ff;
    text-decoration: none;
    outline: none;
}

/* --- Score Pill (Red Circle on Left) --- */
.score-pill {
    width: 28px;
    height: 28px;
    border-radius: 50% !important; /* Perfect Circle */
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
    margin-left: 0;
    margin-right: 0;
}

/* --- Middle Content --- */
.flex-grow-1 {
    flex: 1;
    margin-right: 12px; /* Gap between score and text */
    margin-left: 12px;  /* Gap between text and icon */
    font-size: 0.95rem;
}

/* --- Icon (Right Side) --- */
.item-icon {
    width: 32px;
    height: 32px;
    background: #f1f5f9;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    color: #64748b;
}

/* --- Text Highlighting --- */
.highlight {
    background: #fef08a;
    font-weight: 600;
    padding: 0 2px;
    border-radius: 2px;
    color: #000;
}

/* --- Search Icon Prefix --- */
.search-icon-prefix {
    position: absolute;
    right: 15px; 
    color: #94a3b8;
    pointer-events: none;
    z-index: 5;
}

/* --- Bootstrap 4 Input Customization --- */
.mega_autocomplete.form-control-lg {
    padding-right: 45px !important; /* Space for search icon */
    border-radius: 12px;
    border: 2px solid #e2e8f0;
    height: calc(1.5 em + 1rem + 2px); /* BS4 height fix */
}

.mega_autocomplete:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 0.2rem rgba(99, 102, 241, 0.25);
}

/* --- Footer & Load More --- */
.load-more-wrap {
    padding: 12px;
    text-align: center;
    background-color: #f8fafc;
    border-top: 1px solid #f1f5f9;
}

.btn-load-more {
    background: #fff;
    border: 1px solid #6366f1;
    color: #6366f1;
    padding: 5px 20px;
    border-radius: 6px;
    font-weight: 600;
    transition: all 0.2s;
    cursor: pointer;
}

.btn-load-more:hover {
    background: #6366f1;
    color: #fff;
}

/* --- Mobile Responsiveness --- */
@media (max-width: 768px) {
    .autocomplete-results {
        left: 10px;
        right: 10px;
    }
}