/**
 * autocomplete.css — Styles for the Arabic-aware search autocomplete dropdown.
 *
 * RTL-aware, grouped suggestions with type headers.
 * Used by autocomplete.js on poetry-search.php and header search.
 */

/* ==========================================================================
   Dropdown Container
   ========================================================================== */

.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1000;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    max-height: 400px;
    overflow-y: auto;
    display: none;
    margin-top: 4px;
    font-family: 'Cairo', sans-serif;
}

/* RTL support */
html[dir="rtl"] .autocomplete-dropdown,
html[lang="ar"] .autocomplete-dropdown {
    text-align: right;
}

/* ==========================================================================
   Group Headers
   ========================================================================== */

.autocomplete-group {
    padding: 8px 12px;
    border-bottom: 1px solid #f0f0f0;
}

.autocomplete-group:last-child {
    border-bottom: none;
}

.autocomplete-group-label {
    font-size: 12px;
    font-weight: 600;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
    padding: 0 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.autocomplete-group-label i {
    color: #f97316;
    font-size: 13px;
}

/* ==========================================================================
   Suggestion Items
   ========================================================================== */

.autocomplete-item {
    padding: 10px 12px;
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.15s ease;
    display: flex;
    align-items: center;
    gap: 10px;
}

.autocomplete-item:hover,
.autocomplete-item[aria-selected="true"] {
    background: #f0f4ff;
}

.autocomplete-item:focus {
    outline: none;
    background: #f0f4ff;
}

.autocomplete-item-title {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 15px;
    color: #0f172a;
    font-weight: 500;
}

.autocomplete-item-title strong {
    color: #0f172a;
    font-weight: 700;
}

.autocomplete-item-meta {
    font-size: 13px;
    color: #f97316;
    white-space: nowrap;
    flex-shrink: 0;
    font-weight: 600;
}

/* ==========================================================================
   Empty State
   ========================================================================== */

.autocomplete-empty {
    padding: 16px;
    text-align: center;
    color: #888;
    font-size: 14px;
}

/* ==========================================================================
   Input Integration (when autocomplete is active)
   ========================================================================== */

.form-field--search {
    position: relative;
}

.form-field--search .form-field__input {
    padding-left: 44px; /* space for icon */
}

html[dir="rtl"] .form-field--search .form-field__input,
html[lang="ar"] .form-field--search .form-field__input {
    padding-right: 44px;
    padding-left: 16px;
}

.form-field__icon {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    color: #888;
    font-size: 18px;
    pointer-events: none;
}

html[dir="ltr"] .form-field__icon {
    left: 14px;
}

html[dir="rtl"] .form-field__icon,
html[lang="ar"] .form-field__icon {
    right: 14px;
}

/* ==========================================================================
   Loading State
   ========================================================================== */

.autocomplete-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    color: #888;
}

.autocomplete-loading::after {
    content: '';
    width: 18px;
    height: 18px;
    border: 2px solid #e0e0e0;
    border-top-color: #f97316;
    border-radius: 50%;
    animation: autocomplete-spin 0.8s linear infinite;
    margin-right: 10px;
}

html[dir="rtl"] .autocomplete-loading::after {
    margin-right: 0;
    margin-left: 10px;
}

@keyframes autocomplete-spin {
    to { transform: rotate(360deg); }
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 600px) {
    .autocomplete-dropdown {
        max-height: 300px;
        border-radius: 0 0 8px 8px;
    }

    .autocomplete-group-label {
        font-size: 11px;
    }

    .autocomplete-item {
        padding: 12px 14px;
    }

    .autocomplete-item-title {
        font-size: 14px;
    }
}