/* ═══════════════════════════════════════════
   Smart Sales Chat - Widget CSS v2
   طراحی مثل رایچت
═══════════════════════════════════════════ */

.ssc-hidden { display: none !important; }
#ssc-root .ssc-hidden,
#ssc-root .ssc-panel.ssc-hidden { display: none !important; }

/* Root */
#ssc-root {
    position: fixed;
    z-index: 2147483647;
    font-family: inherit;
    direction: rtl;
    display: block;
    isolation: isolate;
}

#ssc-root *,
#ssc-root *::before,
#ssc-root *::after {
    box-sizing: border-box;
    font-family: inherit;
}

@media (max-width: 600px) {
    body.ssc-open {
        overflow: hidden;
        position: fixed;
        width: 100%;
        height: 100%;
    }
}

/* ═══════════════════════════════════════════
   موقعیت پنل بر اساس محل ویجت
═══════════════════════════════════════════ */

/* پیش‌فرض: پایین-راست → پنل بالای دکمه، هم‌تراز راست */
#ssc-root .ssc-panel {
    bottom: calc(100% + 14px);
    top: auto;
    right: 0;
    left: auto;
}

/* پایین-چپ */
#ssc-root[data-pos="bottom-left"] .ssc-panel {
    bottom: calc(100% + 14px);
    top: auto;
    left: 0;
    right: auto;
}

/* بالا-راست → پنل زیر دکمه */
#ssc-root[data-pos="top-right"] .ssc-panel {
    top: calc(100% + 14px);
    bottom: auto;
    right: 0;
    left: auto;
}

/* بالا-چپ → پنل زیر دکمه، هم‌تراز چپ */
#ssc-root[data-pos="top-left"] .ssc-panel {
    top: calc(100% + 14px);
    bottom: auto;
    left: 0;
    right: auto;
}

/* در حالت بالا، انیمیشن از بالا بیاید */
#ssc-root[data-pos^="top-"] .ssc-panel {
    animation: ssc-slide-down .3s ease;
}

@keyframes ssc-slide-down {
    from { opacity: 0; transform: translateY(-12px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ─── دکمه شناور ─── */
.ssc-toggle {
    position: relative;
    z-index: 1;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, var(--ssc-primary), var(--ssc-primary-dark));
    color: #fff;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .2);
    transition: transform .2s, box-shadow .2s;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 0;
}
.ssc-toggle:hover { transform: scale(1.08); }
.ssc-toggle:active { transform: scale(0.95); }

/* ═══════════════════════════════════════════
   ⭐ آیکن هوش مصنوعی — مدرن و متحرک
═══════════════════════════════════════════ */

/* هاله نبض‌دار پشت دکمه */
.ssc-toggle-halo {
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--ssc-primary), var(--ssc-primary-light, var(--ssc-primary)));
    opacity: .35;
    z-index: -1;
    animation: ssc-halo 2.8s ease-in-out infinite;
    pointer-events: none;
}

@keyframes ssc-halo {
    0%, 100% { transform: scale(1);    opacity: .32; }
    50%      { transform: scale(1.16); opacity: 0; }
}

.ssc-ai-icon {
    width: 30px;
    height: 30px;
    display: block;
    color: #fff;
    overflow: visible;
}

/* حباب: تنفس ملایم */
.ssc-ai-bubble,
.ssc-ai-bubble-line {
    transform-origin: 16px 18px;
    animation: ssc-ai-breathe 3.4s ease-in-out infinite;
}

@keyframes ssc-ai-breathe {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.05); }
}

/* سه نقطه: موج «در حال فکر کردن» */
.ssc-ai-d {
    animation: ssc-ai-think 1.5s ease-in-out infinite;
    transform-origin: center;
}
.ssc-ai-d1 { animation-delay: 0s; }
.ssc-ai-d2 { animation-delay: .18s; }
.ssc-ai-d3 { animation-delay: .36s; }

@keyframes ssc-ai-think {
    0%, 60%, 100% { opacity: .45; transform: translateY(0) scale(.88); }
    30%           { opacity: 1;   transform: translateY(-2.2px) scale(1.12); }
}

/* جرقه‌ها: درخشش نامتقارن */
.ssc-ai-spark { transform-box: fill-box; transform-origin: center; }

.ssc-ai-spark-1 { animation: ssc-ai-sparkle 2.6s ease-in-out infinite; }
.ssc-ai-spark-2 { animation: ssc-ai-sparkle 2.6s ease-in-out infinite 1.1s; }

@keyframes ssc-ai-sparkle {
    0%, 100% { opacity: .55; transform: scale(.7)  rotate(0deg); }
    45%      { opacity: 1;   transform: scale(1.18) rotate(90deg); }
    70%      { opacity: .7;  transform: scale(.92) rotate(150deg); }
}

/* هنگام هاور: کمی سرزنده‌تر */
.ssc-toggle:hover .ssc-ai-spark-1,
.ssc-toggle:hover .ssc-ai-spark-2 { animation-duration: 1.4s; }

/* پنل باز است → آیکن بسته شدن */
.ssc-toggle.ssc-open .ssc-ai-icon { display: none; }

.ssc-toggle-close {
    display: none;
    width: 24px;
    height: 24px;
}
.ssc-toggle.ssc-open .ssc-toggle-close { display: block; }
.ssc-toggle.ssc-open .ssc-toggle-halo  { animation: none; opacity: 0; }

/* ♿ احترام به تنظیم «کاهش حرکت» سیستم */
@media (prefers-reduced-motion: reduce) {
    .ssc-toggle-halo,
    .ssc-ai-bubble,
    .ssc-ai-bubble-line,
    .ssc-ai-d,
    .ssc-ai-spark { animation: none !important; }
    .ssc-toggle-halo { opacity: .25; }
}

.ssc-dot {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #22c55e;
    border: 2px solid #fff;
    animation: ssc-pulse 2s infinite;
}
.ssc-dot.offline { background: #ef4444; animation: none; }

@keyframes ssc-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%      { opacity: .6; transform: scale(1.1); }
}

/* ═══════════════════════════════════════════
   ⭐ حباب دعوت (صفحه محصول / دسته‌بندی)
═══════════════════════════════════════════ */
.ssc-invite {
    position: absolute;
    bottom: calc(100% + 12px);
    right: 0;
    left: auto;
    z-index: 3;
    width: max-content;
    max-width: min(300px, calc(100vw - 40px));
    background: #fff;
    color: #1f2937;
    border-radius: 16px 16px 4px 16px;
    padding: 13px 15px;
    padding-left: 30px;
    font-size: 13.5px;
    line-height: 1.85;
    text-align: right;
    box-shadow: 0 10px 34px rgba(0, 0, 0, .18);
    border: 1px solid rgba(0, 0, 0, .06);
    cursor: pointer;
    animation: ssc-invite-in .38s cubic-bezier(.22, 1, .36, 1);
    transition: transform .18s, box-shadow .18s;
}

.ssc-invite:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 40px rgba(0, 0, 0, .22);
}

/* وقتی ویجت سمت چپ است، دم حباب هم چپ شود */
#ssc-root[data-pos$="-left"] .ssc-invite {
    right: auto;
    left: 0;
    border-radius: 16px 16px 16px 4px;
}

/* وقتی ویجت بالای صفحه است، حباب زیر دکمه بیاید */
#ssc-root[data-pos^="top-"] .ssc-invite {
    bottom: auto;
    top: calc(100% + 12px);
    border-radius: 4px 16px 16px 16px;
    animation: ssc-invite-in-down .38s cubic-bezier(.22, 1, .36, 1);
}

