:root {
    --sg-blue: #1520a1;
    --sg-orange: #f97316;
    --sg-green: #22c55e;
    --sg-white: #ffffff;
    --sg-text: #1f2937;
    --sg-border: #e5e7eb;
}


/* =========================================
   پیام خوش آمدگویی
========================================= */

.sg-chat-welcome {
    position: fixed;

    right: 84px;
    bottom: 20px;

    width: 300px;
    max-width: calc(100vw - 40px);

    padding: 14px 15px;

    background: #fff;

    border: 1px solid var(--sg-border);
    border-radius: 14px;

    box-shadow: 0 10px 30px rgba(0, 0, 0, .12);

    z-index: 999997;

    direction: rtl;
    text-align: right;

    font-family: inherit;
}

.sg-chat-welcome-title {
    display: flex;
    align-items: center;

    gap: 8px;

    color: var(--sg-blue);

    font-size: 14px;
    font-weight: 700;

    line-height: 1.6;
}

.sg-chat-wave {
    width: 28px;
    height: 28px;

    display: inline-flex;

    align-items: center;
    justify-content: center;

    background: #fff7ed;

    border: 1px solid var(--sg-orange);
    border-radius: 8px;

    font-size: 16px;

    flex: 0 0 28px;
}

.sg-chat-welcome-text {
    margin-top: 5px;

    color: var(--sg-text);

    font-size: 12px;

    line-height: 1.8;
}


/* =========================================
   دکمه شناور
========================================= */

.sg-chat-floating-button {
    position: fixed;

    right: 20px;
    bottom: 20px;

    width: 54px;
    height: 54px;

    padding: 0;
    margin: 0;

    display: flex;

    align-items: center;
    justify-content: center;

    background: var(--sg-blue);

    color: #fff;

    border: none;
    border-radius: 50%;

    outline: none;

    box-shadow: 0 8px 24px rgba(21, 32, 161, .28);

    cursor: pointer;

    z-index: 999998;

    font-family: inherit;
}

.sg-chat-floating-button:hover,
.sg-chat-floating-button:focus,
.sg-chat-floating-button:active {
    background: var(--sg-blue);
    color: #fff;

    border: none;
    outline: none;

    box-shadow: 0 8px 24px rgba(21, 32, 161, .28);
}

.sg-chat-floating-button svg {
    width: 27px;
    height: 27px;

    display: block;
}

.sg-chat-floating-button .sg-chat-chat-icon {
    display: none;
}

.sg-chat-floating-button.sg-chat-is-open .sg-chat-user-icon {
    display: none;
}

.sg-chat-floating-button.sg-chat-is-open .sg-chat-chat-icon {
    display: block;
}

.sg-chat-floating-button.sg-chat-welcome-pulse {
    animation: sgChatFloatingHeartbeat .7s ease-in-out infinite;
}


/* =========================================
   پنجره چت
========================================= */

.sg-chat-box {
    position: fixed;

    right: 20px;
    bottom: 86px;

    width: 390px;
    height: 580px;

    max-width: calc(100vw - 30px);
    max-height: calc(100vh - 105px);

    display: flex;

    flex-direction: column;

    overflow: hidden;

    background: #fff;

    border-radius: 20px;

    box-shadow:
        0 20px 60px rgba(0, 0, 0, .20),
        0 5px 20px rgba(0, 0, 0, .08);

    direction: rtl;

    opacity: 0;
    visibility: hidden;
    pointer-events: none;

    transform: translateY(12px) scale(.98);

    transition:
        opacity .2s ease,
        visibility .2s ease,
        transform .2s ease;

    z-index: 999999;

    font-family: inherit;
}

.sg-chat-box.sg-chat-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;

    transform: translateY(0) scale(1);
}


/* =========================================
   هدر
========================================= */

.sg-chat-header {
    position: relative;

    min-height: 68px;

    padding: 10px 15px;

    display: flex;

    align-items: center;

    gap: 14px;

    background: var(--sg-blue);

    color: #fff;

    flex-shrink: 0;
}

