/* =========================================
   1. CONTAINER & RESET
   ========================================= */
.sbss-wrapper { 
    position: relative; width: 100%; direction: rtl;
    --sbss-drop-offset: 8px;
    --sbss-panel-gap: 0px;
    --sbss-icon-offset: 15px;
    --sbss-icon-space: 55px;
    --sbss-input-row-h: 45px;
    --sbss-overlay-z: 10051;
    border: none !important; background: transparent !important; 
    padding: 0 !important; margin: 0 !important; box-shadow: none !important; 
}
.sbss-form { 
    position: relative; display: block;
    width: 100%; margin: 0 !important; padding: 0 !important; 
}
.sbss-input-row {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
    flex-shrink: 0;
    direction: rtl;
    padding: 0;
    z-index: 2;
}
.sbss-wrapper.sbss-has-text .sbss-input-row,
.sbss-wrapper.sbss-panel-open .sbss-input-row {
    position: relative;
    z-index: calc(var(--sbss-overlay-z, 10051) + 2);
}

/* =========================================
   2. INPUT FIELD
   ========================================= */
.sbss-search-field {
    width: 100%; box-sizing: border-box;
    background: transparent; outline: none;
    transition: color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
    -webkit-appearance: none; appearance: none;
    position: relative; z-index: 1;
    min-height: 45px; display: block;
    direction: rtl;
    text-align: right;
    padding-left: calc(var(--sbss-icon-offset) + var(--sbss-icon-space));
    padding-right: 15px;
    margin: 0;
}
.sbss-search-field::-webkit-search-decoration,
.sbss-search-field::-webkit-search-cancel-button,
.sbss-search-field::-webkit-search-results-button,
.sbss-search-field::-webkit-search-results-decoration { display: none; }

/* اتصال بصری فیلد به پنل — بدون تغییر ابعاد */
.sbss-wrapper.sbss-panel-open .sbss-search-field {
    border-bottom-left-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
}

/* =========================================
   3. ICONS (SAFEGUARDED)
   ========================================= */
.sbss-icon-wrapper {
    position: absolute; z-index: 120;
    left: var(--sbss-icon-offset);
    right: auto;
    top: 0; bottom: 0;
    display: flex !important;
    flex-direction: row;
    align-items: center; justify-content: center;
    gap: 8px; pointer-events: none; width: auto;
}
.sbss-icon-slot {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    --sbss-slot-size: 22px;
    width: max(var(--sbss-slot-size), 22px);
    min-width: 22px;
    height: max(var(--sbss-slot-size), 22px);
    min-height: 22px;
    pointer-events: auto;
    font-size: 18px;
}
.sbss-icon-slot > .sbss-icon-single,
.sbss-icon-slot > .sbss-loading-spinner {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.2s, visibility 0.2s;
}
.sbss-icon-slot > .sbss-icon-single.sbss-icon-active,
.sbss-icon-slot > .sbss-loading-spinner.sbss-icon-active,
.sbss-wrapper:not(.sbss-has-text):not(.sbss-loading) .sbss-icon-slot > .sbss-search-icon,
.sbss-wrapper.sbss-has-text:not(.sbss-loading) .sbss-icon-slot > .sbss-close-icon,
.sbss-wrapper.sbss-loading .sbss-icon-slot > .sbss-loading-spinner {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    z-index: 1;
}
.sbss-wrapper.sbss-has-text:not(.sbss-loading) .sbss-icon-slot > .sbss-search-icon,
.sbss-wrapper.sbss-loading .sbss-icon-slot > .sbss-search-icon,
.sbss-wrapper.sbss-loading .sbss-icon-slot > .sbss-close-icon {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}
.sbss-icon-single, .sbss-mic-icon, .sbss-loading-spinner {
    align-items: center; justify-content: center; 
    pointer-events: auto; cursor: pointer; transition: color 0.2s, opacity 0.2s;
    font-size: inherit; color: #333; min-width: 22px; min-height: 22px;
    line-height: 1;
}
.sbss-mic-icon {
    display: none;
}
.sbss-icon-single svg, .sbss-icon-single i, .sbss-mic-icon svg, .sbss-mic-icon i {
    width: 1em; height: 1em; font-size: inherit;
    fill: currentColor; color: inherit;
    display: block !important;
}
.sbss-fallback-icon {
    width: 1em; height: 1em; display: block !important;
    flex-shrink: 0;
    color: inherit;
}
.sbss-icon-single .e-font-icon-svg,
.sbss-mic-icon .e-font-icon-svg {
    width: 1em; height: 1em; fill: currentColor; display: block !important;
}
.sbss-icon-single i.fas,
.sbss-icon-single i.far,
.sbss-mic-icon i.fas {
    font-family: "Font Awesome 5 Free", "Font Awesome 6 Free", FontAwesome, sans-serif;
    font-weight: 900;
    font-style: normal;
    display: inline-block !important;
}

