/* ===== AI Chat Widget ===== */
.chatbot-toggle {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0a3d62, #1a6dad);
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(10, 61, 98, 0.35);
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    transition: transform 0.2s, box-shadow 0.2s;
}

.chatbot-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 24px rgba(10, 61, 98, 0.45);
}

.chatbot-toggle .chatbot-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 14px;
    height: 14px;
    background: #e74c3c;
    border-radius: 50%;
    border: 2px solid #fff;
    display: none;
}

.chatbot-window {
    position: fixed;
    bottom: 92px;
    right: 24px;
    width: 380px;
    max-height: 520px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.18);
    z-index: 9999;
    display: none;
    flex-direction: column;
    overflow: hidden;
    font-family: 'Mulish', sans-serif;
}

.chatbot-window.open {
    display: flex;
    animation: chatbot-slide-up 0.3s ease-out;
}

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

/* Header */
.chatbot-header {
    background: linear-gradient(135deg, #0a3d62, #1a6dad);
    color: #fff;
    padding: 14px 18px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.chatbot-header__avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.chatbot-header__info {
    flex: 1;
}

.chatbot-header__title {
    font-size: 0.95rem;
    font-weight: 700;
    margin: 0;
}

.chatbot-header__status {
    font-size: 0.72rem;
    opacity: 0.85;
    margin: 0;
}

.chatbot-header__close {
    background: none;
    border: none;
    color: #fff;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.chatbot-header__close:hover {
    opacity: 1;
}

/* Messages area */
.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 280px;
    max-height: 340px;
    background: #f8f9fb;
}

.chatbot-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 0.88rem;
    line-height: 1.55;
    word-wrap: break-word;
}

.chatbot-msg--bot {
    align-self: flex-start;
    background: #fff;
    color: #333;
    border: 1px solid #e8edf2;
    border-bottom-left-radius: 4px;
}

.chatbot-msg--user {
    align-self: flex-end;
    background: linear-gradient(135deg, #0a3d62, #1a6dad);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.chatbot-msg--typing {
    align-self: flex-start;
    background: #fff;
    border: 1px solid #e8edf2;
    border-bottom-left-radius: 4px;
    padding: 12px 18px;
}

.chatbot-typing-dots {
    display: flex;
    gap: 4px;
}

.chatbot-typing-dots span {
    width: 7px;
    height: 7px;
    background: #aab;
    border-radius: 50%;
    animation: chatbot-dot-bounce 1.2s infinite;
}

.chatbot-typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.chatbot-typing-dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes chatbot-dot-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

/* Input area */
.chatbot-input {
    display: flex;
    align-items: center;
    padding: 12px 14px;
    border-top: 1px solid #e8edf2;
    background: #fff;
    gap: 8px;
    flex-shrink: 0;
}

.chatbot-input__field {
    flex: 1;
    border: 1px solid #dde3ea;
    border-radius: 24px;
    padding: 9px 16px;
    font-size: 0.88rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
    background: #f8f9fb;
}

.chatbot-input__field:focus {
    border-color: #1a6dad;
    background: #fff;
}

.chatbot-input__send {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0a3d62, #1a6dad);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    transition: transform 0.15s;
    flex-shrink: 0;
}

.chatbot-input__send:hover {
    transform: scale(1.06);
}

.chatbot-input__send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* RTL support */
[dir="rtl"] .chatbot-window {
    right: auto;
    left: 24px;
}

[dir="rtl"] .chatbot-toggle {
    right: auto;
    left: 24px;
}

[dir="rtl"] .chatbot-msg--bot {
    border-bottom-left-radius: 14px;
    border-bottom-right-radius: 4px;
}

[dir="rtl"] .chatbot-msg--user {
    border-bottom-right-radius: 14px;
    border-bottom-left-radius: 4px;
}

[dir="rtl"] .chatbot-input__send {
    transform: scaleX(-1);
}

[dir="rtl"] .chatbot-input__send:hover {
    transform: scaleX(-1) scale(1.06);
}

/* Responsive */
@media (max-width: 480px) {
    .chatbot-window {
        right: 0;
        left: 0;
        bottom: 0;
        width: 100%;
        max-height: 100vh;
        border-radius: 16px 16px 0 0;
    }

    .chatbot-messages {
        max-height: calc(100vh - 160px);
    }

    [dir="rtl"] .chatbot-window {
        right: 0;
        left: 0;
    }

    .chatbot-toggle,
    [dir="rtl"] .chatbot-toggle {
        bottom: 16px;
        right: 16px;
        left: auto;
    }
}
