/* ویجت دستیار — گوشه پایین، بالاتر از دکمه بازگشت به بالا و نوار موبایل */

.dr-chatbot {
    font-family: inherit;
}

.dr-chatbot-launcher {
    position: fixed;
    z-index: 9995;
    right: 24px;
    left: auto;
    bottom: 88px;
    min-width: 0;
    height: 52px;
    box-sizing: border-box;
    padding: 0 24px;
    border: 2px solid rgba(255, 255, 255, 0.85);
    border-radius: 999px;
    background: linear-gradient(135deg, #0f766e, #0891b2);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 24px rgba(15, 118, 110, 0.5);
    white-space: nowrap;
    animation: dr-launcher-pulse 2.4s ease-out infinite;
}

.dr-chatbot-launcher[aria-expanded="true"] {
    animation: none;
}

/* حلقه نوری دور دکمه تا در گوشه صفحه دیده شود */
@keyframes dr-launcher-pulse {
    0%   { box-shadow: 0 6px 24px rgba(15, 118, 110, 0.5), 0 0 0 0 rgba(8, 145, 178, 0.55); }
    70%  { box-shadow: 0 6px 24px rgba(15, 118, 110, 0.5), 0 0 0 14px rgba(8, 145, 178, 0); }
    100% { box-shadow: 0 6px 24px rgba(15, 118, 110, 0.5), 0 0 0 0 rgba(8, 145, 178, 0); }
}

@media (prefers-reduced-motion: reduce) {
    .dr-chatbot-launcher {
        animation: none;
    }
}

.dr-chatbot-launcher-label {
    font-size: 1rem;
    font-weight: 700;
    line-height: 1;
}

.dr-chatbot-panel {
    position: fixed;
    z-index: 9996;
    right: 24px;
    left: auto;
    bottom: 148px;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 520px;
    max-height: calc(100vh - 180px);
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 16px 48px rgba(15, 23, 42, 0.22);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.dr-chatbot-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    background: linear-gradient(135deg, #0f766e, #0e7490);
    color: #fff;
}

.dr-chatbot-title {
    display: block;
    font-size: 0.95rem;
}

.dr-chatbot-sub {
    margin: 4px 0 0;
    font-size: 0.75rem;
    opacity: 0.9;
}

.dr-chatbot-head-actions {
    display: flex;
    gap: 4px;
}

.dr-chatbot-close,
.dr-chatbot-clear {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 1.05rem;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 8px;
}

.dr-chatbot-close:hover,
.dr-chatbot-clear:hover {
    background: rgba(255, 255, 255, 0.15);
}

.dr-chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.dr-chat-bubble {
    max-width: 88%;
    padding: 10px 12px;
    border-radius: 14px;
    font-size: 0.88rem;
    line-height: 1.7;
    white-space: pre-wrap;
}

.dr-chat-bubble.assistant {
    background: #fff;
    color: #0f172a;
    border: 1px solid #e2e8f0;
    align-self: flex-start;
}

.dr-chat-bubble.user {
    background: #0f766e;
    color: #fff;
    align-self: flex-end;
}

.dr-chatbot-form {
    display: flex;
    gap: 8px;
    padding: 10px;
    border-top: 1px solid #e2e8f0;
    background: #fff;
}

.dr-chatbot-form textarea {
    flex: 1;
    resize: none;
    border: 1px solid #cbd5e1;
    border-radius: 12px;
    padding: 8px 10px;
    font: inherit;
    line-height: 1.6;
    min-height: 64px;
    max-height: 120px;
}

.dr-chat-pending {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 148px;
}

.dr-chat-live::after {
    content: '';
    display: inline-block;
    width: 2px;
    height: 1em;
    margin-inline-start: 2px;
    background: #0f766e;
    vertical-align: text-bottom;
    animation: dr-caret 1s steps(1) infinite;
}

@keyframes dr-caret {
    0%, 50% { opacity: 1; }
    50.01%, 100% { opacity: 0; }
}

.dr-chat-status {
    font-size: 0.8rem;
    color: #475569;
}

.dr-chat-dots {
    display: flex;
    gap: 5px;
    height: 12px;
    align-items: flex-end;
}

.dr-chat-dots i {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #0f766e;
    animation: dr-dot-bounce 1.05s infinite ease-in-out;
}

.dr-chat-dots i:nth-child(2) { animation-delay: 0.15s; }
.dr-chat-dots i:nth-child(3) { animation-delay: 0.3s; }

@keyframes dr-dot-bounce {
    0%, 70%, 100% { transform: translateY(0); opacity: 0.35; }
    35% { transform: translateY(-6px); opacity: 1; }
}

.dr-chatbot-form button {
    width: 42px;
    border: none;
    border-radius: 12px;
    background: #0f766e;
    color: #fff;
    cursor: pointer;
}

.dr-chatbot-honeypot {
    position: absolute;
    left: -9999px;
    height: 0;
    overflow: hidden;
}

@media (max-width: 767px) {
    .dr-chatbot-launcher {
        right: 12px;
        left: auto;
        bottom: calc(92px + env(safe-area-inset-bottom, 0px));
        max-width: calc(100vw - 24px);
        height: 56px;
        padding: 0 20px;
    }

    /* در LTR دکمه بازگشت به بالا سمت راست است؛ دکمه مشاوره به چپ می‌رود */
    .dr-chatbot[dir="ltr"] .dr-chatbot-launcher {
        left: 12px;
        right: auto;
    }

    .dr-chatbot-launcher-label {
        font-size: 15px;
    }

    .dr-chatbot-panel {
        left: 0;
        right: 0;
        top: 0;
        bottom: 0;
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }
}
