/* ════════════════════════════════════════════════════════════════════════
   FURI Chat Widget — Futurobots
   Floating bubble + slide-up panel, full-screen on mobile
════════════════════════════════════════════════════════════════════════ */

/* ── Root ── */
#fbm-chat-root {
    position: fixed;
    bottom: 0;
    right: 0;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ── Floating Bubble ── */
#fbm-chat-bubble {
    position: fixed;
    bottom: 28px;
    right: 28px;
    z-index: 999999;
    display: flex;
    align-items: center;
    gap: 10px;
    background: #0066FF;
    color: #fff;
    border: none;
    border-radius: 100px;
    padding: 14px 22px;
    font-size: 15px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    box-shadow: 0 4px 24px rgba(0, 102, 255, .38);
    transition: background .2s, transform .2s, box-shadow .2s;
    white-space: nowrap;
}
#fbm-chat-bubble:hover {
    background: #0050cc;
    transform: translateY(-2px);
    box-shadow: 0 8px 32px rgba(0, 102, 255, .48);
}
#fbm-chat-bubble.active {
    background: #0050cc;
}
.fbm-bubble-icon {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}
.fbm-bubble-txt {
    display: block;
}

/* ── Chat Panel ── */
#fbm-chat-panel {
    position: fixed;
    bottom: 96px;
    right: 28px;
    z-index: 999998;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 580px;
    max-height: calc(100vh - 120px);
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 12px 56px rgba(0, 0, 0, .18), 0 2px 8px rgba(0, 0, 0, .08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* Hidden state */
    opacity: 0;
    pointer-events: none;
    transform: translateY(16px) scale(.97);
    transform-origin: bottom right;
    transition: opacity .22s ease, transform .22s ease;
}
#fbm-chat-panel.open {
    opacity: 1;
    pointer-events: all;
    transform: translateY(0) scale(1);
}

/* ── Header ── */
.fbm-chat-header {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px;
    background: linear-gradient(135deg, #0a0f1e 0%, #0d1b3e 100%);
    border-radius: 20px 20px 0 0;
}
.fbm-chat-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}
.fbm-chat-avatar {
    width: 42px;
    height: 42px;
    background: #0066FF;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 800;
    color: #fff;
    flex-shrink: 0;
    border: 2px solid rgba(255, 255, 255, .15);
}
.fbm-chat-agent-name {
    color: #fff;
    font-weight: 700;
    font-size: 16px;
    line-height: 1.2;
}
.fbm-chat-agent-status {
    color: #94a3b8;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 2px;
}
.fbm-status-dot {
    width: 7px;
    height: 7px;
    background: #22c55e;
    border-radius: 50%;
    display: inline-block;
    animation: fbm-pulse 2s infinite;
}
@keyframes fbm-pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: .5; }
}
.fbm-chat-close-btn {
    background: none;
    border: none;
    color: #64748b;
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color .2s, background .2s;
    flex-shrink: 0;
}
.fbm-chat-close-btn:hover {
    color: #fff;
    background: rgba(255, 255, 255, .1);
}

/* ── Chat Body (shared) ── */
.fbm-chat-body {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    scroll-behavior: smooth;
}

/* ── Pre-chat ── */
#fbm-prechat {
    padding: 24px 20px;
}
.fbm-prechat-intro {
    text-align: center;
    margin-bottom: 24px;
}
.fbm-prechat-avatar {
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, #0066FF, #0d1b3e);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    font-weight: 800;
    color: #fff;
    margin: 0 auto 14px;
}
.fbm-prechat-hi {
    font-size: 17px;
    font-weight: 700;
    color: #1a202c;
    margin: 0 0 8px;
}
.fbm-prechat-sub {
    font-size: 13.5px;
    color: #64748b;
    line-height: 1.6;
    margin: 0;
}

/* Fields */
.fbm-field {
    margin-bottom: 14px;
}
.fbm-field label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 6px;
}
.fbm-field input,
.fbm-field textarea {
    width: 100%;
    padding: 10px 13px;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    font-size: 14px;
    color: #1a202c;
    font-family: inherit;
    resize: none;
    transition: border-color .2s, box-shadow .2s;
    box-sizing: border-box;
    background: #fff;
}
.fbm-field input:focus,
.fbm-field textarea:focus {
    outline: none;
    border-color: #0066FF;
    box-shadow: 0 0 0 3px rgba(0, 102, 255, .10);
}

.fbm-prechat-error {
    color: #dc2626;
    font-size: 13px;
    margin: 0 0 10px;
    min-height: 18px;
}

