/* ===== 建工AI智能体平台 - 样式表 V4 ===== */

/* --- CSS变量 --- */
:root {
    --primary: #1a73e8;
    --primary-hover: #1557b0;
    --primary-light: rgba(26, 115, 232, 0.15);
    --accent: #ff6d00;
    --accent-hover: #e65100;
    --accent-light: rgba(255, 109, 0, 0.15);

    --bg-primary: #0f1419;
    --bg-secondary: #1c2333;
    --bg-tertiary: #252d3d;
    --bg-hover: #2a3348;
    --bg-active: #30394d;
    --bg-input: #1a2232;

    --text-primary: #e7e9ea;
    --text-secondary: #8b98a5;
    --text-muted: #5c6b7a;

    --border-color: #2f3b4e;
    --border-light: #38465b;

    --success: #00c853;
    --success-bg: rgba(0, 200, 83, 0.1);
    --error: #ff1744;
    --error-bg: rgba(255, 23, 68, 0.1);
    --warning: #ff9100;
    --warning-bg: rgba(255, 145, 0, 0.1);
    --info: #448aff;
    --info-bg: rgba(68, 138, 255, 0.1);

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.5);

    --sidebar-width: 280px;
    --navbar-height: 56px;

    --font-family: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --transition: 0.2s ease;
}

/* 亮色主题 */
[data-theme="light"] {
    --bg-primary: #f5f7fa;
    --bg-secondary: #ffffff;
    --bg-tertiary: #eef1f5;
    --bg-hover: #e3e8ef;
    --bg-active: #d5dbe5;
    --bg-input: #f0f3f7;

    --text-primary: #1a1a2e;
    --text-secondary: #5a6577;
    --text-muted: #9aa5b4;

    --border-color: #dde3eb;
    --border-light: #c8d0db;

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.12);
}

/* --- 重置与基础 --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: var(--font-family);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

::selection {
    background: var(--primary);
    color: #fff;
}

::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* --- 配置提示横幅 --- */
.config-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1001;
    background: linear-gradient(90deg, var(--accent), #ff8f00);
    color: #fff;
    padding: 8px 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    animation: slideDown 0.3s ease;
}

.config-banner-content {
    display: flex;
    align-items: center;
    gap: 6px;
}

.config-banner-content a {
    color: #fff;
    font-weight: 700;
    text-decoration: underline;
    cursor: pointer;
}

.config-banner-close {
    position: absolute;
    right: 16px;
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    opacity: 0.7;
    font-size: 14px;
}

.config-banner-close:hover {
    opacity: 1;
}

@keyframes slideDown {
    from { transform: translateY(-100%); }
    to { transform: translateY(0); }
}

/* --- 导航栏 --- */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--navbar-height);
    background: rgba(15, 20, 25, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 100;
}

[data-theme="light"] .navbar {
    background: rgba(255, 255, 255, 0.85);
}

.navbar-left, .navbar-center, .navbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon {
    width: 34px;
    height: 34px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 16px;
}

.brand-text {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 0.5px;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 18px;
    padding: 8px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.sidebar-toggle:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* 提供商切换器 */
.provider-switcher {
    display: flex;
    background: var(--bg-tertiary);
    border-radius: var(--radius-xl);
    padding: 3px;
    gap: 2px;
}

.provider-btn {
    padding: 6px 16px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: var(--radius-xl);
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.provider-btn.active {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 2px 8px rgba(26, 115, 232, 0.3);
}

.provider-btn:not(.active):hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* 导航按钮 */
.nav-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    white-space: nowrap;
}

.nav-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-btn-text {
    display: none;
}

@media (min-width: 768px) {
    .nav-btn-text {
        display: inline;
    }
}

/* --- 侧边栏 --- */
.sidebar {
    position: fixed;
    top: var(--navbar-height);
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 50;
    transition: transform 0.3s ease;
}

.sidebar.collapsed {
    transform: translateX(-100%);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: var(--navbar-height);
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 49;
}

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

.sidebar-header {
    padding: 16px;
}

.new-chat-btn {
    width: 100%;
    padding: 10px 16px;
    background: linear-gradient(135deg, var(--primary), #4a90d9);
    color: #fff;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: var(--transition);
}

.new-chat-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(26, 115, 232, 0.4);
}

.sidebar-search {
    padding: 0 16px 8px;
}

.search-input-wrap {
    display: flex;
    align-items: center;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0 12px;
    transition: var(--transition);
}

.search-input-wrap:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.search-input-wrap i {
    color: var(--text-muted);
    font-size: 13px;
}

.search-input-wrap input {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-primary);
    padding: 8px;
    font-size: 13px;
    outline: none;
}

