* {
    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%);
    min-height: 100vh;
    overflow: hidden;
}

.app-container {
    display: flex;
    height: 100vh;
    position: relative;
}

/* 设置面板样式 */
.settings-panel {
    position: fixed;
    right: -400px;
    top: 0;
    width: 400px;
    height: 100vh;
    background: white;
    box-shadow: -2px 0 10px rgba(0,0,0,0.1);
    padding: 20px;
    transition: right 0.3s ease;
    z-index: 1000;
    overflow-y: auto;
}

.settings-panel.active {
    right: 0;
}

.settings-panel h3 {
    margin-bottom: 20px;
    color: #333;
    font-size: 24px;
}

.setting-group {
    margin-bottom: 25px;
}

.setting-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    color: #333;
}

.setting-group select {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    background-color: white;
    transition: border-color 0.3s ease;
}

.setting-group select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.setting-group textarea {
    width: 100%;
    min-height: 100px;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 8px;
    resize: vertical;
    font-family: inherit;
}

.setting-group input[type="file"] {
    margin: 10px 0;
}

.setting-group button {
    background: #667eea;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    margin-right: 10px;
    margin-top: 10px;
    transition: background 0.3s;
}

.setting-group button:hover {
    background: #5a6fd8;
}

.setting-group .btn {
    margin: 5px 0;
    width: 100%;
    padding: 10px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
}

.setting-group .btn-primary {
    background: #667eea;
    color: white;
}

.setting-group .btn-secondary {
    background: #6c757d;
    color: white;
}

.setting-group .btn-success {
    background: #28a745;
    color: white;
}

.setting-group .btn-info {
    background: #17a2b8;
    color: white;
}

.setting-group .btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.avatar-preview, .bg-preview {
    width: 80px;
    height: 80px;
    border: 2px dashed #ddd;
    border-radius: 8px;
    margin-top: 10px;
    object-fit: cover;
    background-size: cover;
    background-position: center;
    cursor: pointer;
    transition: border-color 0.3s;
}

.avatar-preview:hover, .bg-preview:hover {
    border-color: #667eea;
}

/* 图片裁剪模态框 */
.crop-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 2000;
    animation: fadeIn 0.3s ease;
}

.crop-modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.crop-modal-content {
    background: white;
    border-radius: 12px;
    padding: 20px;
    max-width: 90%;
    max-height: 90%;
    width: 600px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.crop-modal-content h3 {
    margin-bottom: 20px;
    color: #333;
    text-align: center;
}

.crop-container {
    max-height: 400px;
    margin-bottom: 20px;
    border: 1px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
}

.crop-container img {
    display: block;
    max-width: 100%;
    max-height: 400px;
}

.crop-controls {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.crop-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 5px;
}

.crop-btn:hover {
    transform: translateY(-1px);
}

.crop-btn.confirm {
    background: #667eea;
    color: white;
}

.crop-btn.confirm:hover {
    background: #5a6fd8;
}

.crop-btn.cancel {
    background: #f1f3f4;
    color: #333;
}

.crop-btn.cancel:hover {
    background: #e8eaed;
}

.crop-btn:not(.confirm):not(.cancel) {
    background: #fff;
    color: #667eea;
    border: 1px solid #667eea;
}

.crop-btn:not(.confirm):not(.cancel):hover {
    background: #f8f9ff;
}

/* 聊天容器样式 */
.chat-container {
    flex: 1;
    max-width: 800px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 90vh;
    margin-top: 5vh;
    min-height: 0;
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

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

.chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin-right: 12px;
    object-fit: cover;
}

.chat-title {
    font-size: 18px;
    font-weight: 600;
}

.settings-btn {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: background 0.3s;
}

.settings-btn:hover {
    background: rgba(255,255,255,0.2);
}

/* 消息区域样式 */
.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #f8f9fa;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
    min-height: 0;
}

.message {
    display: flex;
    margin-bottom: 15px;
    animation: fadeIn 0.3s ease;
}

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

.message-avatar {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    margin-right: 12px;
    object-fit: cover;
}

.message-content {
    max-width: 70%;
}

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

.user-message .message-avatar {
    margin-right: 0;
    margin-left: 12px;
}

.user-message .message-content {
    background: #667eea;
    color: white;
    margin-left: auto;
}

.ai-message .message-content {
    background: white;
    color: #333;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.message-text {
    padding: 12px 16px;
    border-radius: 18px;
    word-wrap: break-word;
    line-height: 1.5;
}

.message-text pre {
    background: #2d3748;
    color: #e2e8f0;
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 8px 0;
}

.message-text code {
    background: #f1f3f4;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.9em;
}

.message-text pre code {
    background: none;
    padding: 0;
}

.message-time {
    font-size: 12px;
    color: #888;
    margin-top: 4px;
    text-align: right;
}

/* 输入区域样式 */
.chat-input-container {
    padding: 20px;
    background: white;
    border-top: 1px solid #eee;
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 10px;
}

#messageInput {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 20px;
    padding: 12px 16px;
    font-family: inherit;
    resize: none;
    min-height: 40px;
    max-height: 120px;
    outline: none;
    transition: border-color 0.3s;
}

#messageInput:focus {
    border-color: #667eea;
}

.send-btn {
    background: #667eea;
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    transition: background 0.3s;
}

.send-btn:hover {
    background: #5a6fd8;
}

