/* 全局样式 */
* {
    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%);
    color: #333;
    height: 100vh;
    overflow: hidden;
}

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

/* 侧边栏样式 */
.sidebar {
    width: 300px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-right: 1px solid rgba(255, 255, 255, 0.2);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.sidebar-header h2 {
    color: #4a5568;
    font-size: 1.2rem;
    margin-bottom: 15px;
}

.new-chat-btn {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.3s ease;
}

.new-chat-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);
}

.chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.history-item {
    padding: 12px;
    margin-bottom: 8px;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    border-left: 3px solid transparent;
}

.history-item:hover {
    background: rgba(102, 126, 234, 0.1);
    border-left-color: #667eea;
}

.history-item.active {
    background: rgba(102, 126, 234, 0.15);
    border-left-color: #667eea;
}

.history-title {
    font-weight: 500;
    color: #2d3748;
    font-size: 0.9rem;
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.history-time {
    font-size: 0.75rem;
    color: #718096;
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.user-stats {
    background: rgba(255, 255, 255, 0.7);
    padding: 15px;
    border-radius: 8px;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
}

.stat-item:last-child {
    margin-bottom: 0;
}

.stat-label {
    font-size: 0.8rem;
    color: #718096;
}

.stat-value {
    font-weight: 600;
    color: #2d3748;
    font-size: 0.8rem;
}

/* 主聊天区域 */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
}

.chat-header {
    padding: 20px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 15px;
}

.sidebar-toggle {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: #4a5568;
    padding: 8px;
    border-radius: 6px;
    transition: background-color 0.3s ease;
}

.sidebar-toggle:hover {
    background: rgba(0, 0, 0, 0.05);
}

#chatTitle {
    color: #2d3748;
    font-weight: 600;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.welcome-message {
    text-align: center;
    padding: 40px 20px;
    color: #4a5568;
}

.welcome-icon {
    font-size: 3rem;
    margin-bottom: 20px;
    color: #667eea;
}

.welcome-message h3 {
    margin-bottom: 10px;
    font-size: 1.5rem;
}

.welcome-message p {
    color: #718096;
    line-height: 1.6;
}

/* 使用指南样式 */
.usage-guide {
    margin: 20px auto;
    max-width: 800px;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.05) 0%, rgba(118, 75, 162, 0.05) 100%);
    border: 1px solid rgba(102, 126, 234, 0.2);
    border-radius: 12px;
    overflow: hidden;
    backdrop-filter: blur(10px);
}

.guide-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: rgba(102, 126, 234, 0.1);
    border-bottom: 1px solid rgba(102, 126, 234, 0.15);
    cursor: pointer;
    transition: all 0.3s ease;
}

.guide-header:hover {
    background: rgba(102, 126, 234, 0.15);
}

