/* ============ Chatbot Widget ============ */
#alijm-ai-chatbot {
    position: fixed;
    bottom: 20px;
    z-index: 999999;
    font-family: Tahoma, Arial, sans-serif;
    direction: rtl;
}

.alijm-ai-chatbot-right { right: 20px; }
.alijm-ai-chatbot-left  { left: 20px; }

#alijm-ai-chatbot-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--alijm-ai-color, #2271b1);
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

#alijm-ai-chatbot-toggle:hover {
    transform: scale(1.1);
}

#alijm-ai-chatbot-window {
    display: none;
    position: absolute;
    bottom: 75px;
    right: 0;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 550px;
    max-height: calc(100vh - 100px);
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.15);
    overflow: hidden;
    flex-direction: column;
}

.alijm-ai-chatbot-left #alijm-ai-chatbot-window {
    right: auto;
    left: 0;
}

#alijm-ai-chatbot.open #alijm-ai-chatbot-window {
    display: flex;
}

.alijm-ai-chatbot-header {
    background: var(--alijm-ai-color, #2271b1);
    color: #fff;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.alijm-ai-chatbot-title {
    font-weight: bold;
    font-size: 15px;
}

#alijm-ai-chatbot-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    padding: 0 5px;
    line-height: 1;
}

#alijm-ai-chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    background: #f8f9fa;
}

.alijm-ai-msg {
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
    max-width: 85%;
}

.alijm-ai-msg-user {
    margin-right: auto;
    align-items: flex-end;
    margin-left: 0;
}

.alijm-ai-msg-assistant {
    margin-left: auto;
    align-items: flex-start;
    margin-right: 0;
}

.alijm-ai-msg-bubble {
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.6;
    word-wrap: break-word;
}

.alijm-ai-msg-user .alijm-ai-msg-bubble {
    background: var(--alijm-ai-color, #2271b1);
    color: #fff;
    border-bottom-right-radius: 3px;
}

.alijm-ai-msg-assistant .alijm-ai-msg-bubble {
    background: #fff;
    color: #333;
    border: 1px solid #e0e0e0;
    border-bottom-left-radius: 3px;
}

.alijm-ai-msg-time {
    font-size: 10px;
    color: #999;
    margin-top: 3px;
    padding: 0 5px;
}

#alijm-ai-chatbot-typing {
    padding: 10px 20px;
    display: flex;
    gap: 4px;
    align-items: center;
}

#alijm-ai-chatbot-typing span {
    width: 8px;
    height: 8px;
    background: #999;
    border-radius: 50%;
    display: inline-block;
    animation: alijm-ai-typing 1.4s infinite;
}

#alijm-ai-chatbot-typing span:nth-child(2) { animation-delay: 0.2s; }
#alijm-ai-chatbot-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes alijm-ai-typing {
    0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
    30% { opacity: 1; transform: translateY(-5px); }
}

.alijm-ai-chatbot-input-wrap {
    padding: 10px;
    border-top: 1px solid #e0e0e0;
    display: flex;
    gap: 8px;
    background: #fff;
    align-items: flex-end;
}

#alijm-ai-chatbot-input {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 20px;
    padding: 10px 14px;
    font-family: inherit;
    font-size: 14px;
    resize: none;
    max-height: 100px;
    outline: none;
    line-height: 1.5;
}

#alijm-ai-chatbot-input:focus {
    border-color: var(--alijm-ai-color, #2271b1);
}

#alijm-ai-chatbot-send {
    background: var(--alijm-ai-color, #2271b1);
    color: #fff;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s;
}

#alijm-ai-chatbot-send:hover { opacity: 0.9; }

#alijm-ai-chatbot-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.alijm-ai-chatbot-footer {
    padding: 6px;
    text-align: center;
    font-size: 10px;
    color: #999;
    background: #fafafa;
    border-top: 1px solid #eee;
}

/* موبایل */
@media (max-width: 480px) {
    #alijm-ai-chatbot-window {
        width: calc(100vw - 20px);
        height: calc(100vh - 100px);
        bottom: 75px;
        right: 10px !important;
        left: 10px !important;
    }
}




/* ============ استایل لینک‌ها در پیام‌های چت‌بات ============ */
.alijm-ai-msg-bubble a {
    color: inherit;
    text-decoration: underline;
    word-break: break-word;
    font-weight: 600;
}

.alijm-ai-msg-assistant .alijm-ai-msg-bubble a {
    color: var(--alijm-ai-color, #2271b1);
}

.alijm-ai-msg-assistant .alijm-ai-msg-bubble a:hover {
    opacity: 0.8;
    text-decoration: none;
}

.alijm-ai-msg-user .alijm-ai-msg-bubble a {
    color: #fff;
    text-decoration: underline;
}

/* استایل لیست‌ها */
.alijm-ai-msg-bubble ul,
.alijm-ai-msg-bubble ol {
    margin: 8px 15px 8px 0;
    padding-right: 20px;
}

.alijm-ai-msg-bubble li {
    margin-bottom: 4px;
    line-height: 1.6;
}

/* استایل bold و italic */
.alijm-ai-msg-bubble strong,
.alijm-ai-msg-bubble b {
    font-weight: 700;
}

.alijm-ai-msg-bubble em,
.alijm-ai-msg-bubble i {
    font-style: italic;
}

/* استایل code */
.alijm-ai-msg-bubble code {
    background: rgba(0,0,0,0.08);
    padding: 2px 6px;
    border-radius: 3px;
    font-family: monospace;
    font-size: 0.9em;
}

.alijm-ai-msg-user .alijm-ai-msg-bubble code {
    background: rgba(255,255,255,0.25);
}

/* استایل عناوین کوچک */
.alijm-ai-msg-bubble h3,
.alijm-ai-msg-bubble h4 {
    margin: 10px 0 5px 0;
    font-weight: 700;
    font-size: 1.05em;
}

/* استایل پاراگراف */
.alijm-ai-msg-bubble p {
    margin: 0 0 8px 0;
}

.alijm-ai-msg-bubble p:last-child {
    margin-bottom: 0;
}