/* ═══════════════════════════════════════════════════════
   REDBERRY CLOUD — AI CHATBOT WIDGET
   css/chatbot.css
   Brand: Burgundy #800020 | Font: Nunito
   ═══════════════════════════════════════════════════════ */

/* ── TOGGLE BUTTON ────────────────────────────────────── */
.rb-chat-toggle {
    position: fixed;
    bottom: 100px;
    right: 30px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #800020;
    color: #fff;
    border: none;
    cursor: pointer;
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(128, 0, 32, 0.45);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    font-size: 26px;
    line-height: 1;
    padding: 0;
    font-family: 'Nunito', sans-serif;
    overflow: hidden;
}

/* Icon span fills the full button */
.rb-chat-toggle .rb-chat-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    line-height: 1;
}

/* Image fills the circle perfectly */
.rb-chat-toggle .rb-chat-icon img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    display: block;
    border-radius: 50%;
}

.rb-chat-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 28px rgba(128, 0, 32, 0.55);
    animation: rb-pulse 1.5s infinite;
}

.rb-chat-toggle:focus {
    outline: 3px solid rgba(128, 0, 32, 0.4);
    outline-offset: 3px;
}

/* Badge */
.rb-chat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 20px;
    height: 20px;
    background: #e53e3e;
    color: #fff;
    border-radius: 50%;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Nunito', sans-serif;
    border: 2px solid #fff;
}

/* ── CHAT WINDOW ──────────────────────────────────────── */
.rb-chat-window {
    position: fixed;
    bottom: 170px;
    right: 30px;
    width: 380px;
    height: 550px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.18);
    z-index: 10001;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: 'Nunito', sans-serif;
    animation: rb-fadeIn 0.25s ease;
}

/* ── HEADER ───────────────────────────────────────────── */
.rb-chat-header {
    background: linear-gradient(135deg, #800020, #a00028);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.rb-chat-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.rb-chat-avatar {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.rb-chat-name {
    color: #fff;
    font-weight: 700;
    font-size: 15px;
    line-height: 1.2;
}

.rb-chat-status {
    display: flex;
    align-items: center;
    gap: 5px;
    color: rgba(255, 255, 255, 0.85);
    font-size: 12px;
}

.rb-status-dot {
    width: 7px;
    height: 7px;
    background: #4ade80;
    border-radius: 50%;
    animation: rb-blink 2s infinite;
}

.rb-chat-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: #fff;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
    font-family: 'Nunito', sans-serif;
}

.rb-chat-close:hover {
    background: rgba(255, 255, 255, 0.35);
}

/* ── MESSAGES AREA ────────────────────────────────────── */
.rb-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

.rb-chat-messages::-webkit-scrollbar {
    width: 4px;
}

.rb-chat-messages::-webkit-scrollbar-track {
    background: #f5f5f5;
}

.rb-chat-messages::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 2px;
}

/* ── MESSAGE BUBBLES ──────────────────────────────────── */
.rb-msg-wrap {
    display: flex;
    flex-direction: column;
    max-width: 82%;
}

.rb-msg-wrap.rb-msg-user {
    align-self: flex-end;
    align-items: flex-end;
}

.rb-msg-wrap.rb-msg-bot {
    align-self: flex-start;
    align-items: flex-start;
}

.rb-msg-bubble {
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.55;
    word-break: break-word;
}

.rb-msg-user .rb-msg-bubble {
    background: #f0f0f0;
    color: #333;
    border-radius: 16px 16px 4px 16px;
}

.rb-msg-bot .rb-msg-bubble {
    background: #fff;
    color: #333;
    border: 1px solid #e0e0e0;
    border-radius: 16px 16px 16px 4px;
}

.rb-msg-time {
    font-size: 10px;
    color: #aaa;
    margin-top: 3px;
    padding: 0 4px;
}

/* Lead capture inline input inside bot message */
.rb-lead-input-wrap {
    margin-top: 10px;
    display: flex;
    gap: 8px;
}

.rb-lead-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #800020;
    border-radius: 20px;
    font-size: 13px;
    font-family: 'Nunito', sans-serif;
    outline: none;
    color: #333;
}

.rb-lead-input:focus {
    border-color: #a00028;
    box-shadow: 0 0 0 2px rgba(128, 0, 32, 0.15);
}

.rb-lead-submit {
    padding: 8px 14px;
    background: #800020;
    color: #fff;
    border: none;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    font-family: 'Nunito', sans-serif;
    transition: background 0.2s;
    white-space: nowrap;
}

.rb-lead-submit:hover {
    background: #a00028;
}

