/* 聊天界面专属样式 */
.chat-container {
    max-width: 800px;
    margin: 20px auto;
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    padding: 10px 20px;
    height: 80vh; /* 固定高度 */
    display: flex;
    flex-direction: column;
    overflow: hidden; /* 防止内容溢出 */
}

/* 模式切换按钮样式 */
.chat-mode-switch {
    display: flex;
    justify-content: center;
    margin-bottom: 10px;
}

.switch-wrapper {
    position: relative;
    width: 200px;
    -webkit-tap-highlight-color: transparent; /* 禁用 iOS 触摸高亮 */
    -webkit-touch-callout: none; /* 禁用长按菜单 */
    user-select: none; /* 禁用文本选择 */
}

.mode-checkbox {
    display: none;
}

.mode-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent; /* 禁用 iOS 触摸高亮 */
}

.mode-toggle {
    width: 150px;
    height: 40px;
    background: #e8e8e8;
    border-radius: 20px;
    padding: 4px;
    position: relative;
    transition: all 0.3s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.mode-toggle::before {
    content: '';
    position: absolute;
    width: 70px;
    height: 32px;
    border-radius: 16px;
    background: #f5b048; /* 修改为主题色 */
    left: 4px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.mode-option {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 70px;
    height: 32px;
    z-index: 1;
    transition: all 0.3s ease;
}

.mode-option i {
    font-size: 20px;
    margin-right: 6px;
    color: #f5b048;
}

.mode-option span {
    font-size: 20px;
    color: #666;
    transition: all 0.3s ease;
}

/* 未选中时，左侧（文本模式）图标和文字为白色 */
.mode-checkbox:not(:checked) + .mode-label .text-option i,
.mode-checkbox:not(:checked) + .mode-label .text-option span {
    color: white;
    font-weight: 500;
}

/* 选中时，右侧（语音模式）图标和文字为白色 */
.mode-checkbox:checked + .mode-label .voice-option i,
.mode-checkbox:checked + .mode-label .voice-option span {
    color: white;
    font-weight: 500;
}

.mode-checkbox:checked + .mode-label .mode-toggle::before {
    transform: translateX(72px);
}

/* 删除不再需要的样式 */
.mode-text {
    display: none;
}

/* 适配移动端 */
@media (max-width: 768px) {
    .switch-wrapper {
        width: 180px;
    }
    
    .mode-toggle {
        width: 100px;
        height: 36px;
    }
    
    .mode-toggle::before {
        width: 45px;
        height: 28px;
        border-radius: 14px;
    }
    
    .mode-option {
        width: 45px;
        height: 28px;
    }
    
    .mode-option i {
        font-size: 18px;
        margin-right: 4px;
    }
    
    .mode-option span {
        font-size: 12px;
    }
    
    .mode-checkbox:checked + .mode-label .mode-toggle::before {
        transform: translateX(48px);
    }
}

/* 聊天模式容器样式 */
.chat-mode {
    display: none;
    flex: 1;
    flex-direction: column;
    overflow: hidden; /* 防止内容溢出 */
    min-height: 0; /* 确保flex布局正常工作 */
}

.chat-mode.active {
    display: flex;
}

#voiceMode {
    height: 100%;
    overflow: hidden;
}

#voiceMode iframe {
    flex: 1;
    min-height: 0;
    width: 100%;
    height: 100%;
}

.chat-messages {
    flex: 1;
    overflow-y: auto; /* 允许内容滚动 */
    padding: 15px;
    background: var(--light-color);
    border-radius: 8px;
    margin-bottom: 10px;
    min-height: 0; /* 确保flex布局正常工作 */
}

.message {
    margin: 10px 0;
    padding: 12px 16px;
    border-radius: 15px;
    max-width: 90%;
    width: fit-content;
    word-wrap: break-word;
    word-break: break-word;
    display: inline-block;
    white-space: pre-wrap;
    font-size: 14px;
    font-weight: 400;
}

.user-message {
    background: #f5b048;
    color: white;
    margin-left: auto;
    float: right;
    clear: both;
}

.bot-message {
    font-family: PingFang SC;
    background: #e8e8e8;
    margin-right: auto;
    float: left;
    clear: both;
}

.chat-input {
    display: flex;
    gap: 10px;
    clear: both;
}

#messageInput {
    flex: 1;
    padding: 12px;
    border: 2px solid var(--secondary-color);
    border-radius: 25px;
    font-size: 16px;
    outline: none;
    min-width: 50px;
}

#sendButton {
    background: var(--accent-color);
    color: white;
    border: none;
    padding: 12px 25px;
    border-radius: 25px;
    cursor: pointer;
    transition: background 0.3s;
    display: flex;
    align-items: center;
    gap: 8px;
}

#sendButton:hover {
    background: #f5b048;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .chat-container {
        /* margin: 10px; */
        height: 75vh; /* 移动端稍微降低高度 */
    }
    
    .mode-btn {
        padding: 6px 12px;
        font-size: 12px;
    }
    
    .mode-btn i {
        font-size: 14px;
    }

    .fa-microphone:before {
        padding-left: 5px;
    }
}

/* 添加图标活动和非活动状态的样式 */
.icon-active, .icon-inactive {
    width: 20px;
    height: 20px;
    transition: opacity 0.3s ease;
}

/* 默认状态下 */
.mode-option .icon-active {
    display: none;
}

.mode-option .icon-inactive {
    display: block;
}

/* 文本模式激活时 (默认) */
input.mode-checkbox:not(:checked) ~ .mode-label .text-option .icon-active {
    display: block;
}

input.mode-checkbox:not(:checked) ~ .mode-label .text-option .icon-inactive {
    display: none;
}

/* 语音模式激活时 */
input.mode-checkbox:checked ~ .mode-label .voice-option .icon-active {
    display: block;
}

input.mode-checkbox:checked ~ .mode-label .voice-option .icon-inactive {
    display: none;
} 