﻿/* 全局重置与基础样式 - 适配1080×1920竖屏 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: "微软雅黑", sans-serif;
    touch-action: manipulation; /* 优化触控体验 */
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden; /* 禁止页面滚动 */
    background-color: #f5f7fa;
}

body {
    /* width: 1080px;
    height: 1920px;*/
    /*padding: 15px;*/
    /*display: flex;
    flex-direction: column;*/ /*竖屏垂直布局 */
    /*align-items: end;
    justify-content: end;
    background-image: url('../images/bg.png');
    background-repeat: no-repeat;
    background-size: cover;*/
    margin: 0 auto;
}

.body-content {
    width: 100%;
    height: 100%;
    display: flex;
    /* display: flex; */
    flex-direction: column;
    align-items: end;
    justify-content: end;
    background-image: url(../images/bg.png);
    background-repeat: no-repeat;
    background-size: cover;
    position: relative;
}

/* 人物容器 - 右下角定位 */
.character-wrapper {
    position: relative;
    width: 51%;
    height: 82%;
}

/* 身体图层（静态） */
.character-body {
    position: absolute;
    width: 100%;
    height: 100%;
    background-image: url('../images/body.png');
    background-size: contain;
    background-repeat: no-repeat;
    z-index: 1;
    background-position: center;
    /* 开启硬件加速，提升动画流畅度 */
    transform: translateZ(0);
}
    /** 眼睛遮罩 - 模拟眨眼 */
    .character-body::before {
        content: '';
        position: absolute;
        /* 根据实际眼睛位置调整 top/left/width/height */
        top: 30%;
        left: 80px;
        width: 140px;
        height: 50px;
        background-color: transparent;
        border-radius: 50%;
        /* 眨眼动画：默认无限循环，每3秒眨一次 */
        /*animation: blink 3s infinite ease-in-out;*/
        pointer-events: none;
    }

    /* 嘴巴区域 - 模拟说话时的开合 */
    .character-body::after {
        content: '';
        position: absolute;
        /* 根据实际嘴巴位置调整 top/left/width/height */
        top: 200px;
        left: 120px;
        width: 60px;
        height: 30px;
        border-radius: 50%;
        /* 初始状态：无动画 */
        transform: scaleY(1);
        /*transition: transform 0.1s ease;*/
        pointer-events: none;
    }

/* 眨眼动画关键帧 */
@keyframes blink {
    0%, 90%, 100% {
        /* 睁眼：透明遮罩 */
        background-color: transparent;
        transform: scaleY(1);
    }

    95% {
        /* 闭眼：白色/同背景色遮罩覆盖眼睛 */
        background-color: #ffffff; /* 替换为人物皮肤色，更自然 */
        transform: scaleY(0.1);
    }
}
/* 说话时嘴巴动画 */
.character-body.speaking::after {
    /* 嘴巴开合动画：无限快速缩放 */
    animation: mouthMove 0.2s infinite alternate ease-in-out;
}
/* 嘴巴开合关键帧 */
@keyframes mouthMove {
    0% {
        transform: scaleY(1); /* 闭合 */
    }

    100% {
        transform: scaleY(1.5); /* 张开（根据需要调整缩放比例） */
    }
}

.speaking {
    animation: talk 0.8s steps(9) infinite;
}



/* 状态提示文字 */
.dialog-status {
    display: none;
    position: absolute;
    top: 500px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 18px;
    color: #ffffff;
    text-align: center;
    z-index: 9;
}


/* 按钮内容器强制横向 */
.btn-content {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 12px !important;
    white-space: nowrap !important;
    flex-wrap: nowrap !important;
}

