/*
Theme Name: BenjiyunAI
Author: JeyooZ
Description: 一个极简风格的AI对话主题，灵感源自 Apple 设计风格。
Version: 1.0
*/

/* * ==============================
 * 全局变量定义 (CSS Variables)
 * ==============================
 * 这里定义了主题的主色调、背景色、边框色等，方便一键换肤。
 */
 :root {
    --primary: #0071e3;          /* 主色调 (Apple Blue) */
    --primary-hover: #0077ed;    /* 悬停时的深蓝色 */
    --bg: #ffffff;               /* 全局背景白 */
    --sidebar: #f5f5f7;          /* 侧边栏浅灰 (Apple Light Gray) */
    --border: #e5e5e5;           /* 边框颜色 */
    --text: #1d1d1f;             /* 主文字颜色 (Apple Black) */
    --text-sub: #86868b;         /* 次要文字颜色 (灰色) */
    --glass: rgba(255, 255, 255, 0.8); /* 毛玻璃背景基色 */
    --glass-blur: 20px;          /* 毛玻璃模糊度 */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);   /* 小阴影 */
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);  /* 中阴影 */
    --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.15); /* 大阴影 (用于弹窗) */
    --font-stack: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", sans-serif; /* 系统字体栈 */
}

/* 基础重置 */
* { box-sizing: border-box; }

html, body {
    margin: 0; padding: 0;
    width: 100%; height: 100%;
    overflow: hidden; /* 防止页面整体滚动，只允许聊天区域滚动 */
    font-family: var(--font-stack);
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased; /* 字体抗锯齿 */
}

/* * ==============================
 * 布局结构 (Layout)
 * ==============================
 */
#app {
    display: flex;
    width: 100%;
    height: 100%;
    position: relative;
}

/* * ==============================
 * 侧边栏样式 (Sidebar)
 * ==============================
 */
aside {
    width: 260px;
    background: var(--sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1); /* 移动端滑出动画 */
    z-index: 100;
    flex-shrink: 0;
}

/* Logo 区域 */
.sidebar-header {
    height: 60px;
    padding: 0 20px;
    display: flex;
    align-items: center;
    font-weight: 600;
    font-size: 17px;
}
.sidebar-logo { height: 24px; width: auto; }

/* "新对话" 按钮 */
.new-chat-btn {
    margin: 10px 15px;
    padding: 10px 16px;
    background: #fff;
    border-radius: 12px;
    border: 1px solid rgba(0, 0, 0, 0.05);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    box-shadow: var(--shadow-sm);
}
.new-chat-btn:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

/* 历史记录列表 */
.history-list {
    flex: 1; /* 占据剩余空间 */
    overflow-y: auto; /* 内容过多时滚动 */
    padding: 10px;
}
.h-item {
    padding: 10px 14px;
    margin-bottom: 2px;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis; /* 文字超长显示省略号 */
    color: var(--text);
}
.h-item:hover { background: rgba(0, 0, 0, 0.05); }

/* 用户信息栏 (左下角) */
.user-bar {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.2s;
}
.user-bar:hover { background: rgba(0, 0, 0, 0.03); }

.user-profile { display: flex; align-items: center; gap: 12px; }
.user-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid rgba(0, 0, 0, 0.1);
}
.user-info { flex: 1; display: flex; flex-direction: column; justify-content: center; }
.user-name { font-weight: 600; font-size: 14px; color: var(--text); }
.user-status { font-size: 12px; color: var(--text-sub); }
.settings-icon { width: 20px; height: 20px; color: var(--text-sub); transition: color 0.2s; }
.user-bar:hover .settings-icon { color: var(--text); }

/* * ==============================
 * 主内容区域 (Main Content)
 * ==============================
 */
main {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    width: 100%;
}

/* 顶部导航栏 (Header) */
header {
    height: 60px;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(20px); /* 毛玻璃效果 */
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    position: absolute;
    top: 0; left: 0; right: 0;
    z-index: 10;
}

/* 移动端菜单按钮 */
.mobile-menu {
    display: none; /* 默认隐藏，小屏幕显示 */
    background: none; border: none;
    font-size: 20px; padding: 0; cursor: pointer;
}

