/* ============================================================================
   Live Chat widget — pure CSS, no external lib. Scoped under #gcw so nothing
   leaks into / out of the host page. Dark theme matches the dashboard.
   ============================================================================ */

#gcw, #gcw * { box-sizing: border-box; font-family: 'Inter',-apple-system,'Segoe UI',sans-serif; }

#gcw-bubble {
    position: fixed; bottom: 22px; right: 22px; z-index: 99998;
    width: 58px; height: 58px; border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    color: #fff; border: none; cursor: pointer;
    box-shadow: 0 8px 24px rgba(99,102,241,0.45);
    display: flex; align-items: center; justify-content: center;
    transition: transform .15s, box-shadow .15s;
}
#gcw-bubble:hover { transform: scale(1.05); box-shadow: 0 10px 30px rgba(99,102,241,0.55); }
#gcw-bubble svg { width: 26px; height: 26px; fill: #fff; }
#gcw-bubble .gcw-unread {
    position: absolute; top: -2px; right: -2px;
    min-width: 20px; height: 20px; border-radius: 10px;
    background: #ef4444; color: #fff; font-size: 11px; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    padding: 0 5px; border: 2px solid #0a0e1a;
}

#gcw-panel {
    position: fixed; bottom: 90px; right: 22px; z-index: 99999;
    width: 360px; max-width: calc(100vw - 32px);
    height: 540px; max-height: calc(100vh - 120px);
    background: #0f1623; color: #e2e8f0;
    border: 1px solid rgba(255,255,255,0.10);
    border-radius: 14px;
    box-shadow: 0 25px 60px rgba(0,0,0,0.55);
    display: none; flex-direction: column; overflow: hidden;
    transform-origin: bottom right;
    animation: gcw-pop .18s ease-out;
}
#gcw-panel.open { display: flex; }
@keyframes gcw-pop { from { opacity: 0; transform: scale(.95) translateY(8px); } to { opacity: 1; transform: scale(1) translateY(0); } }

#gcw-head {
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    color: #fff; padding: 14px 16px;
    display: flex; align-items: center; gap: 10px;
}
#gcw-head .gcw-avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: rgba(255,255,255,0.18);
    display: flex; align-items: center; justify-content: center;
    font-size: 16px; flex-shrink: 0;
}
#gcw-head .gcw-title { flex: 1; min-width: 0; }
#gcw-head .gcw-name { font-size: 14px; font-weight: 600; line-height: 1.2; }
#gcw-head .gcw-status { font-size: 11px; opacity: .85; display: flex; align-items: center; gap: 5px; margin-top: 2px; }
#gcw-head .gcw-dot { width: 7px; height: 7px; border-radius: 50%; background: #10b981; box-shadow: 0 0 0 2px rgba(16,185,129,0.30); }
#gcw-head .gcw-close {
    width: 28px; height: 28px; border: none; border-radius: 6px;
    background: rgba(255,255,255,0.16); color: #fff; cursor: pointer;
    font-size: 20px; line-height: 1;
    display: flex; align-items: center; justify-content: center;
}
#gcw-head .gcw-close:hover { background: rgba(255,255,255,0.28); }

#gcw-body {
    flex: 1; overflow-y: auto;
    padding: 14px; background: #0f1623;
    display: flex; flex-direction: column; gap: 10px;
    scroll-behavior: smooth;
}
#gcw-body::-webkit-scrollbar { width: 6px; }
#gcw-body::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.10); border-radius: 3px; }

.gcw-msg { display: flex; gap: 8px; max-width: 88%; animation: gcw-msgin .2s ease-out; }
@keyframes gcw-msgin { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
.gcw-msg-bubble {
    padding: 8px 12px; border-radius: 12px; font-size: 13px;
    line-height: 1.45; word-break: break-word; white-space: pre-wrap;
}
.gcw-msg-time { font-size: 10.5px; color: #64748b; margin-top: 3px; padding: 0 4px; }

.gcw-msg.user { align-self: flex-end; }
.gcw-msg.user .gcw-msg-bubble { background: #6366f1; color: #fff; border-bottom-right-radius: 4px; }
.gcw-msg.user .gcw-msg-time { text-align: right; }

.gcw-msg.ai, .gcw-msg.admin, .gcw-msg.system { align-self: flex-start; }
.gcw-msg.ai .gcw-msg-bubble    { background: rgba(255,255,255,0.06); color: #e2e8f0; border-bottom-left-radius: 4px; border: 1px solid rgba(255,255,255,0.08); }
.gcw-msg.admin .gcw-msg-bubble { background: #10b981; color: #fff; border-bottom-left-radius: 4px; }
.gcw-msg.system .gcw-msg-bubble{ background: transparent; color: #94a3b8; font-size: 11.5px; font-style: italic; text-align: center; padding: 4px 8px; border: 1px dashed rgba(255,255,255,0.10); border-radius: 8px; }
.gcw-msg.system { align-self: center; max-width: 100%; }
.gcw-msg.system .gcw-msg-time { display: none; }

.gcw-msg-author { font-size: 10.5px; color: #94a3b8; margin-bottom: 3px; font-weight: 600; }

.gcw-typing { display: flex; align-items: center; gap: 6px; padding: 8px 12px; background: rgba(255,255,255,0.06); border-radius: 12px; border-bottom-left-radius: 4px; align-self: flex-start; }
.gcw-typing span { width: 6px; height: 6px; background: #94a3b8; border-radius: 50%; animation: gcw-blink 1.4s infinite both; }
.gcw-typing span:nth-child(2) { animation-delay: .2s; }
.gcw-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes gcw-blink { 0%, 80%, 100% { opacity: .3; } 40% { opacity: 1; } }

#gcw-foot {
    padding: 10px 12px; background: #0a0e1a;
    border-top: 1px solid rgba(255,255,255,0.06);
    display: flex; align-items: flex-end; gap: 8px;
}
#gcw-input {
    flex: 1; padding: 9px 12px;
    border: 1px solid rgba(255,255,255,0.10); border-radius: 8px;
    background: rgba(255,255,255,0.04); color: #f1f5f9;
    font-size: 13px; font-family: inherit; line-height: 1.4;
    resize: none; min-height: 36px; max-height: 120px; outline: none;
}
#gcw-input::placeholder { color: #64748b; }
#gcw-input:focus { border-color: #6366f1; box-shadow: 0 0 0 2px rgba(99,102,241,0.20); background: rgba(255,255,255,0.06); }
#gcw-send {
    width: 36px; height: 36px; border-radius: 8px; border: none;
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    color: #fff; cursor: pointer; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
}
#gcw-send:hover:not(:disabled) { filter: brightness(1.1); }
#gcw-send:disabled { opacity: .4; cursor: not-allowed; }
#gcw-send svg { width: 18px; height: 18px; fill: #fff; }

#gcw-err { padding: 6px 12px; background: rgba(239,68,68,0.10); color: #fca5a5; font-size: 12px; border-top: 1px solid rgba(239,68,68,0.20); display: none; }
#gcw-err.show { display: block; }

@media (max-width: 480px) {
    #gcw-panel { right: 8px; left: 8px; width: auto; bottom: 84px; }
    #gcw-bubble { right: 14px; bottom: 14px; }
}