.sg-chat-avatar {
    position: absolute;

    right: 12px;
    top: 50%;

    width: 48px;
    height: 48px;

    min-width: 48px;

    display: flex;

    align-items: center;
    justify-content: center;

    overflow: hidden;

    background: transparent;

    color: #fff;

    border-radius: 50%;

    transform: translateY(-50%);

    z-index: 1;

    pointer-events: none;
}

.sg-chat-avatar img {
    width: 100%;
    height: 100%;

    display: block;

    object-fit: contain;
    object-position: center;

    background: transparent;
}

.sg-chat-avatar svg {
    width: 28px;
    height: 28px;
}

.sg-chat-header-info {
    position: relative;

    min-width: 0;

    flex: 1 1 auto;

    margin-right: 58px;

    padding-right: 4px;

    z-index: 2;
}

.sg-chat-admin-name {
    color: #fff;

    font-size: 13px;
    font-weight: 700;

    line-height: 1.5;
}

.sg-chat-online {
    margin-top: 2px;

    display: flex;

    align-items: center;

    gap: 5px;

    font-size: 9px;

    color: rgba(255, 255, 255, .80);
}

.sg-chat-online-dot {
    position: relative;

    width: 7px;
    height: 7px;

    flex: 0 0 7px;

    display: block;

    background: var(--sg-green);

    border-radius: 50%;

    box-shadow: 0 0 0 0 rgba(34, 197, 94, .65);

    animation: sgChatHeartbeat 1.6s ease-in-out infinite;
}

.sg-chat-online-dot::after {
    content: "";

    position: absolute;

    top: 50%;
    left: 50%;

    width: 7px;
    height: 7px;

    border-radius: 50%;

    background: transparent;

    border: 1px solid rgba(34, 197, 94, .55);

    transform: translate(-50%, -50%) scale(1);

    animation: sgChatPulse 1.6s ease-out infinite;
}


/* =========================================
   دکمه های هدر
========================================= */

.sg-chat-header-actions {
    display: flex;

    align-items: center;
    justify-content: center;

    gap: 7px;

    margin-left: 2px;

    flex-shrink: 0;

    position: relative;

    z-index: 3;
}

.sg-chat-phone {
    height: 31px;

    padding: 0 9px;

    display: inline-flex;

    align-items: center;
    justify-content: center;

    gap: 5px;

    background: transparent !important;

    border: 1.5px solid var(--sg-orange) !important;
    border-radius: 9px !important;

    color: #fff !important;

    text-decoration: none !important;

    font-size: 10px;
    font-weight: 600;

    line-height: 1;

    white-space: nowrap;

    box-shadow: none !important;
    outline: none !important;

    cursor: pointer;

    appearance: none;
    -webkit-appearance: none;

    transition: none !important;
}

.sg-chat-phone:hover,
.sg-chat-phone:focus,
.sg-chat-phone:active {
    background: transparent !important;

    border-color: var(--sg-orange) !important;

    color: #fff !important;

    outline: none !important;

    box-shadow: none !important;
}

.sg-chat-phone svg {
    width: 14px;
    height: 14px;

    flex: 0 0 14px;
}

.sg-chat-icon-action {
    width: 25px;
    height: 25px;

    padding: 0;
    margin: 0;

    display: flex;

    align-items: center;
    justify-content: center;

    background: transparent !important;

    border: none !important;

    color: var(--sg-orange) !important;

    outline: none !important;

    box-shadow: none !important;

    cursor: pointer;

    appearance: none !important;
    -webkit-appearance: none !important;
}

.sg-chat-icon-action:hover,
.sg-chat-icon-action:focus,
.sg-chat-icon-action:active {
    background: transparent !important;

    border: none !important;

    color: var(--sg-orange) !important;

    outline: none !important;

    box-shadow: none !important;
}

.sg-chat-icon-action svg {
    width: 17px;
    height: 17px;

    display: block;
}

.sg-chat-reset-icon svg,
.sg-chat-close-icon svg {
    transition: transform .35s ease;
}

