/* === 全局变量 === */
:root {
    --primary-color: #667eea;
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --text-primary: #2c2c2c;
    --white: #ffffff;
    --sidebar-width: 280px;
}

/* === 基础重置 === */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--primary-gradient);
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    color: var(--text-primary);
}

/* === 1. 顶部导航栏样式 === */
.top-nav {
    height: 60px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
}

.nav-logo {
    color: var(--white);
    font-size: 1.5rem;
    font-weight: bold;
    text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* 导航链接样式（搜索、使用说明） */
.nav-link {
    color: rgba(255, 255, 255, 0.9);
    text-decoration: none;
    font-size: 14px;
    transition: opacity 0.2s;
}
.nav-link:hover { opacity: 1; text-decoration: underline; }

/* 导航按钮样式（登录、注册） */
.nav-btn {
    padding: 6px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.register-btn { background: var(--white); color: var(--primary-color); font-weight: 500; }
.login-btn { background: rgba(255, 255, 255, 0.2); color: var(--white); border: 1px solid rgba(255, 255, 255, 0.3); }
.nav-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,0.15); }

/* === 2. 主体布局 === */
.main-container {
    flex: 1;
    display: flex;
    padding-top: 60px; /* 留出导航栏高度 */
    height: 100%;
    position: relative;
}

.content-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 20px;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

/* === 3. 结果展示区 === */
#results-container {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.result-item {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 24px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
    animation: fadeInUp 0.4s ease;
}

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

/* 【修改点】对话模式背景改为纯白色，不再透明 */
.bot-response {
    background: #ffffff; 
    border-left: 4px solid var(--primary-color);
    border: 1px solid #e0e0e0; /* 增加边框以便在白色背景下可见 */
}

.search-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px dashed rgba(0,0,0,0.1);
}

.query-badge {
    background: var(--primary-gradient);
    color: white;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: bold;
}

.result-title { font-size: 1.2rem; font-weight: 600; margin-bottom: 10px; color: var(--primary-color); }
.result-content { line-height: 1.7; color: #555; margin-bottom: 15px; }
.result-content a { color: #1677ff; text-decoration: none; }

.result-actions { display: flex; gap: 10px; justify-content: flex-end; }
.action-btn {
    background: #f5f5f5;
    border: 1px solid #e0e0e0;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
}
.action-btn:hover { background: #e0e0e0; }

#thinking { text-align: center; color: white; padding: 20px; font-style: italic; }

/* === 4. 底部搜索区 === */
.bottom-area {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 15px;
    box-shadow: 0 -2px 20px rgba(0,0,0,0.1);
}

.mode-toggle { display: flex; background: #f0f0f0; border-radius: 8px; margin-bottom: 10px; padding: 4px; }
.mode-toggle button {
    flex: 1;
    padding: 8px;
    border: none;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    color: #666;
}
.mode-toggle button.active { background: white; color: var(--primary-color); font-weight: bold; box-shadow: 0 2px 4px rgba(0,0,0,0.05); }

.input-group { display: flex; gap: 10px; }
#query {
    flex: 1;
    padding: 14px 18px;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    font-size: 16px;
    outline: none;
}
#query:focus { border-color: var(--primary-color); }
#searchBtn {
    padding: 14px 28px;
    background: var(--primary-gradient);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    cursor: pointer;
    font-weight: 500;
}

/* === 5. 侧边栏 === */
.history-sidebar {
    position: fixed;
    top: 60px;
    left: 0;
    width: var(--sidebar-width);
    height: calc(100% - 60px);
    background: white;
    z-index: 999;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
}
.history-sidebar.open { transform: translateX(0); }

.sidebar-header { padding: 15px; border-bottom: 1px solid #eee; display: flex; justify-content: space-between; align-items: center; font-weight: bold; }
.history-list { flex: 1; overflow-y: auto; padding: 10px; }
.history-item { padding: 10px; border-bottom: 1px solid #f5f5f5; cursor: pointer; font-size: 14px; display: flex; justify-content: space-between; }
.history-item:hover { background: #f9f9f9; }
.history-query { flex: 1; }
.history-delete { color: #ff4d4f; margin-left: 10px; cursor: pointer; }

.overlay { position: fixed; top: 60px; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.3); z-index: 998; display: none; }
.overlay.show { display: block; }

.history-toggle-btn {
    position: fixed;
    bottom: 100px;
    left: 20px;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: white;
    border: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    cursor: pointer;
    z-index: 997;
    font-size: 20px;
    color: var(--primary-color);
}
.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-right: 10px;
}
#usernameDisplay {
    color: #333;
    font-weight: bold;
}
.logout-btn {
    background: #dc3545;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
}
.logout-btn:hover {
    background: #c82333;
}