.guide-header h4 {
    margin: 0;
    color: #4c51bf;
    font-size: 1.1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.guide-toggle {
    background: none;
    border: none;
    color: #4c51bf;
    font-size: 1rem;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.guide-toggle.expanded {
    transform: rotate(180deg);
}

.guide-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

/* 移动端时使用不同的动画方式 */
@media (max-width: 768px) {
    .guide-content {
        transition: max-height 0.4s ease-out;
    }
    
    .guide-content.expanded {
        max-height: 2000px !important; /* 设置一个足够大的值 */
    }
}

.guide-content.expanded {
    max-height: none;
}

.guide-text {
    padding: 20px;
    color: #2d3748;
    line-height: 1.6;
}

.guide-text h5 {
    margin: 0 0 12px 0;
    color: #1a202c;
    font-size: 1.1rem;
    font-weight: 600;
}

.guide-text > p {
    margin: 0 0 16px 0;
    color: #4a5568;
}

.guide-section {
    margin: 16px 0;
    padding: 16px;
    background: rgba(255, 255, 255, 0.6);
    border-left: 4px solid #667eea;
    border-radius: 8px;
}

.guide-section h6 {
    margin: 0 0 8px 0;
    color: #2d3748;
    font-size: 0.95rem;
}

.guide-section p {
    margin: 0;
    color: #4a5568;
    font-size: 0.9rem;
    line-height: 1.5;
}

.guide-footer {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid rgba(102, 126, 234, 0.15);
}

.guide-footer p {
    margin: 8px 0;
    color: #2d3748;
}

.guide-cta {
    font-weight: 600;
    color: #4c51bf !important;
    font-size: 1rem !important;
}

.message {
    display: flex;
    margin-bottom: 20px;
}

.message.user {
    justify-content: flex-end;
}

.message.assistant {
    justify-content: flex-start;
}

.message-content {
    max-width: 70%;
    padding: 15px 20px;
    border-radius: 18px;
    position: relative;
    word-wrap: break-word;
    line-height: 1.5;
}

.message.user .message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-right-radius: 6px;
}

.message.assistant .message-content {
    background: #f7fafc;
    color: #2d3748;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 6px;
}

.message-time {
    font-size: 0.75rem;
    opacity: 0.7;
    margin-top: 8px;
}

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

.action-btn {
    background: none;
    border: 1px solid #e2e8f0;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.3s ease;
    color: #4a5568;
}

.action-btn:hover {
    background: #f7fafc;
    border-color: #cbd5e0;
}

.action-btn.rate-btn {
    color: #667eea;
    border-color: #667eea;
}

.action-btn.rate-btn:hover {
    background: rgba(102, 126, 234, 0.1);
}

.message-rating {
    margin-top: 10px;
    padding: 10px;
    background: rgba(102, 126, 234, 0.1);
    border-radius: 8px;
    font-size: 0.8rem;
}

.rating-stars-display {
    color: #fbbf24;
    margin-bottom: 5px;
}

.rating-comment {
    color: #4a5568;
    font-style: italic;
}

/* Markdown 样式 */
.message-text h1,
.message-text h2,
.message-text h3,
.message-text h4,
.message-text h5,
.message-text h6 {
    margin: 16px 0 8px 0;
    font-weight: 600;
    line-height: 1.2;
}

.message-text h1 { font-size: 1.5em; }
.message-text h2 { font-size: 1.3em; }
.message-text h3 { font-size: 1.2em; }
.message-text h4 { font-size: 1.1em; }
.message-text h5 { font-size: 1em; }
.message-text h6 { font-size: 0.9em; }

.message-text p {
    margin: 8px 0;
    line-height: 1.6;
}

.message-text ul,
.message-text ol {
    margin: 8px 0;
    padding-left: 24px;
}

.message-text li {
    margin: 4px 0;
    line-height: 1.5;
}

.message-text blockquote {
    margin: 12px 0;
    padding: 8px 16px;
    border-left: 4px solid #667eea;
    background: rgba(102, 126, 234, 0.05);
    font-style: italic;
}

.message-text code {
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    padding: 2px 6px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.85em;
    color: #e53e3e;
}

.message-text pre {
    margin: 12px 0;
    background: #1a202c;
    border-radius: 8px;
    overflow-x: auto;
    border: 1px solid #e2e8f0;
}

.message-text pre code {
    display: block;
    padding: 16px;
    background: transparent;
    border: none;
    color: #f7fafc;
    font-size: 0.9em;
    line-height: 1.5;
    overflow-x: auto;
}

.message-text table {
    border-collapse: collapse;
    margin: 12px 0;
    width: 100%;
    font-size: 0.9em;
}

.message-text table th,
.message-text table td {
    border: 1px solid #e2e8f0;
    padding: 8px 12px;
    text-align: left;
}

.message-text table th {
    background: #f7fafc;
    font-weight: 600;
}

.message-text a {
    color: #667eea;
    text-decoration: none;
}

.message-text a:hover {
    text-decoration: underline;
}

.message-text hr {
    border: none;
    border-top: 2px solid #e2e8f0;
    margin: 16px 0;
}

.message-text strong {
    font-weight: 600;
}

.message-text em {
    font-style: italic;
}

/* 输入区域 */
.chat-input-container {
    padding: 20px;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
}

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

#messageInput {
    flex: 1;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    padding: 12px 16px;
    font-size: 1rem;
    resize: none;
    outline: none;
    transition: all 0.3s ease;
    font-family: inherit;
    max-height: 120px;
    min-height: 48px;
}

