#eca-widget * { box-sizing: border-box; }

#eca-launcher {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 6px 22px rgba(0,0,0,.22);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999998;
    transition: transform .2s ease;
    padding: 0;
}
#eca-launcher:hover { transform: scale(1.06); }

.eca-launcher-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    overflow: hidden;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
}
.eca-launcher-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.eca-online {
    position: absolute;
    bottom: 4px;
    right: 4px;
    width: 14px;
    height: 14px;
    background: #24c65f;
    border: 2.5px solid #fff;
    border-radius: 50%;
    z-index: 3;
}

.eca-pulse {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: var(--eca-color, #0b5cad);
    opacity: .35;
    z-index: 1;
    animation: eca-pulse 2s infinite;
}
@keyframes eca-pulse {
    0%   { transform: scale(1);   opacity: .35; }
    70%  { transform: scale(1.6); opacity: 0; }
    100% { transform: scale(1.6); opacity: 0; }
}

#eca-greeting {
    position: fixed;
    bottom: 100px;
    right: 24px;
    max-width: 230px;
    background: #fff;
    color: #222;
    padding: 12px 34px 12px 14px;
    border-radius: 14px 14px 4px 14px;
    box-shadow: 0 6px 22px rgba(0,0,0,.18);
    font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.4;
    z-index: 999998;
    animation: eca-slide-up .4s ease;
}
#eca-greeting.eca-hidden { display: none; }
#eca-greeting::after {
    content: "";
    position: absolute;
    bottom: -7px;
    right: 20px;
    width: 14px;
    height: 14px;
    background: #fff;
    transform: rotate(45deg);
    box-shadow: 2px 2px 3px rgba(0,0,0,.06);
}
.eca-greeting-text { position: relative; z-index: 1; }
#eca-greeting-close {
    position: absolute;
    top: 6px;
    right: 8px;
    background: transparent;
    border: none;
    font-size: 18px;
    line-height: 1;
    color: #999;
    cursor: pointer;
    padding: 0;
}
#eca-greeting-close:hover { color: #333; }
@keyframes eca-slide-up {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

#eca-box {
    position: fixed;
    bottom: 100px;
    right: 24px;
    width: 360px;
    max-width: calc(100vw - 32px);
    height: 520px;
    max-height: calc(100vh - 140px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(0,0,0,.28);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 999999;
    font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    animation: eca-pop .25s ease;
}
@keyframes eca-pop {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}
#eca-box.eca-hidden { display: none; }

#eca-header {
    background: var(--eca-color, #0b5cad);
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.eca-head-left { display: flex; align-items: center; gap: 10px; }
.eca-avatar {
    width: 42px; height: 42px;
    border-radius: 50%;
    background: #fff;
    display: flex; align-items: center; justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}
.eca-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}
.eca-title { font-weight: 700; font-size: 15px; }
.eca-status { font-size: 12px; opacity: .9; display: flex; align-items: center; gap: 5px; }
.eca-dot { width: 8px; height: 8px; background: #4caf50; border-radius: 50%; display: inline-block; }
#eca-close {
    background: transparent; border: none; color: #fff;
    font-size: 26px; cursor: pointer; line-height: 1; padding: 0 4px;
}

#eca-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f5f7fb;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.eca-msg {
    max-width: 82%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.45;
    word-wrap: break-word;
    white-space: pre-line;
}
.eca-bot  { align-self: flex-start; background: #fff; color: #222; border-bottom-left-radius: 4px; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.eca-user { align-self: flex-end; background: var(--eca-color, #0b5cad); color: #fff; border-bottom-right-radius: 4px; }

.eca-typing { display: flex; gap: 4px; padding: 12px 14px; }
.eca-typing span {
    width: 7px; height: 7px; border-radius: 50%; background: #b5b5b5;
    animation: eca-blink 1.2s infinite both;
}
.eca-typing span:nth-child(2) { animation-delay: .2s; }
.eca-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes eca-blink { 0%,80%,100% { opacity: .3; } 40% { opacity: 1; } }

.eca-quick { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 2px; }
.eca-quick button {
    background: #fff;
    border: 1.5px solid var(--eca-color, #0b5cad);
    color: var(--eca-color, #0b5cad);
    padding: 7px 12px;
    border-radius: 18px;
    font-size: 13px;
    cursor: pointer;
    transition: all .15s ease;
}
.eca-quick button:hover { background: var(--eca-color, #0b5cad); color: #fff; }

#eca-input-area {
    display: flex;
    align-items: center;
    padding: 10px;
    gap: 8px;
    border-top: 1px solid #eee;
    background: #fff;
}
#eca-input {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 22px;
    padding: 10px 14px;
    font-size: 14px;
    outline: none;
}
#eca-input:focus { border-color: var(--eca-color, #0b5cad); }
#eca-send {
    background: var(--eca-color, #0b5cad);
    border: none;
    width: 40px; height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
#eca-send:disabled { opacity: .5; cursor: not-allowed; }

@media (max-width: 480px) {
    #eca-box { right: 8px; bottom: 88px; width: calc(100vw - 16px); height: calc(100vh - 110px); }
    #eca-launcher { right: 16px; bottom: 16px; }
    #eca-greeting { right: 16px; bottom: 90px; }
}
