/* ========================================
   数字人 SaaS 系统 - 前台样式 (优化版)
   ======================================== */

:root {
    /* 主色调 - 渐变紫蓝 */
    --primary: #6366f1;
    --primary-light: #818cf8;
    --primary-dark: #4f46e5;
    --secondary: #8b5cf6;
    
    /* 功能色 */
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #06b6d4;
    
    /* 背景色 */
    --bg-base: #0c0a1d;
    --bg-surface: #151328;
    --bg-elevated: #1e1b3a;
    --bg-card: rgba(255, 255, 255, 0.03);
    --bg-hover: rgba(255, 255, 255, 0.06);
    
    /* 文字色 */
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    /* 边框 */
    --border: rgba(255, 255, 255, 0.08);
    --border-light: rgba(255, 255, 255, 0.12);
    
    /* 阴影 */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.25);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.45);
    --shadow-glow: 0 0 30px rgba(99, 102, 241, 0.3);
    
    /* 圆角 */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;
    
    /* 动画 */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 400ms ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Hiragino Sans GB', 
                 'Microsoft YaHei', 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-base);
    -webkit-font-smoothing: antialiased;
}

/* ======== 应用包装器 ======== */
.app-wrapper {
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(ellipse at 20% 80%, rgba(139, 92, 246, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(99, 102, 241, 0.08) 0%, transparent 50%),
        var(--bg-base);
}

/* ======== 主容器 ======== */
.live-chat-container {
    display: flex;
    width: 100%;
    height: 100%;
    max-width: 1600px;
    margin: 0 auto;
}

/* ======== 数字人区域 ======== */
.avatar-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 40px;
    background: transparent;
}

.avatar-background {
    position: absolute;
    inset: 0;
    background: 
        radial-gradient(circle at 50% 50%, rgba(99, 102, 241, 0.06) 0%, transparent 60%);
    pointer-events: none;
}

.live2d-canvas {
    max-width: 100%;
    max-height: 70vh;
    position: relative;
    z-index: 1;
}

/* 动态头像 Canvas */
.avatar-canvas {
    width: 100%;
    height: 100%;
    max-height: 70vh;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1;
}

/* 默认头像（Live2D未加载时显示） */
.default-avatar {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 2;
}

.default-avatar .avatar-circle {
    width: 180px;
    height: 180px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 72px;
    color: white;
    box-shadow: var(--shadow-glow), var(--shadow-lg);
    animation: float 3s ease-in-out infinite;
}

.default-avatar .avatar-hint {
    margin-top: 20px;
    color: var(--text-muted);
    font-size: 14px;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

/* 状态指示器 */
.status-indicator {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 24px;
    background: var(--bg-elevated);
    backdrop-filter: blur(20px);
    border-radius: var(--radius-full);
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-md);
    z-index: 10;
    transition: var(--transition-normal);
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: var(--transition-normal);
}

.status-indicator.connecting .status-dot { 
    background: var(--warning);
    animation: blink 1s infinite;
}
.status-indicator.connected .status-dot { 
    background: var(--success); 
    box-shadow: 0 0 10px var(--success);
}
.status-indicator.disconnected .status-dot { background: var(--danger); }
.status-indicator.recording .status-dot { 
    background: var(--danger);
    animation: pulse 1s infinite;
}
.status-indicator.processing .status-dot { 
    background: var(--primary);
    animation: pulse 1s infinite;
}
.status-indicator.speaking .status-dot { 
    background: var(--info);
    animation: pulse 0.5s infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.4); opacity: 0.6; }
}

.status-text {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

/* 字幕覆盖层 */
.subtitle-overlay {
    position: absolute;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    max-width: 600px;
    padding: 16px 28px;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(10px);
    border-radius: var(--radius-lg);
    font-size: 18px;
    line-height: 1.6;
    color: white;
    text-align: center;
    z-index: 20;
    animation: fadeInUp 0.3s ease;
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateX(-50%) translateY(20px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ======== 聊天区域 ======== */
.chat-section {
    width: 440px;
    display: flex;
    flex-direction: column;
    background: var(--bg-surface);
    border-left: 1px solid var(--border);
    box-shadow: -10px 0 40px rgba(0, 0, 0, 0.3);
}

/* 聊天头部 */
.chat-header {
    padding: 20px 24px;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.avatar-small {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: white;
    box-shadow: var(--shadow-glow);
}

.header-info h2 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.header-status {
    font-size: 12px;
    color: var(--success);
    display: flex;
    align-items: center;
    gap: 6px;
}

.header-status::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--success);
}

.header-actions {
    display: flex;
    gap: 8px;
}

.action-btn {
    width: 38px;
    height: 38px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
    text-decoration: none;
}

.action-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* ======== 消息列表 ======== */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    scroll-behavior: smooth;
}

/* 欢迎消息 */
.welcome-message {
    text-align: center;
    padding: 60px 30px;
}

.welcome-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 24px;
    border-radius: var(--radius-xl);
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    color: white;
    box-shadow: var(--shadow-glow);
}

