/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    height: 100vh;
    overflow: hidden;
}

.container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 800px;
    margin: 0 auto;
    background: white;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
}

/* 头部样式 */
.header {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: white;
    padding: 1rem;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.avatar {
    font-size: 2rem;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.header h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

/* 聊天容器 */
.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    background: #f8fafc;
}

.messages {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-width: 100%;
}

/* 消息样式 */
.message {
    display: flex;
    gap: 0.75rem;
    max-width: 80%;
    animation: slideIn 0.3s ease-out;
}

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

.message-avatar {
    font-size: 1.5rem;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.bot-message .message-avatar {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
}

.user-message .message-avatar {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.message-content {
    flex: 1;
}

.message-text {
    background: white;
    padding: 0.75rem 1rem;
    border-radius: 1rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    word-wrap: break-word;
    line-height: 1.6;
    white-space: pre-wrap; /* 保留换行和空格 */
    max-width: 100%;
    overflow-wrap: break-word;
}

.user-message .message-text {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
}

.message-image {
    max-width: 200px;
    border-radius: 0.5rem;
    margin-top: 0.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* 输入区域 */
.input-area {
    background: white;
    border-top: 1px solid #e2e8f0;
    padding: 1rem;
}

.input-container {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
}

.text-input-wrapper {
    flex: 1;
}

.text-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid #e2e8f0;
    border-radius: 1.5rem;
    font-size: 1rem;
    outline: none;
    transition: all 0.2s ease;
    resize: none;
    min-height: 44px;
    max-height: 120px;
}

.text-input:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.action-buttons {
    display: flex;
    gap: 0.5rem;
}

.action-btn {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    color: white;
}

.voice-btn {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
}

.voice-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.voice-btn.recording {
    animation: pulse 1s infinite;
}

.camera-btn {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
}

.camera-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.send-btn {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.send-btn:disabled {
    background: #9ca3af;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* 语音录制指示器 */
.voice-indicator {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 2rem;
    border-radius: 1rem;
    text-align: center;
    z-index: 1000;
}

.voice-animation {
    display: flex;
    justify-content: center;
    gap: 0.25rem;
    margin-bottom: 1rem;
}

.wave {
    width: 4px;
    height: 20px;
    background: #ef4444;
    border-radius: 2px;
    animation: wave 1s infinite ease-in-out;
}

.wave:nth-child(2) {
    animation-delay: 0.1s;
}

.wave:nth-child(3) {
    animation-delay: 0.2s;
}

.stop-voice-btn {
    background: #ef4444;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    cursor: pointer;
    margin-top: 1rem;
}

/* 相机模态框 */
.camera-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.camera-content {
    background: white;
    border-radius: 1rem;
    padding: 1rem;
    max-width: 90%;
    max-height: 90%;
}

#cameraVideo {
    width: 100%;
    max-width: 400px;
    border-radius: 0.5rem;
}

.camera-controls {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 1rem;
}

.capture-btn, .close-camera-btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    font-weight: 600;
}

.capture-btn {
    background: #10b981;
    color: white;
}

.close-camera-btn {
    background: #6b7280;
    color: white;
}

/* 图片预览 */
.image-preview {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.preview-content {
    background: white;
    border-radius: 1rem;
    padding: 1rem;
    max-width: 90%;
    max-height: 90%;
    text-align: center;
}

#previewImage {
    max-width: 100%;
    max-height: 400px;
    border-radius: 0.5rem;
}

.preview-controls {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 1rem;
    flex-wrap: wrap;
}

.send-image-btn, .retake-btn, .cancel-image-btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    font-weight: 600;
}

.send-image-btn {
    background: #10b981;
    color: white;
}

.retake-btn {
    background: #3b82f6;
    color: white;
}

.cancel-image-btn {
    background: #6b7280;
    color: white;
}

/* 加载指示器 */
.loading-indicator {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 2rem;
    border-radius: 1rem;
    text-align: center;
    z-index: 1000;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

/* 工具类 */
.hidden {
    display: none !important;
}

/* 动画 */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

@keyframes wave {
    0%, 40%, 100% {
        transform: scaleY(0.4);
    }
    20% {
        transform: scaleY(1);
    }
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        height: 100vh;
        border-radius: 0;
    }
    
    .message {
        max-width: 90%;
    }
    
    .input-container {
        gap: 0.5rem;
    }
    
    .action-btn {
        width: 40px;
        height: 40px;
    }
    
    .preview-controls {
        flex-direction: column;
        align-items: center;
    }
    
    .send-image-btn, .retake-btn, .cancel-image-btn {
        width: 100%;
        max-width: 200px;
    }
}

@media (max-width: 480px) {
    .header {
        padding: 0.75rem;
    }
    
    .header h1 {
        font-size: 1.25rem;
    }
    
    .avatar {
        width: 40px;
        height: 40px;
        font-size: 1.5rem;
    }
    
    .chat-container {
        padding: 0.75rem;
    }
    
    .input-area {
        padding: 0.75rem;
    }
}
