/* ============================================================
   Smile Now Dentistry – Chat Widget
   ============================================================ */

#snd-chat-bubble {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: #1a73e8;
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0,0,0,0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99998;
    transition: transform 0.2s, background 0.2s;
}
#snd-chat-bubble:hover { background: #1557b0; transform: scale(1.07); }
#snd-chat-bubble svg   { width: 26px; height: 26px; }

/* Green pulse ring when a live agent is available */
#snd-chat-bubble.snd-agent-live {
    background: #2e7d32;
    box-shadow: 0 4px 16px rgba(0,0,0,0.25), 0 0 0 0 rgba(46,125,50,0.7);
    animation: snd-agent-pulse 2s infinite;
}
#snd-chat-bubble.snd-agent-live:hover { background: #1b5e20; }
@keyframes snd-agent-pulse {
    0%   { box-shadow: 0 4px 16px rgba(0,0,0,0.25), 0 0 0 0   rgba(46,125,50,0.7); }
    60%  { box-shadow: 0 4px 16px rgba(0,0,0,0.25), 0 0 0 14px rgba(46,125,50,0);   }
    100% { box-shadow: 0 4px 16px rgba(0,0,0,0.25), 0 0 0 0   rgba(46,125,50,0);   }
}

.snd-unread-badge {
    position: absolute;
    top: -3px;
    right: -3px;
    background: #e53935;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    border-radius: 10px;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    display: none;
    align-items: center;
    justify-content: center;
}

#snd-chat-window {
    position: fixed;
    bottom: 94px;
    right: 24px;
    width: 360px;
    max-width: calc(100vw - 32px);
    height: 520px;
    max-height: calc(100vh - 120px);
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 8px 40px rgba(0,0,0,0.22);
    display: flex;
    flex-direction: column;
    z-index: 99999;
    overflow: hidden;
    transform: scale(0.92) translateY(20px);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.22s ease, opacity 0.22s ease;
}
#snd-chat-window.snd-open {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: all;
}

.snd-header {
    background: #1a73e8;
    color: #fff;
    padding: 14px 16px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}
.snd-header-avatar {
    width: 38px; height: 38px;
    border-radius: 50%;
    background: rgba(255,255,255,0.25);
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; flex-shrink: 0;
}
.snd-header-info { flex: 1; }
.snd-header-name   { font-weight: 700; font-size: 15px; line-height: 1.2; }
.snd-header-status { font-size: 12px; opacity: 0.85; }
.snd-header-close {
    background: none; border: none; color: #fff;
    cursor: pointer; font-size: 22px; opacity: 0.8; padding: 0 2px; line-height: 1;
}
.snd-header-close:hover { opacity: 1; }

#snd-prechat {
    padding: 20px 18px; flex: 1;
    display: flex; flex-direction: column; gap: 12px; overflow-y: auto;
}
#snd-prechat p { color: #444; font-size: 14px; margin: 0; line-height: 1.5; }

