/* 全局重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    color: #333;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: background 0.3s, color 0.3s;
}

body.dark-mode {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: #e0e0e0;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* 导航栏 */
.navbar {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    box-shadow: 0 2px 20px rgba(0,0,0,0.1);
    padding: 15px 0;
    position: sticky;
    top: 0;
    z-index: 1000;
    transition: background 0.3s;
}

.dark-mode .navbar {
    background: rgba(26, 26, 46, 0.9);
    box-shadow: 0 2px 20px rgba(0,0,0,0.3);
}

.navbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: #667eea;
    text-decoration: none;
    background: linear-gradient(135deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-links {
    display: flex;
    gap: 20px;
}

.nav-links a {
    color: #555;
    text-decoration: none;
    padding: 8px 16px;
    border-radius: 8px;
    transition: all 0.3s;
    font-weight: 500;
}

.dark-mode .nav-links a {
    color: #b0b0b0;
}

.nav-links a:hover, .nav-links a.active {
    background: rgba(102, 126, 234, 0.1);
    color: #667eea;
}

.hamburger {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
}

.hamburger span {
    width: 25px;
    height: 3px;
    background: #667eea;
    border-radius: 3px;
    transition: 0.3s;
}

/* 主内容 */
main {
    flex: 1;
    padding: 40px 0;
}

.chat-main {
    max-width: 800px;
}

.chat-header {
    margin-bottom: 30px;
}

.chat-header h1 {
    font-size: 1.8rem;
    background: linear-gradient(135deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 15px;
}

.model-selector {
    display: flex;
    align-items: center;
    gap: 10px;
}

.model-selector select {
    padding: 8px 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    background: white;
    font-size: 1rem;
    cursor: pointer;
    transition: border-color 0.3s;
}

.dark-mode .model-selector select {
    background: #2a2a4a;
    border-color: #444;
    color: #e0e0e0;
}

.model-selector select:focus {
    border-color: #667eea;
    outline: none;
}

.btn-icon {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: #667eea;
    padding: 8px;
    border-radius: 50%;
    transition: background 0.3s;
}

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

/* 聊天容器 */
.chat-container {
    background: white;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.1);
    overflow: hidden;
    transition: background 0.3s;
}

.dark-mode .chat-container {
    background: #2a2a4a;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}

.chat-messages {
    height: 400px;
    overflow-y: auto;
    padding: 20px;
}

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

.message-content {
    max-width: 80%;
    padding: 12px 18px;
    border-radius: 18px;
    background: #f0f2f5;
    line-height: 1.6;
    transition: background 0.3s;
}

.dark-mode .message-content {
    background: #3a3a5a;
}

.ai-message .message-content {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border-bottom-left-radius: 5px;
}

.user-message .message-content {
    background: #e8f0fe;
    margin-left: auto;
    border-bottom-right-radius: 5px;
}

.dark-mode .user-message .message-content {
    background: #4a4a6a;
    color: #e0e0e0;
}

/* 流式响应动画 */
.streaming .message-content p::after {
    content: '|';
    animation: blink 0.7s infinite;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

/* 聊天输入 */
.chat-input-area {
    display: flex;
    padding: 15px 20px;
    border-top: 1px solid #eee;
    gap: 10px;
    background: #fafafa;
    transition: background 0.3s;
}

.dark-mode .chat-input-area {
    border-top-color: #444;
    background: #2a2a4a;
}

.chat-input-area textarea {
    flex: 1;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 12px;
    resize: none;
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.3s;
}

.dark-mode .chat-input-area textarea {
    background: #3a3a5a;
    border-color: #555;
    color: #e0e0e0;
}

.chat-input-area textarea:focus {
    border-color: #667eea;
    outline: none;
}

.btn-primary {
    padding: 12px 24px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

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

.btn-secondary {
    padding: 10px 20px;
    background: #6c757d;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.3s;
}

.btn-secondary:hover {
    background: #5a6268;
}

.btn-danger {
    padding: 8px 16px;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.3s;
}

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

.btn-sm {
    padding: 5px 10px;
    font-size: 0.85rem;
}

/* 卡片 */
.card {
    background: white;
    border-radius: 16px;
    padding: 30px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.08);
    margin-bottom: 30px;
    transition: background 0.3s, box-shadow 0.3s;
}

.dark-mode .card {
    background: #2a2a4a;
    box-shadow: 0 5px 20px rgba(0,0,0,0.2);
}

.card h2 {
    margin-bottom: 20px;
    color: #667eea;
}

/* 表格 */
.table {
    width: 100%;
    border-collapse: collapse;
}

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

.dark-mode .table th, .dark-mode .table td {
    border-bottom-color: #444;
}

.table th {
    background: #f8f9fa;
    font-weight: 600;
}

.dark-mode .table th {
    background: #3a3a5a;
}

/* 表单 */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
}

.form-group input {
    width: 100%;
    padding: 10px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s;
}

.form-group input:focus {
    border-color: #667eea;
    outline: none;
}

.form-inline {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.form-inline input {
    flex: 1;
    padding: 8px;
    border: 2px solid #ddd;
    border-radius: 8px;
}

/* 管理后台 */
.admin-main {
    max-width: 1000px;
}

.admin-main h1 {
    margin-bottom: 30px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.admin-login-card {
    max-width: 400px;
    margin: 0 auto;
}

.admin-dashboard {
    display: grid;
    gap: 30px;
}

.model-list {
    list-style: none;
    margin-bottom: 15px;
}

.model-list li {
    padding: 8px 0;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.dark-mode .model-list li {
    border-bottom-color: #444;
}

.alert {
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.alert-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* 搜索结果 */
.search-results {
    margin-top: 20px;
}

.search-item {
    padding: 15px;
    margin-bottom: 15px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    transition: background 0.3s;
}

.dark-mode .search-item {
    background: #2a2a4a;
}

.search-item h3 {
    margin-bottom: 5px;
    color: #667eea;
}

/* 页脚 */
.footer {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    padding: 20px 0;
    text-align: center;
    box-shadow: 0 -2px 20px rgba(0,0,0,0.05);
    margin-top: auto;
    transition: background 0.3s;
}

.dark-mode .footer {
    background: rgba(26, 26, 46, 0.9);
}

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

/* Markdown 样式 */
.message-content h1, .message-content h2, .message-content h3 {
    margin: 10px 0;
}

.message-content p {
    margin: 5px 0;
}

.message-content ul, .message-content ol {
    margin: 5px 0;
    padding-left: 20px;
}

.message-content code {
    background: rgba(0,0,0,0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.9em;
}

.message-content pre {
    background: #1e1e2e;
    padding: 15px;
    border-radius: 10px;
    overflow-x: auto;
    margin: 10px 0;
}

.message-content pre code {
    background: none;
    color: #e0e0e0;
}

/* 响应式 */
@media (max-width: 768px) {
    .nav-links {
        display: none;
        flex-direction: column;
        position: absolute;
        top: 60px;
        left: 0;
        right: 0;
        background: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(10px);
        padding: 20px;
        box-shadow: 0 5px 20px rgba(0,0,0,0.1);
    }

    .dark-mode .nav-links {
        background: rgba(26, 26, 46, 0.95);
    }

    .nav-links.active {
        display: flex;
    }

    .hamburger {
        display: flex;
    }

    .chat-header h1 {
        font-size: 1.3rem;
    }

    .chat-messages {
        height: 300px;
    }

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

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

    .table {
        font-size: 0.85rem;
    }

    .table th, .table td {
        padding: 8px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 10px;
    }

    .chat-header h1 {
        font-size: 1.1rem;
    }

    .card {
        padding: 20px;
    }
}