/*
 * 搜尋即時預覽的下拉。
 *
 * 顏色跟著佈景主題的 CSS 變數走（--r858-* 定義在 theme 的 style.css），
 * 取不到就退回一組寫死的值 —— 這個外掛不該假設一定裝在哪個佈景上。
 */

.r858-sug {
    position: absolute;
    z-index: 999;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    max-height: 420px;
    overflow-y: auto;
    background: var(--r858-surface, #fff);
    color: var(--r858-ink, #222);
    border: 1px solid var(--r858-line, #dcdcde);
    border-radius: 4px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, .12);
    text-align: left;
}

.r858-sug__item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    text-decoration: none;
    color: inherit;
    border-bottom: 1px solid var(--r858-line, #eee);
}

.r858-sug__item:last-of-type { border-bottom: 0; }

/*
 * 滑鼠 hover 與鍵盤選取用同一個外觀 ——
 * 用鍵盤的人才知道自己選到哪一列。
 */
.r858-sug__item:hover,
.r858-sug__item:focus,
.r858-sug__item.is-active {
    background: var(--r858-hover, #f4f6f8);
    color: inherit;
}

.r858-sug__thumb {
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    object-fit: contain;
    background: #fff;
    border: 1px solid var(--r858-line, #eee);
    border-radius: 3px;
}

.r858-sug__thumb--none { background: var(--r858-hover, #f1f1f1); }

.r858-sug__text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.r858-sug__title {
    font-size: 14px;
    line-height: 1.35;
    /* 品名很長（「MSI微星 17吋電競筆電 i7-9750H 16G記憶體…」），限兩行 */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.r858-sug__price {
    font-size: 13px;
    font-weight: 600;
    color: var(--r858-price, #3e7cb4);
}

.r858-sug__empty {
    padding: 12px;
    font-size: 14px;
    color: var(--r858-muted, #666);
}

.r858-sug__all {
    display: block;
    width: 100%;
    padding: 9px 10px;
    border: 0;
    border-top: 1px solid var(--r858-line, #eee);
    background: var(--r858-hover, #f7f7f7);
    color: var(--r858-brand, #f15a23);
    font: inherit;
    font-size: 13px;
    text-align: center;
    cursor: pointer;
}

.r858-sug__all:hover { filter: brightness(.97); }

@media (prefers-color-scheme: dark) {
    .r858-sug {
        background: var(--r858-surface, #1f1f1f);
        color: var(--r858-ink, #e6e6e6);
        border-color: var(--r858-line, #3a3a3a);
        box-shadow: 0 6px 20px rgba(0, 0, 0, .5);
    }
    .r858-sug__item { border-bottom-color: var(--r858-line, #333); }
    .r858-sug__item:hover,
    .r858-sug__item.is-active { background: var(--r858-hover, #2a2a2a); }
    .r858-sug__all {
        background: var(--r858-hover, #262626);
        border-top-color: var(--r858-line, #333);
    }
}
