/**
 * ═══════════════════════════════════════════════════════
 *  CHATBOT WIDGET — Floating chat assistant
 *  Uses CSS custom properties from theme
 * ═══════════════════════════════════════════════════════
 */

/* ─── Floating Button ───────────────────── */
.chatbot-widget {
    position: fixed;
    bottom: 2rem;
    right: 5.5rem;
    z-index: 9000;
    font-family: var(--font-body, 'DM Sans', sans-serif);
}

.chatbot-toggle {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--color-primary, #313945);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    transition: transform 0.3s, background 0.3s;
    position: relative;
}
.chatbot-toggle:hover {
    transform: scale(1.08);
    background: var(--color-accent, #1c1e4d);
}
.chatbot-toggle .badge-dot {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 12px;
    height: 12px;
    background: #22c55e;
    border-radius: 50%;
    border: 2px solid #fff;
}

/* ─── Chat Window ───────────────────────── */
.chatbot-window {
    position: absolute;
    bottom: 70px;
    right: 0;
    width: 380px;
    max-height: 520px;
    background: var(--color-bg, #fff);
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.15);
    display: none;
    flex-direction: column;
    overflow: hidden;
}
.chatbot-window.open {
    display: flex;
    animation: chatSlideUp 0.3s ease;
}

@keyframes chatSlideUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ─── Chat Header ───────────────────────── */
.chatbot-header {
    background: var(--color-primary, #313945);
    color: #fff;
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: 12px 12px 0 0;
}
.chatbot-header-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.chatbot-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255,255,255,0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}
.chatbot-header-text h4 {
    color: #fff;
    font-size: 0.9rem;
    font-weight: 600;
    margin: 0;
}
.chatbot-header-text small {
    color: rgba(255,255,255,0.65);
    font-size: 0.7rem;
}
.chatbot-close {
    background: none;
    border: none;
    color: rgba(255,255,255,0.6);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.2rem;
    transition: color 0.2s;
}
.chatbot-close:hover { color: #fff; }

/* ─── Messages Area ─────────────────────── */
.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-height: 340px;
    scroll-behavior: smooth;
}

.chat-message {
    display: flex;
    gap: 0.5rem;
    max-width: 85%;
    animation: msgFade 0.25s ease;
}
@keyframes msgFade {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.chat-message.bot { align-self: flex-start; }
.chat-message.user { align-self: flex-end; flex-direction: row-reverse; }

.chat-bubble {
    padding: 0.6rem 1rem;
    border-radius: 12px;
    font-size: 0.85rem;
    line-height: 1.5;
    word-break: break-word;
}
.chat-message.bot .chat-bubble {
    background: var(--color-surface, #f1f5f9);
    color: var(--color-text, #333);
    border-bottom-left-radius: 4px;
}
.chat-message.user .chat-bubble {
    background: var(--color-primary, #313945);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.chat-bubble a {
    color: var(--color-secondary, #C9A892);
    text-decoration: underline;
}
.chat-message.user .chat-bubble a { color: rgba(255,255,255,0.9); }

/* Typing indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 0.75rem 1rem;
    background: var(--color-surface, #f1f5f9);
    border-radius: 12px;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}
.typing-indicator span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--color-muted, #94a3b8);
    animation: typingBounce 1.4s infinite both;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

/* ─── Input Area ────────────────────────── */
.chatbot-input {
    display: flex;
    padding: 0.75rem;
    border-top: 1px solid rgba(0,0,0,0.08);
    gap: 0.5rem;
    background: var(--color-bg, #fff);
}
.chatbot-input input {
    flex: 1;
    padding: 0.55rem 0.75rem;
    border: 1px solid rgba(0,0,0,0.12);
    border-radius: 8px;
    font-size: 0.85rem;
    background: var(--color-surface, #f8f9fa);
    color: var(--color-text, #333);
    outline: none;
    transition: border-color 0.2s;
    font-family: inherit;
}
.chatbot-input input:focus {
    border-color: var(--color-secondary, #C9A892);
}
.chatbot-input input::placeholder { color: var(--color-muted, #94a3b8); }

.chatbot-send {
    width: 38px;
    height: 38px;
    border-radius: 8px;
    background: var(--color-primary, #313945);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}
.chatbot-send:hover { background: var(--color-accent, #1c1e4d); }
.chatbot-send:disabled { opacity: 0.5; cursor: not-allowed; }

/* ─── Suggested Questions ───────────────── */
.chatbot-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    padding: 0.75rem;
    border-top: 1px solid rgba(0,0,0,0.05);
}
.chatbot-suggestion {
    padding: 0.3rem 0.75rem;
    background: var(--color-surface, #f1f5f9);
    border: 1px solid rgba(0,0,0,0.08);
    border-radius: 100px;
    font-size: 0.75rem;
    color: var(--color-primary, #313945);
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}
.chatbot-suggestion:hover {
    background: var(--color-primary, #313945);
    color: #fff;
    border-color: var(--color-primary, #313945);
}

/* ─── Responsive ────────────────────────── */
@media (max-width: 480px) {
    .chatbot-window {
        width: calc(100vw - 2rem);
        right: -1rem;
        bottom: 65px;
        max-height: 80vh;
    }
}

/* ─── Print ─────────────────────────────── */
@media print {
    .chatbot-widget { display: none !important; }
}