.sg-chat-reset-icon:hover svg {
    transform: rotate(180deg);
}

.sg-chat-close-icon:hover svg {
    transform: rotate(90deg);
}


/* =========================================
   پیام ها
========================================= */

.sg-chat-messages {
    flex: 1 1 auto;

    min-height: 0;

    overflow-y: auto;

    padding: 15px;

    background-color: #e7ebf0;

    background-image:
        radial-gradient(circle at 15px 15px,
            rgba(255, 255, 255, .40) 1px,
            transparent 1.5px),
        radial-gradient(circle at 45px 45px,
            rgba(180, 190, 202, .22) 1px,
            transparent 1.5px),
        linear-gradient(135deg,
            rgba(255, 255, 255, .18),
            rgba(220, 226, 234, .16));

    background-size:
        60px 60px,
        90px 90px,
        100% 100%;
}


/* =========================================
   پیام اولیه مدیر
========================================= */

.sg-chat-message-admin {
    display: flex;

    justify-content: flex-start;

    margin-bottom: 8px;
}

.sg-chat-message-admin .sg-chat-message-bubble {
    max-width: 92%;

    padding: 10px 11px;

    background: #fff;

    color: var(--sg-text);

    border-radius: 12px 12px 12px 4px;

    font-size: 11px;

    line-height: 1.9;

    direction: rtl;

    text-align: right;

    box-shadow: 0 3px 10px rgba(0, 0, 0, .07);
}


/* =========================================
   گزینه ها
========================================= */

.sg-chat-options {
    width: 100%;

    display: flex;

    flex-direction: row;

    flex-wrap: nowrap;

    gap: 6px;

    margin-top: 8px;

    direction: rtl;
}

.sg-chat-option {
    flex: 1 1 0;

    min-width: 0;

    padding: 8px 6px;

    background: var(--sg-blue);

    color: #fff;

    border: 1px solid var(--sg-blue);

    border-radius: 10px;

    font-family: inherit;

    font-size: 10px;

    line-height: 1.6;

    text-align: center;

    cursor: pointer;

    transition:
        background .2s ease,
        border-color .2s ease,
        transform .2s ease;
}

.sg-chat-option:hover,
.sg-chat-option:focus,
.sg-chat-option:active {
    background: var(--sg-orange) !important;

    color: #fff !important;

    border-color: var(--sg-orange) !important;
}

.sg-chat-option:active {
    transform: scale(.98);
}


/* =========================================
   پیام مشتری
========================================= */

.sg-chat-message-user {
    width: 100%;

    display: flex;

    justify-content: flex-start !important;

    direction: ltr !important;

    margin: 10px 0 8px !important;
}

.sg-chat-message-user .sg-chat-message-bubble {
    max-width: 72%;

    margin-left: 0;

    margin-right: auto;

    padding: 8px 11px;

    background: var(--sg-blue);

    color: #fff;

    border-radius: 14px 14px 4px 14px;

    font-size: 10px;

    line-height: 1.8;

    direction: rtl;

    text-align: right;

    box-shadow:
        0 4px 12px rgba(21, 32, 161, .16);
}


/* =========================================
   Breadcrumb
========================================= */

.sg-chat-breadcrumb {
    width: 100%;

    margin: 8px 0 5px;

    padding: 0 2px;

    display: flex;

    align-items: center;

    flex-wrap: wrap;

    gap: 2px;

    direction: rtl;

    text-align: right;

    font-size: 8px;

    line-height: 1.7;

    box-sizing: border-box;
}

.sg-chat-breadcrumb-item {
    display: inline-flex;

    align-items: center;

    min-width: 0;

    color: var(--sg-orange);

    white-space: nowrap;

    text-decoration: none !important;

    cursor: pointer;

    transition: color .2s ease;
}

.sg-chat-breadcrumb-item:hover {
    color: #ea580c;

    text-decoration: none !important;
}

