/**
 * AI Chatbot — Styles v3.1.0
 * Colours driven by CSS variables set dynamically from plugin settings.
 * Fallbacks: Chatbot #00BFFF (light blue) | Header #1a3a5c | WA #25D366
 */

:root {
    --fchat-accent:  #00BFFF;
    --fchat-header:  #1a3a5c;
    --fchat-wa:      #25D366;
    --fchat-wa-dark: #128C7E;
}

/* ─────────────────────────────────────────────
   WIDGET WRAPPER — fixed bottom-right, flex column
   Bubbles stack: chatbot on top, WhatsApp below
───────────────────────────────────────────── */
.fchat-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 99999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
}

/* ─────────────────────────────────────────────
   CHAT WINDOW — positioned relative to widget,
   above all bubbles
───────────────────────────────────────────── */
.fchat-window {
    position: absolute;
    bottom: 136px; /* clears both bubbles (58+10+58+10) */
    right: 0;
    width: 340px;
    height: 520px;
    max-height: 80vh;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: fchat-slide-up 0.25s ease;
}
/* When WA button is hidden, window sits closer */
.fchat-widget.no-wa .fchat-window {
    bottom: 72px;
}
@keyframes fchat-slide-up {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ─────────────────────────────────────────────
   CHATBOT BUBBLE
───────────────────────────────────────────── */
.fchat-bubble {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: var(--fchat-accent);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.22);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    position: relative;
    outline: none;
    flex-shrink: 0;
}
.fchat-bubble:hover { transform: scale(1.08); }
.fchat-bubble-icon  { line-height: 1; color: #fff; }

/* Notification badge */
.fchat-badge {
    position: absolute;
    top: -2px; right: -2px;
    width: 20px; height: 20px;
    background: #ff3d00;
    color: #fff;
    border-radius: 50%;
    font-size: 11px; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    border: 2px solid #fff;
}
@keyframes fchat-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(0,191,255,0.55); }
    70%  { box-shadow: 0 0 0 14px rgba(0,191,255,0); }
    100% { box-shadow: 0 0 0 0 rgba(0,191,255,0); }
}
.fchat-bubble-pulse { animation: fchat-pulse 1.8s infinite; }

/* ─────────────────────────────────────────────
   WHATSAPP FLOATING BUTTON
   Sits below chatbot bubble. Expands on hover.
───────────────────────────────────────────── */
.fchat-wa-float {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 58px;
    height: 58px;
    border-radius: 29px;
    background: var(--fchat-wa);
    color: #fff;
    text-decoration: none;
    box-shadow: 0 4px 20px rgba(37,211,102,0.4);
    transition: width 0.25s ease, border-radius 0.25s ease,
                padding 0.25s ease, transform 0.2s ease,
                box-shadow 0.2s ease;
    overflow: hidden;
    white-space: nowrap;
    flex-shrink: 0;
}
.fchat-wa-float:hover {
    width: auto;
    border-radius: 29px;
    padding: 0 18px 0 14px;
    transform: translateY(-2px);
    box-shadow: 0 6px 28px rgba(37,211,102,0.55);
}
.fchat-wa-float svg {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
}
.fchat-wa-float-label {
    max-width: 0;
    overflow: hidden;
    font-size: 13px;
    font-weight: 600;
    transition: max-width 0.25s ease, padding-left 0.25s ease;
    padding-left: 0;
}
.fchat-wa-float:hover .fchat-wa-float-label {
    max-width: 140px;
    padding-left: 8px;
}

