.xt-chat {
    --chat-red: #c41e3a;
    --chat-navy: #2f2f6e;
    --chat-border: #e5e7eb;
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 2500;
    font-family: "Poppins", Arial, sans-serif;
}

.xt-chat [hidden] { display: none !important; }

.xt-chat__launcher {
    position: relative;
    display: grid;
    width: 60px;
    height: 60px;
    padding: 3px;
    place-items: center;
    overflow: visible;
    border: 2px solid var(--chat-red);
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 10px 30px rgba(159, 20, 43, .35);
    cursor: pointer;
    transition: transform .18s ease, box-shadow .18s ease;
}

.xt-chat__launcher-logo { display: block; width: 100%; height: 100%; border-radius: 50%; object-fit: contain; }
.xt-chat__launcher:hover { transform: translateY(-2px); box-shadow: 0 14px 32px rgba(159, 20, 43, .42); }
.xt-chat__launcher:focus-visible, .xt-chat button:focus-visible, .xt-chat input:focus-visible, .xt-chat textarea:focus-visible { outline: 3px solid rgba(47, 47, 110, .28); outline-offset: 2px; }

.xt-chat__unread {
    position: absolute;
    top: -4px;
    right: -3px;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    border: 2px solid #fff;
    border-radius: 11px;
    background: var(--chat-navy);
    color: #fff;
    font: 700 11px/18px Arial, sans-serif;
}

.xt-chat__panel {
    display: none;
    position: absolute;
    right: 0;
    bottom: 74px;
    width: min(390px, calc(100vw - 32px));
    height: min(620px, calc(100vh - 120px));
    overflow: hidden;
    border: 1px solid rgba(15, 23, 42, .1);
    border-radius: 18px;
    background: #fff;
    box-shadow: 0 22px 65px rgba(15, 23, 42, .28);
}

.xt-chat.is-open .xt-chat__panel { display: flex; flex-direction: column; animation: xt-chat-in .2s ease-out; }
@keyframes xt-chat-in { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }

