/* Unified communication widget — self-contained, no dependency on site theme vars. */
.cg-widget-root {
    --cgw-ink: #171923;
    --cgw-ink-2: #5b6172;
    --cgw-line: #e4e7ef;
    --cgw-bg: #ffffff;
    --cgw-bg-2: #f4f6fb;
    --cgw-brand: #0b5fff;
    --cgw-brand-2: #0945c4;
    --cgw-brand-soft: #eaf1ff;
    --cgw-green: #16a34a;
    --cgw-green-soft: #e8f7ee;
    --cgw-amber: #b45309;
    --cgw-amber-soft: #fdf3e7;
    --cgw-grey: #8a90a0;
    --cgw-radius: 14px;
    --cgw-shadow: 0 20px 48px rgba(15, 23, 42, .22), 0 4px 14px rgba(15, 23, 42, .10);
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
html[data-theme="dark"] .cg-widget-root {
    --cgw-ink: #f8fafc;
    --cgw-ink-2: #b8c0d4;
    --cgw-line: #3b455d;
    --cgw-bg: #171b28;
    --cgw-bg-2: #222838;
    --cgw-brand-soft: #252650;
    --cgw-green-soft: #153c2a;
    --cgw-amber-soft: #45331e;
    --cgw-grey: #9da7bd;
}
.cgw-fab {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 9000;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    border: 0;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--cgw-brand), var(--cgw-brand-2));
    color: #fff;
    font-size: .92rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: var(--cgw-shadow);
    transition: transform var(--duration-fast, .15s) ease, box-shadow var(--duration-fast, .15s) ease;
}
.cgw-fab:hover { transform: translateY(-2px); }
.cgw-fab.cgw-fab--left { right: auto; left: 22px; }
.cgw-fab .cgw-fab-badge {
    position: absolute;
    top: -3px;
    right: -3px;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    border-radius: 999px;
    background: #dc2626;
    color: #fff;
    font-size: .62rem;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.cgw-panel {
    position: fixed;
    right: 22px;
    bottom: 84px;
    z-index: 9001;
    width: min(380px, calc(100vw - 32px));
    background: var(--cgw-bg);
    border: 0;
    border-radius: var(--cgw-radius);
    box-shadow: 0 18px 48px rgba(20, 26, 46, .16), 0 4px 14px rgba(20, 26, 46, .08);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    max-height: min(600px, calc(100vh - 120px));
    animation: cgw-pop .18s cubic-bezier(.2, .8, .3, 1);
    transform-origin: bottom right;
}
.cgw-panel.cgw-panel--left { right: auto; left: 22px; transform-origin: bottom left; }
@keyframes cgw-pop { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
.cgw-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 18px;
    background: linear-gradient(135deg, var(--cgw-brand), var(--cgw-brand-2));
    color: #fff;
}
.cgw-head .cgw-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .18);
    display: grid;
    place-items: center;
    font-weight: 800;
}
.cgw-head-text { flex: 1; min-width: 0; }
.cgw-head-text strong { display: block; font-size: .95rem; }
.cgw-head-text small { opacity: .85; font-size: .74rem; display: flex; align-items: center; gap: 5px; }
.cgw-head-text small::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #fff;
    opacity: .9;
}
.cgw-head-text small.cgw-away::before { background: #fbbf24; }
.cgw-head-text small.cgw-offline::before { background: #f87171; }
.cgw-close {
    border: 0;
    background: rgba(255, 255, 255, .16);
    color: #fff;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    display: grid;
    place-items: center;
    flex-shrink: 0;
}
.cgw-close:hover { background: rgba(255, 255, 255, .28); }
.cgw-body { flex: 1; overflow-y: auto; padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; }
.cgw-body::-webkit-scrollbar { width: 6px; }
.cgw-body::-webkit-scrollbar-thumb { background: #d3d7e0; border-radius: 3px; }
.cgw-channels { display: flex; flex-direction: column; gap: 10px; }
.cgw-channel {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13px 14px;
    border: 1px solid var(--cgw-line);
    border-radius: 12px;
    background: var(--cgw-bg);
    color: var(--cgw-ink);
    text-decoration: none;
    font-size: .9rem;
    font-weight: 600;
    cursor: pointer;
    text-align: left;
    transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.cgw-channel:hover { border-color: var(--cgw-brand); box-shadow: 0 6px 16px rgba(11, 95, 255, .12); transform: translateY(-1px); }
.cgw-channel .cgw-channel-ico {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    color: #fff;
    flex-shrink: 0;
    font-size: 1.05rem;
}
.cgw-channel--whatsapp .cgw-channel-ico { background: #25d366; }
.cgw-channel--messenger .cgw-channel-ico { background: #0084ff; }
.cgw-channel--live .cgw-channel-ico { background: #25d366; }
.cgw-channel--live { border-color: transparent; background: var(--cgw-green-soft); }
.cgw-channel--live small { color: #16803d; }
.cgw-channel small { display: block; font-weight: 400; color: var(--cgw-ink-2); margin-top: 1px; }
.cgw-offline-note {
    display: flex;
    gap: 8px;
    padding: 10px 12px;
    border-radius: 10px;
    background: var(--cgw-amber-soft);
    color: var(--cgw-amber);
    font-size: .78rem;
}
.cgw-form { display: flex; flex-direction: column; gap: 10px; }
.cgw-form .cgw-row { display: flex; gap: 10px; }
.cgw-field { width: 100%; }
.cgw-field label { display: block; font-size: .72rem; font-weight: 700; color: var(--cgw-ink-2); margin-bottom: 4px; text-transform: uppercase; letter-spacing: .04em; }
.cgw-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #cfd5e3;
    border-radius: 9px;
    background: #fbfcff;
    color: var(--cgw-ink);
    font-size: .88rem;
    font-family: inherit;
    outline: none;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.cgw-input:focus { border-color: var(--cgw-brand); box-shadow: 0 0 0 3px var(--cgw-brand-soft); }
.cgw-input::placeholder { color: #737b90; opacity: 1; }
html[data-theme="dark"] .cgw-input { border-color: #4a556f; background: #202532; color: #ffffff; }
html[data-theme="dark"] .cgw-input::placeholder { color: #aeb7ca; }
.cgw-input:focus-visible, .cgw-btn:focus-visible, .cgw-close:focus-visible, .cgw-channel:focus-visible { outline: 2px solid rgba(79, 70, 229, .38); outline-offset: 2px; }
select.cgw-input { -webkit-appearance: none; appearance: none; padding-right: 32px; background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235b6172' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }
textarea.cgw-input { resize: vertical; min-height: 70px; }
.cgw-privacy { font-size: .72rem; color: var(--cgw-grey); line-height: 1.4; margin: 0; }
.cgw-btn {
    border: 0;
    border-radius: 10px;
    padding: 12px 14px;
    background: linear-gradient(135deg, var(--cgw-brand), var(--cgw-brand-2));
    color: #fff;
    font-size: .9rem;
    font-weight: 700;
    cursor: pointer;
    transition: opacity .15s ease, transform .15s ease;
}
.cgw-btn:hover { transform: translateY(-1px); }
.cgw-btn:disabled { opacity: .6; cursor: not-allowed; transform: none; }
.cgw-btn--ghost { background: var(--cgw-bg-2); color: var(--cgw-ink); border: 1px solid var(--cgw-line); font-weight: 600; }
.cgw-error { color: #b91c1c; font-size: .78rem; }
.cgw-chat-thread { display: flex; flex-direction: column; gap: 8px; }
.cgw-msg { max-width: 82%; padding: 9px 12px; border-radius: 12px; font-size: .86rem; line-height: 1.45; word-wrap: break-word; white-space: pre-wrap; }
.cgw-msg--visitor { align-self: flex-end; background: linear-gradient(135deg, var(--cgw-brand), var(--cgw-brand-2)); color: #fff; border-bottom-right-radius: 4px; }
.cgw-msg--agent, .cgw-msg--system { align-self: flex-start; background: var(--cgw-bg-2); color: var(--cgw-ink); border-bottom-left-radius: 4px; }
.cgw-msg--system { font-style: italic; background: transparent; color: var(--cgw-ink-2); font-size: .78rem; }
.cgw-msg time { display: block; font-size: .64rem; opacity: .7; margin-top: 3px; }
.cgw-chat-input { display: flex; gap: 8px; padding-top: 4px; }
.cgw-chat-input .cgw-input { flex: 1; }
.cgw-chat-input .cgw-input { min-height: 44px; }
.cgw-quick { display: flex; flex-wrap: wrap; gap: 6px; }
.cgw-quick button {
    border: 1px solid var(--cgw-line);
    background: var(--cgw-bg);
    color: var(--cgw-ink-2);
    border-radius: 999px;
    padding: 6px 11px;
    font-size: .76rem;
    cursor: pointer;
    transition: border-color .15s ease, color .15s ease;
}
.cgw-quick button:hover { border-color: var(--cgw-brand); color: var(--cgw-brand); }
.cgw-typing { font-size: .74rem; color: var(--cgw-ink-2); display: flex; align-items: center; gap: 6px; }
.cgw-typing .cgw-dots { display: inline-flex; gap: 3px; }
.cgw-typing .cgw-dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--cgw-ink-2); animation: cgw-blink 1.2s infinite; }
.cgw-typing .cgw-dots i:nth-child(2) { animation-delay: .2s; }
.cgw-typing .cgw-dots i:nth-child(3) { animation-delay: .4s; }
@keyframes cgw-blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
@media (max-width: 767px) {
    .cgw-fab { right: 16px; bottom: 94px; left: auto; width: 52px !important; min-width: 52px; height: 52px; padding: 0 !important; justify-content: center; border-radius: 50%; }
    .cgw-fab > span { display: none !important; }
    .cgw-fab.cgw-fab--left { right: auto; left: 16px; }
    .cgw-panel { right: 12px; bottom: 156px; left: 12px; width: auto; }
}
