
/*
 * AutoParts Shop - Search Bar UI Upgrade
 * --------------------------------------
 * این فایل فقط ظاهر نوار جستجو را تغییر می‌دهد.
 * منطق جستجو، URL، فرم و JavaScript فعلی دست‌نخورده می‌ماند.
 *
 * نصب:
 * 1) این فایل را داخل static/css/ قرار بده.
 * 2) در base.html بعد از CSSهای فعلی اضافه کن:
 *    <link rel="stylesheet" href="{% static 'css/search-bar.css' %}">
 */

.search-wrapper {
    position: relative;
    width: 100%;
    z-index: 100;
}

/* ---------- Main search field ---------- */
.search-bar {
    position: relative;
    width: 100%;
    height: 58px;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 7px 5px 9px;

    background: rgba(255, 255, 255, 0.98);
    border: 1px solid rgba(255, 255, 255, 0.65);
    border-radius: 17px;

    box-shadow:
        0 8px 24px rgba(0, 0, 0, 0.16),
        0 2px 5px rgba(0, 0, 0, 0.06);

    transition:
        border-color 0.22s ease,
        box-shadow 0.22s ease,
        transform 0.22s ease;
}

.search-bar:hover {
    border-color: rgba(244, 140, 6, 0.28);
    box-shadow:
        0 10px 28px rgba(0, 0, 0, 0.18),
        0 2px 7px rgba(0, 0, 0, 0.07);
}

.search-bar:focus-within {
    border-color: rgba(244, 140, 6, 0.65);
    box-shadow:
        0 12px 30px rgba(0, 0, 0, 0.18),
        0 0 0 4px rgba(244, 140, 6, 0.13);
    transform: translateY(-1px);
}

/* ---------- Search icon button ---------- */
.search-icon-btn {
    width: 45px;
    height: 45px;
    flex: 0 0 45px;

    display: flex;
    align-items: center;
    justify-content: center;

    border: 0;
    border-radius: 13px;
    background: linear-gradient(135deg, #F48C06, #e87500);
    color: #fff;

    cursor: pointer;
    transition:
        transform 0.18s ease,
        box-shadow 0.18s ease,
        background 0.18s ease;
}

.search-icon-btn:hover {
    background: linear-gradient(135deg, #ff9d1c, #e87500);
    transform: scale(1.04);
    box-shadow: 0 5px 13px rgba(244, 140, 6, 0.30);
}

.search-icon-btn:active {
    transform: scale(0.97);
}

.search-icon-btn svg {
    width: 21px;
    height: 21px;
}

/* ---------- Input ---------- */
.search-bar input {
    flex: 1;
    min-width: 0;
    height: 100%;

    padding: 0 12px;
    border: 0 !important;
    outline: 0 !important;
    box-shadow: none !important;

    background: transparent !important;

    color: #20212a;
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
}

.search-bar input::placeholder {
    color: #9699a7;
    opacity: 1;
    transition: color 0.2s ease;
}

.search-bar:focus-within input::placeholder {
    color: #b0b2bc;
}

/* ---------- Clear button ---------- */
.search-clear-btn {
    width: 32px;
    height: 32px;
    flex: 0 0 32px;

    display: none;
    align-items: center;
    justify-content: center;

    margin: 0 2px;
    padding: 0;

    border: 0;
    border-radius: 50%;
    background: #f1f2f5;
    color: #777b88;

    cursor: pointer;
    font-size: 12px;
    transition:
        background 0.18s ease,
        color 0.18s ease,
        transform 0.18s ease;
}

.search-clear-btn:hover {
    background: #e7e8ed;
    color: #30323a;
    transform: rotate(90deg);
}

.search-bar.has-text .search-clear-btn {
    display: flex;
}

/* ---------- Suggestions dropdown ---------- */
.search-dropdown {
    position: absolute;
    top: calc(100% + 9px);
    right: 0;
    left: 0;

    padding: 18px;

    background: rgba(255, 255, 255, 0.985);
    border: 1px solid rgba(20, 22, 35, 0.07);
    border-radius: 17px;

    box-shadow:
        0 20px 45px rgba(3, 7, 30, 0.20),
        0 5px 14px rgba(3, 7, 30, 0.08);

    z-index: 500;

    opacity: 0;
    visibility: hidden;
    pointer-events: none;

    transform: translateY(-7px) scale(0.985);
    transform-origin: top center;

    transition:
        opacity 0.18s ease,
        transform 0.18s ease,
        visibility 0.18s ease;
}

.search-wrapper.open .search-dropdown {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}

/* ---------- Hint ---------- */
.search-dropdown-hint {
    display: flex;
    align-items: center;
    gap: 9px;

    margin-bottom: 17px;
    padding: 11px 13px;

    background: linear-gradient(
        135deg,
        rgba(46, 196, 182, 0.09),
        rgba(244, 140, 6, 0.07)
    );

    border: 1px solid rgba(46, 196, 182, 0.12);
    border-radius: 11px;

    color: #777b88;
    font-size: 12px;
}

.search-dropdown-hint svg {
    width: 17px;
    height: 17px;
    color: #2EC4B6;
    flex-shrink: 0;
}

/* ---------- Popular searches ---------- */
.search-dropdown-title {
    display: flex;
    align-items: center;
    gap: 8px;

    margin-bottom: 11px;

    color: #242631;
    font-size: 13px;
    font-weight: 700;
}

.search-dropdown-title::before {
    content: "";
    width: 4px;
    height: 16px;
    border-radius: 99px;
    background: #F48C06;
}

.search-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;

    list-style: none;
    padding: 0;
    margin: 0;
}

.search-tag {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    min-height: 35px;
    padding: 6px 13px;

    background: #f7f7f9;
    border: 1px solid #ededf1;
    border-radius: 10px;

    color: #454752;
    font-size: 12px;
    cursor: pointer;

    transition:
        color 0.18s ease,
        background 0.18s ease,
        border-color 0.18s ease,
        transform 0.18s ease;
}

.search-tag:hover {
    background: rgba(244, 140, 6, 0.09);
    border-color: rgba(244, 140, 6, 0.30);
    color: #d97706;
    transform: translateY(-2px);
}

/* ---------- Search results ---------- */
.search-results-list {
    list-style: none;
    padding: 0;
    margin: 0 0 14px;
}

.search-results-list li a {
    display: flex;
    align-items: center;
    gap: 11px;

    padding: 9px;
    border-radius: 11px;

    color: #333641;
    font-size: 13px;

    transition: background 0.18s ease, transform 0.18s ease;
}

.search-results-list li a:hover {
    background: #f7f7f9;
    transform: translateX(-2px);
}

.search-results-list li a img {
    width: 42px;
    height: 42px;
    object-fit: contain;

    flex: 0 0 42px;

    background: #f7f7f9;
    border: 1px solid #ededf1;
    border-radius: 9px;
}

/* ---------- Search banner ---------- */
.search-ads-banner {
    display: block;
    margin-top: 17px;

    overflow: hidden;
    border-radius: 12px;

    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.07);
}

