/* 全局样式 */
:root {
    --primary-color: #4361ee;
    --secondary-color: #3f37c9;
    --success-color: #4cc9f0;
    --light-color: #f8f9fa;
    --dark-color: #212529;
    --gray-color: #6c757d;
    --light-gray: #F1F3F9;
    --border-color: #dee2e6;
    --shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    --border-radius: 0.375rem;
}

* {
    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%);
    min-height: 100vh;
    padding: 30px 50px 30px 30px;
    color: var(--dark-color);
}

.container {
    /* max-width: 1200px; */
    margin: 0 auto;
    /* 为固定侧边栏留出空间 */
    margin-left: 280px;
}

/* 头部样式 */
.header {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px;
}

.header h1 {
    color: #4361ee;
    font-size: 40px;
    margin-bottom: 10px;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.1);
    
}

.header p {
    color: #6C758C;
    font-size: 20px;
}

/* 卡片样式 */
.card {
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 45px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

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

/* 聊天容器样式 */
.chat-container {
    display: flex;
    flex-direction: column;
    height: 600px;
    background: white;
    border-radius: var(--border-radius);
    /* box-shadow: var(--shadow); */
    overflow: hidden;
}

.messages-area {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: white;
}

.message {
    max-width: 80%;
    padding: 12px 16px;
    margin-bottom: 15px;
    border-radius: 18px;
    position: relative;
    animation: fadeIn 0.3s ease;
}

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

.user-message {
    background: var(--primary-color);
    color: white;
    margin-left: auto;
    border-bottom-right-radius: 5px;
}

.ai-message {
    background: var(--light-gray);
    color: var(--dark-color);
    margin-right: auto;
    border-bottom-left-radius: 5px;
}

.message-info {
    font-size: 0.75rem;
    margin-top: 5px;
    opacity: 0.7;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

/* 下载链接样式：蓝色文字、无背景 */
.download-link {
    background: transparent;
    border: none;
    color: var(--primary-color);
    padding: 0;
    margin-left: 0;
    cursor: pointer;
    font-size: 0.875rem;
    text-decoration: none;
}
.download-link:hover {
    text-decoration: underline;
}
.download-link:focus { outline: none; }

/* 元信息容器：将时间与操作按钮左右分布 */
.message-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-top: 5px;
}

/* 输入区域样式 */
.input-area {
    display: flex;
    padding: 15px;
    background: white;
    border-top: 1px solid var(--border-color);
}

.input-area input {
    flex: 1;
    padding: 12px 15px;
    border: 1px solid var(--border-color);
    border-radius: 25px;
    outline: none;
    font-size: 1rem;
    margin-right: 10px;
}

.input-area input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(67, 97, 238, 0.25);
}

.input-area button {
    padding: 12px 20px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.3s ease;
}

.input-area button:hover {
    background: var(--secondary-color);
}

.input-area button:disabled {
    background: var(--gray-color);
    cursor: not-allowed;
}

/* 会话控制样式 */
.session-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding: 0 10px;
}

.session-info {
    font-size: 0.9rem;
    color: var(--gray-color);
}

.session-info span {
    font-weight: 600;
    color: var(--primary-color);
}

.new-session-btn {
    background: #91AAFF;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.3s ease;
}

.new-session-btn:hover {
    background: #38b2d0;
}

/* 加载指示器 */
.typing-indicator {
    display: inline-block;
    padding: 12px 16px;
    background: var(--light-gray);
    border-radius: 18px;
    margin-bottom: 15px;
    color: var(--gray-color);
}

.typing-indicator span {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--gray-color);
    margin: 0 2px;
    animation: typing 1.4s infinite ease-in-out;
}

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

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

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-5px); }
}

/* 响应式设计 */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    .header h1 {
        font-size: 2rem;
    }
    
    .chat-container {
        height: 400px;
    }
    
    .message {
        max-width: 90%;
    }
    
    .input-area {
        flex-direction: column;
    }
    
    .input-area input {
        margin-right: 0;
        margin-bottom: 10px;
    }
}

/* 按钮通用样式 */
.btn {
    display: inline-block;
    padding: 10px 20px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 1rem;
    text-align: center;
    text-decoration: none;
    transition: all 0.3s ease;
}

.btn:hover {
    background: var(--secondary-color);
    transform: translateY(-2px);
}

.btn:disabled {
    background: var(--gray-color);
    cursor: not-allowed;
    transform: none;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.875rem;
}

.btn-primary {
    background: var(--primary-color);
}

.btn-success {
    background: #28a745;
}

.btn-info {
    background: #17a2b8;
}

.btn-warning {
    background: #ffc107;
    color: var(--dark-color);
}

.btn-danger {
    background: #dc3545;
}

/* 表单样式 */
.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: var(--dark-color);
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 1rem;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(67, 97, 238, 0.25);
}

/* 提示消息样式 */
.alert {
    padding: 12px 16px;
    border-radius: var(--border-radius);
    margin-bottom: 15px;
    border: 1px solid transparent;
}

.alert-success {
    color: #155724;
    background-color: #d4edda;
    border-color: #c3e6cb;
}

.alert-info {
    color: #0c5460;
    background-color: #d1ecf1;
    border-color: #bee5eb;
}

.alert-warning {
    color: #856404;
    background-color: #fff3cd;
    border-color: #ffeaa7;
}

.alert-danger {
    color: #721c24;
    background-color: #f8d7da;
    border-color: #f5c6cb;
}

/* 加载动画 */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* 会话历史列表 */
.session-history {
    max-height: 300px;
    overflow-y: auto;
}