/* 余额显示胶囊 */
.header-right { display: flex; align-items: center; gap: 15px; margin-left: auto; }
.balance-pill {
    display: flex; align-items: center; gap: 6px;
    background: #f5f5f7; padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px; font-weight: 500;
    color: var(--text); cursor: pointer;
    transition: 0.2s; border: 1px solid transparent;
    font-family: var(--font-stack);
}
.balance-pill:hover { background: #e8e8ed; border-color: #d2d2d7; }
.balance-icon { font-size: 14px; }

/* * ==============================
 * 聊天窗口 (Chat Window)
 * ==============================
 */
#chat-window {
    flex: 1;
    overflow-y: auto; /* 允许垂直滚动 */
    padding: 80px 20px 140px 20px; /* 留出顶部 Header 和底部输入框的空间 */
    scroll-behavior: smooth;
}

/* 欢迎屏幕 */
.welcome {
    margin-top: 8vh;
    text-align: center;
    max-width: 800px;
    margin-left: auto; margin-right: auto;
}
.welcome h1 { font-size: 32px; font-weight: 600; margin-bottom: 10px; letter-spacing: -0.5px; }
.welcome p { color: var(--text-sub); font-size: 16px; margin-bottom: 40px; }

/* 公告胶囊 */
.notice-capsule {
    display: inline-flex; align-items: center; gap: 8px;
    background: #eef5ff; color: var(--primary);
    padding: 8px 16px; border-radius: 20px;
    font-size: 13px; font-weight: 500;
    cursor: pointer; margin-bottom: 30px; transition: 0.2s;
}
.notice-capsule:hover { background: #e0ecff; transform: scale(1.02); }

/* 提示词 (Prompts) */
.prompt-tabs {
    display: flex; justify-content: center; gap: 8px;
    margin-bottom: 24px; flex-wrap: wrap;
}
.tab-btn {
    padding: 6px 14px; border-radius: 18px;
    background: #f2f2f7; color: var(--text-sub);
    font-size: 13px; font-weight: 500;
    cursor: pointer; transition: 0.2s;
}
.tab-btn.active { background: var(--text); color: #fff; }

.prompt-grid {
    display: none; /* 默认隐藏，通过 JS 切换 active 显示 */
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); /* 自适应网格布局 */
    gap: 16px;
}
.prompt-grid.active { display: grid; }

.p-card {
    background: #fff; border: 1px solid rgba(0, 0, 0, 0.08);
    padding: 16px; border-radius: 16px;
    cursor: pointer; transition: 0.2s;
    display: flex; flex-direction: column; gap: 8px;
    box-shadow: var(--shadow-sm);
}
.p-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}
.p-icon img { width: 32px; height: 32px; border-radius: 8px; }
.p-title { font-weight: 600; font-size: 15px; }
.p-desc {
    font-size: 13px; color: var(--text-sub);
    line-height: 1.4;
    display: -webkit-box; -webkit-line-clamp: 2; /* 限制显示2行 */
    -webkit-box-orient: vertical; overflow: hidden;
}