.welcome-message h3 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 10px;
}

.welcome-message p {
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.welcome-tips {
    display: flex;
    justify-content: center;
    gap: 24px;
    flex-wrap: wrap;
}

.welcome-tips span {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--bg-card);
    border-radius: var(--radius-full);
    font-size: 13px;
    color: var(--text-secondary);
}

.welcome-tips span i {
    color: var(--primary-light);
}

/* 消息样式 */
.message {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    animation: messageIn 0.3s ease;
}

@keyframes messageIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

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

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
}

.message.user .message-avatar {
    background: var(--bg-elevated);
    color: var(--text-secondary);
}

.message-content {
    max-width: 75%;
    display: flex;
    flex-direction: column;
}

.message.user .message-content {
    align-items: flex-end;
}

.message-bubble {
    padding: 14px 18px;
    border-radius: var(--radius-lg);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
}

.message-bubble p {
    font-size: 14px;
    line-height: 1.7;
    color: var(--text-primary);
    word-break: break-word;
}

.message.user .message-bubble {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border: none;
}

.message.user .message-bubble p {
    color: white;
}

.message-time {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 6px;
    padding: 0 4px;
}

/* ======== 输入区域 ======== */
.chat-input-area {
    padding: 20px 24px;
    background: var(--bg-elevated);
    border-top: 1px solid var(--border);
}

.input-tips {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
    padding: 0 4px;
    font-size: 12px;
    color: var(--text-muted);
}

.input-tips i {
    color: var(--text-secondary);
}

.input-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px;
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    transition: var(--transition-fast);
}

.input-wrapper:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.input-wrapper input {
    flex: 1;
    padding: 12px 8px;
    background: transparent;
    border: none;
    outline: none;
    font-size: 14px;
    color: var(--text-primary);
}

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

/* 语音按钮 */
.voice-btn {
    width: 48px;
    height: 48px;
    border: none;
    border-radius: var(--radius-md);
    background: var(--bg-hover);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: var(--transition-fast);
}

.voice-btn:hover {
    background: rgba(99, 102, 241, 0.15);
    color: var(--primary-light);
}

.voice-btn.recording {
    background: var(--danger);
    color: white;
    animation: recording-pulse 1.5s infinite;
}

@keyframes recording-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    50% { box-shadow: 0 0 0 12px rgba(239, 68, 68, 0); }
}

.voice-btn .mic-icon {
    font-size: 18px;
    transition: var(--transition-fast);
}

.recording-wave {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
}

.recording-wave span {
    width: 3px;
    height: 18px;
    background: white;
    border-radius: 2px;
    animation: wave 0.8s ease-in-out infinite;
}

.recording-wave span:nth-child(1) { animation-delay: 0s; }
.recording-wave span:nth-child(2) { animation-delay: 0.1s; height: 14px; }
.recording-wave span:nth-child(3) { animation-delay: 0.2s; }
.recording-wave span:nth-child(4) { animation-delay: 0.3s; height: 14px; }
.recording-wave span:nth-child(5) { animation-delay: 0.4s; }

@keyframes wave {
    0%, 100% { height: 8px; }
    50% { height: 22px; }
}

/* 发送按钮 */
.send-btn {
    width: 48px;
    height: 48px;
    border: none;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: var(--transition-fast);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.send-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}

.send-btn:active {
    transform: translateY(0);
}

/* ======== 滚动条 ======== */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

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

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

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ======== 响应式 ======== */
@media (max-width: 1024px) {
    .live-chat-container {
        flex-direction: column;
    }
    
    .avatar-section {
        height: 45vh;
        padding: 20px;
    }
    
    .chat-section {
        width: 100%;
        height: 55vh;
        border-left: none;
        border-top: 1px solid var(--border);
        box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.3);
    }
    
    .status-indicator {
        bottom: 20px;
    }
}

@media (max-width: 480px) {
    .chat-header {
        padding: 16px;
    }
    
    .chat-messages {
        padding: 16px;
    }
    
    .chat-input-area {
        padding: 16px;
    }
    
    .message-content {
        max-width: 85%;
    }
    
    .welcome-tips {
        flex-direction: column;
        align-items: center;
    }
}

/* ======== 录音状态动画 ======== */
.recording-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: var(--danger);
    border-radius: 50%;
    margin-right: 8px;
    animation: recordingPulse 1s ease-in-out infinite;
}

@keyframes recordingPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(1.2); }
}

/* ======== Font Awesome 旋转动画增强 ======== */
.fa-spin {
    animation: fa-spin 1s linear infinite;
}

@keyframes fa-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}
