/* ============================================
   استایل جستجوی ایجکسی - Autocomplete Style
   ============================================ */

/* کانتینر اصلی جستجو - position:relative ضروری است */
.top-bar-z .search,
.top-bar-z .columns.search {
    position: relative;
    z-index: 9999;
}

/* کانتینر نتایج جستجو - Dropdown */
.search-results-container {
    position: absolute;
    top: 100%;
    right: 0;
    left: 0;
    min-width: 380px;
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-top: 2px solid #1583B8;
    border-radius: 0 0 10px 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
    z-index: 100000;
    max-height: 450px;
    overflow-y: auto;
    overflow-x: hidden;
    display: none;
    margin-top: 4px;
}

/* لودینگ */
.search-loading {
    padding: 25px 20px;
    text-align: center;
}

.search-loading .spinner {
    width: 36px;
    height: 36px;
    border: 3px solid #e8e8e8;
    border-top: 3px solid #1583B8;
    border-radius: 50%;
    animation: searchSpin 0.8s linear infinite;
    margin: 0 auto 12px;
}

@keyframes searchSpin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.search-loading p {
    color: #888;
    font-size: 13px;
    margin: 0;
}

/* هدر نتایج */
.search-results-header {
    background: #f5f7fa;
    padding: 8px 14px;
    font-size: 12px;
    color: #777;
    border-bottom: 1px solid #eee;
    font-weight: 600;
}

/* لیست نتایج */
.search-results-list {
    padding: 0;
}

/* هر آیتم نتیجه */
.search-result-item {
    border-bottom: 1px solid #f0f0f0;
    transition: background-color 0.15s ease;
    list-style: none;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background-color: #f0f7fc;
}

/* لینک هر آیتم */
.search-result-item > a {
    display: flex !important;
    align-items: center;
    padding: 10px 14px;
    text-decoration: none;
    color: inherit;
    gap: 12px;
    width: 100%;
    box-sizing: border-box;
}

/* تصویر کتاب - کوچک و جمع‌وجور */
.search-result-image {
    width: 45px !important;
    height: 60px !important;
    flex-shrink: 0;
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid #e0e0e0;
    background: #f9f9f9;
    line-height: 1;
}

.search-result-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* اطلاعات کتاب */
.search-result-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    overflow: hidden;
}

/* عنوان کتاب */
.search-result-title {
    font-size: 14px;
    font-weight: 700;
    color: #2c3e50;
    margin: 0;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* توضیحات */
.search-result-desc {
    font-size: 11px;
    color: #999;
    margin: 0;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* بخش قیمت */
.search-price {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: nowrap;
    margin-top: 2px;
}

.search-original-price {
    font-size: 11px;
    color: #bbb;
    text-decoration: line-through;
    white-space: nowrap;
}

.search-final-price {
    font-size: 14px;
    font-weight: 700;
    color: #e74c3c;
    white-space: nowrap;
}

.search-discount {
    font-size: 10px;
    color: #fff;
    background: #27ae60;
    padding: 1px 6px;
    border-radius: 8px;
    font-weight: 600;
    white-space: nowrap;
}

/* فوتر نتایج - لینک مشاهده همه */
.search-results-footer {
    text-align: center;
    padding: 10px;
    background: #f5f7fa;
    border-top: 1px solid #eee;
}

.search-results-footer a {
    display: inline-block;
    padding: 6px 20px;
    background: #1583B8;
    color: #fff;
    border-radius: 5px;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    transition: background 0.2s;
}

.search-results-footer a:hover {
    background: #0d6da3;
    color: #fff;
}

/* پیام بدون نتیجه */
.search-no-results {
    padding: 30px 20px;
    text-align: center;
    color: #999;
}

.search-no-results i {
    font-size: 36px;
    margin-bottom: 10px;
    display: block;
    color: #ccc;
}

.search-no-results p {
    font-size: 13px;
    margin: 0;
}

/* پیام خطا */
.search-error {
    padding: 25px 20px;
    text-align: center;
    color: #e74c3c;
}

.search-error i {
    font-size: 36px;
    margin-bottom: 10px;
    display: block;
}

.search-error p {
    font-size: 13px;
    margin: 0;
}

/* اسکرول‌بار سفارشی */
.search-results-container::-webkit-scrollbar {
    width: 6px;
}

.search-results-container::-webkit-scrollbar-track {
    background: #f5f5f5;
}

.search-results-container::-webkit-scrollbar-thumb {
    background: #c0c0c0;
    border-radius: 3px;
}

.search-results-container::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* ========== ریسپانسیو ========== */
@media (max-width: 768px) {
    .search-results-container {
        min-width: 100%;
        right: 0;
        left: 0;
        max-height: 400px;
    }

    .search-result-item > a {
        padding: 8px 10px;
        gap: 10px;
    }

    .search-result-image {
        width: 40px !important;
        height: 54px !important;
    }

    .search-result-title {
        font-size: 13px;
    }

    .search-result-desc {
        display: none;
    }

    .search-final-price {
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .search-results-container {
        border-radius: 0 0 6px 6px;
    }

    .search-result-image {
        width: 36px !important;
        height: 48px !important;
    }

    .search-original-price {
        font-size: 10px;
    }

    .search-final-price {
        font-size: 12px;
    }

    .search-discount {
        font-size: 9px;
        padding: 1px 5px;
    }
}