/* 换一批按钮 */
.refresh-container { display: flex; justify-content: center; margin-top: 30px; }
.btn-refresh {
    display: inline-flex; align-items: center; gap: 6px;
    background: transparent; border: 1px solid #d2d2d7;
    padding: 8px 20px; border-radius: 20px;
    font-size: 13px; font-weight: 500;
    color: var(--text-sub); cursor: pointer;
    transition: 0.2s; font-family: var(--font-stack);
}
.btn-refresh:hover { background: #f5f5f7; color: var(--text); border-color: #c7c7cc; }
.btn-refresh:active { transform: scale(0.98); }

/* * ==============================
 * 输入区域 (Input Area)
 * ==============================
 */
.input-area {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    padding: 20px;
    display: flex; justify-content: center;
    z-index: 20;
    background: linear-gradient(to top, #fff 60%, rgba(255, 255, 255, 0) 100%); /* 渐变遮罩 */
}

.input-box {
    width: 100%; max-width: 760px;
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 28px;
    padding: 12px 16px 12px 20px;
    transition: 0.3s;
    box-shadow: var(--shadow-md);
    display: flex; flex-direction: column;
}
.input-box:focus-within {
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12); /* 聚焦时阴影加深 */
    border-color: rgba(0, 0, 0, 0.15);
}

textarea {
    width: 100%; border: none; background: transparent;
    outline: none; resize: none; /* 禁止手动拉伸 */
    font-size: 16px; line-height: 1.5;
    max-height: 200px; min-height: 24px;
    padding: 0; font-family: inherit;
}

.tools { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }
.tool-left { display: flex; align-items: center; }
.tool-right { display: flex; align-items: center; gap: 12px; }

/* 附件按钮 (+) */
.attach-btn {
    display: flex; align-items: center; justify-content: center;
    width: 32px; height: 32px;
    border-radius: 50%; cursor: pointer;
    transition: 0.2s; color: var(--text);
    margin-right: 5px;
}
.attach-btn:hover { background: #f5f5f7; }

/* 自定义模型选择器 */
.model-selector-custom { position: relative; display: inline-block; z-index: 100; }
.model-trigger {
    display: flex; align-items: center; gap: 6px;
    background-color: #f5f5f7; padding: 6px 12px;
    border-radius: 18px; font-size: 13px; font-weight: 600;
    color: var(--text); cursor: pointer;
    transition: background 0.2s; user-select: none; height: 32px;
}
.model-trigger:hover, .model-selector-custom.active .model-trigger { background-color: #e5e5ea; }

.model-popup {
    display: none; /* 默认隐藏 */
    position: absolute; bottom: 100%; left: 0;
    margin-bottom: 10px; width: 220px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(0, 0, 0, 0.05);
    padding: 6px;
    flex-direction: column; gap: 2px;
    animation: popupScale 0.2s cubic-bezier(0.1, 0.9, 0.2, 1);
    transform-origin: bottom left;
}
.model-selector-custom.active .model-popup { display: flex; }

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

.model-option {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 12px; border-radius: 10px;
    cursor: pointer; font-size: 14px;
    color: var(--text); transition: background 0.1s;
}
.model-option:hover { background-color: #f5f5f7; }
.model-option.selected { background-color: #eef5ff; font-weight: 600; }
.check-icon { width: 16px; height: 16px; color: var(--primary); opacity: 0; }
.model-option.selected .check-icon { opacity: 1; }

@media (max-width: 480px) { .model-popup { width: 200px; } }

/* 发送按钮 */
.send-btn {
    border: none; background: transparent; color: var(--primary);
    width: 32px; height: 32px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: all 0.2s; padding: 0;
}
.send-btn:hover { background: #f5f5f7; transform: scale(1.1); }
.send-btn svg { width: 20px; height: 20px; fill: currentColor; margin-left: 2px; }

/* 图片预览区 */
#img-preview { display: flex; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.img-thumb-box { position: relative; width: 50px; height: 50px; transition: transform 0.2s; }
.img-thumb-box:hover { transform: scale(1.05); }
.img-thumb-box img { width: 100%; height: 100%; border-radius: 8px; object-fit: cover; border: 1px solid #eee; }
.img-remove {
    position: absolute; top: -6px; right: -6px;
    width: 18px; height: 18px;
    background: #ff3b30; color: #fff;
    border-radius: 50%; text-align: center; line-height: 16px;
    font-size: 12px; cursor: pointer;
    border: 2px solid #fff; box-shadow: var(--shadow-sm);
}

/* * ==============================
 * 消息气泡 (Messages)
 * ==============================
 */
.msg {
    max-width: 760px; margin: 0 auto 32px;
    display: flex; gap: 16px;
    animation: fadeIn 0.3s ease;
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* 用户消息 (右侧) */
.msg.user { justify-content: flex-end; }
.msg.user .bubble {
    background: #eef5ff; color: var(--text);
    border-radius: 20px 20px 4px 20px;
}

/* AI 消息 (左侧) */
.msg.assistant .bubble { background: transparent; padding: 0; width: 100%; }

.bubble {
    padding: 12px 18px; font-size: 16px; line-height: 1.6;
    max-width: 85%;
}
.bubble img { max-width: 100%; border-radius: 12px; margin-top: 8px; }
.bubble pre {
    background: #1e1e1e; padding: 16px; border-radius: 12px;
    overflow-x: auto; color: #fff; font-size: 14px; margin: 12px 0;
}

.msg .avatar {
    width: 36px; height: 36px; border-radius: 50%;
    flex-shrink: 0; display: flex; align-items: center; justify-content: center;
    font-size: 18px; background: #f2f2f7; object-fit: cover;
}
.msg.assistant .avatar {
    background: linear-gradient(135deg, #00C6FB 0%, #005BEA 100%);
    color: white; box-shadow: 0 4px 10px rgba(0, 91, 234, 0.2);
}
.msg.user .avatar { display: none; }

/* 思考中状态 */
.thinking-container {
    display: inline-flex; align-items: center;
    background: #fff; padding: 10px 16px;
    border-radius: 20px; border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: var(--shadow-sm); color: var(--text-sub); font-size: 14px;
}
.pulse-ring {
    width: 8px; height: 8px; background: var(--primary);
    border-radius: 50%; margin-right: 12px;
    animation: pulse 2s infinite;
}
@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(0, 113, 227, 0.4); }
    70% { box-shadow: 0 0 0 8px rgba(0, 113, 227, 0); }
    100% { box-shadow: 0 0 0 0 rgba(0, 113, 227, 0); }
}

/* * ==============================
 * 弹窗组件 (Modals)
 * ==============================
 */
.modal-overlay {
    display: none; /* 默认隐藏 */
    position: fixed; inset: 0; z-index: 9999;
    background: rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(15px);
    align-items: center; justify-content: center;
}
.modal-box {
    background: #fff; padding: 30px; border-radius: 24px;
    width: 90%; max-width: 400px;
    box-shadow: var(--shadow-lg);
    border: 1px solid rgba(255, 255, 255, 0.8);
    position: relative; text-align: center;
}
.modal-close {
    position: absolute; top: 15px; right: 20px;
    cursor: pointer; font-size: 24px; color: #ccc;
}

/* 遮罩层 - 用于移动端侧边栏等 */
#overlay {
    display: none; position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.4);
    z-index: 90; backdrop-filter: blur(2px);
}

/* 弹窗表单元素 */
.modal-box input {
    width: 100%; padding: 14px; margin: 8px 0;
    border: 1px solid #d2d2d7; border-radius: 12px;
    font-size: 16px; outline: none; transition: 0.2s;
    font-family: var(--font-stack);
    -webkit-appearance: none; appearance: none;  
}
.modal-box input::placeholder { font-family: var(--font-stack); color: #999; }
.modal-box input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.1); }
.modal-box button {
    width: 100%; padding: 14px; margin-top: 10px;
    background: var(--primary); color: #fff;
    border: none; border-radius: 12px;
    font-size: 16px; font-weight: 600;
    cursor: pointer; transition: 0.2s;
    font-family: var(--font-stack);
}
.modal-box button:hover { background: var(--primary-hover); transform: scale(1.01); }
.modal-box button:active { transform: scale(0.98); }

/* 用户资料弹窗特有样式 */
.ac-avatar {
    width: 80px; height: 80px; border-radius: 50%;
    margin: 0 auto 15px; object-fit: cover;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
}
.ac-name { font-size: 20px; font-weight: 700; color: var(--text); margin-bottom: 5px; }
.ac-role {
    font-size: 13px; color: var(--primary);
    background: rgba(0, 113, 227, 0.1); padding: 4px 10px;
    border-radius: 12px; display: inline-block;
    margin-bottom: 20px; font-weight: 600;
}
.ac-stats {
    display: flex; justify-content: space-between; margin-bottom: 25px;
    padding: 15px; background: #f5f5f7; border-radius: 16px;
}
.ac-stat-item { flex: 1; text-align: center; }
.ac-stat-num { font-size: 18px; font-weight: 700; color: var(--text); display: block; }
.ac-stat-label { font-size: 12px; color: var(--text-sub); }
.ac-divider { height: 40px; width: 1px; background: #e5e5e5; }
.ac-logout {
    margin-top: 15px; display: block;
    font-size: 14px; color: #ff3b30;
    text-decoration: none; cursor: pointer;
}

/* * ==============================
 * 响应式适配 (Mobile Responsive)
 * ==============================
 */
@media (max-width: 768px) {
    aside {
        position: fixed; height: 100%;
        transform: translateX(-100%); /* 默认移出屏幕 */
        box-shadow: 10px 0 30px rgba(0, 0, 0, 0.1);
    }
    aside.active { transform: translateX(0); /* 激活时滑入 */ }
    .mobile-menu { display: block; }
    .header-right { margin-right: 5px; }
    .balance-pill span { display: inline-block; }
}