#ssc-root[data-pos="top-left"] .ssc-invite {
    border-radius: 16px 4px 16px 16px;
}

.ssc-invite-text { pointer-events: none; }

.ssc-invite-close {
    position: absolute;
    top: 5px;
    left: 6px;
    width: 22px;
    height: 22px;
    border: 0;
    background: transparent;
    color: #9ca3af;
    font-size: 19px;
    line-height: 1;
    cursor: pointer;
    border-radius: 50%;
    padding: 0;
    font-family: inherit;
    transition: background .15s, color .15s;
}

.ssc-invite-close:hover { background: #f1f5f9; color: #475569; }

.ssc-invite.ssc-invite-out {
    animation: ssc-invite-out .22s ease forwards;
}

@keyframes ssc-invite-in {
    from { opacity: 0; transform: translateY(10px) scale(.94); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes ssc-invite-in-down {
    from { opacity: 0; transform: translateY(-10px) scale(.94); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes ssc-invite-out {
    to { opacity: 0; transform: translateY(6px) scale(.96); }
}

.ssc-notif {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ef4444;
    color: #fff;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
    padding: 0 4px;
    animation: ssc-bounce 1s infinite;
}

@keyframes ssc-bounce {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.15); }
}

/* ─── پنل چت ─── */
.ssc-panel {
    position: absolute;
    bottom: calc(100% + 14px);
    right: 0;
    z-index: 2;
    width: 400px;
    max-width: calc(100vw - 30px);
    /* ارتفاع = فضای موجود منهای دکمه شناور (60) + فاصله (14) + حاشیه ایمن (34) */
    height: min(720px, calc(100vh - 108px));
    height: min(720px, calc(100dvh - 108px));
    max-height: calc(100vh - 108px);
    max-height: calc(100dvh - 108px);
    background: #fff;
    border-radius: 20px;
    overflow: hidden;
    margin-bottom: 0;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .25);
    display: flex;
    flex-direction: column;
    animation: ssc-slide-up .3s ease;
    overscroll-behavior: contain;
}

@keyframes ssc-slide-up {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ─── Content Area ─── */
.ssc-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    position: relative;
}

.ssc-view {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

/* ═══════════════════════════════════════════
   🏠 صفحه Welcome (Home)
═══════════════════════════════════════════ */

/* ═══════════════════════════════════════════
   صفحه خانه (Welcome) — استایل رایچت
   گرادیانت پیوسته از بالا تا پایین
═══════════════════════════════════════════ */
#ssc-root .ssc-welcome-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    background: linear-gradient(180deg,
                var(--ssc-primary) 0%,
                var(--ssc-primary) 30%,
                color-mix(in srgb, var(--ssc-primary) 45%, #fff) 55%,
                color-mix(in srgb, var(--ssc-primary) 12%, #fff) 78%,
                #ffffff 100%);
}

/* هدر — شفاف روی گرادیانت */
#ssc-root .ssc-welcome-header {
    background: transparent;
    padding: 12px 16px 16px;
    color: #fff;
    position: relative;
    flex-shrink: 0;
}

#ssc-root .ssc-welcome-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
    flex-direction: row;
}

/* آیکن گفتگو — مربع گرد سفید، سمت راست */
#ssc-root .ssc-welcome-icon {
    order: 1;
    width: 44px;
    height: 44px;
    background: #fff;
    border-radius: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ssc-primary);
    box-shadow: 0 3px 10px rgba(0, 0, 0, .12);
    flex-shrink: 0;
}

#ssc-root .ssc-welcome-icon svg {
    width: 24px;
    height: 24px;
}

/* دکمه بستن — سمت چپ */
#ssc-root .ssc-welcome-close {
    order: 2;
    background: transparent;
    color: #fff;
    border: none;
    width: 34px;
    height: 34px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    opacity: .95;
    transition: opacity .15s;
}

#ssc-root .ssc-welcome-close:hover { opacity: 1; }

#ssc-root .ssc-welcome-title {
    font-size: 18px;
    font-weight: 700;
    line-height: 1.55;
    margin: 0 0 3px;
    text-align: right;
    color: #fff;
    letter-spacing: -.2px;
}

#ssc-root .ssc-welcome-subtitle {
    font-size: 12px;
    margin: 0;
    text-align: right;
    font-weight: 400;
    line-height: 1.7;
    color: rgba(255,255,255,.92);
}

/* بدنه — شفاف تا گرادیانت دیده شود */
#ssc-root .ssc-welcome-body {
    flex: 1;
    overflow-y: auto;
    padding: 0 16px 10px;
    margin-top: 0;
    overscroll-behavior: contain;
    display: flex;
    flex-direction: column;
    background: transparent;
}

#ssc-root .ssc-welcome-body::-webkit-scrollbar { width: 4px; }
#ssc-root .ssc-welcome-body::-webkit-scrollbar-thumb { background: rgba(0,0,0,.15); border-radius: 10px; }

/* کارت سفید جستجو + سوالات */
#ssc-root .ssc-search-card {
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, .07);
    overflow: hidden;
    margin-bottom: 10px;
    flex-shrink: 0;
    border: none;
    padding: 12px 12px 4px;
}

/* باکس جستجو — بوردر گرد کامل */
#ssc-root .ssc-search-box {
    padding: 0 12px;
    display: flex;
    align-items: center;
    gap: 9px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 9px;
    height: 39px;
    margin-bottom: 2px;
}

#ssc-root .ssc-search-box:focus-within {
    border-color: #d8dce1;
}

#ssc-root .ssc-search-icon {
    color: #1f2937;
    flex-shrink: 0;
    order: 2;
}

#ssc-root .ssc-search-input {
    flex: 1;
    min-width: 0;
    border: 0 !important;
    outline: 0 !important;
    box-shadow: none !important;
    font-size: 16px !important;
    transform: scale(0.75);
    transform-origin: right center;
    width: 133.34%;
    flex: 0 0 auto;
    color: #1f2937;
    background: transparent !important;
    font-family: inherit;
    text-align: right;
    padding: 0 !important;
    height: 37px;
    line-height: 37px;
    -webkit-appearance: none;
    appearance: none;
}

#ssc-root .ssc-search-input:focus {
    border: 0 !important;
    outline: 0 !important;
    box-shadow: none !important;
}

#ssc-root .ssc-search-input::placeholder {
    color: #9ca3af;
    font-size: 16px;
    opacity: 1;
}

#ssc-root .ssc-suggestions {
    max-height: 400px;
    overflow-y: auto;
}

#ssc-root .ssc-suggestions::-webkit-scrollbar { width: 4px; }
#ssc-root .ssc-suggestions::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }

/* سوالات پیشنهادی — خط جداکننده نازک */
#ssc-root .ssc-suggestion-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 3px;
    cursor: pointer;
    transition: background .15s;
    background: transparent;
    border: none;
    border-bottom: 1px solid #f1f3f5;
    width: 100%;
    text-align: right;
    font-family: inherit;
    gap: 8px;
    min-height: 0;
}

#ssc-root .ssc-suggestion-item:last-child { border-bottom: none; }
#ssc-root .ssc-suggestion-item:first-child { border-top: none; }

#ssc-root .ssc-suggestion-item:hover {
    background: #fafbfc;
    padding-right: 3px;
}

#ssc-root .ssc-suggestion-item:active { background: #f4f6f8; }

#ssc-root .ssc-suggestion-text {
    font-size: 12px;
    color: var(--ssc-primary);
    font-weight: 500;
    flex: 1;
    line-height: 1.55;
}

