/* 对话页样式 - 移动端 */

/* 页面包装 */
.page-wrapper {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* 移动端头部 */
.chat-header-mobile {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.5);
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.btn-back {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.8);
    color: var(--text-main);
    transition: all 0.3s ease;
}

.btn-back:active {
    background: rgba(5, 175, 181, 0.1);
}

.current-agent {
    display: flex;
    align-items: center;
    gap: 10px;
}

.agent-avatar.small {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    background: linear-gradient(135deg, var(--current-primary) 0%, var(--current-light) 100%);
    color: white;
}

.agent-info {
    display: flex;
    flex-direction: column;
}

.agent-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--current-accent);
}

.agent-status {
    font-size: 11px;
    color: #4CAF50;
}

.agent-status::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #4CAF50;
    margin-right: 4px;
}

.btn-clear-mobile {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: none;
    background: rgba(255, 255, 255, 0.8);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.btn-clear-mobile:active {
    background: rgba(255, 100, 100, 0.2);
    color: #ff6b6b;
}

/* 头部右侧按钮组 */
.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* 转接人工按钮 */
.btn人工 {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--current-primary) 0%, var(--current-light) 100%);
    color: white;
    font-size: 12px;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.3s ease;
}

.btn人工:active {
    transform: scale(0.95);
}

.btn人工 svg {
    flex-shrink: 0;
}

/* 消息列表 */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 70px 16px 80px 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* 消息气泡 */
.message {
    display: flex;
    gap: 16px;
    max-width: 85%;
}

.message-user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message-ai {
    align-self: flex-start;
}

.message-avatar {
    flex-shrink: 0;
}

.message-content {
    border-radius: 20px;
    line-height: 1.5;
    font-size: 14px;
    word-wrap: break-word;
    word-break: break-word;
    overflow-wrap: break-word;
    white-space: normal;
}

.message-user .message-content {
    background: linear-gradient(135deg, var(--current-primary) 0%, var(--current-light) 100%);
    color: white;
    border-bottom-right-radius: 6px;
    padding: 1px 6px 1px 6px;
}

.message-ai .message-content {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: var(--text-main);
    border-bottom-left-radius: 6px;
    padding: 1px 6px 1px 6px;
}

/* 打字机和markdown显示 */
.typing-content {
    display: block;
    margin: 0;
}

.rendered-content {
    display: none;
    margin: 0;
}

.rendered-content p {
    margin: 0 0 8px 0;
}

.rendered-content p:last-child {
    margin-bottom: 0;
}

/* 加载动画 */
.message-loading {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 18px;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    border-bottom-left-radius: 4px;
}

.loading-dots {
    display: flex;
    gap: 4px;
}

.loading-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--current-primary);
    animation: loadingBounce 1.4s infinite ease-in-out both;
}

.loading-dots span:nth-child(1) {
    animation-delay: -0.32s;
}

.loading-dots span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes loadingBounce {
    0%, 80%, 100% {
        transform: scale(0);
    }
    40% {
        transform: scale(1);
    }
}

.loading-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.loading-text {
    color: #888;
    font-size: 14px;
}

/* 底部输入区域包装器 */
.input-bottom-wrapper {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    flex-direction: column;
}

/* Agent选择栏 */
.agent-selector {
    position: relative;
    background: rgba(255, 255, 255, 0.65);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    padding: 10px 0;
    border-top: 1px solid rgba(255, 255, 255, 0.45);
    z-index: 99;
    box-shadow:
        0 -4px 24px rgba(0, 0, 0, 0.06),
        0 -1px 2px rgba(0, 0, 0, 0.04),
        inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.agent-scroll {
    display: flex;
    gap: 10px;
    padding: 0 16px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.agent-scroll::-webkit-scrollbar {
    display: none;
}

.agent-chip {
    flex-shrink: 0;
    padding: 8px 16px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(200, 200, 200, 0.3);
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
}

.agent-chip:active {
    transform: scale(0.95);
}

.agent-chip.active {
    background: linear-gradient(135deg, var(--current-primary) 0%, var(--current-light) 100%);
    color: white;
    border-color: transparent;
    box-shadow: 0 4px 12px rgba(5, 175, 181, 0.3);
}

/* 输入区域 */
.chat-input-area-mobile {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(255, 255, 255, 0.5);
    z-index: 100;
}

.btn-voice {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: none;
    background: rgba(255, 255, 255, 0.8);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.btn-voice:active {
    background: rgba(5, 175, 181, 0.1);
    color: var(--current-primary);
}

.btn-voice.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* 语音模式激活 */
.chat-input-area-mobile.voice-mode .btn-voice {
    background: linear-gradient(135deg, var(--current-primary) 0%, var(--current-light) 100%);
    color: white;
    animation: voicePulse 1.5s ease-in-out infinite;
}

.chat-input-area-mobile.voice-mode .btn-voice svg {
    display: none;
}

.chat-input-area-mobile.voice-mode .btn-voice::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: white;
    animation: voiceIconPulse 1s ease-in-out infinite;
}

@keyframes voicePulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(5, 175, 181, 0.4);
    }
    50% {
        box-shadow: 0 0 0 10px rgba(5, 175, 181, 0);
    }
}

@keyframes voiceIconPulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(0.8);
    }
}

/* 按住说话状态 */
.chat-input-mobile.voice-active {
    display: none;
}

.voice-hint {
    display: none;
    flex: 1;
    height: 40px;
    border-radius: 20px;
    background: linear-gradient(135deg, var(--current-primary) 0%, var(--current-light) 100%);
    color: white;
    font-size: 15px;
    font-weight: 500;
    align-items: center;
    justify-content: center;
    text-align: center;
    box-shadow: 0 4px 16px rgba(5, 175, 181, 0.3);
    user-select: none;
    -webkit-user-select: none;
}

.chat-input-area-mobile.voice-mode .voice-hint {
    display: flex;
    animation: hintAppear 0.3s ease;
}

.chat-input-area-mobile.voice-mode .btn-send-mobile {
    display: none;
}

@keyframes hintAppear {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.input-wrapper-mobile {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
}

.chat-input-mobile {
    width: 100%;
    padding: 10px 14px;
    border-radius: 20px;
    border: 2px solid rgba(200, 200, 200, 0.3);
    background: rgba(255, 255, 255, 0.9);
    font-size: 14px;
    line-height: 1.4;
    resize: none;
    outline: none;
    transition: all 0.3s ease;
    max-height: 120px;
    min-height: 40px;
    box-sizing: border-box;
}

.chat-input-mobile:focus {
    border-color: var(--current-primary);
    background: white;
}

.chat-input-mobile::placeholder {
    color: var(--text-muted);
}

.btn-send-mobile {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: none;
    background: linear-gradient(135deg, var(--current-primary) 0%, var(--current-light) 100%);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.btn-send-mobile:active {
    transform: scale(0.95);
}

/* 滚动条美化 */
.chat-messages::-webkit-scrollbar {
    width: 4px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--current-light);
    border-radius: 2px;
}

/* 版权信息 - 移动端 */
.copyright {
    padding: 8px 16px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
    text-align: center;
    background: rgba(255, 255, 255, 0.65);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border-top: 1px solid rgba(255, 255, 255, 0.45);
}

.copyright p {
    font-size: 11px;
    color: #234C4F;
    line-height: 1.4;
    margin: 0;
}
