/* ── EWT AI Chat Widget ──────────────────────────────────────────────────── */

/* Bubble trigger ──────────────────────────────────────────────────────────── */
#ewt-chat-bubble {
    position: fixed;
    bottom: 2rem;
    left: 1.5rem;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: #0049CA;
    color: #fff;
    border: none;
    cursor: pointer;
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 18px rgba(0, 73, 202, .5);
    transition: transform .2s, box-shadow .2s;
    padding: 0;
}

#ewt-chat-bubble:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 8px 26px rgba(0, 73, 202, .55);
}

#ewt-chat-bubble svg {
    width: 24px;
    height: 24px;
    display: block;
    pointer-events: none;
}

#ewt-chat-bubble .ewt-chat-dot {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 11px;
    height: 11px;
    background: #22c55e;
    border-radius: 50%;
    border: 2px solid #fff;
    animation: ewt-pulse 2s infinite;
}

@keyframes ewt-pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50%       { transform: scale(1.18); opacity: .8; }
}

/* Panel ───────────────────────────────────────────────────────────────────── */
#ewt-chat-panel {
    position: fixed;
    bottom: 6.25rem;
    left: 1.5rem;
    width: 360px;
    max-height: 560px;
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 10px 48px rgba(0, 0, 0, .18), 0 2px 8px rgba(0, 0, 0, .08);
    display: flex;
    flex-direction: column;
    z-index: 9997;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transform: translateY(14px) scale(.97);
    transform-origin: bottom left;
    transition: opacity .22s, transform .22s;
}

#ewt-chat-panel.ewt-chat-open {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}

/* Header ──────────────────────────────────────────────────────────────────── */
.ewt-chat-header {
    background: #0B1426;
    padding: .875rem 1rem;
    display: flex;
    align-items: center;
    gap: .75rem;
    flex-shrink: 0;
}

.ewt-chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #0049CA;
    color: #fff;
    font-size: 1rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    letter-spacing: -.02em;
    border: 2px solid rgba(255, 255, 255, .15);
}

.ewt-chat-info { flex: 1; min-width: 0; }

.ewt-chat-agent-name {
    color: #fff;
    font-size: .88rem;
    font-weight: 700;
    line-height: 1.25;
}

.ewt-chat-agent-role {
    color: rgba(255, 255, 255, .45);
    font-size: .7rem;
    margin-top: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ewt-chat-status {
    display: flex;
    align-items: center;
    gap: .3rem;
    font-size: .68rem;
    color: rgba(255, 255, 255, .4);
    flex-shrink: 0;
}

.ewt-chat-status::before {
    content: '';
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #22c55e;
    display: block;
    flex-shrink: 0;
}

.ewt-chat-close {
    background: rgba(255, 255, 255, .08);
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    color: rgba(255, 255, 255, .55);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s, color .15s;
    flex-shrink: 0;
    padding: 0;
}

.ewt-chat-close:hover { background: rgba(255, 255, 255, .16); color: #fff; }
.ewt-chat-close svg { width: 15px; height: 15px; display: block; pointer-events: none; }

/* Messages ────────────────────────────────────────────────────────────────── */
.ewt-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: .875rem .875rem .5rem;
    display: flex;
    flex-direction: column;
    gap: .5rem;
    scroll-behavior: smooth;
    overscroll-behavior: contain;
}

.ewt-chat-messages::-webkit-scrollbar { width: 3px; }
.ewt-chat-messages::-webkit-scrollbar-track { background: transparent; }
.ewt-chat-messages::-webkit-scrollbar-thumb { background: rgba(0, 0, 0, .1); border-radius: 3px; }

/* Message bubbles */
.ewt-msg {
    max-width: 84%;
    font-size: .83rem;
    line-height: 1.58;
    padding: .55rem .85rem;
    border-radius: 16px;
    word-break: break-word;
    animation: ewt-msg-in .16s ease;
}

@keyframes ewt-msg-in {
    from { opacity: 0; transform: translateY(7px); }
    to   { opacity: 1; transform: translateY(0); }
}

.ewt-msg-agent {
    background: #f0f3f8;
    color: #1a2035;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
}

.ewt-msg-user {
    background: #0049CA;
    color: #fff;
    border-bottom-right-radius: 4px;
    align-self: flex-end;
}

/* Typing indicator */
.ewt-typing {
    align-self: flex-start;
    background: #f0f3f8;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    padding: .55rem .85rem;
    display: flex;
    gap: .28rem;
    align-items: center;
    animation: ewt-msg-in .16s ease;
}

.ewt-typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #8896a5;
    display: block;
    animation: ewt-dot-bounce .85s infinite ease-in-out;
}