.snd-input {
    width: 100%; padding: 10px 12px;
    border: 1.5px solid #ddd; border-radius: 8px;
    font-size: 14px; outline: none;
    transition: border-color 0.15s; box-sizing: border-box; font-family: inherit;
}
.snd-input:focus { border-color: #1a73e8; }

.snd-btn-start {
    background: #1a73e8; color: #fff; border: none;
    border-radius: 8px; padding: 11px; font-size: 15px;
    font-weight: 600; cursor: pointer; transition: background 0.15s;
}
.snd-btn-start:hover { background: #1557b0; }

#snd-messages {
    flex: 1; overflow-y: auto;
    padding: 14px 14px 6px;
    display: flex; flex-direction: column; gap: 8px;
}
#snd-messages::-webkit-scrollbar { width: 4px; }
#snd-messages::-webkit-scrollbar-thumb { background: #ddd; border-radius: 4px; }

.snd-msg-wrap { display: flex; flex-direction: column; }
.snd-msg-wrap.right { align-items: flex-end; }
.snd-msg-label { font-size: 11px; color: #aaa; margin-bottom: 2px; padding: 0 4px; }

.snd-msg {
    max-width: 82%; padding: 9px 13px;
    border-radius: 16px; font-size: 14px; line-height: 1.5;
    word-break: break-word;
    animation: snd-fadein 0.2s ease;
}
@keyframes snd-fadein { from { opacity:0; transform:translateY(6px); } to { opacity:1; transform:none; } }

.snd-msg-visitor {
    background: #1a73e8; color: #fff;
    border-bottom-right-radius: 4px;
}
.snd-msg-ai {
    background: #f1f3f4; color: #1a1a1a;
    border-bottom-left-radius: 4px;
}
.snd-msg-agent {
    background: #e8f5e9; color: #1a1a1a;
    border-bottom-left-radius: 4px;
}

.snd-typing {
    display: flex; gap: 4px; padding: 10px 14px;
    background: #f1f3f4; border-radius: 16px; border-bottom-left-radius: 4px;
    align-self: flex-start; align-items: center;
}
.snd-typing span {
    width: 7px; height: 7px; border-radius: 50%;
    background: #999; display: inline-block;
    animation: snd-bounce 1.2s infinite;
}
.snd-typing span:nth-child(2) { animation-delay: 0.15s; }
.snd-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes snd-bounce { 0%,60%,100%{transform:translateY(0)} 30%{transform:translateY(-6px)} }

.snd-mode-banner {
    text-align: center; font-size: 11px; color: #888;
    padding: 5px 0; border-top: 1px solid #eee; border-bottom: 1px solid #eee;
    background: #fafafa; flex-shrink: 0;
}

.snd-input-bar {
    display: flex; gap: 8px; padding: 10px 12px;
    border-top: 1px solid #eee; flex-shrink: 0; background: #fff;
    align-items: flex-end;
}
#snd-input {
    flex: 1; padding: 9px 12px;
    border: 1.5px solid #ddd; border-radius: 22px;
    font-size: 14px; outline: none; resize: none;
    font-family: inherit; max-height: 90px;
    transition: border-color 0.15s; line-height: 1.4;
}
#snd-input:focus { border-color: #1a73e8; }

#snd-send-btn {
    width: 38px; height: 38px; border-radius: 50%;
    background: #1a73e8; color: #fff; border: none;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; transition: background 0.15s;
}
#snd-send-btn:hover    { background: #1557b0; }
#snd-send-btn:disabled { background: #ccc; cursor: default; }
#snd-send-btn svg { width: 18px; height: 18px; }

.snd-closed-notice {
    background: #fff8e1; border-top: 1px solid #ffe082;
    padding: 7px 14px; font-size: 12px; color: #795548;
    text-align: center; flex-shrink: 0;
}

@media (max-width: 420px) {
    #snd-chat-window  { right: 8px; bottom: 84px; width: calc(100vw - 16px); }
    #snd-chat-bubble  { right: 16px; bottom: 16px; }
}

#snd-disclaimer-bar {
    flex-shrink: 0;
    border-top: 1px solid #eee;
    background: #fafafa;
    padding: 7px 14px;
    max-height: 80px;
    overflow-y: auto;
}
#snd-disclaimer-bar .snd-disclaimer {
    margin: 0;
    font-size: 10px;
    line-height: 1.5;
    color: #aaa;
    font-style: italic;
}

/* ── Visitor Greeting Bubble ──────────────────────────────── */
#snd-greeting {
    position: fixed;
    bottom: 96px;    /* sits above the chat bubble */
    right: 24px;
    max-width: 280px;
    min-width: 200px;
    background: #fff;
    border-radius: 16px 16px 4px 16px;
    box-shadow: 0 6px 24px rgba(0,0,0,0.18);
    padding: 14px 40px 14px 16px;
    z-index: 99997;
    cursor: default;
    /* start invisible/shifted for animation */
    opacity: 0;
    transform: translateY(12px) scale(0.95);
    transition: opacity .28s ease, transform .28s ease;
    pointer-events: none;
}
#snd-greeting.snd-greeting-visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}
/* speech-bubble tail pointing toward the chat button */
#snd-greeting::after {
    content: '';
    position: absolute;
    bottom: -8px;
    right: 20px;
    border-left: 8px solid transparent;
    border-right: 0 solid transparent;
    border-top: 8px solid #fff;
    filter: drop-shadow(0 3px 3px rgba(0,0,0,0.08));
}
#snd-greeting-msg {
    margin: 0;
    font-size: 14px;
    line-height: 1.5;
    color: #222;
    cursor: pointer;
}
#snd-greeting-msg:hover { color: #1a73e8; }
#snd-greeting-close {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    color: #999;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: color .15s, background .15s;
}
#snd-greeting-close:hover { color: #333; background: #f0f0f0; }

@media (max-width: 420px) {
    #snd-greeting { right: 16px; max-width: calc(100vw - 40px); }
}