/* DISPLAY LOGIC — جستجو / بستن / لودینگ با کلاس sbss-icon-active در JS */
.sbss-wrapper:not(.sbss-loading):not(.sbss-has-text).sbss-is-android .sbss-mic-icon { display: flex !important; }

@media (max-width: 767px) {
    .sbss-wrapper.sbss-has-text .sbss-icon-wrapper { display: flex !important; z-index: 100000 !important; }
}

.sbss-close-icon.sbss-icon-active:hover { opacity: 0.8; color: #000; }
.sbss-mic-icon.listening { animation: sbss-pulse-anim 1.5s infinite; color: #ff0000; }
@keyframes sbss-pulse-anim { 0% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.2); opacity: 0.7; } 100% { transform: scale(1); opacity: 1; } }

/* SPINNERS */
.sbss-loading-spinner { display: flex; }
.sbss-spinner-classic { width: 20px; height: 20px; border: 2px solid #ccc; border-top-color: #333; border-radius: 50%; animation: sbss-spin 0.8s linear infinite; }
.sbss-spinner-dual { width: 20px; height: 20px; }
.sbss-spinner-dual:after { content: " "; display: block; width: 100%; height: 100%; border-radius: 50%; border: 2px solid; border-color: currentColor transparent currentColor transparent; animation: sbss-spin 1.2s linear infinite; }
.sbss-spinner-pulse { width: 20px; height: 20px; background-color: currentColor; border-radius: 100%; animation: sbss-scaleout 1.0s infinite ease-in-out; }
.sbss-spinner-dots { display: flex; align-items: center; gap: 2px; }
.sbss-spinner-dot { width: 6px; height: 6px; background-color: currentColor; border-radius: 100%; display: inline-block; animation: sbss-bouncedelay 1.4s infinite ease-in-out both; }
.sbss-spinner-dot:nth-child(1) { animation-delay: -0.32s; } .sbss-spinner-dot:nth-child(2) { animation-delay: -0.16s; }
@keyframes sbss-spin { to { transform: rotate(360deg); } }
@keyframes sbss-scaleout { 0% { transform: scale(0); } 100% { transform: scale(1.0); opacity: 0; } }
@keyframes sbss-bouncedelay { 0%, 80%, 100% { transform: scale(0); } 40% { transform: scale(1.0); } }

/* =========================================
   4. ANIMATED PLACEHOLDER
   ========================================= */
.tx-placeholder-inside {
    position: absolute; top: 0; bottom: 0;
    left: calc(var(--sbss-icon-offset) + var(--sbss-icon-space));
    right: 15px;
    display: flex; align-items: center; justify-content: flex-end;
    pointer-events: none; overflow: hidden; z-index: 1; direction: rtl;
}
.tx-placeholder-inside.sbss-hidden { opacity: 0; visibility: hidden; transition: opacity 0.2s; }
.tx-line { position: absolute; right: 0; height: 100%; display: flex; align-items: center; gap: 8px; white-space: nowrap; opacity: 0; transform: translateY(150%); visibility: hidden; transition: all 0.5s cubic-bezier(0.25, 1, 0.5, 1), visibility 0s 0.5s; color: #888; }
.tx-line.active { opacity: 1; transform: translateY(0); visibility: visible; transition: all 0.5s cubic-bezier(0.25, 1, 0.5, 1), visibility 0s 0s; }
.tx-line.exit { opacity: 0; transform: translateY(-150%); visibility: hidden; }
.tx-icons { display: flex; align-items: center; height: 100%; gap: 5px; }
.tx-icons img { display: block; object-fit: contain; max-height: 100%; margin:0; padding:0; border:none; }
.tx-text { display: flex; align-items: center; height: 100%; line-height: 1; }
.sbss-wrapper.sbss-is-android .sbss-search-field {
    padding-left: calc(var(--sbss-icon-offset) + var(--sbss-icon-space) + 30px);
}
.sbss-wrapper.sbss-is-android .tx-placeholder-inside {
    left: calc(var(--sbss-icon-offset) + var(--sbss-icon-space) + 30px);
}

/* =========================================
   5. DROPDOWN — همیشه overlay، خارج از جریان layout
   ========================================= */
.sbss-dropdown-panel {
    position: relative;
    width: 100%;
    box-sizing: border-box;
}

.sbss-wrapper.sbss-panel-open {
    z-index: 10050;
}

.sbss-results-container {
    display: none;
    position: fixed;
    left: 0;
    top: 0;
    width: 100px;
    z-index: var(--sbss-overlay-z, 10051) !important;
    background: #fff;
    border: 1px solid #e0e0e2;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
    border-radius: var(--sbss-drop-radius, 12px);
    overflow: hidden;
    overflow-y: auto;
    box-sizing: border-box;
    animation: sbss-fade-in 0.2s ease-out;
}

@keyframes sbss-fade-in { from { opacity: 0; transform: translateY(-5px); } to { opacity: 1; transform: translateY(0); } }

.sbss-start-screen { padding: 20px; }
.sbss-section-title { font-size: 13px; font-weight: 700; color: #777; margin-bottom: 12px; display: flex; align-items: center; gap: 5px; }
.sbss-section-title img.emoji { width: 16px; height: 16px; margin: 0; }
.sbss-trend-list, .sbss-history-list { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.sbss-trend-item, .sbss-history-item { display: inline-flex; align-items: center; padding: 6px 14px; background-color: #f5f7fa; border-radius: 50px; font-size: 12px; color: #555; cursor: pointer; transition: all 0.2s ease; white-space: nowrap; border: 1px solid transparent; }
.sbss-trend-item:hover, .sbss-history-item:hover { background-color: #fff; border-color: #ddd; box-shadow: 0 2px 5px rgba(0,0,0,0.05); color: #333; }
.sbss-banner { display: block; overflow: hidden; margin-bottom: 20px; border-radius: 8px; }
.sbss-banner img { width: 100%; height: auto; display: block; transition: transform 0.5s ease; }
.sbss-banner:hover img { transform: scale(1.02); }

.sbss-results { max-height: 400px; overflow-y: auto; padding: 0; }
.sbss-results::-webkit-scrollbar { width: 5px; }
.sbss-results::-webkit-scrollbar-track { background: #f1f1f1; }
.sbss-results::-webkit-scrollbar-thumb { background: #ccc; border-radius: 4px; }
.sbss-results::-webkit-scrollbar-thumb:hover { background: #aaa; }
.sbss-results ul, .sbss-results .sbss-product-list { list-style: none; margin: 0; padding: 0; }
.sbss-results li a { display: flex; align-items: center; padding: 12px 15px; border-bottom: 1px solid #f0f0f0; text-decoration: none; color: #333; transition: background 0.2s; background: #fff; }
.sbss-results .sbss-product-list li:last-child a { border-bottom: none; }
.sbss-results li a:hover { background: #f9f9f9; }
.sbss-results img { flex-shrink: 0; width: 50px; height: 50px; object-fit: cover; border-radius: var(--sbss-prod-img-radius, 6px); margin-left: 15px; border: 1px solid #eee; background: #fff; }
.sbss-results-info { display: flex; flex-direction: column; justify-content: center; flex-grow: 1; }
.sbss-results-title { font-weight: 500; font-size: 13px; line-height: 1.5; color: #333; margin-bottom: 4px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.sbss-results-price { font-size: 13px; font-weight: 700; color: #333; display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.sbss-results-price del { color: #aaa; font-size: 11px; text-decoration: line-through; font-weight: normal; }
.sbss-results-price ins { color: #ff0000; text-decoration: none; font-weight: 700; }
.sbss-results-price .amount { display: inline-flex; align-items: center; }

/* --- CORRECTION MESSAGE --- */
.sbss-correction-msg {
    padding: 12px 15px;
    background: #fff8e1; 
    border-bottom: 1px solid #fae1a0;
    font-size: 12px;
    color: #5d4037;
    display: flex; align-items: center; gap: 5px;
}
.sbss-correction-word {
    font-weight: bold;
    color: #d35400;
    text-decoration: underline;
    text-decoration-style: dotted;
    cursor: pointer;
    transition: color 0.2s;
}
.sbss-correction-word:hover {
    color: #e67e22;
}

/* پیش‌نمایش در ویرایشگر المنتور */
.elementor-editor-active .sbss-wrapper.sbss-elementor-preview .sbss-results-container {
    position: absolute !important;
    top: 100% !important;
    left: 0 !important;
    right: 0 !important;
    width: auto !important;
    display: block !important;
}
.elementor-editor-active .sbss-wrapper.sbss-elementor-preview .sbss-start-screen {
    display: block !important;
}

/* =========================================
   7. KEYWORD SUGGESTIONS + CATEGORY HINT
   ========================================= */
.sbss-suggestions {
    border-bottom: 1px solid #f0f0f0;
    max-height: 220px;
    overflow-y: auto;
}
.sbss-suggest-section-title,
.sbss-results-section-title {
    padding: 10px 16px 6px;
    font-size: 12px;
    font-weight: 700;
    color: #81858b;
}
.sbss-results-section-title {
    border-top: 1px solid #f0f0f0;
    background: #fafbfc;
}
.sbss-suggest-count {
    color: #a1a3a8;
    font-size: 11px;
    font-weight: 400;
}
.sbss-suggest-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.sbss-suggest-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    cursor: pointer;
    transition: background 0.15s ease;
    border-bottom: 1px solid #f5f5f5;
}
.sbss-suggest-item:last-child { border-bottom: none; }
.sbss-suggest-item:hover { background: #f7f9fc; }
.sbss-suggest-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    opacity: 0.55;
    background-repeat: no-repeat;
    background-position: center;
    background-size: 18px 18px;
}
.sbss-suggest-icon-search {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3-3'/%3E%3C/svg%3E");
}
.sbss-suggest-icon-history {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 7v5l3 2'/%3E%3C/svg%3E");
}
.sbss-suggest-icon-category {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23666'%3E%3Crect x='3' y='3' width='8' height='8' rx='1'/%3E%3Crect x='13' y='3' width='8' height='8' rx='1'/%3E%3Crect x='3' y='13' width='8' height='8' rx='1'/%3E%3Crect x='13' y='13' width='8' height='8' rx='1'/%3E%3C/svg%3E");
}
.sbss-suggest-main {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-width: 0;
    direction: rtl;
}
.sbss-suggest-term {
    font-size: 14px;
    font-weight: 500;
    color: #232933;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: right;
}
.sbss-suggest-cat {
    flex-shrink: 0;
    font-size: 12px;
    color: #19bfd3;
    font-weight: 400;
    white-space: nowrap;
    text-align: left;
}
.sbss-results .sbss-product-list {
    border-top: 1px solid #f0f0f0;
}

/* --- EMPTY STATE --- */
.sbss-no-results {
    padding: 15px;
    text-align: center;
    color: #888;
    font-size: 13px;
    line-height: 1.6;
}
.sbss-no-results .sbss-correction-msg {
    border: none;
    background: transparent;
    padding: 0;
    justify-content: center;
}

/* --- RESULTS SKELETON --- */
.sbss-results-skeleton {
    padding: 0;
}
.sbss-skeleton-section-title {
    height: 14px;
    width: 72px;
    margin: 10px 16px 8px;
    border-radius: 4px;
    background: linear-gradient(90deg, #eceff1 25%, #f5f7fa 50%, #eceff1 75%);
    background-size: 200% 100%;
    animation: sbss-skeleton-shimmer 1.2s ease-in-out infinite;
}
.sbss-skeleton-section-title--wide {
    width: 96px;
}
.sbss-skeleton-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.sbss-skeleton-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px 15px;
    border-bottom: 1px solid #f0f0f0;
}
.sbss-skeleton-item:last-child {
    border-bottom: none;
}
.sbss-skeleton-thumb {
    flex-shrink: 0;
    width: 50px;
    height: 50px;
    border-radius: 6px;
    background: linear-gradient(90deg, #eceff1 25%, #f5f7fa 50%, #eceff1 75%);
    background-size: 200% 100%;
    animation: sbss-skeleton-shimmer 1.2s ease-in-out infinite;
    animation-delay: 0.05s;
}
.sbss-skeleton-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.sbss-skeleton-line {
    height: 12px;
    border-radius: 4px;
    background: linear-gradient(90deg, #eceff1 25%, #f5f7fa 50%, #eceff1 75%);
    background-size: 200% 100%;
    animation: sbss-skeleton-shimmer 1.2s ease-in-out infinite;
}
.sbss-skeleton-line-title {
    width: 78%;
    height: 14px;
}
.sbss-skeleton-line-price {
    width: 42%;
    height: 12px;
    animation-delay: 0.15s;
}
@keyframes sbss-skeleton-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* --- SUGGESTIONS / CATEGORIES SKELETON --- */
.sbss-suggestions-skeleton {
    padding: 0;
}
.sbss-skeleton-suggest-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.sbss-skeleton-suggest-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid #f5f5f5;
}
.sbss-skeleton-suggest-item:last-child {
    border-bottom: none;
}
.sbss-skeleton-suggest-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    border-radius: 4px;
    background: linear-gradient(90deg, #eceff1 25%, #f5f7fa 50%, #eceff1 75%);
    background-size: 200% 100%;
    animation: sbss-skeleton-shimmer 1.2s ease-in-out infinite;
}
.sbss-skeleton-suggest-main {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    direction: rtl;
}
.sbss-skeleton-line-term {
    width: 38%;
    height: 14px;
    flex-shrink: 0;
}
.sbss-skeleton-line-cat {
    width: 32%;
    height: 12px;
    animation-delay: 0.12s;
}
