/* 全局重置与高端字体 */
:root {
    --bg-main: #fcfcfc;
    --sidebar-bg: rgba(255, 255, 255, 0.95);
    --accent: #1a1a1a;
    --text-main: #2c2c2e;
    --text-muted: #8e8e93;
    --glass: rgba(255, 255, 255, 0.7);
    --shadow: 0 10px 30px rgba(0,0,0,0.05);
    --transition: all 0.4s cubic-bezier(0.25, 1, 0.5, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body { 
    font-family: 'Inter', 'Noto Sans SC', -apple-system, sans-serif; 
    background-color: var(--bg-main); 
    color: var(--text-main);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

/* 布局：呼吸感的核心 */
.app-container { display: flex; height: 100vh; width: 100vw; position: relative; }

/* 侧边栏：抽屉式克制设计 */
.sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: 300px;
    background: var(--sidebar-bg); backdrop-filter: blur(20px);
    border-right: 1px solid rgba(0,0,0,0.05);
    z-index: 100; padding: 40px 24px;
    transform: translateX(-100%); transition: var(--transition);
}
.sidebar.active { transform: translateX(0); box-shadow: 20px 0 50px rgba(0,0,0,0.03); }

/* 侧边栏遮罩层 */
.sidebar-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.3);
    opacity: 0; visibility: hidden; transition: var(--transition); z-index: 90;
}
.sidebar-overlay.active { opacity: 1; visibility: visible; }

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}
.sidebar-close {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: var(--text-muted);
    opacity: 0.6;
    transition: 0.3s;
}
.sidebar-close:hover { opacity: 1; }
.sidebar h2 { font-weight: 500; font-size: 1.2rem; letter-spacing: -0.5px; }
.settings-group label { display: block; font-size: 0.8rem; color: var(--text-muted); margin: 15px 0 8px 4px; }
.settings-group input, .settings-group select {
    width: 100%; padding: 12px 16px; border-radius: 12px;
    border: 1px solid rgba(0,0,0,0.08); background: #fbfbfb;
    font-size: 0.9rem; outline: none; transition: var(--transition);
}
.settings-group input:focus { border-color: var(--accent); background: #fff; }

/* 主聊天区 */
.chat-wrapper { flex: 1; display: flex; flex-direction: column; position: relative; height: 100%; }

.chat-header {
    height: 70px; display: flex; align-items: center; justify-content: space-between;
    padding: 0 30px; border-bottom: 1px solid rgba(0,0,0,0.03); background: var(--glass);
    backdrop-filter: blur(10px); z-index: 10;
}
.friend-info { display: flex; align-items: center; gap: 10px; }
.status-dot { width: 8px; height: 8px; background: #34c759; border-radius: 50%; }
.friend-info h1 { font-size: 1rem; font-weight: 500; }

/* 消息流 */
.message-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 40px 15% 120px 15%;
    scroll-behavior: smooth;
}

/* 欢迎页动画 */
.welcome-view { margin: auto; text-align: center; opacity: 0.6; transition: 1s; }
.logo-animation { display: flex; justify-content: center; gap: 8px; margin-bottom: 20px; }
.logo-animation span {
    width: 6px; height: 6px; background: var(--accent); border-radius: 50%;
    animation: pulse 1.5s infinite ease-in-out;
}
.logo-animation span:nth-child(2) { animation-delay: 0.2s; }
.logo-animation span:nth-child(3) { animation-delay: 0.4s; }

/* 气泡设计 */
.bubble-wrapper {
    margin-bottom: 24px;
    opacity: 0;
    transform: translateY(10px);
    animation: fadeIn 0.5s forwards;
}
.bubble-wrapper.me { text-align: right; }
.bubble-wrapper.him { text-align: left; }
.bubble {
    display: inline-block;
    max-width: 80%;
    padding: 14px 20px;
    border-radius: 20px;
    font-size: 0.95rem;
    line-height: 1.6;
    text-align: left;
    word-break: break-word;
    overflow-wrap: break-word;
}
.bubble-wrapper.me .bubble {
    background: var(--accent);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.bubble-wrapper.him .bubble {
    background: #fff;
    border: 1px solid rgba(0,0,0,0.05);
    border-bottom-left-radius: 4px;
    box-shadow: var(--shadow);
}

/* 输入区：悬浮卡片感 */
.input-area {
    position: absolute; bottom: 30px; left: 0; right: 0;
    padding: 0 15%; display: flex; justify-content: center;
}
.input-card {
    width: 100%; max-width: 800px; background: #fff;
    padding: 8px 12px; border-radius: 24px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.08);
    display: flex; align-items: center; gap: 10px;
}
textarea {
    flex: 1; border: none; outline: none; padding: 12px;
    font-size: 0.95rem; resize: none; max-height: 150px; font-family: inherit;
}
.send-btn {
    width: 44px; height: 44px; border-radius: 50%; border: none;
    background: var(--accent); color: #fff; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: var(--transition);
}
.send-btn:hover { transform: scale(1.05); filter: brightness(1.2); }

.icon-btn { background: none; border: none; cursor: pointer; color: var(--text-main); opacity: 0.6; transition: 0.3s; }
.icon-btn:hover { opacity: 1; }

.btn-secondary {
    width: 100%; padding: 14px; border-radius: 12px; border: 1px solid var(--accent);
    background: none; cursor: pointer; margin-top: 20px; font-weight: 500; transition: 0.3s;
}
.btn-secondary:hover { background: var(--accent); color: #fff; }

/* 动画帧 */
@keyframes fadeIn { to { opacity: 1; transform: translateY(0); } }
@keyframes pulse { 0%, 100% { transform: scale(1); opacity: 0.3; } 50% { transform: scale(1.5); opacity: 1; } }

/* 自定义滚动条 */
.message-container::-webkit-scrollbar { width: 4px; }
.message-container::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.05); border-radius: 10px; }