/* پیکان سمت چپ */
#ssc-root .ssc-suggestion-arrow {
    color: #9ca3af;
    flex-shrink: 0;
    opacity: 1;
    transition: transform .15s;
    order: 2;
}

#ssc-root .ssc-suggestion-item:hover .ssc-suggestion-arrow {
    transform: translateX(-3px);
    color: var(--ssc-primary);
}

#ssc-root .ssc-suggestions-empty {
    padding: 30px 16px;
    text-align: center;
    color: #94a3b8;
    font-size: 12px;
}

#ssc-root .ssc-suggestions-loading {
    padding: 26px 16px;
    text-align: center;
    color: #94a3b8;
    font-size: 12px;
}

/* ═══════════════════════════════════════════
   بخش پایین Welcome — کارت اپراتور + دکمه شروع
═══════════════════════════════════════════ */
#ssc-root .ssc-welcome-footer {
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, .07);
    padding: 10px;
    margin-top: auto;
    margin-bottom: 2px;
    flex-shrink: 0;
    border: none;
}

/* آواتارهای اپراتور — سمت راست، روی هم */
#ssc-root .ssc-operators {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    margin-bottom: 9px;
    padding: 1px 1px 0;
    flex-direction: row;
    direction: rtl;
    width: 100%;
}

#ssc-root .ssc-operator-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid #fff;
    background-size: cover;
    background-position: center;
    background-color: #e5e7eb;
    margin-left: -10px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .12);
    transition: transform .15s;
    flex-shrink: 0;
}

#ssc-root .ssc-operator-avatar:last-child { margin-left: 0; }

#ssc-root .ssc-operator-avatar:hover {
    transform: scale(1.08) translateY(-2px);
    z-index: 10;
}

/* دکمه شروع گفتگو — رنگ تخت، پیکان چپ */
#ssc-root .ssc-start-chat-btn {
    width: 100%;
    background: var(--ssc-primary);
    background-image: none;
    color: #fff;
    border: none;
    border-radius: 9px;
    padding: 0 14px;
    height: 50px;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: filter .2s;
    font-family: inherit;
    box-shadow: none;
    flex-direction: row-reverse;
}

#ssc-root .ssc-start-chat-btn:hover { filter: brightness(1.08); }
#ssc-root .ssc-start-chat-btn:active { filter: brightness(.95); }

#ssc-root .ssc-start-chat-btn:focus,
#ssc-root .ssc-start-chat-btn:focus-visible {
    outline: none;
    box-shadow: none;
}

#ssc-root .ssc-start-chat-btn-inner {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 13.5px;
    font-weight: 600;
    flex-direction: row-reverse;
}

#ssc-root .ssc-start-chat-btn-inner span:first-child {
    font-size: 16px;
    line-height: 1;
}

/* پیکان — سمت چپ دکمه */
#ssc-root .ssc-start-chat-btn > svg {
    flex-shrink: 0;
    opacity: .95;
}

/* ═══════════════════════════════════════════
   💬 صفحه Messenger (چت)
═══════════════════════════════════════════ */

.ssc-messenger-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* Header داخل چت */
.ssc-chat-header {
    background: linear-gradient(135deg, var(--ssc-primary), var(--ssc-primary-dark));
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .1);
}

.ssc-chat-title strong {
    display: block;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.4;
}

.ssc-chat-status {
    font-size: 11px;
    opacity: .95;
    margin-top: 3px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.ssc-chat-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

/* دکمه بازگشت — سمت چپ هدر (RTL) */
#ssc-root .ssc-chat-back {
    background: rgba(255,255,255,.18);
    color: #fff;
    border: none;
    width: 34px;
    height: 34px;
    min-width: 34px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    flex-shrink: 0;
    order: 99;
    margin-right: auto;
    transition: background .15s, transform .1s;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

#ssc-root .ssc-chat-back:hover { background: rgba(255,255,255,.32); }
#ssc-root .ssc-chat-back:active { transform: scale(.94); }
#ssc-root .ssc-chat-back:focus,
#ssc-root .ssc-chat-back:focus-visible { outline: none; box-shadow: none; }
#ssc-root .ssc-chat-back svg { display: block; }

.ssc-chat-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(255,255,255,.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.ssc-chat-title strong {
    display: block;
    font-size: 14px;
    font-weight: 600;
}

.ssc-chat-status {
    font-size: 11px;
    opacity: .95;
    margin-top: 2px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.ssc-chat-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #22c55e;
}
.ssc-chat-status-dot.offline { background: #fbbf24; }

/* Body چت */
.ssc-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px 12px 14px;
    background: #f5f7fa;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

.ssc-messages::-webkit-scrollbar { width: 5px; }
.ssc-messages::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }

.ssc-msg {
    margin-bottom: 4px;
    max-width: 80%;
    animation: ssc-msg-in .32s cubic-bezier(.22, 1, .36, 1) both;
    clear: both;
    display: flex;
    flex-direction: column;
}

/* پیام‌های پشت‌سرهم از یک نفر → چسبیده‌تر */
#ssc-root .ssc-msg.ssc-msg-grouped { margin-top: -1px; margin-bottom: 2px; }
#ssc-root .ssc-msg.ssc-msg-grouped .ssc-msg-sender { display: none; }

/* تغییر گوینده → کمی نفس بکشد */
#ssc-root .ssc-msg-visitor + .ssc-msg-bot,
#ssc-root .ssc-msg-visitor + .ssc-msg-ai,
#ssc-root .ssc-msg-visitor + .ssc-msg-operator,
#ssc-root .ssc-msg-bot + .ssc-msg-visitor,
#ssc-root .ssc-msg-ai + .ssc-msg-visitor,
#ssc-root .ssc-msg-operator + .ssc-msg-visitor {
    margin-top: 8px;
}

/* آخرین پیام کمی فاصله از کادر تایپ بگیرد */
#ssc-root .ssc-msg:last-child { margin-bottom: 2px; }

@keyframes ssc-msg-in {
    from { opacity: 0; transform: translateY(10px) scale(.985); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
    #ssc-root .ssc-msg { animation-duration: .01ms !important; }
    #ssc-root .ssc-messages { scroll-behavior: auto; }
}

/* ═══ بازدیدکننده (مشتری) → راست ═══ */
.ssc-msg-visitor {
    margin-right: 0;
    margin-left: auto;
    align-items: flex-start;
}

.ssc-msg-visitor .ssc-msg-bubble {
    background: var(--ssc-primary);
    color: #fff;
    border: none;
    border-radius: 16px 16px 16px 5px;
    padding: 8px 13px;
    box-shadow: 0 1px 2px rgba(37, 99, 235, .18);
}

/* در گروه پیام‌ها، گوشه‌ها یکدست شوند */
#ssc-root .ssc-msg-visitor.ssc-msg-grouped .ssc-msg-bubble {
    border-radius: 16px 16px 16px 5px;
}

/* ═══ ادمین / پشتیبان / بات / AI → چپ ═══ */
.ssc-msg-bot,
.ssc-msg-ai,
.ssc-msg-operator {
    margin-left: 0;
    margin-right: auto;
    align-items: flex-end;
}

.ssc-msg-bot .ssc-msg-bubble,
.ssc-msg-ai .ssc-msg-bubble,
.ssc-msg-operator .ssc-msg-bubble {
    background: #fff;
    color: #1f2937;
    border: 1px solid #eceff3;
    border-radius: 16px 16px 5px 16px;
    padding: 8px 13px;
    box-shadow: 0 1px 2px rgba(16, 24, 40, .06);
}

.ssc-msg-system .ssc-msg-bubble {
    background: #fef3c7;
    border: 1px solid #fde68a;
    border-radius: 12px;
    padding: 7px 12px;
    max-width: 100%;
    text-align: center;
    font-size: 12px;
    color: #92400e;
}

.ssc-msg-system { max-width: 100%; align-items: center; }

/* نام فرستنده — بیرون حباب، مثل رایچت */
.ssc-msg-sender {
    font-size: 10px;
    font-weight: 600;
    color: #9aa2b0;
    margin-bottom: 1px;
    opacity: 1;
    padding: 0 5px;
    letter-spacing: .1px;
    line-height: 1.4;
}

.ssc-msg-visitor .ssc-msg-sender { display: none; }
.ssc-msg-bot .ssc-msg-sender,
.ssc-msg-ai .ssc-msg-sender,
.ssc-msg-operator .ssc-msg-sender { color: #6b7280; text-align: right; }

.ssc-msg-bubble {
    position: relative;
    display: inline-block;
    max-width: 100%;
}

.ssc-msg-text {
    white-space: pre-wrap;
    line-height: 1.65;
    font-size: 12.5px;
    word-break: break-word;
    letter-spacing: .1px;
}

/* خطوط خالی پشت‌سرهم در پاسخ AI فشرده شوند */
#ssc-root .ssc-msg-text { max-height: none; }

.ssc-msg-text a {
    color: inherit;
    text-decoration: underline;
}

#ssc-root .ssc-msg-text strong {
    font-weight: 700;
    color: inherit;
}

/* ⭐ لینک محصول — دکمه‌ای کوچک و کلیک‌شدنی */
#ssc-root .ssc-msg-text a.ssc-msg-link {
    display: inline-flex !important;
    align-items: center !important;
    gap: 5px !important;
    max-width: 100% !important;
    margin: 4px 0 2px !important;
    padding: 5px 11px !important;
    border-radius: 999px !important;
    border: 1px solid var(--ssc-brand, #2563eb) !important;
    background: #fff !important;
    color: var(--ssc-brand, #2563eb) !important;
    font-size: 11.5px !important;
    font-weight: 700 !important;
    line-height: 1.6 !important;
    text-decoration: none !important;
    vertical-align: middle !important;
    cursor: pointer !important;
    transition: background .15s ease, color .15s ease !important;

    /* نام محصول بلند: یک خط، با سه‌نقطه */
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}

/* آیکن نباید در فشردگی کوچک شود */
#ssc-root .ssc-msg-text a.ssc-msg-link::before {
    flex: 0 0 auto;
}

#ssc-root .ssc-msg-text a.ssc-msg-link::before {
    content: "🔗";
    font-size: 11px;
    line-height: 1;
}