.sidebar-conversations {
    flex: 1;
    overflow-y: auto;
    padding: 4px 8px;
}

.conversation-item {
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 2px;
    position: relative;
}

.conversation-item:hover {
    background: var(--bg-hover);
}

.conversation-item.active {
    background: var(--primary-light);
    border-left: 3px solid var(--primary);
}

.conversation-item .conv-icon {
    color: var(--text-muted);
    font-size: 14px;
    flex-shrink: 0;
}

.conversation-item .conv-title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
    color: var(--text-primary);
}

.conversation-item .conv-time {
    font-size: 11px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.conversation-item .conv-delete {
    display: none;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    font-size: 12px;
    flex-shrink: 0;
}

.conversation-item:hover .conv-delete {
    display: block;
}

.conversation-item:hover .conv-delete:hover {
    color: var(--error);
}

.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border-color);
}

.sidebar-info {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    font-size: 11px;
}

/* --- 主布局 --- */
.main-layout {
    margin-top: var(--navbar-height);
    height: calc(100vh - var(--navbar-height));
    display: flex;
}

.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    margin-left: var(--sidebar-width);
    height: 100%;
    transition: margin-left 0.3s ease;
    position: relative;
}

.sidebar.collapsed ~ .chat-main,
.chat-main.expanded {
    margin-left: 0;
}

/* --- 欢迎页 --- */
.welcome-page {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    overflow-y: auto;
}

.welcome-content {
    text-align: center;
    max-width: 680px;
}

.welcome-icon {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 24px;
    font-size: 36px;
    color: #fff;
    box-shadow: 0 8px 30px rgba(26, 115, 232, 0.3);
}

.welcome-title {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 12px;
    background: linear-gradient(135deg, var(--text-primary), var(--primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.welcome-subtitle {
    color: var(--text-secondary);
    font-size: 15px;
    margin-bottom: 40px;
    line-height: 1.7;
}

.welcome-features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 16px;
}

.feature-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}

.feature-card:hover {
    transform: translateY(-4px);
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
    background: var(--bg-tertiary);
}

.feature-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 12px;
    font-size: 20px;
}

.feature-card:nth-child(1) .feature-icon { background: rgba(26, 115, 232, 0.15); color: var(--primary); }
.feature-card:nth-child(2) .feature-icon { background: rgba(255, 23, 68, 0.15); color: var(--error); }
.feature-card:nth-child(3) .feature-icon { background: rgba(0, 200, 83, 0.15); color: var(--success); }
.feature-card:nth-child(4) .feature-icon { background: rgba(255, 145, 0, 0.15); color: var(--warning); }

.feature-name {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 4px;
}

.feature-desc {
    color: var(--text-muted);
    font-size: 12px;
}

/* --- 对话区域 --- */
.chat-area {
    flex: 1;
    overflow: hidden;
}

.chat-messages {
    height: 100%;
    overflow-y: auto;
    padding: 24px 0;
}

/* --- 消息样式 --- */
.message {
    padding: 12px 24px;
    animation: fadeInUp 0.3s ease;
}

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

.message-wrapper {
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    gap: 12px;
}

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

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 16px;
}