/* 开始按钮 - 人物左侧 */
.start-btn {
    position: absolute;
    bottom: 128px;
    left: -204px;
    /*bottom: 100px;
    left: -180px;*/ /* 调整到人物左侧 */
    transform: translateX(0);
    /*padding: 15px 35px;*/
    padding: 15px 45px;
    background: #624aff;
    color: #fff;
    border: none;
    /*border-radius: 30px;*/
    border-radius: 40px;
    font-size: 29px;
    cursor: pointer;
    transition: background 0.3s;
    z-index: 10;
    min-width: 320px; /* 加宽避免内容挤在一起 */
    width: auto;
    display: flex;
    flex-flow: row nowrap !important; /* 关键：!important 防止被覆盖 */
    align-items: center;
    justify-content: center;
    gap: 12px; /* 文字和动画之间的间距 */
    /* 核心修复3：禁止内容换行 */
    white-space: nowrap;
    flex-wrap: nowrap;
}

#startBtnText {
    display: inline-block;
    flex-shrink: 0; /* 关键：禁止文字容器收缩 */
    white-space: nowrap;
}

.start-btn:hover {
    background: #5038e0;
}

.start-btn:disabled {
    background: #5038e0; /* 和加载状态背景一致 */
    cursor: wait;
    opacity: 1; /* 不透明 */
}

/* 跳动原点加载动画容器 - 放在按钮内部 */
.loading-animation {
    display: none; /* 默认隐藏 */
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 100%;
    height: 24px; /* 固定高度，避免变形 */
    width: auto;
    flex-shrink: 0;
}

/* 单个原点 */
.loading-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: #ffffff;
    animation: bounce 1.4s infinite ease-in-out both;
}

    .loading-dot:nth-child(1) {
        animation-delay: -0.32s;
    }

    .loading-dot:nth-child(2) {
        animation-delay: -0.16s;
    }