#ssc-root .ssc-msg-text a.ssc-msg-link:hover,
#ssc-root .ssc-msg-text a.ssc-msg-link:focus {
    background: var(--ssc-brand, #2563eb) !important;
    color: #fff !important;
}

#ssc-root .ssc-msg-text a.ssc-msg-link:active {
    transform: scale(.97) !important;
}

/* داخل حباب مشتری (پس‌زمینه رنگی) */
#ssc-root .ssc-msg-visitor .ssc-msg-text a.ssc-msg-link {
    border-color: rgba(255, 255, 255, .85) !important;
    background: rgba(255, 255, 255, .16) !important;
    color: #fff !important;
}

#ssc-root .ssc-msg-visitor .ssc-msg-text a.ssc-msg-link:hover {
    background: #fff !important;
    color: var(--ssc-brand, #2563eb) !important;
}

/* زمان — بیرون حباب، کنارش */
.ssc-msg-time {
    font-size: 9.5px;
    margin-top: 1px;
    opacity: .9;
    color: #aab2bf;
    padding: 0 5px;
    line-height: 1.3;
}

/* ساعت پیام میانی گروه پنهان می‌شود (فقط آخرین ساعت می‌ماند) */
#ssc-root .ssc-msg-time.ssc-time-hidden {
    display: none !important;
}

.ssc-msg-visitor .ssc-msg-time  { text-align: right; }
.ssc-msg-bot .ssc-msg-time,
.ssc-msg-ai .ssc-msg-time,
.ssc-msg-operator .ssc-msg-time { text-align: left; }

/* ═══════════════════════════════════════════
   انیمیشن نرم پیام‌ها + وضعیت ارسال
═══════════════════════════════════════════ */

/* ورود نرم‌تر و طبیعی‌تر */
#ssc-root .ssc-msg {
    animation: ssc-msg-in .28s cubic-bezier(.22,.68,.36,1);
    will-change: transform, opacity;
}

@keyframes ssc-msg-in {
    from { opacity: 0; transform: translateY(10px) scale(.985); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* پیام کاربر از سمت راست */
#ssc-root .ssc-msg-visitor {
    animation: ssc-msg-in-right .26s cubic-bezier(.22,.68,.36,1);
}

@keyframes ssc-msg-in-right {
    from { opacity: 0; transform: translateX(14px) translateY(6px); }
    to   { opacity: 1; transform: translateX(0) translateY(0); }
}

/* پیام فروشنده/بات از سمت چپ */
#ssc-root .ssc-msg-bot,
#ssc-root .ssc-msg-ai,
#ssc-root .ssc-msg-operator {
    animation: ssc-msg-in-left .3s cubic-bezier(.22,.68,.36,1);
}

@keyframes ssc-msg-in-left {
    from { opacity: 0; transform: translateX(-14px) translateY(6px); }
    to   { opacity: 1; transform: translateX(0) translateY(0); }
}

/* حالت «در حال ارسال»
   قبلاً opacity .62 بود و حباب واضحاً کم‌رنگ‌تر دیده می‌شد؛
   وقتی پیام واقعی می‌آمد، اختلاف رنگ توی چشم می‌زد. */
#ssc-root .ssc-msg-pending .ssc-msg-bubble {
    opacity: .88;
    transition: opacity .18s ease;
}

/* حذف نرم حباب موقت — بدون پرش */
#ssc-root .ssc-msg-pending.ssc-msg-settled {
    animation: ssc-settle .16s ease forwards;
}

@keyframes ssc-settle {
    to { opacity: 0; }
}

#ssc-root .ssc-msg-status {
    font-size: 9.5px;
    color: #9ca3af;
}

#ssc-root .ssc-msg-pending .ssc-msg-status::after {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    margin-right: 5px;
    border: 1.5px solid #d7dce3;
    border-top-color: var(--ssc-primary);
    border-radius: 50%;
    vertical-align: -1px;
    animation: ssc-spin .7s linear infinite;
}

/* اسپینر فقط بعد از ۴۵۰ms ظاهر شود
   (اگر شبکه سریع بود، اصلاً دیده نمی‌شود) */
#ssc-root .ssc-msg-pending .ssc-msg-status {
    opacity: 0;
    animation: ssc-show-status .01s linear .45s forwards;
}

@keyframes ssc-show-status { to { opacity: 1; } }

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

/* ارسال ناموفق */
#ssc-root .ssc-msg-failed .ssc-msg-bubble {
    opacity: .55;
    outline: 1px dashed #ef4444;
    outline-offset: 2px;
}

#ssc-root .ssc-msg-failed .ssc-msg-status {
    color: #ef4444;
    font-weight: 600;
}

#ssc-root .ssc-msg-failed .ssc-msg-status::after { display: none; }