.ewt-typing span:nth-child(2) { animation-delay: .14s; }
.ewt-typing span:nth-child(3) { animation-delay: .28s; }

@keyframes ewt-dot-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: .7; }
    30%            { transform: translateY(-5px); opacity: 1; }
}

/* Lead capture form ───────────────────────────────────────────────────────── */
.ewt-chat-capture {
    background: #f7f9fc;
    border-top: 1px solid #e5eaf2;
    padding: .75rem .875rem .875rem;
    flex-shrink: 0;
}

.ewt-chat-capture-label {
    font-size: .75rem;
    font-weight: 700;
    color: #3d4f66;
    margin: 0 0 .55rem;
    display: block;
}

.ewt-chat-capture input {
    display: block;
    width: 100%;
    border: 1.5px solid #d0d9e5;
    border-radius: 9px;
    padding: .48rem .75rem;
    font-size: .81rem;
    margin-bottom: .4rem;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
    box-sizing: border-box;
    color: #1a2035;
    background: #fff;
    font-family: inherit;
}

.ewt-chat-capture input:focus {
    border-color: #0049CA;
    box-shadow: 0 0 0 3px rgba(0, 73, 202, .1);
}

.ewt-chat-capture input::placeholder { color: #a0adb8; }

.ewt-cap-submit {
    width: 100%;
    background: #0049CA;
    color: #fff;
    border: none;
    border-radius: 9px;
    padding: .58rem;
    font-size: .83rem;
    font-weight: 700;
    cursor: pointer;
    transition: background .15s, transform .1s;
    margin-top: .25rem;
    font-family: inherit;
}

.ewt-cap-submit:hover:not(:disabled)  { background: #003aad; }
.ewt-cap-submit:active:not(:disabled) { transform: scale(.98); }
.ewt-cap-submit:disabled { opacity: .55; cursor: not-allowed; }

.ewt-capture-success {
    text-align: center;
    font-size: .81rem;
    color: #16a34a;
    font-weight: 700;
    padding: .5rem 0 .25rem;
}

/* Input bar ───────────────────────────────────────────────────────────────── */
.ewt-chat-input-bar {
    display: flex;
    align-items: flex-end;
    gap: .45rem;
    padding: .65rem .875rem;
    border-top: 1px solid #eaeef4;
    flex-shrink: 0;
}

.ewt-chat-input {
    flex: 1;
    border: 1.5px solid #d0d9e5;
    border-radius: 20px;
    padding: .48rem .875rem;
    font-size: .83rem;
    outline: none;
    resize: none;
    line-height: 1.45;
    max-height: 80px;
    overflow-y: auto;
    transition: border-color .15s, box-shadow .15s;
    color: #1a2035;
    font-family: inherit;
    background: #fff;
}

.ewt-chat-input:focus {
    border-color: #0049CA;
    box-shadow: 0 0 0 3px rgba(0, 73, 202, .08);
}

.ewt-chat-input::placeholder { color: #a0adb8; }

.ewt-chat-send {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #0049CA;
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background .15s, transform .15s;
    padding: 0;
}

.ewt-chat-send:hover:not(:disabled)  { background: #003aad; transform: scale(1.06); }
.ewt-chat-send:disabled { opacity: .45; cursor: not-allowed; }
.ewt-chat-send svg { width: 16px; height: 16px; display: block; pointer-events: none; }

/* Powered-by strip ────────────────────────────────────────────────────────── */
.ewt-chat-powered {
    text-align: center;
    font-size: .62rem;
    color: #b5bfcc;
    padding: .28rem 0 .38rem;
    flex-shrink: 0;
    letter-spacing: .02em;
}

/* Mobile ──────────────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
    #ewt-chat-panel {
        width: calc(100vw - 1.75rem);
        left: .875rem;
        bottom: 5.5rem;
        max-height: 72vh;
        border-radius: 14px;
    }
}
