/* ═══════════════════════════════════════════════════════════
   SmartBot – Chatbot Styles  |  Softnetic Studio
   ═══════════════════════════════════════════════════════════ */

/* ── Google Font import ─────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap');

/* ── Variables ──────────────────────────────────────────────── */
#smartbot-wrapper {
    --sb-primary:     #6c63ff;
    --sb-primary-d:   #5a52e0;
    --sb-accent:      #00d4aa;
    --sb-dark:        #0d0d1a;
    --sb-panel:       #16162a;
    --sb-panel-l:     #1e1e35;
    --sb-border:      rgba(255,255,255,.08);
    --sb-text:        #e8e8f0;
    --sb-text-muted:  #8888aa;
    --sb-bot-bubble:  #1e1e35;
    --sb-user-bubble: #6c63ff;
    --sb-radius:      16px;
    --sb-font:        'Plus Jakarta Sans', system-ui, sans-serif;
    --sb-shadow:      0 24px 64px rgba(0,0,0,.55);
    --sb-z:           99999;

    position: fixed;
    bottom: 40px;
    right: 24px;
    z-index: var(--sb-z);
    font-family: var(--sb-font);
}

/* ── Toggle Button ──────────────────────────────────────────── */
#smartbot-toggle {
    position: relative;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    background: linear-gradient(135deg, var(--sb-primary), #9b59b6);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 28px rgba(108,99,255,.55);
    transition: transform .25s cubic-bezier(.34,1.56,.64,1), box-shadow .25s;
    outline: none;
}
#smartbot-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 12px 36px rgba(108,99,255,.7);
}
#smartbot-toggle svg { width: 26px; height: 26px; }

/* Pulse ring */
#smartbot-toggle::before {
    content: '';
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    border: 2px solid rgba(108,99,255,.4);
    animation: sb-pulse 2s ease-out infinite;
}
@keyframes sb-pulse {
    0%   { transform: scale(1); opacity: .7; }
    100% { transform: scale(1.5); opacity: 0; }
}

/* Unread dot */
.sb-unread-dot {
    position: absolute;
    top: 4px; right: 4px;
    width: 12px; height: 12px;
    border-radius: 50%;
    background: #ff4757;
    border: 2px solid #fff;
    display: none;
}
.sb-unread-dot.visible { display: block; }

/* ── Chat Window ────────────────────────────────────────────── */
#smartbot-window {
    position: absolute;
    bottom: 76px;
    right: 0;
    width: 360px;
    height: 450px;
    max-height: 450px;
    background: var(--sb-dark);
    border-radius: var(--sb-radius);
    border: 1px solid var(--sb-border);
    box-shadow: var(--sb-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;

    opacity: 0;
    transform: translateY(12px) scale(.96);
    pointer-events: none;
    transition: opacity .28s ease, transform .28s cubic-bezier(.34,1.2,.64,1);
}
#smartbot-window.sb-open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* ── Header ─────────────────────────────────────────────────── */
.sb-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: linear-gradient(135deg, #1a1a2e, #16213e);
    border-bottom: 1px solid var(--sb-border);
    flex-shrink: 0;
}
.sb-avatar {
    width: 38px; height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--sb-primary), var(--sb-accent));
    display: flex; align-items: center; justify-content: center;
    color: #fff; flex-shrink: 0;
}
.sb-avatar svg { width: 20px; height: 20px; }
.sb-header-info { flex: 1; }
.sb-bot-name { display: block; color: #fff; font-weight: 700; font-size: 14px; line-height: 1.2; }
.sb-status { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--sb-text-muted); margin-top: 2px; }
.sb-dot {
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--sb-accent);
    box-shadow: 0 0 6px var(--sb-accent);
    animation: sb-blink 2s ease-in-out infinite;
}
@keyframes sb-blink { 0%,100%{opacity:1} 50%{opacity:.4} }
.sb-close-btn {
    background: none; border: none; color: var(--sb-text-muted);
    cursor: pointer; padding: 4px; border-radius: 4px; display: flex;
    transition: color .2s;
}
.sb-close-btn:hover { color: #fff; }

/* ── Messages area ──────────────────────────────────────────── */
.sb-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
    min-height: 0;
}
.sb-messages::-webkit-scrollbar { width: 4px; }
.sb-messages::-webkit-scrollbar-thumb { background: var(--sb-border); border-radius: 4px; }

/* ── Message bubbles ─────────────────────────────────────────── */
.sb-msg {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    animation: sb-fadein .25s ease;
}
@keyframes sb-fadein { from { opacity:0; transform:translateY(6px); } }

.sb-msg.bot  { align-self: flex-start; }
.sb-msg.user { flex-direction: row-reverse; }