/* اسکرول نرم لیست پیام‌ها */
#ssc-root .ssc-messages {
    scroll-behavior: smooth;
    overscroll-behavior: contain;
}

/* احترام به تنظیمات دسترس‌پذیری */
@media (prefers-reduced-motion: reduce) {
    #ssc-root .ssc-msg,
    #ssc-root .ssc-msg-visitor,
    #ssc-root .ssc-msg-bot,
    #ssc-root .ssc-msg-ai,
    #ssc-root .ssc-msg-operator {
        animation: none;
    }
    #ssc-root .ssc-messages { scroll-behavior: auto; }
}

/* ═══════════════════════════════════════════
   گزینه‌های کلیک‌شدنی داخل پیام (نیازسنجی)
═══════════════════════════════════════════ */
#ssc-root .ssc-msg-options {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
    margin-top: 8px;
    width: 100%;
}

#ssc-root .ssc-msg-option {
    display: inline-block;
    max-width: 100%;
    background: #fff;
    color: var(--ssc-primary);
    border: 1px solid var(--ssc-primary);
    border-radius: 10px;
    padding: 8px 13px;
    font-size: 12px;
    font-weight: 500;
    font-family: inherit;
    line-height: 1.5;
    cursor: pointer;
    text-align: right;
    transition: background .15s, color .15s, transform .1s;
    box-shadow: none;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    word-break: break-word;
}

#ssc-root .ssc-msg-option:hover:not(:disabled) {
    background: var(--ssc-primary);
    color: #fff;
}

#ssc-root .ssc-msg-option:active:not(:disabled) {
    transform: scale(.98);
}

#ssc-root .ssc-msg-option:focus,
#ssc-root .ssc-msg-option:focus-visible {
    outline: none;
    box-shadow: none;
}

/* گزینه انتخاب‌شده */
#ssc-root .ssc-msg-option.ssc-option-picked {
    background: var(--ssc-primary);
    color: #fff;
    border-color: var(--ssc-primary);
    opacity: 1;
}

/* گزینه‌های غیرفعال بعد از انتخاب */
#ssc-root .ssc-msg-option.ssc-option-dim {
    opacity: .38;
    cursor: default;
    background: #fff;
    color: var(--ssc-primary);
}

#ssc-root .ssc-msg-option:disabled {
    cursor: default;
}

/* Typing */
.ssc-typing {
    padding: 2px 12px 6px;
    animation: ssc-fade-in .28s cubic-bezier(.22, 1, .36, 1);
}

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

.ssc-typing { text-align: left; }

.ssc-typing-bubble {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    background: #fff;
    border: 1px solid #eceff3;
    border-radius: 16px 16px 5px 16px;
    padding: 8px 13px;
    box-shadow: 0 1px 2px rgba(16, 24, 40, .06);
}

.ssc-typing-name { font-size: 11px; font-weight: 700; color: #16a34a; }

.ssc-typing-dots { display: inline-flex; gap: 3px; }

.ssc-typing-dots span {
    width: 5.5px;
    height: 5.5px;
    background: #9aa2b0;
    border-radius: 50%;
    animation: ssc-typing-bounce 1.3s ease-in-out infinite;
}

.ssc-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.ssc-typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes ssc-typing-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: .35; }
    30% { transform: translateY(-5px); opacity: 1; }
}

/* فرم شروع (Pre-form) - داخل چت */
.ssc-preform {
    padding: 20px;
    background: #fff;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.ssc-preform-title {
    font-size: 15px;
    font-weight: 700;
    color: #1f2937;
    margin-bottom: 6px;
    text-align: center;
}

.ssc-preform-subtitle {
    font-size: 12px;
    color: #6b7280;
    margin-bottom: 18px;
    text-align: center;
    line-height: 1.6;
}

.ssc-preform {
    padding: 24px 20px;
    background: #fff;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow-y: auto;
}

.ssc-preform input {
    width: 100%;
    margin-bottom: 10px;
    border: 1.5px solid #e5e7eb;
    border-radius: 12px;
    padding: 12px 14px;
    font-size: 16px !important;
    font-family: inherit;
    background: #f9fafb;
    color: #1f2937;
    transition: all .15s;
}

.ssc-preform input:focus {
    outline: none;
    border-color: var(--ssc-primary);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(124, 26, 153, .1);
}

.ssc-preform button[type="submit"] {
    width: 100%;
    border: none;
    border-radius: 12px;
    padding: 13px;
    background: linear-gradient(135deg, var(--ssc-primary), var(--ssc-primary-dark));
    color: #fff;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    margin-top: 8px;
    transition: all .15s;
    box-shadow: 0 4px 12px rgba(0, 0, 0, .1);
}

.ssc-preform button[type="submit"]:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, .15);
}

.ssc-preform input {
    width: 100%;
    margin-bottom: 8px;
    border: 1.5px solid #e5e7eb;
    border-radius: 10px;
    padding: 11px 13px;
    font-size: 16px !important;
    font-family: inherit;
    background: #f9fafb;
    color: #1f2937;
    transition: border-color .15s;
}

.ssc-preform input[name="phone"] { direction: ltr; text-align: right; }

.ssc-preform input:focus {
    outline: none;
    border-color: var(--ssc-primary);
    background: #fff;
}

.ssc-preform button[type="submit"] {
    width: 100%;
    border: none;
    border-radius: 10px;
    padding: 12px;
    background: linear-gradient(135deg, var(--ssc-primary), var(--ssc-primary-dark));
    color: #fff;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    margin-top: 4px;
}

.ssc-preform small {
    display: block;
    margin-top: 8px;
    color: #9ca3af;
    font-size: 11px;
    text-align: center;
}

/* ═══════════════════════════════════════════
   فرم ارسال پیام — استایل رایچت
   با #ssc-root و !important برای مقاومت
   در برابر استایل قالب سایت
═══════════════════════════════════════════ */
#ssc-root .ssc-sendform {
    padding: 8px 10px !important;
    border-top: 1px solid #eef0f3 !important;
    background: #fff !important;
    display: flex !important;
    gap: 8px !important;
    align-items: center !important;
    flex-shrink: 0 !important;
    margin: 0 !important;
    box-shadow: none !important;
}

/* کادر گرد دور ورودی */
#ssc-root .ssc-input-wrap {
    flex: 1 1 auto !important;
    display: flex !important;
    align-items: center !important;
    min-width: 0 !important;
    background: #fff !important;
    border: 1px solid #e3e6ea !important;
    border-radius: 20px !important;
    padding: 0 14px !important;
    height: 38px !important;
    min-height: 38px !important;
    max-height: 38px !important;
    box-shadow: none !important;
    outline: none !important;
    transition: border-color .15s !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
}

#ssc-root .ssc-input-wrap:focus-within {
    border-color: #d5d9de !important;
    box-shadow: none !important;
    outline: none !important;
}

/* ورودی تک‌خطی — بدون ارتفاع اضافه، بدون بوردر */
#ssc-root .ssc-sendform textarea,
#ssc-root .ssc-input-wrap textarea {
    flex: 1 1 auto !important;
    width: 100% !important;
    border: 0 !important;
    border-width: 0 !important;
    border-color: transparent !important;
    background: transparent !important;
    background-color: transparent !important;
    background-image: none !important;
    border-radius: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    /* iOS زیر 16px را زوم می‌کند → 16px واقعی + کوچک‌نمایی بصری */
    font-size: 16px !important;
    font-family: inherit !important;
    font-weight: 400 !important;
    resize: none !important;
    height: 26px !important;
    min-height: 26px !important;
    max-height: 26px !important;
    line-height: 26px !important;
    transform: scale(0.75);
    transform-origin: right center;
    width: 133.34% !important;
    margin-right: 0 !important;
    color: #1f2937 !important;
    text-align: right !important;
    direction: rtl !important;
    overflow: hidden !important;
    overflow-y: hidden !important;
    box-shadow: none !important;
    outline: none !important;
    outline-width: 0 !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
    display: block !important;
    vertical-align: middle !important;
    white-space: nowrap !important;
    box-sizing: border-box !important;
    transition: none !important;
}