/* ── TYPING INDICATOR ─────────────────────────────────── */
.rb-typing-indicator {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 8px 14px;
    flex-shrink: 0;
}

.rb-typing-dot {
    width: 7px;
    height: 7px;
    background: #800020;
    border-radius: 50%;
    animation: rb-bounce 1.2s infinite;
}

.rb-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.rb-typing-dot:nth-child(3) { animation-delay: 0.4s; }

.rb-typing-text {
    font-size: 11px;
    color: #aaa;
    font-family: 'Nunito', sans-serif;
    margin-left: 4px;
}

/* ── QUICK REPLIES ────────────────────────────────────── */
.rb-quick-replies {
    padding: 8px 14px;
    display: flex;
    gap: 7px;
    flex-wrap: wrap;
    border-top: 1px solid #f0f0f0;
    flex-shrink: 0;
}

.rb-quick-btn {
    padding: 7px 12px;
    border: 1.5px solid #800020;
    border-radius: 20px;
    background: #fff;
    color: #800020;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    font-family: 'Nunito', sans-serif;
    transition: background 0.2s, color 0.2s;
    white-space: nowrap;
}

.rb-quick-btn:hover {
    background: #800020;
    color: #fff;
}

/* ── INPUT AREA ───────────────────────────────────────── */
.rb-chat-input-area {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid #f0f0f0;
    flex-shrink: 0;
    background: #fff;
}

.rb-chat-input {
    flex: 1;
    padding: 10px 14px;
    border: 1.5px solid #e0e0e0;
    border-radius: 24px;
    font-size: 14px;
    font-family: 'Nunito', sans-serif;
    outline: none;
    color: #333;
    transition: border-color 0.2s;
    background: #fafafa;
}

.rb-chat-input:focus {
    border-color: #800020;
    background: #fff;
    box-shadow: 0 0 0 2px rgba(128, 0, 32, 0.1);
}

.rb-chat-input::placeholder {
    color: #bbb;
}

.rb-chat-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #800020;
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s, transform 0.15s;
}

.rb-chat-send:hover {
    background: #a00028;
    transform: scale(1.05);
}

.rb-chat-send:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

/* ── FOOTER ───────────────────────────────────────────── */
.rb-chat-footer {
    text-align: center;
    padding: 5px 0 7px;
    border-top: 1px solid #f5f5f5;
    flex-shrink: 0;
    background: #fff;
}

/* ── GREETING BUBBLE ──────────────────────────────────── */
.rb-greeting-bubble {
    position: fixed;
    bottom: 170px;
    right: 30px;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 12px 12px 4px 12px;
    padding: 12px 16px;
    font-size: 13px;
    color: #333;
    font-family: 'Nunito', sans-serif;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    z-index: 9997;
    max-width: 220px;
    animation: rb-fadeIn 0.4s ease;
    cursor: pointer;
    line-height: 1.5;
}

.rb-greeting-bubble::after {
    content: '';
    position: absolute;
    bottom: -8px;
    right: 16px;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 0px solid transparent;
    border-top: 8px solid #fff;
    filter: drop-shadow(0 1px 1px rgba(0,0,0,0.1));
}

.rb-greeting-bubble-close {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 20px;
    height: 20px;
    background: #800020;
    color: #fff;
    border: none;
    border-radius: 50%;
    font-size: 11px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Nunito', sans-serif;
    line-height: 1;
}

/* ── ANIMATIONS ───────────────────────────────────────── */
@keyframes rb-pulse {
    0%, 100% { box-shadow: 0 4px 20px rgba(128, 0, 32, 0.45); }
    50%       { box-shadow: 0 4px 32px rgba(128, 0, 32, 0.7); }
}

@keyframes rb-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30%           { transform: translateY(-6px); }
}

@keyframes rb-fadeIn {
    from { opacity: 0; transform: translateY(10px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes rb-blink {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.3; }
}

@keyframes rb-slideUp {
    from { transform: translateY(100%); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}

/* ── MOBILE (<600px) ──────────────────────────────────── */
@media (max-width: 600px) {
    .rb-chat-toggle {
        bottom: 88px;
        right: 16px;
        width: 52px;
        height: 52px;
        font-size: 22px;
    }

    .rb-chat-window {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        border-radius: 0;
        animation: rb-slideUp 0.3s ease;
    }

    .rb-greeting-bubble {
        bottom: 152px;
        right: 12px;
        max-width: 200px;
    }

    .rb-quick-replies {
        overflow-x: auto;
        flex-wrap: nowrap;
        padding-bottom: 10px;
    }

    .rb-quick-btn {
        flex-shrink: 0;
    }
}
