/* ShaarpMind AI Chatbot — Professional UI */
:root { --sm-p: #6366f1; --sm-pd: #4f46e5; }

#sm-chatbot {
    position: fixed; z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
.sm-pos-bottom-right { bottom: 24px; right: 24px; }
.sm-pos-bottom-left  { bottom: 24px; left:  24px; }

/* ── Launcher button ───────────────────────────── */
#sm-toggle {
    width: 60px; height: 60px; border-radius: 50%;
    background: var(--sm-p); border: none; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    color: #fff;
    box-shadow: 0 4px 24px rgba(99,102,241,.5);
    transition: transform .25s cubic-bezier(.34,1.56,.64,1), box-shadow .25s;
}
#sm-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 30px rgba(99,102,241,.65);
}

/* ── Chat window ───────────────────────────────── */
#sm-window {
    position: absolute; bottom: 74px;
    width: 380px; max-height: 600px;
    background: #fff; border-radius: 20px;
    box-shadow: 0 12px 48px rgba(0,0,0,.18), 0 2px 8px rgba(0,0,0,.08);
    display: flex; flex-direction: column; overflow: hidden;
    animation: sm-pop .3s cubic-bezier(.34,1.56,.64,1);
}
.sm-pos-bottom-right #sm-window { right: 0; }
.sm-pos-bottom-left  #sm-window { left:  0; }
@keyframes sm-pop {
    from { opacity: 0; transform: scale(.92) translateY(20px); }
    to   { opacity: 1; transform: scale(1)   translateY(0); }
}
@media (max-width: 440px) {
    #sm-window { width: calc(100vw - 20px); border-radius: 16px; }
}

/* ── Header ────────────────────────────────────── */
#sm-header {
    background: linear-gradient(135deg, var(--sm-p) 0%, #8b5cf6 100%);
    padding: 14px 16px;
    display: flex; align-items: center; justify-content: space-between;
    flex-shrink: 0;
}
#sm-header-info { display: flex; align-items: center; gap: 10px; }
#sm-avatar {
    width: 38px; height: 38px; border-radius: 50%;
    background: rgba(255,255,255,.22);
    display: flex; align-items: center; justify-content: center;
    color: #fff;
}
#sm-bot-name { font-weight: 700; font-size: 14px; color: #fff; line-height: 1.2; }
#sm-online-dot { font-size: 11px; color: rgba(255,255,255,.85); display: flex; align-items: center; gap: 5px; margin-top: 2px; }
.sm-dot-pulse {
    display: inline-block; width: 7px; height: 7px; border-radius: 50%;
    background: #4ade80;
    box-shadow: 0 0 0 0 rgba(74,222,128,.6);
    animation: sm-dot-anim 2s infinite;
}
@keyframes sm-dot-anim {
    0%   { box-shadow: 0 0 0 0 rgba(74,222,128,.6); }
    70%  { box-shadow: 0 0 0 6px rgba(74,222,128,0); }
    100% { box-shadow: 0 0 0 0 rgba(74,222,128,0); }
}
#sm-header-actions { display: flex; align-items: center; gap: 4px; }
#sm-voice-toggle, #sm-close-btn {
    background: rgba(255,255,255,.15); border: none; color: #fff;
    width: 32px; height: 32px; border-radius: 8px;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: background .18s;
}
#sm-voice-toggle:hover, #sm-close-btn:hover { background: rgba(255,255,255,.28); }
#sm-voice-toggle.sm-muted { background: rgba(255,255,255,.08); opacity: .6; }

/* ── Messages ──────────────────────────────────── */
#sm-messages {
    flex: 1; overflow-y: auto;
    padding: 16px; display: flex; flex-direction: column; gap: 12px;
    scroll-behavior: smooth; background: #f8fafc;
}
#sm-messages::-webkit-scrollbar { width: 4px; }
#sm-messages::-webkit-scrollbar-thumb { background: #dde1e7; border-radius: 4px; }

.sm-msg { display: flex; flex-direction: column; max-width: 82%; }
.sm-msg-bot  { align-self: flex-start; }
.sm-msg-user { align-self: flex-end; }
.sm-msg { animation: sm-msg-in .22s ease; }
@keyframes sm-msg-in { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:none; } }