.search-ads-banner img {
    display: block;
    width: 100%;
    height: auto;

    transition: transform 0.35s ease;
}

.search-ads-banner:hover img {
    transform: scale(1.025);
}

/* ---------- Background overlay ---------- */
.search-modal-bg {
    position: fixed;
    inset: 0;

    background: rgba(3, 7, 30, 0.42);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);

    z-index: 90;

    opacity: 0;
    visibility: hidden;
    pointer-events: none;

    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.search-modal-bg.show {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* Keep the search itself above the overlay */
.search-wrapper {
    z-index: 120;
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
    .search-bar {
        height: 54px;
        border-radius: 15px;
    }

    .search-icon-btn {
        width: 42px;
        height: 42px;
        flex-basis: 42px;
        border-radius: 12px;
    }

    .search-dropdown {
        top: calc(100% + 7px);
        padding: 14px;
        border-radius: 15px;
        max-height: min(70vh, 430px);
    }
}

@media (max-width: 600px) {
    .search-bar {
        height: 50px;
        padding: 4px 6px 4px 7px;
        border-radius: 14px;
    }

    .search-icon-btn {
        width: 40px;
        height: 40px;
        flex-basis: 40px;
        border-radius: 11px;
    }

    .search-icon-btn svg {
        width: 19px;
        height: 19px;
    }

    .search-bar input {
        padding: 0 8px;
        font-size: 13px;
    }

    .search-clear-btn {
        width: 29px;
        height: 29px;
        flex-basis: 29px;
    }

    .search-dropdown {
        right: -4px;
        left: -4px;
        padding: 13px;
        border-radius: 14px;
    }

    .search-dropdown-hint {
        font-size: 11px;
        padding: 9px 10px;
    }

    .search-tag {
        min-height: 33px;
        padding: 5px 10px;
        font-size: 11px;
    }
}

/* Prevent browser default focus styles from fighting the design */
.search-bar button:focus-visible,
.search-bar input:focus-visible,
.search-tag:focus-visible {
    outline: 2px solid rgba(244, 140, 6, 0.55);
    outline-offset: 2px;
}
