/* ── CFL Chatbot Widget ─────────────────────────────────────────────────────── */
#cfl-chat-widget {
    position: fixed;
    bottom: 24px;
    left: 24px;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
}

/* ── Floating bubble ─────────────────────────────────────────────────────────── */
#cfl-chat-bubble {
    width: 62px;
    height: 62px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 6px 24px rgba(102, 126, 234, 0.55);
    transition: transform 0.25s ease;
    position: relative;
    animation: cfl-pulse 2.5s infinite;
}
#cfl-chat-bubble:hover { transform: scale(1.08); }

@keyframes cfl-pulse {
    0%, 100% { box-shadow: 0 6px 24px rgba(102,126,234,0.55); }
    50%       { box-shadow: 0 6px 32px rgba(102,126,234,0.8), 0 0 0 10px rgba(102,126,234,0.12); }
}

/* Badge */
#cfl-badge {
    position: absolute;
    top: -3px;
    right: -3px;
    background: #ff4757;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
}

/* ── Chat window ─────────────────────────────────────────────────────────────── */
#cfl-chat-window {
    position: absolute;
    bottom: 76px;
    left: 0;
    width: 360px;
    height: 520px;
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 12px 48px rgba(0,0,0,0.18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.85) translateY(20px);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.32s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.25s ease;
    transform-origin: bottom left;
}
#cfl-chat-window.cfl-open {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: all;
}

/* ── Header ──────────────────────────────────────────────────────────────────── */
#cfl-chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
.cfl-agent-info { display: flex; align-items: center; gap: 11px; }
.cfl-avatar {
    width: 42px;
    height: 42px;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}
.cfl-agent-name   { color: #fff; font-weight: 700; font-size: 15px; line-height: 1.2; }
.cfl-agent-status { color: rgba(255,255,255,0.88); font-size: 11px; margin-top: 2px; }

#cfl-close-btn {
    background: rgba(255,255,255,0.18);
    border: none;
    color: #fff;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}
#cfl-close-btn:hover { background: rgba(255,255,255,0.3); }

/* ── Messages area ───────────────────────────────────────────────────────────── */
#cfl-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: #f5f6fa;
    scroll-behavior: smooth;
}
#cfl-messages::-webkit-scrollbar { width: 4px; }
#cfl-messages::-webkit-scrollbar-thumb { background: #d0d3e8; border-radius: 4px; }

/* Message bubbles */
.cfl-msg {
    max-width: 82%;
    padding: 10px 14px;
    border-radius: 18px;
    font-size: 13.5px;
    line-height: 1.55;
    word-break: break-word;
    animation: cfl-msg-in 0.28s ease;
}
@keyframes cfl-msg-in {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}
.cfl-msg.bot {
    background: #fff;
    color: #2d2d2d;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.07);
    align-self: flex-start;
}
.cfl-msg.user {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    border-bottom-right-radius: 4px;
    align-self: flex-end;
}

/* Typing indicator */
.cfl-typing {
    display: flex;
    gap: 5px;
    align-items: center;
    padding: 12px 16px;
    background: #fff;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.07);
    align-self: flex-start;
    width: 58px;
}
.cfl-typing span {
    width: 7px;
    height: 7px;
    background: #667eea;
    border-radius: 50%;
    animation: cfl-bounce 1.3s infinite;
}
.cfl-typing span:nth-child(2) { animation-delay: 0.18s; }
.cfl-typing span:nth-child(3) { animation-delay: 0.36s; }
@keyframes cfl-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
    30%            { transform: translateY(-7px); opacity: 1; }
}

/* ── Input area ──────────────────────────────────────────────────────────────── */
#cfl-input-area {
    padding: 11px 14px;
    background: #fff;
    border-top: 1px solid #ebebf0;
    display: flex;
    gap: 8px;
    align-items: center;
    flex-shrink: 0;
}
#cfl-input {
    flex: 1;
    border: 1.5px solid #e0e2ef;
    border-radius: 24px;
    padding: 10px 16px;
    font-size: 13.5px;
    outline: none;
    transition: border-color 0.2s;
    background: #f8f9fd;
    color: #2d2d2d;
}
#cfl-input:focus  { border-color: #667eea; background: #fff; }
#cfl-input:disabled { opacity: 0.5; cursor: not-allowed; }

#cfl-send {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: transform 0.2s, opacity 0.2s;
}
#cfl-send:hover    { transform: scale(1.08); }
#cfl-send:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

/* Shake animation for invalid input */
@keyframes cfl-shake {
    0%, 100% { transform: translateX(0); }
    20%, 60%  { transform: translateX(-5px); }
    40%, 80%  { transform: translateX(5px); }
}
.cfl-shake { animation: cfl-shake 0.4s ease !important; border-color: #ff4757 !important; }

/* ── Mobile responsive ───────────────────────────────────────────────────────── */
@media (max-width: 480px) {
    #cfl-chat-widget { bottom: 16px; left: 14px; }
    #cfl-chat-window {
        width: calc(100vw - 28px);
        left: -14px;
        height: 72vh;
        bottom: 74px;
        border-radius: 16px;
    }
}
