/* Live Chat Assistant — Clean floating character styles */

.lca-wrap {
    position: fixed;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    align-items: center;
    pointer-events: none; /* let clicks through except on interactive elements */
    transition: all 0.3s ease;
}

/* ── Positioning ── */
.lca-wrap[data-position="bottom-right"] { bottom: var(--lca-y,20px); right: var(--lca-x,20px); align-items: flex-end; }
.lca-wrap[data-position="bottom-left"]  { bottom: var(--lca-y,20px); left:  var(--lca-x,20px); align-items: flex-start; }
.lca-wrap[data-position="top-right"]    { top: var(--lca-y,20px);    right: var(--lca-x,20px); align-items: flex-end; }
.lca-wrap[data-position="top-left"]     { top: var(--lca-y,20px);    left:  var(--lca-x,20px); align-items: flex-start; }
.lca-wrap[data-position="inline"]       { position: relative; bottom:auto; right:auto; left:auto; top:auto; align-items:center; }

/* ── Character image ── */
.lca-character {
    position: relative;
    cursor: pointer;
    pointer-events: all;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}
.lca-img {
    width: var(--lca-size, 200px);
    height: auto;
    display: block;
    transition: transform 0.2s ease;
    -webkit-user-drag: none;
    user-select: none;
    /* No background — transparent gif/png shows through */
    background: transparent;
}
.lca-character:hover .lca-img {
    transform: scale(1.05);
}
.lca-character:active .lca-img {
    transform: scale(0.97);
}

/* Idle float animation */
.lca-img.lca-idle {
    animation: lca-float 3s ease-in-out infinite;
}
@keyframes lca-float {
    0%,100% { transform: translateY(0); }
    50%      { transform: translateY(-8px); }
}
.lca-img.lca-listening {
    animation: lca-listen 0.8s ease-in-out infinite alternate;
}
@keyframes lca-listen {
    from { transform: scale(1); }
    to   { transform: scale(1.03); }
}
.lca-img.lca-talking {
    animation: lca-talk 0.2s ease-in-out infinite alternate;
}
@keyframes lca-talk {
    from { transform: scale(1) rotate(-0.5deg); }
    to   { transform: scale(1.02) rotate(0.5deg); }
}

/* Pulse ring — shown when idle/waiting for click */
.lca-pulse {
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 50px; height: 50px;
    border-radius: 50%;
    background: rgba(255,255,255,0.15);
    animation: lca-pulse 2s ease-out infinite;
    pointer-events: none;
}
.lca-pulse.hidden { display: none; }
@keyframes lca-pulse {
    0%   { transform: translateX(-50%) scale(0.8); opacity: 0.6; }
    100% { transform: translateX(-50%) scale(2);   opacity: 0; }
}