@keyframes bounce {
    0%, 80%, 100% {
        transform: scale(0);
        opacity: 0.5;
    }

    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* 按钮加载状态样式 */
.start-btn.loading {
    background: #5038e0; /* 稍微暗一点 */
    cursor: wait;
}

    .start-btn.loading .loading-animation {
        display: flex; /* 显示动画 */
    }

/* 控制按钮容器（结束/隐藏记录） */
/*.control-buttons {
    display: none;*/ /* 初始隐藏 */
/*margin-top: 20px;
    text-align: center;
}*/

/* 结束/切换按钮样式 */
.end-btn, .toggle-dialog-btn {
    /*padding: 12px 30px;*/
    /*padding: 25px 60px;*/
    padding: 15px 60px;
    border: none;
    border-radius: 40px;
    /*font-size: 29px;*/
    font-size: 25px;
    cursor: pointer;
    transition: background 0.3s;
    /*margin: 0 5px 10px;*/
    min-width: 180px;
}

.end-btn {
    background: #ff4d4f;
    color: #fff;
}

    .end-btn:hover {
        background: #d9363e;
    }

.toggle-dialog-btn {
    background: #40a9ff;
    color: #fff;
}

    .toggle-dialog-btn:hover {
        background: #1890ff;
    }

/* 对话记录区域 - 顶部开始往下显示 */
.dialog-history {
    display: none;
    position: absolute;
    /*top: 5%;*/
    left: 8%;
    /*top: 4%;
    left: 50%;*/
    /*transform: translateX(-50%);*/
    width: 90%;
    /*max-width: 900px;*/
    max-width: 80%;
    /*height: 75%;*/
    height: 80%;
    /*height: 450px;*/
    /*border: 1px solid #eee;*/
    /*border-radius: 8px;*/
    /*padding: 15px;*/
    overflow-y: auto;
    /*background: #f9f9f9;*/
    /*font-size: 25px;*/
    font-size: 17px;
    flex-direction: column;
    justify-content: flex-start;
    z-index: 999;
    /* ========== 新增：隐藏滚动条 ========== */
    /* Chrome, Safari, Edge */
    scrollbar-width: none;
    -ms-overflow-style: none;
}
    /* Chrome, Safari, Edge 隐藏滚动条 */
    .dialog-history::-webkit-scrollbar {
        display: none;
    }

/* 对话状态提示 */
.dialog-status {
    display: none;
    position: absolute;
    top: 500px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 18px;
    color: #624aff;
    text-align: center;
}

/* 控制按钮容器 */
.control-buttons {
    display: none;
    position: absolute;
    /*top: 80%;*/
    top: 86%;
    /*top: 550px;*/
    left: 49%;
    /*transform: translateX(-60%);*/
    /*margin-top: 20px;*/
    text-align: center;
    z-index: 9999;
    left: -172px;
    transform: translateX(0);
}

/* 对话记录区域 */
/*.dialog-history {
    display: none;*/ /* 初始隐藏 */
/*width: 100%;
    max-width: 90vw;
    height: 200px;
    border: 1px solid #eee;
    border-radius: 8px;
    padding: 15px;
    overflow-y: auto;
    background: #f9f9f9;
    font-size: 16px;
    margin-top: 20px;
}*/

.dialog-item {
    margin: 10px 0;
    padding: 8px 12px;
    border-radius: 8px;
    max-width: 80%;
    clear: both;
}

    /* 用户提问样式（右对齐，蓝色） */
    .dialog-item.user {
        /*background-color: #007bff;*/
        background-color: #358fef;
        color: white;
        float: right;
    }

    /* 机器人回答样式（左对齐，灰色） */
    .dialog-item.bot {
        background-color: #f0f0f0;
        color: #333;
        float: left;
    }

    /* 系统消息样式（居中，浅灰色） */
    .dialog-item.system {
        background-color: #e9ecef;
        color: #666;
        float: none;
        margin: 8px auto;
        text-align: center;
        max-width: 60%;
    }

/* 角色标签 */
.role-label {
    font-weight: bold;
    /*margin-bottom: 4px;*/
    font-size: 0.9em;
}

.dialog-item.user .role-label {
    color: #1976d2;
}

.dialog-item.bot .role-label {
    color: #43a047;
}

.dialog-item.system .role-label {
    color: #757575;
}

.content {
    word-wrap: break-word;
    line-height: 1.4;
}

/*.dialog-item .content {
    white-space: pre-wrap;*/ /* 保留换行符，让合并的消息自动换行 */
/*word-wrap: break-word;
    line-height: 1.4;
}*/
/* 先添加CSS样式，解决背景跳动问题 */
.dialog-item .content {
    min-width: 120px; /* 最小宽度，防止收缩 */
    min-height: 30px; /* 最小高度，防止跳动 */
    white-space: pre-wrap; /* 保留换行符，排版更稳定 */
    padding: 3px 12px;
    border-radius: 8px;
    transition: all 0.2s ease; /* 平滑过渡尺寸变化 */
    word-wrap: break-word;
    line-height: 1.4;
}




/* 时间样式 */
.time {
    font-size: 0.8em;
    color: #9e9e9e;
    opacity: 0.7;
    margin-top: 4px;
    text-align: right;
}




/* 对话状态提示 */
/*.dialog-status {
    display: none;*/ /* 初始隐藏 */
/*font-size: 18px;
    color: #624aff;
    margin: 10px 0;
    text-align: center;
}*/

/* 音频播放器和错误提示 */
.audio-player {
    display: none;
    width: 100%;
    max-width: 90vw;
    margin-top: 10px;
}

.audio-worklet-error {
    display: none;
    color: #ff4d4f;
    padding: 10px;
    margin: 10px 0;
    background: #fff2f0;
    border-radius: 4px;
    font-size: 16px;
    max-width: 90vw;
}

/* 适配1080×1920竖屏 */
/*@media screen and (width: 1080px) and (height: 1920px) {
    .character-wrapper {
        width: 51%;
        height: 82%;
    }

    .dialog-history {
        height: 80%;
    }

    .start-btn {
        font-size: 29px;
        padding: 25px 45px;
    }

    .dialog-status {
        font-size: 20px;
    }
}*/