/* حذف کامل بوردر/سایه آبی قالب هنگام کلیک */
#ssc-root .ssc-sendform textarea:focus,
#ssc-root .ssc-sendform textarea:focus-visible,
#ssc-root .ssc-sendform textarea:active,
#ssc-root .ssc-sendform textarea:hover,
#ssc-root .ssc-input-wrap textarea:focus,
#ssc-root .ssc-input-wrap textarea:focus-visible {
    border: 0 !important;
    border-color: transparent !important;
    outline: 0 !important;
    outline-color: transparent !important;
    box-shadow: none !important;
    background: transparent !important;
    background-color: transparent !important;
}

#ssc-root .ssc-sendform textarea::placeholder {
    color: #b4b9c0 !important;
    font-size: 16px !important;
    opacity: 1 !important;
    line-height: 26px !important;
}

#ssc-root .ssc-sendform textarea::-webkit-input-placeholder { color: #b4b9c0 !important; font-size: 16px !important; }
#ssc-root .ssc-sendform textarea::-moz-placeholder          { color: #b4b9c0 !important; font-size: 16px !important; opacity: 1 !important; }
#ssc-root .ssc-sendform textarea:-ms-input-placeholder       { color: #b4b9c0 !important; font-size: 16px !important; }

/* اسکرول‌بار داخل ورودی پنهان */
#ssc-root .ssc-sendform textarea::-webkit-scrollbar { display: none !important; }

/* دکمه ارسال — دایره، سمت چپ */
#ssc-root .ssc-btn-send {
    width: 38px !important;
    min-width: 38px !important;
    max-width: 38px !important;
    height: 38px !important;
    min-height: 38px !important;
    max-height: 38px !important;
    border: 0 !important;
    border-radius: 50% !important;
    background: #c3c9d0 !important;
    background-image: none !important;
    color: #fff !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
    flex-grow: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    /* فرم RTL است: order بزرگ‌تر = سمت چپ */
    order: 2 !important;
    box-shadow: none !important;
    outline: none !important;
    text-shadow: none !important;
    line-height: 1 !important;
    font-size: 0 !important;
    -webkit-appearance: none !important;
    appearance: none !important;
    box-sizing: border-box !important;
    transition: background .15s !important;
}

#ssc-root .ssc-btn-send:focus,
#ssc-root .ssc-btn-send:focus-visible,
#ssc-root .ssc-btn-send:active {
    outline: none !important;
    box-shadow: none !important;
    border: 0 !important;
}

#ssc-root .ssc-btn-send svg {
    width: 18px !important;
    height: 18px !important;
    display: block !important;
    flex-shrink: 0 !important;
    margin: 0 1px 0 0 !important;
    fill: none !important;
    stroke: currentColor !important;
}

#ssc-root .ssc-btn-send:hover {
    background: #aeb5bd !important;
}

#ssc-root .ssc-btn-send.ssc-active {
    background: var(--ssc-primary) !important;
}

#ssc-root .ssc-btn-send:disabled {
    opacity: .6 !important;
    cursor: default !important;
}

/* ═══════════════════════════════════════════
   📎 ابزارهای ورودی: ایموجی / عکس / میکروفون
═══════════════════════════════════════════ */

/* کادر ورودی سمت راست بماند */
#ssc-root .ssc-input-wrap { order: 1 !important; }

#ssc-root .ssc-tools {
    display: flex !important;
    align-items: center !important;
    gap: 2px !important;
    flex-shrink: 0 !important;
    order: 3 !important;      /* داخل کادر: سمت چپ متن */
}

#ssc-root .ssc-tool {
    width: 30px !important;
    height: 30px !important;
    min-width: 30px !important;
    border: 0 !important;
    background: transparent !important;
    background-image: none !important;
    color: #8b93a1 !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 !important;
    margin: 0 !important;
    border-radius: 50% !important;
    flex-shrink: 0 !important;
    box-shadow: none !important;
    outline: none !important;
    -webkit-appearance: none !important;
    appearance: none !important;
    transition: color .15s, background .15s !important;
}

/* ⛔️ باگ: .ssc-tool با display:flex !important تعریف شده و چون
   ویژگی (specificity) برابر با .ssc-hidden است، قانون بعدی برنده می‌شد
   و دکمه‌های عکس/میکروفون هرگز پنهان نمی‌شدند. */
#ssc-root .ssc-tool.ssc-hidden { display: none !important; }

#ssc-root .ssc-tool:hover { color: var(--ssc-primary) !important; background: #f1f5f9 !important; }
#ssc-root .ssc-tool:focus, #ssc-root .ssc-tool:focus-visible { outline: none !important; box-shadow: none !important; }

#ssc-root .ssc-tool svg {
    width: 18px !important;
    height: 18px !important;
    display: block !important;
    fill: none !important;
    stroke: currentColor !important;
}

/* میکروفون بیرون کادر، کنار دکمه ارسال */
#ssc-root .ssc-tool-mic {
    order: 0 !important;
    width: 34px !important;
    height: 34px !important;
    min-width: 34px !important;
}

/* حالت ضبط فعال */
#ssc-root .ssc-tool-mic.ssc-rec {
    color: #fff !important;
    background: #ef4444 !important;
    animation: ssc-recpulse 1.3s infinite;
}

@keyframes ssc-recpulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, .45) !important; }
    70%      { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0) !important; }
}

/* ─── نوار در حال ضبط ─── */
#ssc-root .ssc-recbar {
    position: absolute;
    left: 10px;
    right: 10px;
    bottom: calc(100% + 6px);
    display: flex;
    align-items: center;
    gap: 8px;
    background: #fff;
    border: 1px solid #fecaca;
    border-radius: 12px;
    padding: 8px 12px;
    font-size: 12px;
    color: #7f1d1d;
    box-shadow: 0 6px 20px rgba(0, 0, 0, .1);
    z-index: 6;
}

#ssc-root .ssc-recdot {
    width: 9px; height: 9px;
    border-radius: 50%;
    background: #ef4444;
    flex-shrink: 0;
    animation: ssc-blink 1s infinite;
}

@keyframes ssc-blink { 0%,100% { opacity: 1; } 50% { opacity: .25; } }

#ssc-root .ssc-rectime { font-weight: 700; font-variant-numeric: tabular-nums; flex-shrink: 0; }
#ssc-root .ssc-recmsg  { flex: 1 1 auto; min-width: 0; color: #9ca3af; font-size: 11px; }

#ssc-root .ssc-reccancel {
    border: 0 !important;
    background: #fee2e2 !important;
    color: #b91c1c !important;
    border-radius: 8px !important;
    padding: 4px 10px !important;
    font-size: 11px !important;
    font-weight: 700 !important;
    cursor: pointer !important;
    font-family: inherit !important;
    flex-shrink: 0 !important;
}

#ssc-root .ssc-reccancel:hover { background: #fecaca !important; }

/* ─── انتخابگر ایموجی ─── */
#ssc-root .ssc-sendform { position: relative !important; }

