/* 主体样式 */
body {
    font-family: 'Microsoft YaHei', 'PingFang SC', 'Helvetica Neue', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

/* 导航栏样式 */
.navbar {
    background: rgba(255, 255, 255, 0.95) !important;
    backdrop-filter: blur(10px);
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.1);
}

.navbar-brand {
    font-weight: 600;
    color: #667eea !important;
    font-size: 1.5rem;
}

/* 卡片样式 */
.card {
    border: none;
    border-radius: 15px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.15);
}

.card-header {
    background: linear-gradient(90deg, #667eea, #764ba2);
    color: white;
    border-radius: 15px 15px 0 0 !important;
    border: none;
    padding: 1rem 1.5rem;
}

/* 聊天容器样式 */
.chat-container {
    height: calc(100vh - 200px);
    display: flex;
    flex-direction: column;
}

.chat-messages {
    flex-grow: 1;
    overflow-y: auto;
    padding: 20px;
    background: white;
    border-radius: 12px;
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.05);
}

/* 消息样式 */
.message {
    margin-bottom: 20px;
    padding: 15px 20px;
    border-radius: 20px;
    max-width: 85%;
    word-wrap: break-word;
    position: relative;
    animation: fadeInUp 0.3s ease;
}

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

.user-message {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    align-self: flex-end;
    margin-left: auto;
    border-bottom-right-radius: 5px;
}

.ai-message {
    background: #f8f9fa;
    color: #333;
    align-self: flex-start;
    border-bottom-left-radius: 5px;
    border: 1px solid #e9ecef;
}

/* 输入区域样式 */
.input-area {
    margin-top: 20px;
    display: flex;
    gap: 15px;
    align-items: flex-end;
}

.input-area textarea {
    flex-grow: 1;
    border-radius: 25px;
    padding: 15px 20px;
    resize: none;
    border: 2px solid #e9ecef;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    min-height: 50px;
    max-height: 150px;
}

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

.send-btn {
    border-radius: 25px;
    padding: 12px 25px;
    font-weight: 600;
    transition: all 0.3s ease;
    min-width: 100px;
}

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

.send-btn:disabled {
    opacity: 0.6;
    transform: none;
    cursor: not-allowed;
}

/* 会话列表样式 */
.session-list {
    max-height: calc(100vh - 250px);
    overflow-y: auto;
    padding: 10px;
}