/* ── Speech bubble ── */
.lca-bubble {
    pointer-events: none;
    background: var(--lca-bubble-bg, #ffffff);
    color: var(--lca-bubble-color, #333333);
    border-radius: 16px;
    padding: 10px 14px;
    max-width: var(--lca-bubble-width, 260px);
    font-size: var(--lca-font-size, 14px);
    line-height: 1.5;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    opacity: 0;
    transform: scale(0.9) translateY(4px);
    transition: opacity 0.2s, transform 0.2s;
    position: relative;
    margin: 8px 0;
    word-break: break-word;
}
.lca-bubble.show {
    opacity: 1;
    transform: scale(1) translateY(0);
    pointer-events: all;
}

/* Bubble tail — above character (bubble above, tail points down) */
.lca-bubble.tail-below::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    border: 8px solid transparent;
    border-top-color: var(--lca-bubble-bg, #ffffff);
    border-bottom: 0;
}
/* Bubble tail — below character (bubble below, tail points up) */
.lca-bubble.tail-above::after {
    content: '';
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    border: 8px solid transparent;
    border-bottom-color: var(--lca-bubble-bg, #ffffff);
    border-top: 0;
}
/* Bubble tail — right of character */
.lca-bubble.tail-left::after {
    content: '';
    position: absolute;
    top: 50%;
    left: -8px;
    transform: translateY(-50%);
    border: 8px solid transparent;
    border-right-color: var(--lca-bubble-bg, #ffffff);
    border-left: 0;
}
/* Bubble tail — left of character */
.lca-bubble.tail-right::after {
    content: '';
    position: absolute;
    top: 50%;
    right: -8px;
    transform: translateY(-50%);
    border: 8px solid transparent;
    border-left-color: var(--lca-bubble-bg, #ffffff);
    border-right: 0;
}

/* ── Status text ── */
.lca-status {
    font-size: 11px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--lca-status-color, #ffffff);
    text-align: center;
    min-height: 16px;
    pointer-events: none;
    text-shadow: 0 1px 4px rgba(0,0,0,0.5);
    margin: 4px 0;
}

/* ── Type input ── */
.lca-type-row {
    display: flex;
    gap: 6px;
    width: 100%;
    max-width: var(--lca-bubble-width, 260px);
    pointer-events: all;
    margin: 4px 0;
}
.lca-type-input {
    flex: 1;
    border: none;
    border-radius: 20px;
    padding: 8px 14px;
    font-size: 13px;
    background: var(--lca-bubble-bg, #ffffff);
    color: var(--lca-bubble-color, #333333);
    outline: none;
    box-shadow: 0 2px 10px rgba(0,0,0,0.12);
    font-family: inherit;
}
.lca-send-btn {
    border: none;
    border-radius: 50%;
    width: 36px; height: 36px;
    background: #333;
    color: #fff;
    font-size: 14px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.15);
    transition: transform 0.15s, opacity 0.15s;
}
.lca-send-btn:hover { transform: scale(1.1); opacity: 0.85; }
.lca-send-btn:disabled { opacity: 0.3; cursor: not-allowed; }

/* ── Transcript ── */
.lca-transcript {
    max-height: 140px;
    overflow-y: auto;
    width: 100%;
    max-width: var(--lca-bubble-width, 260px);
    display: flex;
    flex-direction: column;
    gap: 5px;
    pointer-events: all;
    margin-top: 6px;
}
.lca-transcript::-webkit-scrollbar { width: 3px; }
.lca-transcript::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.2); border-radius: 3px; }

.lca-msg {
    font-size: 12px;
    padding: 5px 10px;
    border-radius: 10px;
    max-width: 85%;
    line-height: 1.4;
    animation: lca-fadein 0.25s ease;
}
@keyframes lca-fadein { from { opacity:0; transform:translateY(3px); } to { opacity:1; transform:none; } }
.lca-msg.user      { background:rgba(0,0,0,0.12); align-self:flex-end; color:var(--lca-bubble-bg,#fff); }
.lca-msg.assistant { background:var(--lca-bubble-bg,#fff); color:var(--lca-bubble-color,#333); align-self:flex-start; }

/* ── Close button ── */
.lca-close-btn {
    position: absolute;
    top: 0; right: 0;
    background: rgba(0,0,0,0.4);
    border: none;
    color: #fff;
    width: 22px; height: 22px;
    border-radius: 50%;
    font-size: 11px;
    cursor: pointer;
    display: none; /* shown when connected */
    align-items: center;
    justify-content: center;
    pointer-events: all;
    transition: background 0.2s;
    z-index: 10;
}
.lca-close-btn.show { display: flex; }
.lca-close-btn:hover { background: rgba(0,0,0,0.7); }

/* ── Bubble ordering by position ── */
.lca-wrap.bubble-above   { flex-direction: column-reverse; }
.lca-wrap.bubble-below   { flex-direction: column; }
.lca-wrap.bubble-left    { flex-direction: row-reverse; align-items: center; }
.lca-wrap.bubble-right   { flex-direction: row; align-items: center; }