/* 移动端适配 */
@media (max-width: 768px) {
    .message-container { padding: 20px 20px 100px 20px; }
    .input-area { padding: 0 20px; bottom: 20px; }
}

/* Agent 分析过程样式 */
.agent-steps-wrapper {
    margin: 20px 0;
    border-radius: 12px;
    overflow: hidden;
}
.agent-steps-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: none;
    padding: 10px 20px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.3s;
}
.agent-steps-btn:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}
.agent-steps-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease-out;
    background: #f8f9fa;
    border-radius: 12px;
    margin-top: 10px;
}
.agent-steps-content.active {
    max-height: 800px;
    padding: 15px;
}
.agent-step {
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid rgba(0,0,0,0.05);
}
.agent-step:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}
.agent-step-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: #667eea;
    margin-bottom: 8px;
}
.agent-step-content {
    font-size: 0.85rem;
    color: #666;
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* RAG 检索信息样式 */
.rag-info-wrapper {
    margin: 20px 0;
    border-radius: 12px;
    overflow: hidden;
}
.rag-info-btn {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: #fff;
    border: none;
    padding: 10px 20px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.3s;
}
.rag-info-btn:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 15px rgba(245, 87, 108, 0.4);
}
.rag-info-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease-out;
    background: #f8f9fa;
    border-radius: 12px;
    margin-top: 10px;
}
.rag-info-content.active {
    max-height: 800px;
    padding: 15px;
}
.rag-section {
    margin-bottom: 20px;
}
.rag-section:last-child {
    margin-bottom: 0;
}
.rag-section-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: #f5576c;
    margin-bottom: 10px;
}
.rag-keywords {
    font-size: 0.9rem;
    color: #333;
    padding: 10px 12px;
    background: #fff;
    border-radius: 8px;
    border-left: 3px solid #f5576c;
}
.rag-records {
    font-size: 0.85rem;
    color: #666;
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
    max-height: 400px;
    overflow-y: auto;
    padding: 10px 12px;
    background: #fff;
    border-radius: 8px;
}