.wss-wrapper {
    position: relative;
    width: 100%;
    max-width: 560px;
    margin: 0 auto;
    font-family: Tahoma, 'Segoe UI', sans-serif;
    direction: rtl;
}

.wss-input-wrap {
    display: flex;
    align-items: center;
    background: #fff;
    border: 2px solid #e0e0e0;
    border-radius: 14px;
    padding: 0 14px;
    gap: 8px;
    transition: border-color .2s, box-shadow .2s;
    box-shadow: 0 2px 8px rgba(0,0,0,.06);
}

.wss-input-wrap:focus-within {
    border-color: #0088cc;
    box-shadow: 0 4px 16px rgba(0,136,204,.15);
}

.wss-icon { font-size: 18px; opacity: .5; flex-shrink: 0; }

.wss-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 15px;
    padding: 13px 0;
    background: transparent;
    color: #222;
    direction: rtl;
}

.wss-input::placeholder { color: #bbb; }

.wss-spinner {
    width: 18px; height: 18px;
    border: 2px solid #e0e0e0;
    border-top-color: #0088cc;
    border-radius: 50%;
    animation: wss-spin .7s linear infinite;
    display: none;
    flex-shrink: 0;
}

.wss-spinner.active { display: block; }

@keyframes wss-spin { to { transform: rotate(360deg); } }

.wss-clear {
    background: none; border: none; cursor: pointer;
    font-size: 14px; color: #aaa; padding: 0;
    display: none; line-height: 1; flex-shrink: 0;
}
.wss-clear.visible { display: block; }
.wss-clear:hover { color: #e74c3c; }

/* RESULTS DROPDOWN */
.wss-results {
    position: absolute;
    top: calc(100% + 8px);
    right: 0; left: 0;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 8px 32px rgba(0,0,0,.13);
    border: 1px solid #f0f0f0;
    overflow: hidden;
    z-index: 99999;
    max-height: 480px;
    overflow-y: auto;
    display: none;
    animation: wss-fade-in .15s ease;
}

.wss-results.open { display: block; }

@keyframes wss-fade-in {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* PRODUCT CARD */
.wss-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid #f5f5f5;
    transition: background .15s;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
}

.wss-item:last-child { border-bottom: none; }
.wss-item:hover { background: #f8fbff; }
.wss-item.focused { background: #eef6ff; }

.wss-item-img {
    width: 56px; height: 56px;
    object-fit: cover;
    border-radius: 8px;
    flex-shrink: 0;
    border: 1px solid #f0f0f0;
}

.wss-item-info { flex: 1; min-width: 0; }

.wss-item-name {
    font-size: 14px;
    font-weight: 600;
    color: #222;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.wss-item-price {
    font-size: 13px;
    color: #0088cc;
}

.wss-item-price ins {
    text-decoration: none;
    font-weight: 700;
}

.wss-item-price del {
    opacity: .5;
    font-size: 11px;
    margin-left: 4px;
}

.wss-item-badge {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 20px;
    font-weight: 600;
    flex-shrink: 0;
}

.wss-item-badge.instock   { background: #eafaf1; color: #27ae60; }
.wss-item-badge.outofstock { background: #fdf2f2; color: #e74c3c; }

.wss-add-btn {
    padding: 7px 14px;
    background: #0088cc;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    transition: background .2s, transform .1s;
    flex-shrink: 0;
}

.wss-add-btn:hover { background: #0077b3; }
.wss-add-btn:active { transform: scale(.96); }
.wss-add-btn.added  { background: #27ae60; }
.wss-add-btn.loading { background: #aaa; pointer-events: none; }

.wss-goto-btn {
    padding: 7px 14px;
    background: #f5f5f5;
    color: #555;
    border: none;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    transition: background .2s;
    flex-shrink: 0;
    text-decoration: none;
    display: inline-block;
}

.wss-goto-btn:hover { background: #e0e0e0; color: #222; }

/* STATUS BAR */
.wss-status {
    padding: 16px;
    text-align: center;
    font-size: 13px;
    color: #aaa;
}

/* TOAST */
.wss-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: #222;
    color: #fff;
    padding: 10px 24px;
    border-radius: 24px;
    font-size: 14px;
    z-index: 999999;
    opacity: 0;
    transition: opacity .3s, transform .3s;
    pointer-events: none;
    white-space: nowrap;
}

.wss-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* SCROLLBAR */
.wss-results::-webkit-scrollbar { width: 6px; }
.wss-results::-webkit-scrollbar-track { background: #f5f5f5; }
.wss-results::-webkit-scrollbar-thumb { background: #ddd; border-radius: 3px; }

/* ── OVERLAY ── */
.wss-popup-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.35);
    z-index: 999998;
    animation: wss-overlay-in .2s ease;
}
.wss-popup-overlay.active { display: block; }
@keyframes wss-overlay-in { from { opacity: 0; } to { opacity: 1; } }

/* ── POPUP ── */
.wss-popup {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 420px;
    max-width: calc(100vw - 32px);
    max-height: 90vh;
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 16px 56px rgba(0,0,0,.22);
    z-index: 999999;
    overflow: hidden;
    direction: rtl;
    font-family: Tahoma, 'Segoe UI', sans-serif;
}
.wss-popup.active {
    display: block;
    animation: wss-popup-in .22s cubic-bezier(.34,1.56,.64,1) forwards;
}
@keyframes wss-popup-in {
    from { opacity: 0; transform: translate(-50%, -48%) scale(.96); }
    to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
.wss-popup-inner { padding: 20px 20px 0; }
.wss-popup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}
.wss-popup-title { font-size: 16px; font-weight: 700; color: #FF7900; }
.wss-popup-close {
    background: none; border: none; font-size: 18px; color: #aaa;
    cursor: pointer; line-height: 1; padding: 4px; border-radius: 50%;
    transition: background .15s, color .15s;
    width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
}
.wss-popup-close:hover { background: #f5f5f5; color: #e74c3c; }

/* نتایج داخل پاپ‌آپ */
.wss-popup .wss-results {
    position: static;
    margin: 14px -20px 0;
    border-radius: 0;
    box-shadow: none;
    border: none;
    border-top: 1px solid #f0f0f0;
    max-height: 380px;
    overflow-y: auto;
}

/* فاصله پایین پاپ‌آپ */
.wss-popup-bottom-space { height: 20px; }

@media (max-width: 480px) {
    .wss-popup {
        width: calc(100vw - 24px);
        top: 50%;
        left: 50%;
    }
}