.fbm-start-btn {
    display: block;
    width: 100%;
    padding: 13px;
    background: #0066FF;
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: background .2s;
}
.fbm-start-btn:hover { background: #0050cc; }

/* ── Chat Messages ── */
#fbm-chat-messages {
    padding: 16px 14px 8px;
    display: flex;
    flex-direction: column;
}
#fbm-messages-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.fbm-msg {
    display: flex;
    flex-direction: column;
    max-width: 88%;
}
.fbm-msg-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .5px;
    text-transform: uppercase;
    color: #94a3b8;
    margin-bottom: 4px;
}
.fbm-msg-bubble {
    padding: 11px 15px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.65;
    word-wrap: break-word;
}

/* AI message */
.fbm-msg-ai {
    align-self: flex-start;
    align-items: flex-start;
}
.fbm-msg-ai .fbm-msg-bubble {
    background: #f1f5f9;
    color: #1a202c;
    border-bottom-left-radius: 4px;
}

/* User message */
.fbm-msg-user {
    align-self: flex-end;
    align-items: flex-end;
}
.fbm-msg-user .fbm-msg-bubble {
    background: #0066FF;
    color: #fff;
    border-bottom-right-radius: 4px;
}

/* Error message */
.fbm-msg-error .fbm-msg-bubble {
    background: #fef2f2;
    color: #dc2626;
}

/* Links inside AI bubbles */
.fbm-msg-ai .fbm-msg-bubble a {
    color: #0066FF;
    text-decoration: underline;
}

/* ── Typing indicator ── */
.fbm-typing-wrap {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    margin-top: 2px;
    padding: 4px 0 8px;
}
.fbm-typing-dots {
    display: flex;
    align-items: center;
    gap: 5px;
    background: #f1f5f9;
    padding: 12px 16px;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
}
.fbm-typing-dots span {
    width: 7px;
    height: 7px;
    background: #94a3b8;
    border-radius: 50%;
    animation: fbm-bounce .9s infinite ease-in-out;
}
.fbm-typing-dots span:nth-child(1) { animation-delay: 0s; }
.fbm-typing-dots span:nth-child(2) { animation-delay: .18s; }
.fbm-typing-dots span:nth-child(3) { animation-delay: .36s; }

@keyframes fbm-bounce {
    0%, 60%, 100% { transform: translateY(0);    opacity: .6; }
    30%            { transform: translateY(-7px); opacity: 1; }
}

/* ── Input Area ── */
.fbm-input-area {
    flex-shrink: 0;
    border-top: 1px solid #e2e8f0;
    padding: 12px 14px 10px;
    background: #fff;
}
.fbm-input-wrap {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}
#fbm-chat-input {
    flex: 1;
    border: 1.5px solid #e2e8f0;
    border-radius: 12px;
    padding: 10px 13px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    max-height: 120px;
    line-height: 1.5;
    color: #1a202c;
    transition: border-color .2s, box-shadow .2s;
    box-sizing: border-box;
    background: #fff;
}
#fbm-chat-input:focus {
    outline: none;
    border-color: #0066FF;
    box-shadow: 0 0 0 3px rgba(0, 102, 255, .10);
}
#fbm-chat-send {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    background: #0066FF;
    color: #fff;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .2s, transform .15s;
    font-family: inherit;
}
#fbm-chat-send:hover    { background: #0050cc; }
#fbm-chat-send:active   { transform: scale(.93); }
#fbm-chat-send:disabled { opacity: .45; cursor: not-allowed; }

.fbm-input-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 8px;
}
#fbm-human-btn {
    background: none;
    border: none;
    font-size: 12px;
    font-family: inherit;
    color: #94a3b8;
    cursor: pointer;
    padding: 0;
    text-decoration: underline;
    transition: color .2s;
}
#fbm-human-btn:hover { color: #64748b; }
.fbm-powered {
    font-size: 11px;
    color: #cbd5e1;
}

/* ── Escalated state ── */
.fbm-escalated-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px 28px;
    text-align: center;
    gap: 12px;
}
.fbm-esc-icon  { font-size: 48px; line-height: 1; }
.fbm-escalated-state h3 {
    font-size: 20px;
    font-weight: 800;
    color: #1a202c;
    margin: 0;
}
.fbm-escalated-state p {
    font-size: 14px;
    color: #64748b;
    line-height: 1.65;
    margin: 0;
}
.fbm-esc-link {
    display: inline-block;
    margin-top: 8px;
    color: #0066FF;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
}
.fbm-esc-link:hover { text-decoration: underline; }

/* ── Scrollbar ── */
.fbm-chat-body::-webkit-scrollbar       { width: 4px; }
.fbm-chat-body::-webkit-scrollbar-track { background: transparent; }
.fbm-chat-body::-webkit-scrollbar-thumb { background: #e2e8f0; border-radius: 4px; }

/* ── Mobile — full screen panel ── */
@media (max-width: 480px) {
    #fbm-chat-panel {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }
    .fbm-chat-header { border-radius: 0; }
    #fbm-chat-bubble {
        bottom: 18px;
        right: 18px;
    }
    .fbm-bubble-txt { display: none; }
    #fbm-chat-bubble { padding: 16px; border-radius: 50%; }
}
