/* ── Chatbot Widget ── */
.cw-root {
    position: fixed;
    z-index: 2147483000;
    bottom: 20px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.4;
    -webkit-font-smoothing: antialiased;
}
.cw-right { right: 20px; }
.cw-left  { left: 20px; }

.cw-trigger {
    all: unset;
    cursor: pointer;
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background: var(--cw-primary, #6366f1);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 14px rgba(0,0,0,0.2);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.cw-trigger:hover { transform: scale(1.08); box-shadow: 0 6px 20px rgba(0,0,0,0.25); }
.cw-trigger:active { transform: scale(0.96); }
.cw-trigger svg { width: 26px; height: 26px; }

.cw-backdrop { position: fixed; inset: 0; z-index: -1; }

.cw-panel {
    /*position: absolute;*/
    bottom: 64px;
    width: 380px;
    height: 580px;
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 12px 48px rgba(0,0,0,0.18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom right;
    transform: scale(0.7) translateY(24px);
    opacity: 0;
    transition: transform 0.22s cubic-bezier(0.2,0.9,0.3,1), opacity 0.18s ease;
    pointer-events: none;
    will-change: transform, opacity;
}
.cw-left .cw-panel { right: 0; transform-origin: bottom left; }
.cw-panel.cw-panel--open { transform: scale(1) translateY(0); opacity: 1; pointer-events: all; }

.cw-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px;
    color: #fff;
    flex-shrink: 0;
    border-radius: 18px 18px 0 0;
}
.cw-header-left { display: flex; align-items: center; gap: 10px; }
.cw-avatar {
    width: 34px; height: 34px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.cw-avatar svg { width: 18px; height: 18px; }
.cw-name { font-size: 0.95rem; font-weight: 600; letter-spacing: -0.01em; }
.cw-status { font-size: 0.68rem; opacity: 0.85; display: flex; align-items: center; gap: 4px; margin-top: 1px; }
.cw-dot {
    width: 7px; height: 7px; border-radius: 50%;
    background: #4ade80;
    display: inline-block;
    animation: cw-blink 1.6s infinite;
}
@keyframes cw-blink { 0%{opacity:1} 50%{opacity:0.25} 100%{opacity:1} }

.cw-close {
    all: unset;
    cursor: pointer;
    width: 32px; height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    flex-shrink: 0;
}
.cw-close:hover { background: rgba(255,255,255,0.18); }
.cw-close svg { width: 16px; height: 16px; }

.cw-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px 8px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #f5f7fa;
}
.cw-body::-webkit-scrollbar { width: 4px; }
.cw-body::-webkit-scrollbar-track { background: transparent; }
.cw-body::-webkit-scrollbar-thumb { background: #d0d5dd; border-radius: 3px; }

.cw-msg { display: flex; max-width: 88%; animation: cw-fadeIn 0.2s ease; }
@keyframes cw-fadeIn { from{opacity:0;transform:translateY(6px)} to{opacity:1;transform:translateY(0)} }
.cw-msg--user { align-self: flex-end; }
.cw-msg--bot  { align-self: flex-start; }

.cw-msg-bubble {
    padding: 10px 16px;
    border-radius: 18px;
    font-size: 0.9rem;
    line-height: 1.5;
    word-wrap: break-word;
    white-space: pre-wrap;
}
.cw-msg--user .cw-msg-bubble { background: var(--cw-primary); color: #fff; border-bottom-right-radius: 4px; }
.cw-msg--bot .cw-msg-bubble { background: #fff; color: #1a1a2e; border: 1px solid #e9edf2; border-bottom-left-radius: 4px; }

.cw-typing { display: flex; gap: 5px; align-items: center; padding: 10px 4px; }
.cw-typing span {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: #9ca3af;
    animation: cw-type 1.3s infinite ease-in-out;
}
.cw-typing span:nth-child(2) { animation-delay: 0.2s; }
.cw-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes cw-type { 0%,60%,100%{transform:translateY(0);opacity:0.3} 30%{transform:translateY(-5px);opacity:1} }

.cw-foot {
    display: flex;
    gap: 8px;
    padding: 10px 14px 14px;
    background: #fff;
    border-top: 1px solid #e9edf2;
    flex-shrink: 0;
}
.cw-foot input {
    flex: 1;
    border: 1.5px solid #e2e8f0;
    border-radius: 24px;
    padding: 9px 16px;
    font-size: 0.9rem;
    font-family: inherit;
    background: #f8fafc;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}
.cw-foot input::placeholder { color: #9ca3af; }
.cw-foot input:focus { border-color: var(--cw-primary); box-shadow: 0 0 0 3px rgba(var(--cw-primary-rgb,99,102,241),0.12); background: #fff; }
.cw-foot input:disabled { opacity: 0.6; }

.cw-send {
    all: unset;
    cursor: pointer;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    flex-shrink: 0;
    transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
}
.cw-send:hover:not(:disabled) { transform: scale(1.08); box-shadow: 0 4px 12px rgba(var(--cw-primary-rgb,99,102,241),0.35); }
.cw-send:active:not(:disabled) { transform: scale(0.94); }
.cw-send:disabled { opacity: 0.45; cursor: not-allowed; }
.cw-send svg { width: 18px; height: 18px; display: block; }

@media (max-width: 520px) {
    .cw-root { bottom: 0; right: 0; left: 0; }
    .cw-trigger { position: fixed; bottom: 16px; right: 16px; z-index: 2147483001; }
    .cw-panel { position: fixed; inset: 0; width: 100%; height: 100%; border-radius: 0; bottom: 0; transform-origin: center bottom; transform: scale(0.9) translateY(40px); }
    .cw-panel.cw-panel--open { transform: scale(1) translateY(0); }
    .cw-header { border-radius: 0; }
}
