/* static/search_filter/css/search_bar.css */

/* ─── Container الرئيسي ─── */
.search-container {
    width: 100%;
    max-width: 780px;
    margin: 0 auto 20px;
    background: #ffffff;
    border-radius: 24px;
    padding: 18px;
    box-shadow:
        0 6px 28px rgba(0, 0, 0, 0.04),
        0 14px 50px rgba(0, 0, 0, 0.06);
    transition: 0.3s ease;
    /* مهم: position relative لكي تعمل الاقتراحات الأولية تحته */
    position: relative;
}

/* ─── صف البحث ─── */
.search-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    direction: rtl;
}

/* ─── حقل النص ─── */
.search-input {
    flex: 1 1 220px;
    height: 52px;
    padding: 0 20px 0 16px;
    border-radius: 16px;
    border: 1px solid #eef1f4;
    font-size: 15px;
    background: #fafafa;
    text-align: right;
    direction: rtl;
    unicode-bidi: plaintext;
    transition: 0.28s ease;
}

.search-input::placeholder {
    color: #a1a7b3;
}

.search-input:focus {
    outline: none;
    background: #fff;
    border-color: #5a3dff;
    box-shadow: 0 0 0 4px rgba(90, 61, 255, 0.18);
}

/* ─── زر البحث ─── */
.search-btn {
    flex: 0 0 auto;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #8a7be0, #b0a4ff);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.28s cubic-bezier(0.17, 0.67, 0.88, 1);
    box-shadow:
        0 8px 24px rgba(98, 78, 255, 0.28),
        inset 0 2px 6px rgba(255, 255, 255, 0.28);
    filter: brightness(1.02);
}

.search-btn:hover {
    transform: translateY(-3px);
    box-shadow:
        0 12px 32px rgba(98, 78, 255, 0.38),
        inset 0 2px 8px rgba(255, 255, 255, 0.35);
}

.search-btn:active {
    transform: scale(0.95);
    box-shadow: 0 4px 14px rgba(98, 78, 255, 0.25);
}

.search-btn svg {
    width: 22px;
    height: 22px;
    fill: #ffffff;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.18));
}

/* ─── Dropdown الاقتراحات المتحرك (مُلحق بـ body) ─── */
.search-results {
    position: absolute;
    z-index: 1050;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.10);
    max-height: 380px;
    overflow-y: auto;
    display: none;
}

.search-results .suggestions-header {
    padding: 8px 14px;
    font-size: 0.78rem;
    font-weight: 600;
    color: #6b7280;
    background: #f8fafc;
    border-bottom: 1px solid #e9ecef;
    border-radius: 12px 12px 0 0;
    user-select: none;
}

.search-results .suggestion-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 14px;
    cursor: pointer;
    border-bottom: 1px solid #f1f5f9;
    transition: background-color 0.15s;
    font-size: 0.9rem;
    color: #1e293b;
    direction: rtl;
}

.search-results .suggestion-item:last-child {
    border-bottom: none;
    border-radius: 0 0 12px 12px;
}

.search-results .suggestion-item:hover {
    background-color: #f1f5f9;
}

.search-results .suggestion-item .flex-grow {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ─── زر حذف السجل ─── */
.search-results .delete-btn {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    margin-inline-start: 10px;
    border-radius: 50%;
    border: 1px solid transparent;
    background: #f1f5f9;
    cursor: pointer;
    color: #94a3b8;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.18s, background-color 0.18s, color 0.18s, border-color 0.18s, transform 0.15s;
}

.search-results .suggestion-item:hover .delete-btn {
    opacity: 1;
}

.search-results .delete-btn:hover {
    background-color: #fee2e2;
    border-color: #fecaca;
    color: #dc2626;
    opacity: 1;
    transform: scale(1.12);
}

.search-results .delete-btn:active {
    transform: scale(0.92);
}

/* موبايل: الزر مرئي دائماً */
@media (hover: none) {
    .search-results .delete-btn,
    .suggestion-item-initial .delete-btn-initial {
        opacity: 1;
    }
}

/* ─── الاقتراحات الأولية (تحت الـ container) ─── */
.initial-suggestions {
    margin-top: 14px;
    padding: 14px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
    direction: rtl;
}

.suggestions-section h4 {
    margin: 0 0 10px;
    font-size: 0.78rem;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.suggestions-list {
    display: grid;
    gap: 8px;
}

.suggestion-item-initial {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: #f8fafc;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    color: #1e293b;
    transition: background-color 0.15s, border-color 0.15s;
    direction: rtl;
}

.suggestion-item-initial .suggestion-text {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.suggestion-item-initial:hover {
    background: #e9f0fa;
    border-color: #c7d9f5;
}

/* ─── زر X داخل الاقتراحات الأولية ─── */
.suggestion-item-initial .delete-btn-initial {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    margin-inline-start: 10px;
    border-radius: 50%;
    border: 1px solid transparent;
    background: #f1f5f9;
    cursor: pointer;
    color: #94a3b8;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.18s, background-color 0.18s, color 0.18s, border-color 0.18s, transform 0.15s;
}

.suggestion-item-initial:hover .delete-btn-initial {
    opacity: 1;
}

.suggestion-item-initial .delete-btn-initial:hover {
    background-color: #fee2e2;
    border-color: #fecaca;
    color: #dc2626;
    opacity: 1;
    transform: scale(1.12);
}

.suggestion-item-initial .delete-btn-initial:active {
    transform: scale(0.92);
}

@media (hover: none), (pointer: coarse) {
    .search-results .delete-btn,
    .suggestion-item-initial .delete-btn-initial {
        opacity: 1;
    }
}

.section-divider {
    height: 1px;
    background: #e9ecef;
    margin: 12px 0;
}

/* ─── Mobile ─── */
@media (max-width: 520px) {
    .search-container {
        margin: 20px 0 20px;
    }

    .search-row {
        gap: 10px;
    }

    .search-input {
        flex: 1 1 70%;
        height: 48px;
        padding: 0 18px 0 14px;
    }

    .search-btn {
        width: 52px;
        height: 52px;
    }
}