#messageInput:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.send-btn {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-size: 1.1rem;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.send-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);
}

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

.input-footer {
    margin-top: 8px;
    text-align: right;
}

.char-counter {
    font-size: 0.75rem;
    color: #718096;
}

/* 模态框样式 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    color: #2d3748;
    font-weight: 600;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: #718096;
    padding: 4px;
    border-radius: 4px;
    transition: background-color 0.3s ease;
}

.close-btn:hover {
    background: #f7fafc;
}

.modal-body {
    padding: 20px;
}

.rating-stars {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-bottom: 20px;
}

.rating-stars i {
    font-size: 2rem;
    color: #e2e8f0;
    cursor: pointer;
    transition: all 0.3s ease;
}

.rating-stars i:hover,
.rating-stars i.active {
    color: #fbbf24;
    transform: scale(1.1);
}

#ratingComment {
    width: 100%;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    padding: 12px;
    font-size: 0.9rem;
    resize: vertical;
    min-height: 80px;
    outline: none;
    transition: border-color 0.3s ease;
    font-family: inherit;
}

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

.modal-footer {
    padding: 20px;
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.3s ease;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);
}

.btn-secondary {
    background: #f7fafc;
    color: #4a5568;
    border: 1px solid #e2e8f0;
}

.btn-secondary:hover {
    background: #edf2f7;
}

/* 加载指示器 */
.loading-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(5px);
    z-index: 999;
    align-items: center;
    justify-content: center;
}

.loading-overlay.show {
    display: flex;
}

.loading-spinner {
    text-align: center;
    color: #4a5568;
}

.loading-spinner i {
    font-size: 2rem;
    color: #667eea;
    margin-bottom: 15px;
}

.loading-spinner p {
    font-size: 1rem;
    color: #718096;
}

/* 通知样式 */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: white;
    border-radius: 8px;
    padding: 15px 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    z-index: 1001;
    transform: translateX(400px);
    transition: transform 0.3s ease;
}

.notification.show {
    transform: translateX(0);
}

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

.notification.success .notification-icon {
    color: #10b981;
}

.notification.error .notification-icon {
    color: #ef4444;
}

.notification.info .notification-icon {
    color: #3b82f6;
}

.notification-message {
    color: #2d3748;
    font-weight: 500;
}

/* 侧边栏遮罩层 */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 90;
    backdrop-filter: blur(2px);
}

.sidebar-overlay.show {
    display: block;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100%;
        z-index: 100;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }
    
    .sidebar.show {
        transform: translateX(0);
    }
    
    .chat-container {
        width: 100%;
        height: auto;
        min-height: 100vh;
        display: flex;
        flex-direction: column;
    }
    
    .message-content {
        max-width: 85%;
    }
    
    .modal-content {
        width: 95%;
        margin: 20px;
    }
    
    .notification {
        right: 10px;
        left: 10px;
        transform: translateY(-100px);
    }
    
    .notification.show {
        transform: translateY(0);
    }
    
    /* 使用指南在移动端的优化 */
    .usage-guide {
        margin: 15px 10px;
        max-width: none;
    }
    
    .guide-content.expanded {
        max-height: none !important;
        height: auto;
        overflow: visible;
    }
    
    .guide-text {
        padding: 15px;
    }
    
    .guide-section {
        margin: 12px 0;
        padding: 12px;
        border-radius: 6px;
    }
    
    .guide-section h6 {
        font-size: 0.9rem;
    }
    
    .guide-section p {
        font-size: 0.85rem;
    }
    
    /* 确保页面整体能够滚动 */
    body {
        overflow-x: hidden;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .chat-messages {
        overflow-y: visible;
        height: auto;
        max-height: none;
        flex: none;
        padding-bottom: 120px; /* 为固定的输入框留出空间 */
    }
    
    .app-container {
        min-height: 100vh;
        height: auto;
    }
    
    .chat-input-container {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: white;
        border-top: 1px solid #e2e8f0;
        z-index: 50;
    }
}

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

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

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

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