/* ===== Search Button (header) ===== */
.search-btn {
    position: relative;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.06);
    color: #ffffff;
    display: grid;
    place-items: center;
    cursor: pointer;
    transition: all var(--transition-base);
    font-size: 0.95rem;
}

.search-btn:hover {
    border-color: #ffffff;
    color: #ffffff;
    background: rgba(255, 255, 255, 0.12);
    transform: translateY(-1px);
}

.search-btn i {
    transition: transform var(--transition-base);
}

.search-btn:hover i {
    transform: scale(1.08);
}

/* ===== Search Overlay ===== */
.search-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding: 10vh 20px 20px;
}

.search-overlay.active {
    display: flex;
    animation: searchFadeIn 0.25s ease both;
}

.search-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(20, 22, 26, 0.45);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    cursor: pointer;
}

.search-panel {
    position: relative;
    width: 100%;
    max-width: 720px;
    background: #ffffff;
    border: 1px solid #e5e5e8;
    border-radius: var(--radius-xl);
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.18);
    overflow: hidden;
    animation: searchSlideDown 0.35s cubic-bezier(0.16, 1, 0.3, 1) both;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

/* ===== Input bar ===== */
.search-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    border-bottom: 1px solid #e5e5e8;
    background: #fafafa;
}

.search-input-icon {
    color: #4a4d52;
    font-size: 1rem;
    transition: color var(--transition-base);
}

.search-input-wrap:focus-within .search-input-icon {
    color: #14161a;
}

.search-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: #14161a;
    font-family: var(--font-arabic);
    font-size: 1.1rem;
    font-weight: 500;
    padding: 6px 2px;
}

.search-input::placeholder {
    color: #8b8e93;
    font-weight: 400;
}

.search-clear {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: #eeeef1;
    color: #4a4d52;
    cursor: pointer;
    display: none;
    place-items: center;
    font-size: 0.75rem;
    transition: all var(--transition-fast);
}

.search-clear.visible {
    display: grid;
}

.search-clear:hover {
    background: #14161a;
    color: #ffffff;
}

.search-close {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: 999px;
    border: 1px solid #d8d8dc;
    background: #ffffff;
    color: #4a4d52;
    font-family: var(--font-arabic);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all var(--transition-base);
}

.search-close kbd {
    font-family: var(--font-arabic);
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 6px;
    border: 1px solid #d8d8dc;
    background: #f7f7f8;
    color: #6e737a;
}

.search-close:hover {
    border-color: #14161a;
    color: #ffffff;
    background: #14161a;
}

.search-close:hover kbd {
    border-color: rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

/* ===== Body / states ===== */
.search-body {
    flex: 1;
    overflow-y: auto;
    padding: 18px 20px 22px;
    scrollbar-width: thin;
    scrollbar-color: #c8cacd transparent;
    background: #ffffff;
}

.search-body::-webkit-scrollbar {
    width: 6px;
}

.search-body::-webkit-scrollbar-thumb {
    background: #c8cacd;
    border-radius: 3px;
}

.search-state {
    animation: searchFadeIn 0.3s ease both;
}

.search-state[hidden] {
    display: none;
}

.search-section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #6e737a;
    font-size: 0.82rem;
    letter-spacing: 0.3px;
    margin: 14px 0 10px;
    font-weight: 600;
}

.search-section-title:first-child {
    margin-top: 4px;
}

.search-section-title i {
    color: #14161a;
    font-size: 0.78rem;
}

.search-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
}

.search-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 999px;
    border: 1px solid #e5e5e8;
    background: #f7f7f8;
    color: #4a4d52;
    font-family: var(--font-arabic);
    font-size: 0.88rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.search-chip:hover {
    border-color: #14161a;
    color: #ffffff;
    background: #14161a;
    transform: translateY(-1px);
}

.search-chip i {
    font-size: 0.72rem;
    color: #8b8e93;
}

.search-chip:hover i {
    color: #ffffff;
}

/* ===== No results state ===== */
.search-state-noresults {
    text-align: center;
    padding: 30px 20px 10px;
}

.search-noresults-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 14px;
    border-radius: 50%;
    background: #f7f7f8;
    border: 1px dashed #d8d8dc;
    display: grid;
    place-items: center;
    color: #6e737a;
    font-size: 1.5rem;
}

.search-state-noresults h3 {
    font-family: var(--font-arabic);
    font-weight: 700;
    color: #14161a;
    margin-bottom: 6px;
    font-size: 1.1rem;
}

.search-state-noresults p {
    color: #4a4d52;
    font-size: 0.92rem;
    margin-bottom: 16px;
}

.search-state-noresults .search-chips {
    justify-content: center;
}

/* ===== Results list ===== */
.search-results {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.search-result {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-align: right;
    background: transparent;
    width: 100%;
    font-family: var(--font-arabic);
    animation: searchResultIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.search-result:hover,
.search-result.active {
    border-color: #e5e5e8;
    background: #f7f7f8;
    transform: translateX(-3px);
}

.search-result-thumb {
    flex-shrink: 0;
    width: 52px;
    height: 52px;
    border-radius: 12px;
    background: #ffffff;
    border: 1px solid #e5e5e8;
    overflow: hidden;
    display: grid;
    place-items: center;
}

.search-result-thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 6px;
}

.search-result-info {
    flex: 1;
    min-width: 0;
}

.search-result-name {
    color: #14161a;
    font-weight: 700;
    font-size: 1rem;
    margin: 0 0 2px;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.search-result-name mark {
    background: transparent;
    color: #14161a;
    font-weight: 800;
    border-bottom: 2px solid #14161a;
}

.search-result-meta {
    color: #8b8e93;
    font-size: 0.82rem;
}

.search-result-meta span + span::before {
    content: '•';
    margin: 0 6px;
    color: #c8cacd;
}

.search-result-price {
    flex-shrink: 0;
    color: #14161a;
    font-weight: 700;
    font-family: var(--font-arabic);
    font-size: 0.95rem;
    padding-inline-start: 8px;
}

/* ===== Animations ===== */
@keyframes searchFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes searchSlideDown {
    from { opacity: 0; transform: translateY(-16px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes searchResultIn {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ===== Mobile ===== */
@media (max-width: 768px) {
    .search-overlay {
        padding: 0;
    }

    .search-panel {
        max-width: 100%;
        height: 100dvh;
        max-height: 100dvh;
        border-radius: 0;
        border: none;
    }

    .search-close span {
        display: none;
    }

    .search-close kbd {
        display: none;
    }

    .search-close {
        width: 40px;
        height: 40px;
        padding: 0;
        border-radius: 50%;
        justify-content: center;
    }

    .search-close::before {
        content: '\f00d';
        font-family: 'Font Awesome 6 Free';
        font-weight: 900;
        font-size: 0.85rem;
    }

    .search-input {
        font-size: 1rem;
    }

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

    /* Hide suggestions text + chips in no-results state on mobile */
    .search-state-noresults p,
    #search-noresults-chips {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .search-overlay.active,
    .search-panel,
    .search-state,
    .search-result {
        animation: none;
    }
}