.input-actions {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.action-btn {
    background: #f8f9fa;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 8px 12px;
    cursor: pointer;
    transition: background 0.3s;
}

.action-btn:hover {
    background: #e9ecef;
}

/* 打字指示器 */
.typing-container {
    display: flex;
    align-items: flex-start;
    padding: 0 20px;
    margin-bottom: 15px;
}

.typing-indicator {
    display: flex;
    align-items: center;
    gap: 2px;
}

.typing-indicator span {
    width: 6px;
    height: 6px;
    background: #667eea;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }

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

/* 图片消息样式 */
.message-image {
    max-width: 100%;
    max-height: 300px;
    width: auto;
    height: auto;
    border-radius: 12px;
    margin-top: 8px;
    cursor: pointer;
    transition: transform 0.3s;
    object-fit: contain;
}

.message-image:hover {
    transform: scale(1.02);
}

/* 响应式设计 */
@media (max-width: 768px) {
    body {
        overflow: hidden;
    }
    
    .chat-container {
        height: 100vh;
        margin: 0;
        border-radius: 0;
        border: none;
    }
    
    .chat-header {
        padding: 12px 15px;
        min-height: 56px;
    }
    
    .chat-header h1 {
        font-size: 18px;
    }
    
    .settings-btn {
        padding: 8px;
        font-size: 14px;
    }
    
    /* 调整输入区域高度，防止被键盘遮挡 */
    .chat-input-container {
        padding: 8px 15px;
        display: block !important;
        visibility: visible !important;
        position: relative;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 100;
    }
    
    #messageInput {
        padding: 8px 14px;
        font-size: 16px;
        border-radius: 18px;
        min-height: 36px;
    }
    
    .send-btn {
        width: 36px;
        height: 36px;
    }
    }
    
    .settings-panel {
        width: 100%;
        right: -100%;
    }

    .settings-panel.active {
        right: 0;
    }

    .setting-group select {
        font-size: 16px; /* 防止iOS缩放 */
        padding: 14px 12px;
    }

    .crop-modal-content {
        width: 95%;
        margin: 10px;
        padding: 15px;
    }
    
    .crop-container {
        max-height: 300px;
    }
    
    .crop-controls {
        flex-direction: column;
        align-items: center;
        gap: 8px;
    }
    
    .crop-btn {
        padding: 8px 16px;
        font-size: 13px;
    }
    
    .chat-messages {
        padding: 10px;
    }
    
    .message-content {
        max-width: 90%;
    }
    
    .message-text {
        padding: 10px 14px;
        font-size: 15px;
        line-height: 1.4;
    }
    
    .message-avatar {
        width: 32px;
        height: 32px;
    }
    
    .chat-input-container {
        padding: 12px 15px;
    }
    
    #messageInput {
        padding: 10px 14px;
        font-size: 16px;
        border-radius: 18px;
    }
    
    .send-btn {
        width: 36px;
        height: 36px;
    }
    
    .input-actions {
        gap: 8px;
    }
    
    .action-btn {
        padding: 6px 10px;
        font-size: 12px;
    }
    
    .message-image {
        max-width: 150px;
        max-height: 150px;
    }


@media (max-width: 480px) {
    .message-content {
        max-width: 95%;
    }
    
    .user-message .message-content {
        margin-left: 8px;
    }
    
    .ai-message .message-content {
        margin-right: 8px;
    }
}

/* 触摸优化 */
@media (hover: none) and (pointer: coarse) {
    .send-btn:hover,
    .action-btn:hover,
    .settings-btn:hover,
    .crop-btn:hover {
        transform: none;
    }
    
    .send-btn:active,
    .action-btn:active,
    .settings-btn:active,
    .crop-btn:active {
        transform: scale(0.95);
    }
}

/* 防止iOS缩放 */
input[type="text"],
textarea {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

/* 聊天区域背景样式 */
#chatMessages {
    background-color: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: all 0.3s ease;
}

#chatMessages[style*="background-image"] {
    background-color: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

/* 危险按钮样式 */
.danger-btn {
    background: #e74c3c;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    margin-right: 10px;
    margin-top: 10px;
    transition: background 0.3s;
    font-size: 14px;
}

.danger-btn:hover {
    background: #c0392b;
}

/* 确认对话框样式 */
.confirm-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 3000;
    animation: fadeIn 0.3s ease;
}

.confirm-modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.confirm-modal-content {
    background: white;
    border-radius: 12px;
    padding: 30px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    animation: slideIn 0.3s ease;
}

.confirm-modal-content h3 {
    margin-bottom: 15px;
    color: #333;
    font-size: 20px;
    text-align: center;
}

.confirm-modal-content p {
    margin-bottom: 25px;
    color: #666;
    text-align: center;
    line-height: 1.5;
}

.confirm-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.confirm-btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.3s;
    min-width: 100px;
}

.confirm-btn.cancel {
    background: #f1f3f4;
    color: #333;
}

.confirm-btn.cancel:hover {
    background: #e8eaed;
}

.confirm-btn.confirm {
    background: #e74c3c;
    color: white;
}

.confirm-btn.confirm:hover {
    background: #c0392b;
}

@keyframes slideIn {
    from {
        transform: translateY(-20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* 移动端确认对话框适配 */
@media (max-width: 768px) {
    .confirm-modal-content {
        margin: 20px;
        padding: 20px;
    }
    
    .confirm-btn {
        padding: 10px 20px;
        font-size: 14px;
    }
}

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

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

.chat-messages::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}