/* ═══════════════════════════════════════════════════════════════
   Corvanta Financial Services — Chatbot Sidebar Widget
   Standalone floating chat widget. Companion to chatbot-sidebar.js
   ═══════════════════════════════════════════════════════════════ */

:root {
    --cb-brand: #0d9e78;
    --cb-brand-dark: #0a7d5f;
    --cb-brand-light: #e6f7f2;
    --cb-bg: #ffffff;
    --cb-bg-sunken: #f7f9fb;
    --cb-text: #1a202c;
    --cb-text-muted: #6b7280;
    --cb-border: #e5e7eb;
    --cb-shadow: 0 20px 48px rgba(0, 0, 0, 0.18);
    --cb-radius: 16px;
}

/* ── FLOATING BUTTON ── */
#cb-toggle {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--cb-brand), var(--cb-brand-dark));
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(13, 158, 120, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    z-index: 999998;
    font-family: system-ui, -apple-system, sans-serif;
}
#cb-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 12px 32px rgba(13, 158, 120, 0.55);
}
#cb-toggle.cb-hidden { display: none; }

#cb-toggle svg { width: 28px; height: 28px; }

#cb-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 10px;
    background: #ef4444;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: none;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
}
#cb-badge.cb-show { display: flex; }

/* ── CHAT PANEL ── */
#cb-panel {
    position: fixed;
    bottom: 96px;
    right: 24px;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 560px;
    max-height: calc(100vh - 140px);
    background: var(--cb-bg);
    border-radius: var(--cb-radius);
    box-shadow: var(--cb-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 999999;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    opacity: 0;
    transform: translateY(12px) scale(0.96);
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
}
#cb-panel.cb-open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* ── HEADER ── */
#cb-header {
    background: linear-gradient(135deg, var(--cb-brand), var(--cb-brand-dark));
    color: #fff;
    padding: 14px 18px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}
#cb-header-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}
#cb-header-info { flex: 1; min-width: 0; }
#cb-header-title {
    font-weight: 700;
    font-size: 14px;
    line-height: 1.2;
}
#cb-header-status {
    font-size: 11px;
    opacity: 0.85;
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 2px;
}
#cb-header-status::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #4ade80;
    box-shadow: 0 0 6px rgba(74, 222, 128, 0.8);
}
#cb-close {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #fff;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    flex-shrink: 0;
}
#cb-close:hover { background: rgba(255, 255, 255, 0.28); }

/* ── MESSAGES ── */
#cb-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: var(--cb-bg-sunken);
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}
#cb-messages::-webkit-scrollbar { width: 6px; }
#cb-messages::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.cb-msg {
    max-width: 82%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 13.5px;
    line-height: 1.5;
    word-wrap: break-word;
    animation: cb-slide-in 0.2s ease;
}
@keyframes cb-slide-in {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}
.cb-msg-bot {
    align-self: flex-start;
    background: #fff;
    color: var(--cb-text);
    border: 1px solid var(--cb-border);
    border-bottom-left-radius: 4px;
}
.cb-msg-user {
    align-self: flex-end;
    background: var(--cb-brand);
    color: #fff;
    border-bottom-right-radius: 4px;
}

/* ── TYPING INDICATOR ── */
.cb-typing {
    display: inline-flex;
    gap: 3px;
    align-items: center;
    padding: 2px 0;
}
.cb-typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--cb-text-muted);
    animation: cb-typing-bounce 1.2s infinite ease-in-out;
}
.cb-typing span:nth-child(2) { animation-delay: 0.15s; }
.cb-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes cb-typing-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-5px); opacity: 1; }
}

/* ── QUICK SUGGESTIONS ── */
#cb-suggestions {
    display: flex;
    gap: 6px;
    padding: 0 16px 10px;
    background: var(--cb-bg-sunken);
    flex-wrap: wrap;
    flex-shrink: 0;
}
.cb-suggestion {
    background: #fff;
    border: 1px solid var(--cb-border);
    color: var(--cb-text);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
    white-space: nowrap;
}
.cb-suggestion:hover {
    border-color: var(--cb-brand);
    color: var(--cb-brand);
    background: var(--cb-brand-light);
}

/* ── INPUT ROW ── */
#cb-input-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    border-top: 1px solid var(--cb-border);
    background: #fff;
    flex-shrink: 0;
}
#cb-input {
    flex: 1;
    border: 1px solid var(--cb-border);
    border-radius: 22px;
    padding: 10px 16px;
    font-size: 13.5px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s;
    background: var(--cb-bg-sunken);
    color: var(--cb-text);
}
#cb-input:focus {
    border-color: var(--cb-brand);
    background: #fff;
}
#cb-input::placeholder { color: var(--cb-text-muted); }

#cb-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--cb-brand);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    flex-shrink: 0;
}
#cb-send:hover:not(:disabled) { background: var(--cb-brand-dark); }
#cb-send:disabled { opacity: 0.5; cursor: not-allowed; }
#cb-send svg { width: 18px; height: 18px; }

/* ── FOOTER ── */
#cb-footer {
    text-align: center;
    font-size: 10px;
    color: var(--cb-text-muted);
    padding: 6px 12px;
    border-top: 1px solid var(--cb-border);
    background: #fff;
    flex-shrink: 0;
}

/* ── MOBILE ── */
@media (max-width: 480px) {
    #cb-toggle {
        bottom: 16px;
        right: 16px;
        width: 54px;
        height: 54px;
    }
    #cb-panel {
        bottom: 0;
        right: 0;
        left: 0;
        top: 0;
        width: 100%;
        height: 100%;
        max-width: 100%;
        max-height: 100%;
        border-radius: 0;
    }
    #cb-header { padding-top: 16px; padding-bottom: 16px; }
}
