/* ============================================
   FATURAIX – AI Chatbot Widget
   Floating widget, expandable panel, SaaS-style UI
   ============================================ */

.chatbot-wrapper {
    position: fixed;
    bottom: 1.5rem;
    inset-inline-end: 1.5rem;
    z-index: 9999;
    font-family: var(--font-sans, 'Inter', sans-serif);
}

.chatbot-toggle {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, var(--primary, #0f3d2e) 0%, var(--primary-light, #1a5c42) 100%);
    color: #fff;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(15, 61, 46, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.chatbot-toggle:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 24px rgba(15, 61, 46, 0.45);
}

.chatbot-toggle svg {
    width: 28px;
    height: 28px;
}

.chatbot-toggle.open svg.chat-icon {
    display: none;
}

.chatbot-toggle.open svg.close-icon {
    display: block;
}

.chatbot-toggle svg.chat-icon {
    display: block;
}

.chatbot-toggle svg.close-icon {
    display: none;
}

.chatbot-panel {
    position: absolute;
    bottom: calc(56px + 0.75rem);
    inset-inline-end: 0;
    width: 380px;
    max-width: calc(100vw - 2rem);
    height: 520px;
    max-height: calc(100vh - 8rem);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.15);
    display: none;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(0, 0, 0, 0.06);
}

.chatbot-panel.open {
    display: flex;
}

html[dir="rtl"] .chatbot-panel {
    inset-inline-end: auto;
    inset-inline-start: 0;
}

.chatbot-header {
    padding: 1rem 1.25rem;
    background: linear-gradient(135deg, var(--primary, #0f3d2e) 0%, var(--primary-light, #1a5c42) 100%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.chatbot-header-title {
    font-weight: 700;
    font-size: 1rem;
}

.chatbot-close {
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.chatbot-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.chatbot-disclaimer {
    padding: 0.5rem 1rem;
    font-size: 0.75rem;
    color: var(--gray, #6b7280);
    background: #f8fafb;
    border-bottom: 1px solid #eee;
    line-height: 1.4;
}

.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.chatbot-msg {
    max-width: 85%;
    padding: 0.75rem 1rem;
    border-radius: 12px;
    font-size: 0.9rem;
    line-height: 1.5;
    word-wrap: break-word;
}

.chatbot-msg.user {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--primary, #0f3d2e) 0%, var(--primary-light, #1a5c42) 100%);
    color: #fff;
    border-bottom-right-radius: 4px;
}

html[dir="rtl"] .chatbot-msg.user {
    border-bottom-right-radius: 12px;
    border-bottom-left-radius: 4px;
}

.chatbot-msg.bot {
    align-self: flex-start;
    background: #f1f5f9;
    color: var(--dark, #0a0e27);
    border-bottom-left-radius: 4px;
}

html[dir="rtl"] .chatbot-msg.bot {
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 4px;
}

.chatbot-msg .chatbot-msg-time {
    font-size: 0.7rem;
    opacity: 0.8;
    margin-top: 0.35rem;
}

.chatbot-typing {
    align-self: flex-start;
    padding: 0.75rem 1rem;
    background: #f1f5f9;
    border-radius: 12px;
    border-bottom-left-radius: 4px;
    display: flex;
    gap: 4px;
    align-items: center;
}

html[dir="rtl"] .chatbot-typing {
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 4px;
}

.chatbot-typing span {
    width: 6px;
    height: 6px;
    background: var(--gray, #6b7280);
    border-radius: 50%;
    animation: chatbot-bounce 1.4s ease-in-out infinite both;
}

.chatbot-typing span:nth-child(1) { animation-delay: 0s; }
.chatbot-typing span:nth-child(2) { animation-delay: 0.2s; }
.chatbot-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes chatbot-bounce {
    0%, 80%, 100% { transform: scale(0.8); opacity: 0.5; }
    40% { transform: scale(1.2); opacity: 1; }
}

.chatbot-input-wrap {
    padding: 0.75rem 1rem;
    border-top: 1px solid #eee;
    background: #fff;
    flex-shrink: 0;
}

.chatbot-form {
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
}

.chatbot-input {
    flex: 1;
    min-height: 44px;
    padding: 0.6rem 1rem;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    font-size: 0.9rem;
    font-family: inherit;
    resize: none;
    transition: border-color 0.2s ease;
}

.chatbot-input:focus {
    outline: none;
    border-color: var(--primary, #0f3d2e);
}

.chatbot-input::placeholder {
    color: #9ca3af;
}

.chatbot-send {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--primary, #0f3d2e) 0%, var(--primary-light, #1a5c42) 100%);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s ease;
}

.chatbot-send:hover:not(:disabled) {
    opacity: 0.9;
}

.chatbot-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.chatbot-send svg {
    width: 20px;
    height: 20px;
}

.chatbot-error {
    padding: 0.75rem 1rem;
    background: #fef2f2;
    color: #b91c1c;
    font-size: 0.85rem;
    border-radius: 12px;
    margin: 0 1rem 0.5rem;
}

@media (max-width: 480px) {
    .chatbot-wrapper {
        bottom: 1rem;
        inset-inline-end: 1rem;
    }

    .chatbot-panel {
        width: calc(100vw - 2rem);
        height: 70vh;
        bottom: calc(56px + 0.5rem);
    }

    .chatbot-toggle {
        width: 52px;
        height: 52px;
    }
}