.sb-bubble {
    max-width: 82%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 13.5px;
    line-height: 1.55;
    word-break: break-word;
   margin-bottom: 25px;

}
.sb-msg.bot .sb-bubble {
    background: var(--sb-bot-bubble);
    color: var(--sb-text);
    border-bottom-left-radius: 4px;
    border: 1px solid var(--sb-border);
}
.sb-msg.user .sb-bubble {
    background: var(--sb-user-bubble);
    color: #fff;
    border-bottom-right-radius: 4px;
}
/* Markdown-like bold */
.sb-bubble strong { color: #fff; font-weight: 700; }
.sb-msg.bot .sb-bubble strong { color: var(--sb-accent); }

.sb-msg-avatar {
    width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0;
    background: linear-gradient(135deg, var(--sb-primary), var(--sb-accent));
    display: flex; align-items: center; justify-content: center;
    font-size: 12px;
}

/* Typing indicator */
.sb-typing {
    display: flex; align-items: center; gap: 4px;
    padding: 10px 14px;
    background: var(--sb-bot-bubble);
    border: 1px solid var(--sb-border);
    border-radius: 14px; border-bottom-left-radius: 4px;
    width: fit-content;
}
.sb-typing span {
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--sb-text-muted);
    animation: sb-bounce .9s ease-in-out infinite;
}
.sb-typing span:nth-child(2) { animation-delay: .15s; }
.sb-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes sb-bounce { 0%,80%,100%{transform:translateY(0)} 40%{transform:translateY(-6px)} }

/* ── Lead form ──────────────────────────────────────────────── */
.sb-lead-form {
    background: var(--sb-panel);
    border-top: 1px solid var(--sb-border);
    padding: 16px;
    flex-shrink: 0;
    animation: sb-fadein .25s ease;
    margin-bottom: 25px;
}
.sb-form-header { margin-bottom: 12px; }
.sb-form-header strong { color: #fff; font-size: 14px; display: block; }
.sb-form-header p { color: var(--sb-text-muted); font-size: 12px; margin: 4px 0 0; }

.sb-lead-form input,
.sb-lead-form textarea {
    width: 100%;
    background: var(--sb-panel-l);
    border: 1px solid var(--sb-border);
    border-radius: 8px;
    color: var(--sb-text);
    font-family: var(--sb-font);
    font-size: 13px;
    padding: 9px 12px;
    margin-bottom: 8px;
    outline: none;
    transition: border-color .2s;
    box-sizing: border-box;
    resize: none;
}
.sb-lead-form input::placeholder,
.sb-lead-form textarea::placeholder { color: var(--sb-text-muted); }
.sb-lead-form input:focus,
.sb-lead-form textarea:focus { border-color: var(--sb-primary); }

.sb-form-errors { color: #ff6b6b; font-size: 12px; margin-bottom: 8px; }
.sb-form-actions { display: flex; gap: 8px; }
.sb-btn-primary {
    flex: 1; padding: 9px;
    background: linear-gradient(135deg, var(--sb-primary), #9b59b6);
    color: #fff; border: none; border-radius: 8px; cursor: pointer;
    font-family: var(--sb-font); font-weight: 600; font-size: 13px;
    transition: opacity .2s, transform .15s;
}
.sb-btn-primary:hover { opacity: .9; transform: translateY(-1px); }
.sb-btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.sb-btn-secondary {
    padding: 9px 14px;
    background: transparent; color: var(--sb-text-muted);
    border: 1px solid var(--sb-border); border-radius: 8px; cursor: pointer;
    font-family: var(--sb-font); font-size: 13px;
    transition: color .2s, border-color .2s;
}
.sb-btn-secondary:hover { color: #fff; border-color: rgba(255,255,255,.2); }

/* ── Input area ─────────────────────────────────────────────── */
.sb-input-area {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    border-top: 1px solid var(--sb-border);
    background: var(--sb-panel);
    flex-shrink: 0;
}
#sb-input {
    flex: 1;
    background: var(--sb-panel-l);
    border: 1px solid var(--sb-border);
    border-radius: 22px;
    color: var(--sb-text);
    font-family: var(--sb-font);
    font-size: 13.5px;
    padding: 9px 16px;
    outline: none;
    transition: border-color .2s;
}
#sb-input::placeholder { color: var(--sb-text-muted); }
#sb-input:focus { border-color: var(--sb-primary); }

#sb-send {
    width: 38px; height: 38px; border-radius: 50%;
    background: linear-gradient(135deg, var(--sb-primary), #9b59b6);
    border: none; cursor: pointer; color: #fff;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    transition: transform .2s, box-shadow .2s;
}
#sb-send:hover { transform: scale(1.1); box-shadow: 0 4px 16px rgba(108,99,255,.5); }

/* ── Footer brand ────────────────────────────────────────────── */
.sb-footer-brand {
    text-align: center;
    font-size: 10.5px;
    color: var(--sb-text-muted);
    padding: 6px;
    background: var(--sb-dark);
    border-top: 1px solid var(--sb-border);
    flex-shrink: 0;
}
.sb-footer-brand strong { color: var(--sb-primary); }

/* ── Mobile responsive ──────────────────────────────────────── */
@media (max-width: 480px) {
    #smartbot-wrapper {
        bottom: 16px;
        right: 16px;
    }

    #smartbot-window {
        width: calc(100vw - 70px);
        right: 0;
        bottom: 72px;
        max-height: 75vh;
    }
}