.message.user .message-avatar {
    background: linear-gradient(135deg, var(--primary), #4a90d9);
    color: #fff;
}

.message.assistant .message-avatar {
    background: linear-gradient(135deg, var(--accent), #ff8f00);
    color: #fff;
}

.message-content {
    flex: 1;
    min-width: 0;
}

.message.user .message-content {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.message-text {
    padding: 12px 16px;
    border-radius: var(--radius-lg);
    line-height: 1.7;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.message.user .message-text {
    background: var(--primary);
    color: #fff;
    border-bottom-right-radius: var(--radius-sm);
}

.message.assistant .message-text {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-bottom-left-radius: var(--radius-sm);
}

.message-text p {
    margin-bottom: 8px;
}

.message-text p:last-child {
    margin-bottom: 0;
}

.message-text pre {
    background: #1e1e2e;
    border-radius: var(--radius-sm);
    padding: 14px;
    overflow-x: auto;
    margin: 8px 0;
    position: relative;
}

.message-text pre code {
    font-size: 13px;
    line-height: 1.5;
}

.message-text code:not(pre code) {
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
    color: var(--accent);
}

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

.message-text li {
    margin-bottom: 4px;
}

.message-text blockquote {
    border-left: 3px solid var(--primary);
    padding: 4px 12px;
    margin: 8px 0;
    color: var(--text-secondary);
    background: var(--primary-light);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.message-text table {
    width: 100%;
    border-collapse: collapse;
    margin: 8px 0;
}

.message-text th, .message-text td {
    border: 1px solid var(--border-color);
    padding: 8px 12px;
    text-align: left;
}

.message-text th {
    background: var(--bg-tertiary);
    font-weight: 600;
}

.message-text img {
    max-width: 100%;
    border-radius: var(--radius-sm);
}

.message-time {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* 思考指示器 */
.thinking-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    color: var(--text-secondary);
    font-size: 13px;
}

.thinking-dots {
    display: flex;
    gap: 4px;
}

.thinking-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--primary);
    animation: thinkingBounce 1.4s ease-in-out infinite;
}

.thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes thinkingBounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* 深度思考指示器 */
.deep-think-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    color: var(--accent);
    font-size: 12px;
    font-style: italic;
}

.deep-think-indicator i {
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

/* 错误消息 */
.error-message {
    background: var(--error-bg);
    border: 1px solid var(--error);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    color: var(--error);
    font-size: 13px;
}

.error-message .error-title {
    font-weight: 600;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.error-message .error-hint {
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-secondary);
}

.error-message .error-hint a {
    color: var(--accent);
    cursor: pointer;
    font-weight: 500;
}

/* --- 输入区域 --- */
.chat-input-area {
    padding: 8px 24px 16px;
    background: var(--bg-primary);
    border-top: 1px solid var(--border-color);
    position: relative;
}

.chat-input-area > .file-preview-area {
    margin-bottom: 8px;
}

.file-preview-area {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 0;
}

.file-preview-item {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    font-size: 12px;
    max-width: 200px;
}

.file-preview-item .file-icon {
    color: var(--primary);
}

.file-preview-item .file-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.file-preview-item .file-remove {
    cursor: pointer;
    color: var(--text-muted);
    font-size: 11px;
}

.file-preview-item .file-remove:hover {
    color: var(--error);
}

.file-preview-item .file-thumb {
    width: 40px;
    height: 40px;
    border-radius: 4px;
    object-fit: cover;
}

/* 技能栏 */
.skill-bar {
    display: flex;
    gap: 6px;
    padding: 6px 0;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.skill-bar::-webkit-scrollbar {
    display: none;
}

.skill-btn {
    padding: 5px 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 12px;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: var(--transition);
}

.skill-btn:hover {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
}

.skill-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

/* 功能开关行 */
.feature-toggles {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 4px 0;
}

.toggle-item {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 12px;
    color: var(--text-secondary);
    user-select: none;
}

.toggle-item input {
    display: none;
}

.toggle-switch {
    width: 34px;
    height: 18px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 9px;
    position: relative;
    transition: var(--transition);
}

.toggle-switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 12px;
    height: 12px;
    background: var(--text-muted);
    border-radius: 50%;
    transition: var(--transition);
}

.toggle-item input:checked + .toggle-switch {
    background: var(--primary-light);
    border-color: var(--primary);
}

.toggle-item input:checked + .toggle-switch::after {
    transform: translateX(16px);
    background: var(--primary);
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 4px;
}

.upload-btn-wrap {
    margin-left: auto;
}

.upload-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px;
    font-size: 16px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

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

/* 输入框行 */
.input-row {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.input-wrap {
    flex: 1;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    transition: var(--transition);
    overflow: hidden;
}

.input-wrap:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.input-wrap textarea {
    width: 100%;
    background: none;
    border: none;
    color: var(--text-primary);
    padding: 12px 16px;
    font-size: 14px;
    line-height: 1.5;
    resize: none;
    outline: none;
    max-height: 150px;
    font-family: var(--font-family);
}

.input-wrap textarea::placeholder {
    color: var(--text-muted);
}

.send-btn {
    width: 44px;
    height: 44px;
    background: var(--primary);
    border: none;
    border-radius: var(--radius-md);
    color: #fff;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    flex-shrink: 0;
}

.send-btn:hover {
    background: var(--primary-hover);
    transform: scale(1.05);
}

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

.stop-btn {
    width: 44px;
    height: 44px;
    background: var(--error);
    border: none;
    border-radius: var(--radius-md);
    color: #fff;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    flex-shrink: 0;
}

.stop-btn:hover {
    background: #d50000;
}

/* --- 弹窗通用 --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    animation: scaleIn 0.3s ease;
}

@keyframes scaleIn {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.settings-card {
    width: 620px;
    max-width: 95vw;
}

.kb-card {
    width: 560px;
    max-width: 95vw;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    font-size: 18px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-header h2 i {
    color: var(--primary);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 18px;
    padding: 4px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.modal-close:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
}

/* --- 设置标签页 --- */
.settings-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    padding: 0 24px;
}

.settings-tab {
    padding: 12px 20px;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    border-bottom: 2px solid transparent;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 6px;
}

.settings-tab:hover {
    color: var(--text-primary);
}

.settings-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.settings-panel {
    display: none;
}

.settings-panel.active {
    display: block;
}

.provider-section {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-bottom: 16px;
}

.section-title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
}

.provider-section:nth-child(1) .section-title::before {
    content: '';
    width: 8px;
    height: 8px;
    background: var(--accent);
    border-radius: 50%;
}

.provider-section:nth-child(2) .section-title::before {
    content: '';
    width: 8px;
    height: 8px;
    background: var(--primary);
    border-radius: 50%;
}

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

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group select,
.form-group textarea {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 9px 12px;
    color: var(--text-primary);
    font-size: 13px;
    outline: none;
    transition: var(--transition);
    font-family: var(--font-family);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.form-group select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238b98a5' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.input-with-action {
    display: flex;
    gap: 6px;
}

.input-with-action input {
    flex: 1;
}

.input-action-btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    padding: 0 10px;
    font-size: 13px;
    transition: var(--transition);
}

.input-action-btn:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

/* 滑块 */
.form-group input[type="range"] {
    width: 100%;
    height: 6px;
    appearance: none;
    background: var(--bg-tertiary);
    border-radius: 3px;
    outline: none;
    margin: 8px 0 4px;
}

.form-group input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 18px;
    height: 18px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(26, 115, 232, 0.3);
    transition: var(--transition);
}