.session-item {
    cursor: pointer;
    padding: 15px;
    border-radius: 10px;
    margin: 8px 0;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.session-item:hover {
    background: rgba(102, 126, 234, 0.1);
    transform: translateX(5px);
}

.session-item.active {
    background: linear-gradient(90deg, rgba(102, 126, 234, 0.2), rgba(118, 75, 162, 0.2));
    border-color: #667eea;
    transform: translateX(5px);
}

.session-item .badge {
    font-size: 0.7em;
    padding: 5px 10px;
    border-radius: 15px;
}

/* 模型选择器样式 */
.model-selector {
    margin-bottom: 15px;
}

.form-select {
    border-radius: 10px;
    border: 2px solid #e9ecef;
    padding: 8px 40px 8px 15px; /* 右侧留出空间给下拉箭头 */
    transition: border-color 0.3s ease;
    background-position: right 15px center; /* 调整箭头位置 */
    background-size: 16px 12px;
}

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

/* Markdown样式优化 */
pre {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 15px;
    margin: 10px 0;
    border: 1px solid #e9ecef;
    overflow-x: auto;
}

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

pre code {
    background: none;
    padding: 0;
}

/* 思考过程样式 */
.thinking-toggle {
    cursor: pointer;
    color: #6c757d;
    margin: 10px 0;
    display: inline-block;
    padding: 8px 15px;
    background: #f8f9fa;
    border-radius: 20px;
    border: 1px solid #e9ecef;
    transition: all 0.3s ease;
}

.thinking-toggle:hover {
    background: #e9ecef;
    color: #495057;
}

.thinking-content {
    background: linear-gradient(135deg, #fff8e1, #ffecb3);
    border-left: 4px solid #ffc107;
    padding: 15px;
    margin: 10px 0;
    border-radius: 0 8px 8px 0;
    font-style: italic;
    color: #856404;
    animation: slideInLeft 0.3s ease;
}

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

.hidden {
    display: none;
}

/* 用户菜单样式 */
.user-menu {
    margin-left: auto;
}

.dropdown-toggle {
    border-radius: 20px;
    padding: 8px 15px;
    font-weight: 500;
}

/* 修复下拉菜单位置 */
.dropdown-menu {
    margin-top: 0.5rem;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.dropdown-item {
    padding: 10px 20px;
    transition: all 0.2s ease;
}

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

.dropdown-item i {
    width: 20px;
    text-align: center;
}

/* 按钮样式优化 */
.btn-primary {
    background: linear-gradient(135deg, #667eea, #764ba2);
    border: none;
    padding: 10px 20px;
    border-radius: 25px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.btn-primary:focus {
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.25);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

.btn-outline-primary {
    border: 2px solid #667eea;
    color: #667eea;
    border-radius: 25px;
    padding: 8px 18px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.btn-outline-primary:focus {
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.25);
}

.btn-outline-primary:hover {
    background: #667eea;
    transform: translateY(-2px);
}

.btn-danger {
    background: linear-gradient(135deg, #ff6b6b, #ee5a52);
    border: none;
    border-radius: 20px;
    padding: 8px 15px;
    transition: all 0.3s ease;
}

.btn-danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(255, 107, 107, 0.4);
}

/* 模态框样式优化 */
.modal-content {
    border-radius: 15px;
    border: none;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
}

.modal-header {
    background: linear-gradient(90deg, #667eea, #764ba2);
    color: white;
    border-radius: 15px 15px 0 0;
    border: none;
    padding: 1.5rem;
}

.modal-title {
    font-weight: 600;
}

.btn-close {
    filter: invert(1);
}

.form-floating {
    margin-bottom: 20px;
}

.form-control {
    border-radius: 10px;
    border: 2px solid #e9ecef;
    padding: 15px;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.form-control:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
}

.form-label {
    padding: 15px;
}

.alert {
    border-radius: 10px;
    border: none;
}

/* 错误提示样式 */
.alert-error {
    background: linear-gradient(135deg, #ffebee, #ffcdd2);
    color: #c62828;
    border-left: 4px solid #f44336;
}

.alert-warning {
    background: linear-gradient(135deg, #fff8e1, #ffecb3);
    color: #f57c00;
    border-left: 4px solid #ffc107;
}

.alert-success {
    background: linear-gradient(135deg, #e8f5e8, #c8e6c9);
    color: #2e7d32;
    border-left: 4px solid #4caf50;
}

.alert-info {
    background: linear-gradient(135deg, #e3f2fd, #bbdefb);
    color: #1565c0;
    border-left: 4px solid #2196f3;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .chat-container {
        height: calc(100vh - 150px);
    }

    .message {
        max-width: 90%;
    }

    .input-area {
        flex-direction: column;
    }

    .send-btn {
        width: 100%;
        margin-left: 0;
    }

    .session-list {
        max-height: 200px;
        padding: 5px;
    }

    .session-item {
        margin: 5px 0;
        padding: 12px;
        width: calc(100% - 10px);
        margin-left: 5px;
        margin-right: 5px;
    }

    .model-selector .form-select {
        min-width: 150px;
        padding: 8px 30px 8px 12px;
    }
}

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

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #5a6fd8, #6a4190);
}

/* Firefox滚动条样式 */
* {
    scrollbar-width: thin;
    scrollbar-color: #667eea #f1f1f1;
}

/* 加载动画 */
.loading-dots::after {
    content: '.';
    animation: dots 1.5s infinite;
}

@keyframes dots {
    0%, 20% { content: '.'; }
    40% { content: '..'; }
    60%, 100% { content: '...'; }
}

/* 确保所有元素都有合适的盒模型 */
*, *::before, *::after {
    box-sizing: border-box;
}

/* 状态指示器 */
.status-indicator {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 8px;
}

.status-online {
    background: #28a745;
    box-shadow: 0 0 10px #28a745;
}

.status-offline {
    background: #dc3545;
}

/* 确保导航栏在各种屏幕尺寸下都能正确显示 */
.navbar-nav .dropdown-menu {
    position: absolute;
    right: 0;
    left: auto;
}

.navbar-nav .dropdown-menu[data-bs-popper] {
    top: 100%;
    margin-top: 0.125rem;
}

/* Toast 提示样式 */
.toast {
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(10px);
}

.toast-body {
    padding: 15px 20px;
    font-weight: 500;
}

/* 网络错误提示样式 */
.network-error-message {
    text-align: center;
    padding: 30px;
    color: #666;
}

.network-error-message i {
    font-size: 3rem;
    color: #ffc107;
    margin-bottom: 15px;
}

/* API错误通用样式 */
.api-error-toast {
    max-width: 400px;
    margin: 10px;
}

/* 错误边界样式 */
.error-boundary {
    text-align: center;
    padding: 50px 20px;
    background: linear-gradient(135deg, #fafafa, #f5f5f5);
    border-radius: 15px;
    margin: 20px;
}

.error-boundary i {
    font-size: 4rem;
    color: #f44336;
    margin-bottom: 20px;
}

.error-boundary h3 {
    color: #333;
    margin-bottom: 15px;
}

.error-boundary p {
    color: #666;
    margin-bottom: 20px;
    line-height: 1.6;
}

/* 响应式错误提示 */
@media (max-width: 768px) {
    .toast {
        margin: 5px;
        max-width: calc(100vw - 20px);
    }
    
    .api-error-toast {
        max-width: calc(100vw - 30px);
    }
    
    .error-boundary {
        padding: 30px 15px;
        margin: 10px;
    }
    
    .error-boundary i {
        font-size: 3rem;
    }
}

/* 暗色主题适配 */
@media (prefers-color-scheme: dark) {
    .alert-error {
        background: linear-gradient(135deg, #380000, #5a0000);
        color: #ff6b6b;
    }
    
    .alert-warning {
        background: linear-gradient(135deg, #332500, #553d00);
        color: #ffd740;
    }
    
    .alert-success {
        background: linear-gradient(135deg, #002800, #004400);
        color: #69f0ae;
    }
    
    .alert-info {
        background: linear-gradient(135deg, #001f3f, #003366);
        color: #4fc3f7;
    }
}

/* Toast 提示样式 */
.toast {
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(10px);
}

.toast-body {
    padding: 15px 20px;
    font-weight: 500;
}

/* 网络错误提示样式 */
.network-error-message {
    text-align: center;
    padding: 30px;
    color: #666;
}

.network-error-message i {
    font-size: 3rem;
    color: #ffc107;
    margin-bottom: 15px;
}

/* API错误通用样式 */
.api-error-toast {
    max-width: 400px;
    margin: 10px;
}

/* 错误边界样式 */
.error-boundary {
    text-align: center;
    padding: 50px 20px;
    background: linear-gradient(135deg, #fafafa, #f5f5f5);
    border-radius: 15px;
    margin: 20px;
}

.error-boundary i {
    font-size: 4rem;
    color: #f44336;
    margin-bottom: 20px;
}

.error-boundary h3 {
    color: #333;
    margin-bottom: 15px;
}

.error-boundary p {
    color: #666;
    margin-bottom: 20px;
    line-height: 1.6;
}

