#crc-chatbot-wrapper {
    position: fixed;
    right: 44px;
    bottom: 65px;
    z-index: 999999;
    font-family: Arial, sans-serif;
}


/* معرفی کوتاه کنار دکمه چت */
#crc-chatbot-wrapper::before {
    content: "Hi, i'm Aljabal asistant 👋";
    position: absolute;
    right: 76px;
    bottom: 9px;
    min-width: 165px;
    padding: 11px 15px;
    background: #ffffff;
    color: #1f2937;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.4;
    text-align: center;
    white-space: nowrap;
    border: 1px solid rgba(22, 103, 217, 0.14);
    border-radius: 14px;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.16);
    opacity: 0;
    visibility: hidden;
    transform: translateX(12px) scale(0.96);
    transform-origin: right center;
    animation: crcAssistantPopup 7s ease-in-out 1.2s forwards;
    pointer-events: none;
}


/* فلش کوچک پاپ‌آپ */
#crc-chatbot-wrapper::after {
    content: "";
    position: absolute;
    right: 68px;
    bottom: 27px;
    width: 14px;
    height: 14px;
    background: #ffffff;
    border-top: 1px solid rgba(22, 103, 217, 0.14);
    border-right: 1px solid rgba(22, 103, 217, 0.14);
    transform: rotate(45deg);
    opacity: 0;
    visibility: hidden;
    animation: crcAssistantArrow 7s ease-in-out 1.2s forwards;
    pointer-events: none;
}


/* نمایش مجدد پیام هنگام رفتن موس روی دکمه */
#crc-chatbot-wrapper:hover::before {
    opacity: 1;
    visibility: visible;
    transform: translateX(0) scale(1);
    animation: none;
}

#crc-chatbot-wrapper:hover::after {
    opacity: 1;
    visibility: visible;
    animation: none;
}


/* دکمه اصلی چت */
#crc-chatbot-toggle {
    position: relative;
    width: 66px;
    height: 66px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background:
        linear-gradient(
            145deg,
            #2795ff 0%,
            #1667d9 52%,
            #0a45a8 100%
        );
    color: #ffffff;
    font-size: 29px;
    line-height: 66px;
    text-align: center;
    cursor: pointer;
    box-shadow:
        0 10px 30px rgba(22, 103, 217, 0.38),
        inset 0 2px 2px rgba(255, 255, 255, 0.32),
        inset 0 -3px 6px rgba(0, 0, 0, 0.14);
    transition:
        transform 0.25s ease,
        box-shadow 0.25s ease,
        filter 0.25s ease;
    animation: crcChatFloat 3.2s ease-in-out infinite;
    isolation: isolate;
}


/* حلقه نور متحرک دور دکمه */
#crc-chatbot-toggle::before {
    content: "";
    position: absolute;
    inset: -7px;
    border: 2px solid rgba(22, 103, 217, 0.28);
    border-radius: 50%;
    opacity: 0;
    z-index: -1;
    animation: crcChatPulse 2.2s ease-out infinite;
}


/* نقطه آنلاین */
#crc-chatbot-toggle::after {
    content: "";
    position: absolute;
    top: 5px;
    right: 5px;
    width: 13px;
    height: 13px;
    background: #22c55e;
    border: 3px solid #ffffff;
    border-radius: 50%;
    box-shadow: 0 2px 7px rgba(0, 0, 0, 0.22);
}


/* افکت دکمه هنگام Hover */
#crc-chatbot-toggle:hover {
    transform: translateY(-5px) scale(1.06);
    filter: brightness(1.06);
    box-shadow:
        0 15px 38px rgba(22, 103, 217, 0.48),
        inset 0 2px 2px rgba(255, 255, 255, 0.34),
        inset 0 -3px 6px rgba(0, 0, 0, 0.14);
    animation-play-state: paused;
}


#crc-chatbot-toggle:active {
    transform: translateY(-1px) scale(0.97);
}


#crc-chatbot-toggle:focus-visible {
    outline: 3px solid rgba(22, 103, 217, 0.3);
    outline-offset: 5px;
}


/* پنجره اصلی چت */
#crc-chatbot-box {
    position: absolute;
    right: 0;
    bottom: 82px;
    width: 370px;
    max-width: calc(100vw - 32px);
    height: 410px;
    max-height: calc(100vh - 120px);
    background: #ffffff;
    border: 1px solid rgba(22, 103, 217, 0.1);
    border-radius: 20px;
    overflow: hidden;
    box-shadow:
        0 20px 55px rgba(15, 23, 42, 0.24),
        0 4px 15px rgba(22, 103, 217, 0.1);
    display: flex;
    flex-direction: column;
    animation: crcChatBoxOpen 0.28s ease-out;
}


#crc-chatbot-box.crc-hidden {
    display: none;
}


/* هدر چت */
.crc-chatbot-header {
    position: relative;
    background:
        linear-gradient(
            135deg,
            #2389f5 0%,
            #1667d9 55%,
            #0d4eaf 100%
        );
    color: #ffffff;
    padding: 18px 17px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    overflow: hidden;
}


.crc-chatbot-header::before {
    content: "";
    position: absolute;
    top: -45px;
    right: -25px;
    width: 120px;
    height: 120px;
    background: rgba(255, 255, 255, 0.09);
    border-radius: 50%;
}


.crc-chatbot-header strong,
.crc-chatbot-header small {
    position: relative;
    z-index: 1;
    display: block;
}


.crc-chatbot-header strong {
    font-size: 17px;
}


.crc-chatbot-header small {
    margin-top: 5px;
    font-size: 12px;
    opacity: 0.88;
}