.session-item {
    padding: 10px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background 0.2s ease;
}

.session-item:hover {
    background: var(--light-gray);
}

.session-item.active {
    background: rgba(67, 97, 238, 0.1);
    border-left: 3px solid var(--primary-color);
}

/* 布局：侧栏 + 主内容 */
.layout {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    /* 使用流式左右布局，不再依赖固定侧栏的外部留白 */
    margin-left: 0;
}

/* 固定侧栏：从页面顶部到底部铺满左侧 */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    height: 100vh;
    width: 250px;
    background: white;
    border-radius: 0 12px 12px 0;
    box-shadow: var(--shadow);
    padding: 28px 18px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    z-index: 60;
}

.sidebar-brand h2 {
    font-size: 1.1rem;
    color: var(--primary-color);
    margin-bottom: 8px;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    background: transparent;
    border: none;
    padding: 12px 14px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    color: var(--dark-color);
    transition: background 0.18s ease, color 0.18s ease, transform 0.08s ease;
}

.nav-item .icon {
    font-size: 1.4rem;
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: rgba(0,0,0,0.02);
}

.nav-item .nav-text {
    display: flex;
    flex-direction: column;
    line-height: 1;
}

.nav-item .title {
    font-size: 22px;
    font-family: Qyn Flavor Grotesk Alt GB, Qyn Flavor Grotesk Alt GB-700;
    font-weight: 700;
    text-align: LEFT;
    color: #4b4b4b;
}

/* .nav-item .desc {
    font-size: 0.82rem;
    color: var(--gray-color);
    font-weight: 500;
} */

.nav-item:hover {
    background: rgba(67,97,238,0.06);
}

.nav-item.active {
    background: linear-gradient(90deg, rgba(67,97,238,0.08), rgba(67,97,238,0.03));
    color: var(--primary-color);
    box-shadow: inset 0 0 0 1px rgba(67,97,238,0.04);
    transform: translateY(-1px);
}

.sidebar-footer {
    padding-top: 5px;
    padding-bottom: 5px;
    margin-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
    box-shadow: rgba(33, 35, 38, 0.1) 0px 10px 10px -10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.main-content {
    flex: 1;
}

/* 响应式：窄屏时侧栏堆叠在上方 */
@media (max-width: 900px) {
    /* 小屏下取消固定侧栏，恢复流式布局 */
    .layout { margin-left: 0; flex-direction: column; }
    .sidebar { position: static; width: 100%; height: auto; border-radius: 12px; padding: 18px; }
}

/* 侧边栏内的模型选择样式 */
.sidebar-model { display: flex; flex-direction: column; gap: 6px; width: 100%; }
.sidebar-model-label { font-size: 0.85rem; color: var(--gray-color); }
.sidebar .model-select-btn { width: 100%; justify-content: space-between; padding: 8px 12px; border-radius: 8px; height: 40px; }
.sidebar .model-select-btn .caret { font-size: 12px; }
.sidebar .model-menu { left: 0; bottom: calc(100% + 6px); min-width: 160px; z-index: 80; }
.sidebar .model-item { padding: 8px 12px; }

/* 通用 model-dropdown 行为：默认隐藏菜单，打开时显示 */
.model-dropdown { position: relative; display: inline-block; }
.model-dropdown .model-select-btn {
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    cursor: pointer;
    background: var(--light-color);
    border: 1px solid var(--border-color);
    color: var(--dark-color);
    border-radius: 20px;
    padding: 10px 14px;
    height: 44px;
    transition: background .18s ease, box-shadow .18s ease, transform .12s ease;
    box-shadow: 0 1px 2px rgba(16,24,40,0.03);
}
.model-dropdown .model-select-btn:hover {
    background: #ffffff;
    box-shadow: 0 4px 10px rgba(67,97,238,0.06);
}
.model-dropdown .model-select-btn:focus { outline: none; box-shadow: 0 0 0 0.12rem rgba(67,97,238,0.12); }
.model-dropdown .model-label {
    display: inline-block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 140px;
    font-weight: 600;
}
.model-dropdown .caret { transition: transform .18s ease; }
.model-dropdown.open .caret { transform: rotate(-180deg); }
.model-dropdown .model-menu {
    display: block; /* keep DOM, use opacity/transform for animation */
    position: absolute;
    left: 0;
    bottom: calc(100% + 10px);
    background: #fff;
    border: 1px solid rgba(221,226,235,0.9);
    box-shadow: 0 8px 28px rgba(16,24,40,0.08);
    border-radius: 10px;
    padding: 6px 0;
    list-style: none;
    margin: 0;
    z-index: 1400;
    opacity: 0;
    transform: translateY(6px) scale(.98);
    pointer-events: none;
    transition: opacity .18s ease, transform .18s ease;
}
.model-dropdown.open .model-menu {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}
.model-dropdown .model-item { padding: 10px 14px; cursor: pointer; color: var(--dark-color); transition: background .12s ease, color .12s ease; }
.model-dropdown .model-item:hover { background: #f5f7fb; color: var(--primary-color); }
.model-dropdown .model-item.disabled { color: #bfcbd9; cursor: default; pointer-events: none; background: transparent; }

/* 在侧栏内略微调整样式以与侧栏配色协调 */
.sidebar .model-select-btn { border-radius: 8px; height: 40px; padding: 8px 12px; font-weight: 600; }
.sidebar .model-label { max-width: 120px; }
.sidebar .model-menu { bottom: calc(100% + 8px); min-width: 180px; }