.sg-chat-breadcrumb-current {
    color: #ea580c !important;

    font-weight: 700;

    cursor: default;

    pointer-events: none;
}

.sg-chat-breadcrumb-separator {
    color: #fb923c;

    margin: 0 2px;

    font-size: 9px;

    line-height: 1;
}


/* =========================================
   کارت جواب
========================================= */

.sg-chat-preview {
    width: 265px;

    max-width: 84%;

    min-height: 84px;

    margin: 0 0 11px auto;

    padding: 6px;

    box-sizing: border-box;

    display: flex;

    align-items: center;

    gap: 9px;

    background: #fff;

    border: 1px solid var(--sg-orange);

    border-radius: 14px;

    overflow: hidden;

    direction: rtl;

    text-align: right;

    text-decoration: none !important;

    color: var(--sg-text) !important;

    box-shadow:
        0 6px 18px rgba(15, 23, 42, .08),
        0 1px 4px rgba(15, 23, 42, .05);

    transition:
        transform .2s ease,
        box-shadow .2s ease;
}

.sg-chat-preview:hover,
.sg-chat-preview:focus {
    transform: translateY(-2px);

    color: var(--sg-text) !important;

    text-decoration: none !important;

    border-color: var(--sg-orange);

    box-shadow:
        0 10px 24px rgba(15, 23, 42, .11),
        0 2px 6px rgba(15, 23, 42, .06);
}


/* =========================================
   تصویر کارت
========================================= */

.sg-chat-preview-image {
    width: 80px !important;

    height: 80px !important;

    min-width: 80px !important;

    max-width: 80px !important;

    min-height: 80px !important;

    max-height: 80px !important;

    flex: 0 0 80px;

    display: block;

    object-fit: contain;

    object-position: center;

    background: transparent !important;

    padding: 0;

    box-sizing: border-box;

    border: none !important;

    border-radius: 8px;
}


/* =========================================
   محتوای کارت
========================================= */

.sg-chat-preview-content {
    flex: 1 1 auto;

    min-width: 0;

    padding: 0;

    display: flex;

    align-items: center;

    text-align: right;
}


/* =========================================
   عنوان کارت
========================================= */

.sg-chat-preview-title {
    width: 100%;

    margin: 0;

    color: #111827;

    font-size: 11px;

    font-weight: 700;

    line-height: 1.7;

    text-align: right;

    display: -webkit-box;

    -webkit-line-clamp: 4;

    -webkit-box-orient: vertical;

    overflow: hidden;
}


/* =========================================
   متن نتیجه جستجو
========================================= */

.sg-chat-keyword-text {
    color: #6b7280;

    font-size: 10px;

    line-height: 1.8;

    text-align: right;
}


/* =========================================
   دکمه کارت
========================================= */

.sg-chat-preview-button {
    width: 100%;

    min-height: 29px;

    padding: 5px 9px;

    display: flex;

    align-items: center;
    justify-content: center;

    box-sizing: border-box;

    background: var(--sg-blue);

    color: #fff;

    border: 1px solid var(--sg-blue);

    border-radius: 8px;

    text-decoration: none;

    font-family: inherit;

    font-size: 9px;

    font-weight: 600;

    line-height: 1.5;

    transition:
        background .2s ease,
        border-color .2s ease,
        transform .2s ease;
}

.sg-chat-preview-button:hover,
.sg-chat-preview-button:focus {
    background: var(--sg-orange);

    border-color: var(--sg-orange);

    color: #fff;

    transform: translateY(-1px);
}


/* =========================================
   پایین چت
========================================= */

.sg-chat-footer {
    position: relative;

    flex-shrink: 0;

    width: 100%;

    padding: 10px !important;

    box-sizing: border-box;

    background: #fff;

    border-top: 1px solid var(--sg-border);

    overflow: visible;
}

.sg-chat-form {
    width: 100% !important;

    height: 42px;

    min-height: 42px;

    display: flex !important;

    align-items: center !important;

    gap: 8px;

    margin: 0 !important;

    padding: 0 !important;

    box-sizing: border-box;

    direction: rtl;
}


