/* avatar.css - AI 来访者虚拟形象面板 */

.chat-layout {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    flex: 1 1 auto;
    min-height: 0;
}

.chat-layout > .chat-main {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    align-self: stretch;
    display: flex;
    flex-direction: column;
}

.chat-layout > .chat-main > .chat-box {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
}

.avatar-panel {
    flex: 0 0 232px;
    width: 232px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    padding: 14px 14px 12px;
    box-shadow: 0 2px 10px rgba(15, 23, 42, 0.06);
    position: sticky;
    top: 12px;
    text-align: center;
}

.avatar-stage {
    background:
        radial-gradient(120% 80% at 50% 12%, #fdfefe 0%, rgba(253, 254, 254, 0) 60%),
        linear-gradient(180deg, #f4f7fd 0%, #e6ecf7 100%);
    border-radius: 12px;
    padding: 6px 0 0;
    overflow: hidden;
    position: relative;
}

/* 情绪色调轻微映射到背景，让整块面板跟着情绪走 */
.avatar-stage::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: radial-gradient(
        90% 70% at 50% 78%,
        var(--avatar-accent, #8d93a8) 0%,
        rgba(255, 255, 255, 0) 62%
    );
    opacity: 0.14;
    transition: background 0.8s ease;
}

.avatar-svg {
    width: 100%;
    height: 200px;
    display: block;
    position: relative;
    z-index: 1;
    filter: drop-shadow(0 4px 6px rgba(15, 23, 42, 0.08));
    animation: avatar-breathe 4.6s ease-in-out infinite;
}

/* 五官的过渡由 avatar.js 的逐帧插值负责，这里不再加 CSS transition，
   否则两套动画会互相拖拽。 */

@keyframes avatar-breathe {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(3px); }
}

.avatar-thinking .avatar-svg {
    animation: avatar-breathe 2.4s ease-in-out infinite;
}

.avatar-speaking .avatar-svg {
    animation: avatar-talk 0.42s ease-in-out infinite;
}

@keyframes avatar-talk {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(1px) scale(1.012); }
}

.avatar-tear,
.avatar-sweat {
    animation: avatar-drop 2.6s ease-in-out infinite;
}

@keyframes avatar-drop {
    0% { transform: translateY(0); }
    70% { transform: translateY(8px); }
    100% { transform: translateY(0); }
}

.avatar-name {
    margin-top: 8px;
    font-size: 13px;
    color: #4b5563;
    font-weight: 600;
}

.avatar-emotion {
    margin-top: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.avatar-emotion-label {
    display: inline-block;
    min-width: 52px;
    padding: 3px 10px;
    border-radius: 11px;
    font-size: 12px;
    color: #fff;
    background: #8d93a8;
    transition: background 0.5s ease;
}

.avatar-emotion-dots {
    font-size: 10px;
    letter-spacing: 1px;
    color: #9aa3ad;
}

.avatar-details {
    margin-top: 8px;
    text-align: left;
    font-size: 12px;
    color: #5b6472;
    line-height: 1.5;
}

.avatar-line {
    display: flex;
    gap: 6px;
    margin-top: 3px;
}

.avatar-line-key {
    flex: 0 0 28px;
    color: #9aa3ad;
}

.avatar-line-value {
    flex: 1 1 auto;
    word-break: break-word;
}

.avatar-controls {
    margin-top: 10px;
}

.avatar-speak-btn {
    width: 100%;
    padding: 6px 8px;
    font-size: 12px;
    border: 1px solid #d7dbe3;
    border-radius: 9px;
    background: #f8fafc;
    color: #4b5563;
    cursor: pointer;
}

.avatar-speak-btn.active {
    background: #eef6ff;
    border-color: #a9c9f5;
    color: #1d4ed8;
}

.avatar-speak-btn:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

/* 每条来访者消息上的情绪小标签 */
.message .affect-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 6px;
    padding: 1px 8px;
    border-radius: 10px;
    font-size: 11px;
    color: #fff;
    background: #8d93a8;
    opacity: 0.92;
}

.message .affect-chip .affect-chip-tone {
    font-size: 11px;
    opacity: 0.9;
}

@media (max-width: 900px) {
    .chat-layout {
        flex-direction: column;
    }

    .avatar-panel {
        width: 100%;
        flex: 1 1 auto;
        position: static;
        display: grid;
        grid-template-columns: 120px 1fr;
        grid-template-areas:
            "stage name"
            "stage emotion"
            "stage details"
            "stage controls";
        column-gap: 12px;
        text-align: left;
    }

    .avatar-stage { grid-area: stage; }
    .avatar-name { grid-area: name; margin-top: 0; }
    .avatar-emotion { grid-area: emotion; justify-content: flex-start; }
    .avatar-details { grid-area: details; }
    .avatar-controls { grid-area: controls; }

    .avatar-svg {
        height: 150px;
    }
}