/* ─────────────────────────────────────────────
   HEADER
───────────────────────────────────────────── */
.fchat-header {
    background: var(--fchat-header);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
.fchat-header-info { display: flex; align-items: center; gap: 10px; }
.fchat-avatar-wrap { position: relative; flex-shrink: 0; }
.fchat-avatar {
    width: 40px; height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255,255,255,0.3);
}
.fchat-online-dot {
    position: absolute; bottom: 1px; right: 1px;
    width: 10px; height: 10px;
    background: #25D366;
    border-radius: 50%;
    border: 2px solid var(--fchat-header);
}
.fchat-agent-name   { color: #fff; font-weight: 700; font-size: 14px; }
.fchat-agent-status { color: rgba(255,255,255,0.65); font-size: 11px; margin-top: 1px; }
.fchat-close-btn {
    background: none; border: none;
    color: rgba(255,255,255,0.65);
    font-size: 18px; cursor: pointer;
    padding: 4px 6px; border-radius: 4px;
    transition: color 0.15s;
}
.fchat-close-btn:hover { color: #fff; }

/* ─────────────────────────────────────────────
   MESSAGES
───────────────────────────────────────────── */
.fchat-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px 14px 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    scroll-behavior: smooth;
}
.fchat-messages::-webkit-scrollbar { width: 4px; }
.fchat-messages::-webkit-scrollbar-track { background: #f1f1f1; }
.fchat-messages::-webkit-scrollbar-thumb { background: #ccc; border-radius: 2px; }

.fchat-msg { display: flex; max-width: 88%; }
.fchat-msg-bot  { align-self: flex-start; }
.fchat-msg-user { align-self: flex-end; flex-direction: row-reverse; }

.fchat-bubble-msg {
    padding: 10px 13px;
    border-radius: 14px;
    font-size: 13.5px;
    line-height: 1.6;
    word-break: break-word;
    white-space: pre-wrap;
}
.fchat-msg-bot  .fchat-bubble-msg {
    background: #f0f4f8;
    color: #1a2a3a;
    border-bottom-left-radius: 4px;
}
.fchat-msg-user .fchat-bubble-msg {
    background: var(--fchat-accent);
    color: #fff;
    border-bottom-right-radius: 4px;
}

/* Typing indicator */
.fchat-typing .fchat-bubble-msg {
    padding: 12px 16px;
    display: flex; gap: 4px; align-items: center;
}
.fchat-typing .fchat-bubble-msg span {
    display: inline-block;
    width: 7px; height: 7px;
    background: var(--fchat-accent);
    border-radius: 50%;
    animation: fchat-bounce 1.2s infinite;
}
.fchat-typing .fchat-bubble-msg span:nth-child(2) { animation-delay: 0.2s; }
.fchat-typing .fchat-bubble-msg span:nth-child(3) { animation-delay: 0.4s; }
@keyframes fchat-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30%            { transform: translateY(-6px); }
}

/* ─────────────────────────────────────────────
   QUICK REPLIES
───────────────────────────────────────────── */
.fchat-quick-replies {
    padding: 6px 14px 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    flex-shrink: 0;
    border-top: 1px solid #f0f0f0;
    max-height: 130px;
    overflow-y: auto;
}
.fchat-qr-btn {
    background: #fff;
    border: 1.5px solid var(--fchat-accent);
    color: var(--fchat-accent);
    border-radius: 20px;
    padding: 5px 12px;
    font-size: 12.5px; font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
    font-family: inherit;
}
.fchat-qr-btn:hover { background: var(--fchat-accent); color: #fff; }

/* ─────────────────────────────────────────────
   INPUT AREA
───────────────────────────────────────────── */
.fchat-input-area {
    display: flex; align-items: center;
    padding: 10px 12px;
    border-top: 1px solid #eee;
    gap: 8px; flex-shrink: 0;
}
.fchat-input {
    flex: 1;
    border: 1.5px solid #e2e8f0;
    border-radius: 22px;
    padding: 8px 14px;
    font-size: 13.5px; outline: none;
    transition: border-color 0.15s;
    background: #f8fafc; color: #1a2a3a;
    font-family: inherit;
}
.fchat-input:focus { border-color: var(--fchat-accent); background: #fff; }
.fchat-send-btn {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: var(--fchat-accent);
    border: none; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    color: #fff; flex-shrink: 0;
    transition: transform 0.15s, opacity 0.15s;
}
.fchat-send-btn:hover { transform: scale(1.08); }

/* ─────────────────────────────────────────────
   FOOTER BRANDING
───────────────────────────────────────────── */
.fchat-footer-brand {
    text-align: center;
    font-size: 10.5px; color: #aaa;
    padding: 5px 0 8px;
    flex-shrink: 0;
}
.fchat-footer-brand a {
    color: var(--fchat-accent);
    text-decoration: none; font-weight: 600;
}

/* ─────────────────────────────────────────────
   RESPONSIVE
───────────────────────────────────────────── */
@media (max-width: 480px) {
    .fchat-widget {
        bottom: 16px;
        right: 16px;
    }
    .fchat-window {
        width: calc(100vw - 32px);
        height: calc(100dvh - 120px);
        max-height: none;
        bottom: 140px;
        right: 0;
    }
    .fchat-widget.no-wa .fchat-window {
        bottom: 72px;
        height: calc(100dvh - 100px);
    }
    .fchat-wa-float,
    .fchat-bubble {
        width: 52px;
        height: 52px;
    }
    .fchat-wa-float svg { width: 24px; height: 24px; }
}
