/* 基础样式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    height: 100vh;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

/* 聊天容器 */
.chat-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 100%;
    margin: 0 auto;
    background: #fff;
    position: relative;
}

/* 顶部标题栏 */
.chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px 16px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    position: relative;
}

.chat-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: env(safe-area-inset-top, 20px);
    background: inherit;
}

.chat-header h1 {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: #4ade80;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* 语音主界面区域 */
.voice-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: #f8fafc;
    padding: 40px 20px;
    position: relative;
}

/* 录音状态 */
.recording-status {
    display: none;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    padding: 30px;
    background: rgba(102, 126, 234, 0.1);
    border-radius: 20px;
    margin-bottom: 40px;
    animation: fadeIn 0.3s ease;
    position: absolute;
    top: 20%;
    left: 50%;
    transform: translateX(-50%);
    min-width: 200px;
    z-index: 10;
}

.recording-status.active {
    display: flex;
}

/* 语音按钮居中显示 */
.voice-main .voice-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: white;
    padding: 24px 32px;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    font-size: 18px;
    font-weight: 600;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    position: relative;
    overflow: hidden;
    box-shadow: 0 8px 24px rgba(102, 126, 234, 0.3);
    min-width: 160px;
    min-height: 160px;
    justify-content: center;
}

.recording-animation {
    display: flex;
    gap: 4px;
    margin-bottom: 8px;
}

.wave {
    width: 4px;
    height: 20px;
    background: #667eea;
    border-radius: 2px;
    animation: wave 1s ease-in-out infinite;
}

.wave:nth-child(2) {
    animation-delay: 0.1s;
}

.wave:nth-child(3) {
    animation-delay: 0.2s;
}

@keyframes wave {
    0%, 100% { height: 20px; }
    50% { height: 30px; }
}

.recording-text {
    font-size: 16px;
    font-weight: 600;
    color: #667eea;
    margin-bottom: 4px;
}

.recording-hint {
    font-size: 12px;
    color: #6b7280;
}

/* 语音按钮悬停和激活效果 */
.voice-main .voice-btn:hover {
    background: linear-gradient(135deg, #5a67d8 0%, #6b46c1 100%);
    box-shadow: 0 12px 32px rgba(102, 126, 234, 0.4);
    transform: translateY(-2px);
}

.voice-main .voice-btn:active {
    transform: translateY(0) scale(0.98);
    background: linear-gradient(135deg, #5a67d8 0%, #6b46c1 100%);
}

.voice-main .voice-btn.recording {
    background: #ef4444;
    animation: recordingPulse 1s ease-in-out infinite;
    box-shadow: 0 0 30px rgba(239, 68, 68, 0.5);
    transform: scale(1.05);
}

.voice-main .voice-btn.recording .mic-icon {
    transform: scale(1.2);
    animation: bounce 0.6s ease-in-out infinite alternate;
}

@keyframes bounce {
    0% { transform: scale(1.2) translateY(0); }
    100% { transform: scale(1.2) translateY(-5px); }
}

.voice-main .voice-btn .mic-icon {
    transition: transform 0.3s ease;
}

.voice-main .voice-btn .voice-text {
    transition: all 0.3s ease;
    font-size: 16px;
}

.voice-main .voice-btn.recording .voice-text {
    transform: scale(1.1);
    color: rgba(255, 255, 255, 0.9);
}

/* 禁用状态 */
.voice-main .voice-btn:disabled {
    background: #d1d5db;
    cursor: not-allowed;
    opacity: 0.6;
    box-shadow: none;
}

.voice-main .voice-btn:disabled:hover {
    background: #d1d5db;
    box-shadow: none;
    transform: none;
}

/* 权限被拒绝状态 */
.voice-main .voice-btn.permission-denied {
    background: #fbbf24;
    color: #92400e;
}

.voice-main .voice-btn.permission-denied:hover {
    background: #f59e0b;
}

/* 加载动画 */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.loading-overlay.active {
    display: flex;
}

.loading-spinner {
    background: white;
    padding: 30px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e5e7eb;
    border-top: 3px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Toast 提示 */
.toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 16px 24px;
    border-radius: 8px;
    font-size: 14px;
    z-index: 1001;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    max-width: 80%;
    text-align: center;
    line-height: 1.4;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.toast.show {
    opacity: 1;
    visibility: visible;
}

.toast-message {
    display: block;
    word-wrap: break-word;
}

/* 权限引导 */
.permission-guide {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1002;
    padding: 20px;
}

.permission-guide.show {
    display: flex;
}

.guide-content {
    background: white;
    border-radius: 16px;
    padding: 32px 24px;
    max-width: 400px;
    width: 100%;
    text-align: center;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    animation: slideInUp 0.3s ease;
}

.guide-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.guide-content h3 {
    margin: 0 0 12px;
    font-size: 20px;
    color: #1f2937;
}

.guide-content p {
    margin: 0 0 24px;
    color: #6b7280;
    line-height: 1.5;
}

.guide-steps {
    text-align: left;
    margin-bottom: 24px;
}

.step {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
    padding: 12px;
    background: #f8fafc;
    border-radius: 8px;
}

.step-number {
    width: 24px;
    height: 24px;
    background: #667eea;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    margin-right: 12px;
    flex-shrink: 0;
}

.step span:last-child {
    font-size: 14px;
    color: #374151;
}

.guide-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.guide-btn {
    padding: 12px 24px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    background: white;
    color: #374151;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.guide-btn:hover {
    background: #f9fafb;
}

.guide-btn.primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-color: #667eea;
    color: white;
}

.guide-btn.primary:hover {
    background: linear-gradient(135deg, #5a67d8 0%, #6b46c1 100%);
}

/* 响应式设计 */
@media (max-width: 480px) {
    .chat-header {
        padding: 16px 12px 12px;
    }
    
    .voice-main {
        padding: 20px 16px;
    }
    
    .voice-main .voice-btn {
        min-width: 140px;
        min-height: 140px;
        padding: 20px 28px;
        font-size: 16px;
    }
    
    .recording-status {
        min-width: 180px;
        padding: 24px;
    }
}

/* 动画效果 */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.message {
    animation: slideInUp 0.3s ease;
}

/* 深色模式支持 */
@media (prefers-color-scheme: dark) {
    .chat-messages {
        background: #111827;
    }
    
    .bot-message .message-content {
        background: #374151;
        color: #f9fafb;
    }
    
    .text-input-wrapper {
        background: #374151;
    }
    
    #textInput {
        color: #f9fafb;
    }
    
    #textInput::placeholder {
        color: #6b7280;
    }
}