/* دکمه بستن */
#crc-chatbot-close {
    position: relative;
    z-index: 2;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.13);
    color: #ffffff;
    font-size: 27px;
    line-height: 34px;
    cursor: pointer;
    transition:
        background 0.2s ease,
        transform 0.2s ease;
}


#crc-chatbot-close:hover {
    background: rgba(255, 255, 255, 0.24);
    transform: rotate(90deg);
}


/* بخش پیام‌ها */
#crc-chatbot-messages {
    flex: 1;
    white-space: pre-line;
    overflow-y: auto;
    padding: 18px 16px;
    background:
        linear-gradient(
            180deg,
            #f6f9fd 0%,
            #eef3f9 100%
        );
    scroll-behavior: smooth;
}


#crc-chatbot-messages::-webkit-scrollbar {
    width: 6px;
}


#crc-chatbot-messages::-webkit-scrollbar-thumb {
    background: rgba(22, 103, 217, 0.25);
    border-radius: 10px;
}


/* پیام‌ها */
.crc-message {
    max-width: 82%;
    margin-bottom: 13px;
    padding: 11px 14px;
    border-radius: 15px;
    line-height: 1.55;
    overflow-wrap: break-word;
    animation: crcMessageIn 0.22s ease-out;
}


.crc-message-bot {
    margin-right: auto;
    background: #ffffff;
    color: #253044;
    border: 1px solid rgba(15, 23, 42, 0.06);
    border-bottom-left-radius: 4px;
    box-shadow: 0 4px 13px rgba(15, 23, 42, 0.07);
}


.crc-message-user {
    margin-left: auto;
    background:
        linear-gradient(
            135deg,
            #2587ee,
            #1667d9
        );
    color: #ffffff;
    border-bottom-right-radius: 4px;
    box-shadow: 0 5px 15px rgba(22, 103, 217, 0.22);
}


/* بخش ورودی */
#crc-chatbot-input-area {
    padding: 12px;
    display: flex;
    gap: 8px;
    align-items: center;
    background: #ffffff;
    border-top: 1px solid #e8edf3;
}


#crc-chatbot-input {
    flex: 1;
    min-width: 0;
    padding: 12px 13px;
    border: 1px solid #d5dce6;
    border-radius: 11px;
    outline: none;
    background: #f9fbfd;
    color: #1f2937;
    transition:
        border-color 0.2s ease,
        box-shadow 0.2s ease,
        background 0.2s ease;
}


#crc-chatbot-input:focus {
    background: #ffffff;
    border-color: #1667d9;
    box-shadow: 0 0 0 3px rgba(22, 103, 217, 0.12);
}


/* دکمه ارسال */
#crc-chatbot-send {
    padding: 11px 17px;
    border: 0;
    border-radius: 10px;
    background:
        linear-gradient(
            135deg,
            #2389f5,
            #1667d9
        );
    color: #ffffff;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 5px 14px rgba(22, 103, 217, 0.22);
    transition:
        transform 0.2s ease,
        box-shadow 0.2s ease;
}


#crc-chatbot-send:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 18px rgba(22, 103, 217, 0.3);
}


#crc-chatbot-send:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}


/* انیمیشن پاپ‌آپ معرفی */
@keyframes crcAssistantPopup {
    0%,
    8% {
        opacity: 0;
        visibility: hidden;
        transform: translateX(12px) scale(0.96);
    }

    18%,
    72% {
        opacity: 1;
        visibility: visible;
        transform: translateX(0) scale(1);
    }

    100% {
        opacity: 0;
        visibility: hidden;
        transform: translateX(8px) scale(0.98);
    }
}


@keyframes crcAssistantArrow {
    0%,
    8% {
        opacity: 0;
        visibility: hidden;
    }

    18%,
    72% {
        opacity: 1;
        visibility: visible;
    }

    100% {
        opacity: 0;
        visibility: hidden;
    }
}


/* شناورشدن آرام دکمه */
@keyframes crcChatFloat {
    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-5px);
    }
}


/* حلقه ضربان */
@keyframes crcChatPulse {
    0% {
        opacity: 0.5;
        transform: scale(0.86);
    }

    75%,
    100% {
        opacity: 0;
        transform: scale(1.28);
    }
}


/* بازشدن پنجره */
@keyframes crcChatBoxOpen {
    from {
        opacity: 0;
        transform: translateY(15px) scale(0.96);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}


/* ورود پیام */
@keyframes crcMessageIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}


/* نسخه موبایل */
@media (max-width: 480px) {
    #crc-chatbot-wrapper {
        right: 16px;
        bottom: 16px;
    }

    #crc-chatbot-toggle {
        width: 60px;
        height: 60px;
        font-size: 26px;
        line-height: 60px;
    }

    #crc-chatbot-wrapper::before {
        right: 70px;
        bottom: 15px;
        min-width: 145px;
        padding: 10px 12px;
        font-size: 12px;
    }

    #crc-chatbot-wrapper::after {
        right: 63px;
        bottom: 26px;
    }

    #crc-chatbot-box {
        position: fixed;
        right: 10px;
        bottom: 100px;
        width: calc(100vw - 20px);
        height: calc(100vh - 110px);
        border-radius: 18px;
    }
}


/* کاهش انیمیشن برای کاربران حساس به حرکت */
@media (prefers-reduced-motion: reduce) {
    #crc-chatbot-toggle,
    #crc-chatbot-toggle::before,
    #crc-chatbot-wrapper::before,
    #crc-chatbot-wrapper::after,
    #crc-chatbot-box,
    .crc-message {
        animation: none;
    }

    #crc-chatbot-wrapper::before,
    #crc-chatbot-wrapper::after {
        opacity: 1;
        visibility: visible;
        transform: none;
    }
}