#ssc-root .ssc-emoji-pop {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 10px;
    right: 10px;
    max-height: 190px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .14);
    padding: 8px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(38px, 1fr));
    gap: 2px;
    z-index: 7;
    animation: ssc-invite-in .2s ease;
    overscroll-behavior: contain;
}

#ssc-root .ssc-emoji-item {
    border: 0 !important;
    background: transparent !important;
    font-size: 21px !important;
    line-height: 1 !important;
    padding: 6px 0 !important;
    cursor: pointer !important;
    border-radius: 8px !important;
    transition: background .12s !important;
    font-family: inherit !important;
}

#ssc-root .ssc-emoji-item:hover { background: #f1f5f9 !important; }

/* ─── نمایش پیوست در حباب پیام ─── */
#ssc-root .ssc-msg-bubble.ssc-msg-hasatt {
    padding: 5px !important;
    background: transparent !important;
    box-shadow: none !important;
}

#ssc-root .ssc-att { display: block; max-width: 230px; }

#ssc-root .ssc-att-imglink { display: block; line-height: 0; }

#ssc-root .ssc-att-img {
    display: block;
    max-width: 100%;
    width: auto;
    max-height: 260px;
    border-radius: 12px;
    border: 1px solid rgba(0, 0, 0, .07);
    cursor: zoom-in;
    background: #f1f5f9;
}

/* ─── پخش‌کننده صوتی سفارشی ─── */
#ssc-root .ssc-audio {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    width: 230px;
    max-width: 100%;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    padding: 9px 11px;
    box-sizing: border-box;
}

#ssc-root .ssc-audio-btn {
    width: 34px !important;
    height: 34px !important;
    min-width: 34px !important;
    border: 0 !important;
    border-radius: 50% !important;
    background: var(--ssc-primary, #2563eb) !important;
    color: #fff !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 !important;
    margin: 0 !important;
    flex-shrink: 0 !important;
    box-shadow: none !important;
    outline: none !important;
    -webkit-appearance: none !important;
    appearance: none !important;
    transition: transform .12s, filter .12s !important;
}

#ssc-root .ssc-audio-btn:hover  { filter: brightness(1.08) !important; }
#ssc-root .ssc-audio-btn:active { transform: scale(.93) !important; }

/* در حال بارگذاری فایل صوتی */
#ssc-root .ssc-audio-btn.ssc-audio-load svg { opacity: 0 !important; }

#ssc-root .ssc-audio-btn.ssc-audio-load::after {
    content: "";
    position: absolute;
    width: 15px;
    height: 15px;
    border: 2px solid rgba(255, 255, 255, .35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: ssc-audio-spin .7s linear infinite;
}

#ssc-root .ssc-audio-btn { position: relative !important; }

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

#ssc-root .ssc-audio-btn svg {
    width: 17px !important;
    height: 17px !important;
    display: block !important;
    fill: currentColor !important;
    stroke: none !important;
}

#ssc-root .ssc-audio-mid {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

#ssc-root .ssc-audio-bar {
    height: 4px;
    background: #e5e7eb;
    border-radius: 3px;
    overflow: hidden;
    width: 100%;
}

#ssc-root .ssc-audio-fill {
    height: 100%;
    width: 0%;
    background: var(--ssc-primary, #2563eb);
    border-radius: 3px;
    transition: width .15s linear;
}

#ssc-root .ssc-audio-time {
    font-size: 11px;
    color: #6b7280;
    font-variant-numeric: tabular-nums;
    line-height: 1;
}

#ssc-root .ssc-audio-dl {
    display: block;
    padding: 9px 12px;
    font-size: 12.5px;
    color: var(--ssc-primary, #2563eb);
    text-decoration: none;
    font-weight: 600;
}

@media (max-width: 600px) {
    #ssc-root .ssc-att,
    #ssc-root .ssc-audio { max-width: 210px; width: 210px; }
    #ssc-root .ssc-emoji-pop { max-height: 165px; }
}

/* ═══════════════════════════════════════════
   ❓ صفحه Knowledge Base
═══════════════════════════════════════════ */

.ssc-kb-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.ssc-kb-header {
    background: linear-gradient(135deg, var(--ssc-primary), var(--ssc-primary-dark));
    color: #fff;
    padding: 20px;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .1);
}

.ssc-kb-title {
    font-size: 17px;
    font-weight: 700;
    margin-bottom: 8px;
    line-height: 1.4;
}

.ssc-kb-desc {
    font-size: 12px;
    opacity: 0.92;
    line-height: 1.7;
    font-weight: 500;
}

.ssc-kb-search {
    background: #fff;
    border-radius: 12px;
    padding: 11px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .1);
}

.ssc-kb-search input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 13px !important;
    color: #1f2937;
    background: transparent;
    font-family: inherit;
}

.ssc-kb-item {
    background: #fff;
    border-radius: 12px;
    padding: 14px 16px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all .15s;
    border: 1.5px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.ssc-kb-item:hover {
    border-color: var(--ssc-primary);
    transform: translateX(-3px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, .08);
}

.ssc-kb-item-text {
    flex: 1;
    font-size: 13.5px;
    color: #1f2937;
    line-height: 1.6;
    font-weight: 500;
}

.ssc-kb-item-arrow {
    color: var(--ssc-primary);
    flex-shrink: 0;
    opacity: 0.7;
    transition: transform .15s;
}

.ssc-kb-item:hover .ssc-kb-item-arrow {
    transform: translateX(-3px);
    opacity: 1;
}

.ssc-kb-search {
    background: #fff;
    border-radius: 10px;
    padding: 10px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 14px;
}

.ssc-kb-search input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 14px !important;
    color: #1f2937;
    background: transparent;
    font-family: inherit;
}

.ssc-kb-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f8fafc;
    overscroll-behavior: contain;
}

.ssc-kb-body::-webkit-scrollbar { width: 4px; }
.ssc-kb-body::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }

.ssc-kb-item {
    background: #fff;
    border-radius: 12px;
    padding: 14px 16px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all .15s;
    border: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ssc-kb-item:hover {
    border-color: var(--ssc-primary);
    transform: translateX(-2px);
}

.ssc-kb-item-text {
    flex: 1;
    font-size: 13px;
    color: #1f2937;
    line-height: 1.5;
    font-weight: 500;
}

.ssc-kb-item-arrow {
    color: var(--ssc-primary);
    flex-shrink: 0;
    margin-left: 8px;
}

/* ═══════════════════════════════════════════
   📱 نوار تب‌های پایین
═══════════════════════════════════════════ */

/* ═══════════════════════════════════════════
   نوار تب‌های پایین — استایل رایچت
   آیکن کنار متن + جداکننده عمودی
═══════════════════════════════════════════ */
#ssc-root .ssc-tabs {
    display: flex;
    background: #fff;
    border-top: 1px solid #eef0f3;
    padding: 0;
    flex-shrink: 0;
    box-shadow: none;
    height: 48px;
    align-items: stretch;
}

#ssc-root .ssc-tab {
    flex: 1;
    background: transparent;
    border: none;
    padding: 0 4px;
    cursor: pointer;
    display: flex;
    flex-direction: row-reverse;
    align-items: center;
    justify-content: center;
    gap: 6px;
    color: #9ca3af;
    transition: color .15s;
    font-family: inherit;
    position: relative;
    margin-top: 0;
    border-top: none;
}

/* جداکننده عمودی بین تب‌ها */
#ssc-root .ssc-tab + .ssc-tab::after {
    content: '';
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 1px;
    height: 20px;
    background: #e9ecef;
}