/* =========================================
   ورودی
========================================= */

.sg-chat-input {
    flex: 1 1 auto !important;

    width: auto !important;

    min-width: 0 !important;

    max-width: none !important;

    height: 42px !important;

    min-height: 42px !important;

    max-height: 42px !important;

    margin: 0 !important;

    padding: 0 13px !important;

    box-sizing: border-box !important;

    border: 1.5px solid var(--sg-blue) !important;

    border-radius: 12px !important;

    background: #fff !important;

    color: var(--sg-orange) !important;

    font-family: inherit;

    font-size: 12px;

    direction: rtl;

    text-align: right;

    outline: none !important;

    box-shadow: none !important;

    appearance: none !important;

    -webkit-appearance: none !important;
}

.sg-chat-input::placeholder {
    color: var(--sg-orange) !important;

    opacity: .75;
}

.sg-chat-input:focus {
    border: 1.5px solid var(--sg-orange) !important;

    color: var(--sg-orange) !important;

    outline: none !important;

    box-shadow: none !important;
}


/* =========================================
   دکمه ارسال
========================================= */

.sg-chat-send {
    position: relative !important;

    flex: 0 0 42px !important;

    width: 42px !important;

    min-width: 42px !important;
    max-width: 42px !important;

    height: 42px !important;

    min-height: 42px !important;
    max-height: 42px !important;

    margin: 0 !important;

    padding: 0 !important;

    box-sizing: border-box !important;

    display: flex !important;

    align-items: center !important;

    justify-content: center !important;

    align-self: center !important;

    background: var(--sg-blue) !important;

    color: var(--sg-orange) !important;

    border: 2px solid var(--sg-orange) !important;

    border-radius: 12px !important;

    outline: none !important;

    box-shadow: none !important;

    cursor: pointer;

    transform: none !important;

    overflow: hidden !important;

    line-height: 0 !important;

    text-align: center !important;

    transition:
        transform .12s ease,
        background .18s ease;
}

.sg-chat-send::before,
.sg-chat-send::after {
    content: none !important;

    display: none !important;
}

.sg-chat-send:hover,
.sg-chat-send:focus,
.sg-chat-send:focus-visible {
    width: 42px !important;

    min-width: 42px !important;
    max-width: 42px !important;

    height: 42px !important;

    min-height: 42px !important;
    max-height: 42px !important;

    margin: 0 !important;

    padding: 0 !important;

    background: var(--sg-blue) !important;

    color: var(--sg-orange) !important;

    border: 2px solid var(--sg-orange) !important;

    border-radius: 12px !important;

    outline: none !important;

    box-shadow: none !important;

    transform: translateY(-1px) !important;
}

.sg-chat-send:active {
    width: 42px !important;

    min-width: 42px !important;
    max-width: 42px !important;

    height: 42px !important;

    min-height: 42px !important;
    max-height: 42px !important;

    background: var(--sg-blue) !important;

    color: var(--sg-orange) !important;

    border: 2px solid var(--sg-orange) !important;

    border-radius: 12px !important;

    transform: scale(.96) !important;
}

.sg-chat-send svg {
    position: static !important;

    width: 19px !important;
    height: 19px !important;

    min-width: 19px !important;
    min-height: 19px !important;

    max-width: 19px !important;
    max-height: 19px !important;

    margin: 0 !important;

    padding: 0 !important;

    display: block !important;

    flex: 0 0 19px !important;

    transform: none !important;

    fill: none !important;

    stroke: var(--sg-orange) !important;

    overflow: visible !important;
}

.sg-chat-send svg path {
    fill: none !important;

    stroke: var(--sg-orange) !important;
}


/* =========================================
   اسکرول
========================================= */

.sg-chat-messages::-webkit-scrollbar {
    width: 5px;
}

.sg-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.sg-chat-messages::-webkit-scrollbar-thumb {
    background: rgba(21, 32, 161, .25);

    border-radius: 10px;
}


/* =========================================
   انیمیشن آنلاین
========================================= */