.xt-chat__header {
    display: flex;
    align-items: center;
    gap: 11px;
    min-height: 72px;
    padding: 12px 14px;
    background: linear-gradient(135deg, var(--chat-navy), #45458f);
    color: #fff;
}

.xt-chat__brandmark { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; background: rgba(255,255,255,.14); font-size: 19px; }
.xt-chat__header > div:nth-child(2) { display: flex; flex: 1; min-width: 0; flex-direction: column; }
.xt-chat__header strong { font-size: 15px; }
.xt-chat__header span { margin-top: 2px; color: rgba(255,255,255,.78); font-size: 11px; }
.xt-chat__header > button { width: 34px; height: 34px; border: 0; border-radius: 50%; background: transparent; color: #fff; cursor: pointer; }
.xt-chat__header > button:hover { background: rgba(255,255,255,.12); }
.xt-chat__header > button.is-enabled { background: rgba(52, 211, 153, .2); color: #a7f3d0; }
.xt-chat__presence-dot { display: inline-block; width: 7px; height: 7px; margin-right: 4px; border-radius: 50%; background: #fbbf24; }
.xt-chat__presence-dot.is-online { background: #34d399; }

.xt-chat__notice { padding: 9px 13px; background: #fff7ed; color: #9a3412; font-size: 12px; text-align: center; }
.xt-chat__start { flex: 1; padding: 32px 28px; overflow-y: auto; text-align: center; }
.xt-chat__welcome-icon { display: grid; place-items: center; width: 66px; height: 66px; margin: 8px auto 18px; border-radius: 50%; background: #fce7eb; color: var(--chat-red); font-size: 26px; }
.xt-chat__start h3 { margin: 0 0 7px; color: #111827; font-size: 21px; }
.xt-chat__start > p { margin: 0 0 25px; color: #64748b; font-size: 13px; }
.xt-chat__start label { display: block; margin: 0 0 14px; text-align: left; }
.xt-chat__start label > span { display: block; margin-bottom: 5px; color: #374151; font-size: 12px; font-weight: 600; }
.xt-chat__start small { color: #94a3b8; font-weight: 400; }
.xt-chat__start input { width: 100%; height: 44px; padding: 0 12px; border: 1px solid var(--chat-border); border-radius: 9px; color: #111827; font-size: 13px; box-sizing: border-box; }
.xt-chat__primary { width: 100%; height: 45px; margin-top: 4px; border: 0; border-radius: 9px; background: var(--chat-red); color: #fff; font-size: 13px; font-weight: 700; cursor: pointer; }
.xt-chat__primary:disabled, .xt-chat__send:disabled { opacity: .58; cursor: wait; }

.xt-chat__conversation { display: flex; flex: 1; min-height: 0; flex-direction: column; background: #f8fafc; }
.xt-chat__actions { display: flex; justify-content: flex-end; padding: 6px 14px; border-bottom: 1px solid var(--chat-border); background: #fff; }
.xt-chat__actions button { padding: 6px 10px; border: 1px solid var(--chat-red); border-radius: 7px; background: #fff; color: var(--chat-red); font: inherit; font-size: 12px; cursor: pointer; }
.xt-chat__actions button:disabled { opacity: .6; cursor: wait; }
.xt-chat__messages { flex: 1; min-height: 0; padding: 17px 14px; overflow-y: auto; overscroll-behavior: contain; }
.xt-chat__message { display: flex; margin: 0 0 12px; flex-direction: column; align-items: flex-start; }
.xt-chat__message.is-customer { align-items: flex-end; }
.xt-chat__bubble { max-width: 82%; padding: 9px 12px; border: 1px solid var(--chat-border); border-radius: 13px 13px 13px 4px; background: #fff; color: #1f2937; box-shadow: 0 2px 5px rgba(15, 23, 42, .04); font-size: 13px; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.xt-chat__message.is-customer .xt-chat__bubble { border-color: var(--chat-navy); border-radius: 13px 13px 4px 13px; background: var(--chat-navy); color: #fff; }
.xt-chat__message.is-automated .xt-chat__bubble { border-style: dashed; }
.xt-chat__meta { margin-top: 4px; color: #94a3b8; font-size: 10px; }
.xt-chat__auto-label { margin-right: 6px; font-weight: 700; }
.xt-chat__attachment { display: block; width: min(240px, 65vw); margin-bottom: 7px; overflow: hidden; border-radius: 8px; background: #e2e8f0; }
.xt-chat__attachment img { display: block; width: 100%; max-height: 260px; object-fit: cover; }
.xt-chat__typing { padding: 4px 16px 8px; color: #64748b; font-size: 11px; font-style: italic; }

.xt-chat__previews { display: flex; gap: 8px; padding: 9px 12px 0; overflow-x: auto; background: #fff; }
.xt-chat__preview { position: relative; flex: 0 0 54px; height: 54px; overflow: hidden; border-radius: 7px; background: #e2e8f0; }
.xt-chat__preview img { width: 100%; height: 100%; object-fit: cover; }
.xt-chat__preview button { position: absolute; top: 2px; right: 2px; width: 19px; height: 19px; padding: 0; border: 0; border-radius: 50%; background: rgba(15,23,42,.75); color: #fff; font-size: 10px; cursor: pointer; }
.xt-chat__composer { display: flex; align-items: flex-end; gap: 7px; padding: 11px 11px 8px; border-top: 1px solid var(--chat-border); background: #fff; }
.xt-chat__attach, .xt-chat__send { display: grid; flex: 0 0 38px; width: 38px; height: 38px; place-items: center; border: 0; border-radius: 50%; cursor: pointer; }
.xt-chat__attach { color: #64748b; }
.xt-chat__attach:hover { background: #f1f5f9; }
.xt-chat__send { background: var(--chat-red); color: #fff; }
.xt-chat__composer textarea { flex: 1; min-height: 38px; max-height: 105px; padding: 9px 10px; resize: none; border: 1px solid var(--chat-border); border-radius: 10px; font: 13px/1.4 inherit; box-sizing: border-box; }
.xt-chat__hint { display: block; padding: 0 12px 9px; background: #fff; color: #94a3b8; font-size: 9px; text-align: center; }

@media (max-width: 520px) {
    .xt-chat { right: 14px; bottom: 14px; }
    .xt-chat__launcher { width: 56px; height: 56px; }
    .xt-chat__panel { position: fixed; inset: 0; width: 100%; height: 100%; max-height: none; border: 0; border-radius: 0; }
    .xt-chat__header { min-height: 66px; padding-top: max(10px, env(safe-area-inset-top)); }
}

@media (max-width: 768px), (pointer: coarse) {
    /* iOS Safari can zoom when a text field smaller than 16px receives focus. */
    .xt-chat__start input,
    .xt-chat__composer textarea {
        font-size: 16px;
    }
}

@media (prefers-reduced-motion: reduce) { .xt-chat.is-open .xt-chat__panel { animation: none; } }
.xt-chat__end-request { flex-shrink: 0; padding: 12px 16px; background: #f1f5fa; border-top: 1px solid #dce3ee; color: #24344a; }
.xt-chat__end-request p { margin: 0 0 8px; font-size: 13px; line-height: 1.5; }
.xt-chat__end-request button { margin: 0 6px 4px 0; padding: 8px 12px; border: 1px solid #b5bfd0; border-radius: 7px; background: #fff; color: #24344a; cursor: pointer; font-size: 13px; }
.xt-chat__end-request button:disabled { opacity: .6; cursor: wait; }
.xt-chat__end-request button:focus-visible { outline: 2px solid #3c3b6e; outline-offset: 2px; }