.form-group input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.15);
}

.param-value {
    float: right;
    color: var(--primary);
    font-weight: 600;
    font-size: 13px;
}

.range-labels {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--text-muted);
}

/* 测试按钮 */
.test-btn {
    padding: 8px 18px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: var(--transition);
    margin-top: 4px;
}

.test-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}

.test-btn.testing {
    pointer-events: none;
    opacity: 0.7;
}

.test-btn.success {
    border-color: var(--success);
    color: var(--success);
    background: var(--success-bg);
}

.test-btn.fail {
    border-color: var(--error);
    color: var(--error);
    background: var(--error-bg);
}

/* --- 知识库弹窗 --- */
.kb-upload-area {
    margin-bottom: 20px;
}

.upload-drop-zone {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-md);
    padding: 30px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-secondary);
}

.upload-drop-zone:hover,
.upload-drop-zone.dragover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.upload-drop-zone i {
    font-size: 36px;
    color: var(--primary);
    margin-bottom: 8px;
    display: block;
}

.upload-drop-zone p {
    font-size: 14px;
    margin-bottom: 4px;
}

.upload-hint {
    font-size: 12px;
    color: var(--text-muted);
}

.kb-files-list {
    max-height: 300px;
    overflow-y: auto;
}

.kb-loading {
    text-align: center;
    padding: 20px;
    color: var(--text-muted);
}