@keyframes sgChatHeartbeat {

    0% {
        transform: scale(1);

        box-shadow:
            0 0 0 0 rgba(34, 197, 94, .55);
    }

    15% {
        transform: scale(1.22);

        box-shadow:
            0 0 0 2px rgba(34, 197, 94, .15);
    }

    30% {
        transform: scale(1);

        box-shadow:
            0 0 0 0 rgba(34, 197, 94, 0);
    }

    45% {
        transform: scale(1.16);

        box-shadow:
            0 0 0 2px rgba(34, 197, 94, .10);
    }

    60%,
    100% {
        transform: scale(1);

        box-shadow:
            0 0 0 0 rgba(34, 197, 94, 0);
    }
}

@keyframes sgChatPulse {

    0% {
        opacity: .75;

        transform:
            translate(-50%, -50%) scale(1);
    }

    70% {
        opacity: 0;

        transform:
            translate(-50%, -50%) scale(2.1);
    }

    100% {
        opacity: 0;

        transform:
            translate(-50%, -50%) scale(2.1);
    }
}

@keyframes sgChatFloatingHeartbeat {

    0%,
    100% {
        transform: scale(1);

        box-shadow:
            0 8px 24px rgba(21, 32, 161, .28);
    }

    20% {
        transform: scale(1.08);

        box-shadow:
            0 10px 28px rgba(21, 32, 161, .38);
    }

    35% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.06);

        box-shadow:
            0 10px 28px rgba(21, 32, 161, .34);
    }

    65% {
        transform: scale(1);
    }
}


/* =========================================
   موبایل
========================================= */

@media (max-width:600px) {

    .sg-chat-welcome {
        right: 73px;

        bottom: 15px;

        width: 285px;

        max-width: calc(100vw - 30px);
    }

    .sg-chat-floating-button {
        right: 15px;

        bottom: 15px;

        width: 50px;

        height: 50px;
    }

    .sg-chat-box {
        right: 15px;

        bottom: 75px;

        width: calc(100vw - 30px);

        height: 580px;

        max-height: calc(100vh - 90px);

        border-radius: 18px;
    }

    .sg-chat-header {
        min-height: 62px;

        padding: 8px 10px;

        gap: 10px;
    }

    .sg-chat-avatar {
        right: 8px;

        width: 42px;

        height: 42px;

        min-width: 42px;
    }

    .sg-chat-header-info {
        margin-right: 49px;

        padding-right: 2px;
    }

    .sg-chat-admin-name {
        font-size: 12px;
    }

    .sg-chat-phone {
        padding: 0 7px;

        font-size: 9px;
    }

    .sg-chat-header-actions {
        gap: 3px;

        margin-left: 0;
    }

    .sg-chat-messages {
        padding: 12px;
    }

    .sg-chat-option {
        padding: 7px 4px;

        font-size: 9px;
    }

    .sg-chat-message-user .sg-chat-message-bubble {
        max-width: 78%;
    }


    /* Breadcrumb موبایل */

    .sg-chat-breadcrumb {
        margin: 7px 0 4px;

        padding: 0 2px;

        font-size: 7px;

        line-height: 1.7;
    }

    .sg-chat-breadcrumb-separator {
        font-size: 8px;

        margin: 0 1px;
    }


    /* کارت موبایل */

    .sg-chat-preview {
        width: 245px;

        max-width: 84%;

        min-height: 84px;

        padding: 6px;

        gap: 8px;
    }

    .sg-chat-preview-image {
        width: 80px !important;

        height: 80px !important;

        min-width: 80px !important;

        max-width: 80px !important;

        min-height: 80px !important;

        max-height: 80px !important;

        border: none !important;

        border-radius: 8px;
    }

    .sg-chat-preview-content {
        padding: 0;
    }

    .sg-chat-preview-title {
        font-size: 10px;
    }

    .sg-chat-footer {
        padding: 9px !important;
    }

    .sg-chat-form {
        height: 42px;

        min-height: 42px;
    }
}