.sm-bubble {
    padding: 11px 15px; font-size: 14px; line-height: 1.6;
    word-break: break-word; border-radius: 18px;
}
.sm-msg-bot  .sm-bubble {
    background: #fff; color: #1e293b;
    border-bottom-left-radius: 5px;
    box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
.sm-msg-user .sm-bubble {
    background: linear-gradient(135deg, var(--sm-p), #8b5cf6);
    color: #fff; border-bottom-right-radius: 5px;
    box-shadow: 0 2px 8px rgba(99,102,241,.35);
}
.sm-time { font-size: 10px; color: #9ca3af; margin-top: 4px; padding: 0 4px; }
.sm-msg-user .sm-time { text-align: right; }

/* ── Menu buttons ──────────────────────────────── */
.sm-menu-btns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.sm-menu-btn {
    padding: 7px 16px;
    border: 1.5px solid var(--sm-p); color: var(--sm-p);
    background: #fff; border-radius: 20px;
    font-size: 13px; font-weight: 600; cursor: pointer;
    transition: all .2s; box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.sm-menu-btn:hover {
    background: var(--sm-p); color: #fff;
    transform: translateY(-1px); box-shadow: 0 4px 12px rgba(99,102,241,.3);
}

/* ── Typing dots ───────────────────────────────── */
.sm-typing .sm-bubble {
    display: flex; gap: 5px; align-items: center; padding: 14px 18px;
    background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
.sm-dot {
    width: 8px; height: 8px; border-radius: 50%; background: #94a3b8;
    animation: sm-bounce .9s ease-in-out infinite;
}
.sm-dot:nth-child(2) { animation-delay: .18s; }
.sm-dot:nth-child(3) { animation-delay: .36s; }
@keyframes sm-bounce { 0%,60%,100%{transform:translateY(0)} 30%{transform:translateY(-7px)} }

/* ── Listening bar (shown when mic is active) ───── */
#sm-listening-bar {
    display: flex; align-items: center; justify-content: center; gap: 12px;
    padding: 10px 16px; background: #fff0f0;
    border-top: 1px solid #fecaca; flex-shrink: 0;
    animation: sm-fadein .2s ease;
}
@keyframes sm-fadein { from{opacity:0} to{opacity:1} }
#sm-listen-text { font-size: 13px; font-weight: 600; color: #ef4444; flex: 1; }
#sm-stop-listen {
    background: #ef4444; color: #fff; border: none;
    padding: 5px 12px; border-radius: 20px; font-size: 12px;
    font-weight: 600; cursor: pointer; transition: background .18s;
}
#sm-stop-listen:hover { background: #dc2626; }

/* Sound wave animation inside listening bar */
.sm-wave { display: flex; align-items: center; gap: 3px; height: 24px; }
.sm-wave span {
    display: inline-block; width: 3px; border-radius: 3px;
    background: #ef4444; min-height: 4px;
    animation: sm-wave-anim 0.8s ease-in-out infinite;
}
.sm-wave span:nth-child(1) { animation-delay: 0s;    }
.sm-wave span:nth-child(2) { animation-delay: 0.1s;  }
.sm-wave span:nth-child(3) { animation-delay: 0.2s;  }
.sm-wave span:nth-child(4) { animation-delay: 0.3s;  }
.sm-wave span:nth-child(5) { animation-delay: 0.4s;  }
@keyframes sm-wave-anim {
    0%,100% { height: 5px;  }
    50%      { height: 22px; }
}

/* ── Input area ────────────────────────────────── */
#sm-input-area {
    display: flex; align-items: flex-end; gap: 8px;
    padding: 12px 14px; border-top: 1px solid #e8ecf0;
    background: #fff; flex-shrink: 0;
}

/* Mic button — properly styled SVG button */
#sm-mic {
    width: 40px; height: 40px; border-radius: 50%;
    background: #f1f5f9; border: 1.5px solid #e2e8f0;
    cursor: pointer; color: #64748b; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    transition: all .2s; outline: none;
}
#sm-mic:hover {
    background: #ede9fe; border-color: var(--sm-p); color: var(--sm-p);
    transform: scale(1.05);
}
#sm-mic.sm-listening {
    background: #ef4444; border-color: #ef4444; color: #fff;
    box-shadow: 0 0 0 0 rgba(239,68,68,.5);
    animation: sm-mic-pulse 1.2s infinite;
}
#sm-mic.sm-no-support { opacity: .3; cursor: not-allowed; }
@keyframes sm-mic-pulse {
    0%   { box-shadow: 0 0 0 0   rgba(239,68,68,.5); }
    70%  { box-shadow: 0 0 0 10px rgba(239,68,68,0); }
    100% { box-shadow: 0 0 0 0   rgba(239,68,68,0); }
}

/* Textarea */
#sm-input {
    flex: 1; padding: 10px 14px; font-size: 14px;
    border: 1.5px solid #e2e8f0; border-radius: 22px;
    resize: none; max-height: 100px; outline: none;
    font-family: inherit; transition: border .2s, box-shadow .2s;
    line-height: 1.45; background: #f8fafc; color: #1e293b;
}
#sm-input:focus {
    border-color: var(--sm-p); background: #fff;
    box-shadow: 0 0 0 3px rgba(99,102,241,.12);
}
#sm-input::placeholder { color: #9ca3af; }

/* Send button */
#sm-send {
    width: 40px; height: 40px; border-radius: 50%;
    background: var(--sm-p); border: none; cursor: pointer;
    color: #fff; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    transition: background .18s, transform .15s;
    box-shadow: 0 2px 8px rgba(99,102,241,.4);
}
#sm-send:hover  { background: var(--sm-pd); transform: scale(1.07); }
#sm-send:disabled { background: #cbd5e1; cursor: default; transform: none; box-shadow: none; }

/* ── Footer ────────────────────────────────────── */
#sm-footer {
    text-align: center; font-size: 10px; color: #b0b8c4;
    padding: 6px; background: #fff; border-top: 1px solid #f1f3f5;
    flex-shrink: 0;
}
#sm-footer strong { color: var(--sm-p); }

/* ── Speaking indicator on bot messages ────────── */
.sm-speak-btn {
    background: none; border: none; cursor: pointer;
    font-size: 12px; margin-left: 6px; opacity: .45;
    transition: opacity .2s; vertical-align: middle; padding: 0; color: #6366f1;
}
.sm-speak-btn:hover   { opacity: 1; }
.sm-speak-btn.sm-talking { opacity: 1; color: #ef4444; }