.kb-file-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    margin-bottom: 6px;
    transition: var(--transition);
}

.kb-file-item:hover {
    background: var(--bg-hover);
}

.kb-file-icon {
    font-size: 20px;
    color: var(--primary);
    width: 28px;
    text-align: center;
}

.kb-file-info {
    flex: 1;
    min-width: 0;
}

.kb-file-name {
    font-size: 13px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.kb-file-meta {
    font-size: 11px;
    color: var(--text-muted);
}

.kb-file-delete {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 13px;
    padding: 4px;
}

.kb-file-delete:hover {
    color: var(--error);
}

/* --- 按钮 --- */
.btn-primary {
    padding: 9px 20px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: var(--transition);
}

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

.btn-secondary {
    padding: 9px 20px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    transition: var(--transition);
}

.btn-secondary:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* --- Toast --- */
.toast-container {
    position: fixed;
    top: 70px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px 18px;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 280px;
    max-width: 400px;
    animation: slideInRight 0.3s ease;
    font-size: 13px;
}

.toast.toast-exit {
    animation: slideOutRight 0.3s ease forwards;
}

@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes slideOutRight {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}

.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--error); }
.toast.warning { border-left: 3px solid var(--warning); }
.toast.info { border-left: 3px solid var(--info); }

.toast-icon {
    font-size: 16px;
    flex-shrink: 0;
}

.toast.success .toast-icon { color: var(--success); }
.toast.error .toast-icon { color: var(--error); }
.toast.warning .toast-icon { color: var(--warning); }
.toast.info .toast-icon { color: var(--info); }

.toast-message {
    flex: 1;
    color: var(--text-primary);
}

/* --- 响应式 --- */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        z-index: 60;
    }

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

    .chat-main {
        margin-left: 0;
    }

    .brand-text {
        display: none;
    }

    .provider-btn span {
        display: none;
    }

    .message {
        padding: 8px 12px;
    }

    .chat-input-area {
        padding: 8px 12px 12px;
    }

    .welcome-features {
        grid-template-columns: repeat(2, 1fr);
    }

    .settings-card, .kb-card {
        width: 100%;
        max-width: 100vw;
        max-height: 100vh;
        border-radius: 0;
    }

    .modal-overlay {
        align-items: flex-end;
    }
}

@media (max-width: 480px) {
    .welcome-title {
        font-size: 22px;
    }

    .welcome-features {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .feature-card {
        padding: 14px 10px;
    }
}

/* --- 打字光标 --- */
.typing-cursor::after {
    content: '▋';
    color: var(--primary);
    animation: blink 1s step-end infinite;
}

@keyframes blink {
    50% { opacity: 0; }
}

/* --- 消息操作按钮 --- */
.message-actions {
    display: flex;
    gap: 4px;
    margin-top: 6px;
    opacity: 0;
    transition: var(--transition);
}

.message:hover .message-actions {
    opacity: 1;
}

.msg-action-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    transition: var(--transition);
}

.msg-action-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* 搜索结果高亮 */
.search-highlight {
    background: var(--accent-light);
    padding: 2px 4px;
    border-radius: 3px;
    color: var(--accent);
}

/* 加载更多按钮 */
.load-more-btn {
    text-align: center;
    padding: 12px;
    color: var(--text-muted);
    font-size: 13px;
    cursor: pointer;
}

.load-more-btn:hover {
    color: var(--primary);
}