#ssc-root .ssc-tab:hover {
    color: var(--ssc-primary);
}

#ssc-root .ssc-tab.active {
    color: var(--ssc-primary);
    font-weight: 600;
    border-top-color: transparent;
}

#ssc-root .ssc-tab span {
    font-size: 11.5px;
    font-weight: 500;
}

#ssc-root .ssc-tab.active span {
    font-weight: 600;
}

#ssc-root .ssc-tab svg {
    width: 19px;
    height: 19px;
    flex-shrink: 0;
}

#ssc-root .ssc-tab:focus,
#ssc-root .ssc-tab:focus-visible {
    outline: none;
    box-shadow: none;
}

.ssc-tab-badge {
    position: absolute;
    top: 6px;
    left: 50%;
    transform: translateX(15px);
    background: #ef4444;
    color: #fff;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    font-size: 10px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

/* ═══════════════════════════════════════════
   موبایل: تمام صفحه
═══════════════════════════════════════════ */

@media (max-width: 600px) {
    /* ⚠️ فاصله از لبه در موبایل اینجا تعریف نمی‌شود.
       از نسخه 1.16.0 توسط SSC_Widget::inject_custom_css() تزریق می‌شود
       (تنظیمات مجزای دسکتاپ/موبایل + نقطه شکست قابل تنظیم). */

    .ssc-panel {
        position: fixed;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100vw !important;
        /* 100vh در iOS شامل نوار آدرس می‌شود → پایین صفحه بریده می‌شد */
        height: 100vh !important;
        height: 100dvh !important;
        max-width: 100vw;
        max-height: 100vh;
        max-height: 100dvh;
        min-height: 0 !important;
        margin: 0 !important;
        border-radius: 0;
        flex-direction: column !important;
        overflow: hidden !important;
    }

    /* فقط وقتی مخفی نیست، flex شود
       (display:flex !important بدون این شرط، ssc-hidden را خنثی می‌کرد
        و پنل در موبایل همیشه باز می‌ماند) */
    .ssc-panel:not(.ssc-hidden) {
        display: flex !important;
    }

    /* fallback برای مرورگرهای بدون dvh — با متغیر JS */
    @supports not (height: 100dvh) {
        .ssc-panel {
            height: calc(var(--ssc-vh, 1vh) * 100) !important;
            max-height: calc(var(--ssc-vh, 1vh) * 100) !important;
        }
    }

    #ssc-root .ssc-content {
        flex: 1 1 auto !important;
        min-height: 0 !important;
        overflow: hidden !important;
    }

    .ssc-welcome-header {
        padding-top: max(18px, env(safe-area-inset-top));
    }

    /* نوار تب‌ها: همیشه دیده شود + احترام به safe-area آیفون */
    #ssc-root .ssc-tabs {
        flex: 0 0 auto !important;
        height: auto !important;
        min-height: 48px;
        padding-bottom: env(safe-area-inset-bottom, 0px);
        box-sizing: content-box;
    }

    /* فرم ارسال هم بالای safe-area بماند (وقتی تب مخفی است) */
    #ssc-root .ssc-tabs.ssc-hidden + .ssc-sendform,
    #ssc-root .ssc-panel:not(:has(.ssc-tabs)) .ssc-sendform {
        padding-bottom: max(8px, env(safe-area-inset-bottom));
    }

    .ssc-welcome-title { font-size: 22px; }
    .ssc-welcome-subtitle { font-size: 13px; }
    .ssc-suggestion-text { font-size: 14px; }
    .ssc-msg-text { font-size: 14px; }
}
/* ═══════════════════════════════════════════
   🎯 پاسخ در Home و Knowledge Base
═══════════════════════════════════════════ */

/* Home Answer */
.ssc-home-answer {
    display: flex;
    flex-direction: column;
    padding: 8px 0;
}

.ssc-home-back-btn {
    background: transparent;
    border: none;
    color: var(--ssc-primary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    margin-bottom: 10px;
    font-family: inherit;
    align-self: flex-start;
    border-radius: 8px;
    transition: background .15s;
}

.ssc-home-back-btn:hover {
    background: rgba(37, 99, 235, .08);
}

.ssc-home-answer-card {
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, .08);
    padding: 18px;
    border: 1px solid #e5e7eb;
}

.ssc-home-answer-question {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding-bottom: 14px;
    margin-bottom: 14px;
    border-bottom: 1px solid #f1f5f9;
}

.ssc-home-answer-icon {
    font-size: 22px;
    line-height: 1;
    flex-shrink: 0;
}

.ssc-home-answer-title {
    flex: 1;
    font-size: 14px;
    font-weight: 700;
    color: #1f2937;
    line-height: 1.6;
}

.ssc-home-answer-text {
    font-size: 13.5px;
    line-height: 1.9;
    color: #374151;
    white-space: pre-wrap;
    word-break: break-word;
    margin-bottom: 18px;
}

.ssc-home-answer-text a {
    color: var(--ssc-primary);
    text-decoration: underline;
}

.ssc-home-answer-chat-btn {
    width: 100%;
    background: linear-gradient(135deg, var(--ssc-primary), var(--ssc-primary-dark));
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 12px 16px;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: inherit;
    transition: all .15s;
    box-shadow: 0 4px 12px rgba(0, 0, 0, .1);
}

.ssc-home-answer-chat-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, .15);
}

/* Knowledge Base Answer */
.ssc-kb-answer {
    display: flex;
    flex-direction: column;
    padding: 4px 0;
}

.ssc-kb-back-btn {
    background: transparent;
    border: none;
    color: var(--ssc-primary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    margin-bottom: 12px;
    font-family: inherit;
    align-self: flex-start;
    border-radius: 8px;
    transition: background .15s;
}

.ssc-kb-back-btn:hover {
    background: rgba(37, 99, 235, .08);
}

.ssc-kb-answer-question {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: #fff;
    border-radius: 14px 14px 0 0;
    padding: 18px;
    border: 1px solid #e5e7eb;
    border-bottom: none;
}

.ssc-kb-answer-icon {
    font-size: 22px;
    line-height: 1;
    flex-shrink: 0;
}

.ssc-kb-answer-title {
    flex: 1;
    font-size: 14px;
    font-weight: 700;
    color: #1f2937;
    line-height: 1.7;
}

.ssc-kb-answer-body {
    background: #f8fafc;
    padding: 18px;
    border: 1px solid #e5e7eb;
    border-top: 2px dashed #e5e7eb;
    border-bottom: none;
}

.ssc-kb-answer-text {
    font-size: 13.5px;
    line-height: 1.9;
    color: #374151;
    white-space: pre-wrap;
    word-break: break-word;
}

.ssc-kb-answer-text a {
    color: var(--ssc-primary);
    text-decoration: underline;
}

.ssc-kb-answer-cta {
    background: #fff;
    border-radius: 0 0 14px 14px;
    padding: 16px 18px;
    text-align: center;
    border: 1px solid #e5e7eb;
    border-top: 1px solid #f1f5f9;
}

.ssc-kb-answer-cta-text {
    font-size: 12px;
    color: #6b7280;
    margin-bottom: 10px;
    font-weight: 500;
}

.ssc-kb-start-chat {
    width: 100%;
    background: linear-gradient(135deg, var(--ssc-primary), var(--ssc-primary-dark));
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 12px 16px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: inherit;
    transition: all .15s;
    box-shadow: 0 4px 12px rgba(0, 0, 0, .1);
}

.ssc-kb-start-chat:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, .15);
}

.ssc-kb-start-chat:active {
    transform: translateY(0);
}