/* ==================== 基础变量 ==================== */
:root {
    /* 配色方案 - 深色专业风格 */
    --bg-primary: #1a1a2e;      /* 主背景 */
    --bg-secondary: #16213e;     /* 次级背景 */
    --bg-tertiary: #0f0f23;      /* 深色区域 */
    --bg-hover: #1f2937;         /* 悬停背景 */
    --bg-active: #374151;        /* 激活背景 */
    
    --text-primary: #f3f4f6;     /* 主文字 */
    --text-secondary: #9ca3af;   /* 次级文字 */
    --text-muted: #6b7280;       /* 弱化文字 */
    
    --accent-primary: #0ea5e9;   /* 主色调 - 天蓝 */
    --accent-secondary: #06b6d4; /* 次色调 - 青色 */
    --accent-gradient: linear-gradient(135deg, #0ea5e9 0%, #06b6d4 100%);
    
    --border-color: #2d3748;     /* 边框颜色 */
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    
    --sidebar-width: 260px;
    --header-height: 60px;
    --input-height: 120px;
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    
    --transition: all 0.3s ease;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
}

/* ==================== 主容器 ==================== */
.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* ==================== 左侧边栏 ==================== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: var(--transition);
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.logo-icon {
    font-size: 32px;
}

.logo-text {
    font-size: 24px;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.new-chat-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--accent-gradient);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition);
}

.new-chat-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.new-chat-btn .icon {
    font-size: 18px;
}

/* 助手列表 */
.assistant-list {
    flex: 1;
    overflow-y: auto;
    padding: 16px 12px;
}

.assistant-list::-webkit-scrollbar {
    width: 6px;
}

.assistant-list::-webkit-scrollbar-track {
    background: transparent;
}

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

.list-title {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0 8px;
    margin-bottom: 12px;
}

.assistant-items {
    list-style: none;
}

.assistant-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    margin-bottom: 4px;
}

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

.assistant-item.active {
    background: var(--bg-active);
    border-left: 3px solid var(--accent-primary);
}

.assistant-item .avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    color: white;
    flex-shrink: 0;
}

.assistant-item .name {
    font-size: 14px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 边栏底部 */
.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
}

.brand-info {
    text-align: center;
}

.brand-info span {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
}

.brand-info small {
    display: block;
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ==================== 移动端菜单按钮 ==================== */
    /* 移动端输入框拉满 */
    .input-container {
        width: 100% !important;
        margin: 0;
    }
.mobile-menu-btn {
    display: none;
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 100;
    width: 40px;
    height: 40px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
}

.mobile-menu-btn span {
    width: 20px;
    height: 2px;
    background: var(--text-primary);
    border-radius: 1px;
    transition: var(--transition);
}

/* ==================== 主聊天区域 ==================== */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
    min-width: 0;
}

/* 聊天头部 */
.chat-header {
    height: var(--header-height);
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.current-assistant {
    display: flex;
    align-items: center;
    gap: 12px;
}

.current-assistant .assistant-avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 600;
    color: white;
}

.assistant-info {
    display: flex;
    flex-direction: column;
}

.assistant-info .assistant-name {
    font-size: 16px;
    font-weight: 600;
}

.assistant-info .assistant-status {
    font-size: 12px;
    color: #10b981;
}

.assistant-info .assistant-status::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    background: #10b981;
    border-radius: 50%;
    margin-right: 6px;
    animation: pulse 2s infinite;
}

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

.chat-actions {
    display: flex;
    gap: 8px;
}

.action-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-secondary);
    transition: var(--transition);
}

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

.action-btn svg {
    width: 18px;
    height: 18px;
}

/* ==================== 消息列表 ==================== */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.chat-messages::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

/* 欢迎消息 */
.welcome-message {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 40px;
}

.welcome-message.hidden {
    display: none;
}

.welcome-icon {
    font-size: 64px;
    margin-bottom: 24px;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.welcome-message h2 {
    font-size: 28px;
    font-weight: 600;
    margin-bottom: 12px;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.welcome-message p {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 32px;
}

.quick-prompts {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
    max-width: 500px;
}

.quick-prompt {
    padding: 10px 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
}

.quick-prompt:hover {
    background: var(--bg-hover);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

/* 消息样式 */
.message {
    display: flex;
    gap: 16px;
    max-width: 800px;
    width: 100%;
    margin: 0 auto;
}

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

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

.message.user .message-avatar {
    background: var(--accent-gradient);
}

.message.assistant .message-avatar {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

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

.message-bubble {
    padding: 16px 20px;
    border-radius: var(--radius-lg);
    line-height: 1.6;
    word-wrap: break-word;
}

.message.user .message-bubble {
    background: var(--accent-gradient);
    color: white;
    border-bottom-right-radius: 4px;
}

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

.message-bubble p {
    margin-bottom: 12px;
}

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

.message-bubble code {
    background: rgba(0, 0, 0, 0.3);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Fira Code', monospace;
    font-size: 13px;
}

.message-bubble pre {
    background: var(--bg-tertiary);
    padding: 16px;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    margin: 12px 0;
}

.message-bubble pre code {
    background: none;
    padding: 0;
}

.message-bubble ul, .message-bubble ol {
    margin: 12px 0;
    padding-left: 24px;
}

.message-bubble li {
    margin-bottom: 6px;
}

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

.message.user .message-time {
    text-align: right;
}

/* 加载动画 */
.message.loading .message-bubble {
    display: flex;
    align-items: center;
    gap: 8px;
}

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

.loading-dots span {
    width: 8px;
    height: 8px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out;
}

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

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* ==================== 输入区域 ==================== */
.chat-input-area {
    display: flex;
    justify-content: center;
    padding: 16px 24px 24px;
    background: var(--bg-primary);
}

.input-container {
    display: flex;
    width: 100%;
    align-items: flex-end;
    gap: 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 12px 16px;
    transition: var(--transition);
}

.input-container:focus-within {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.input-container textarea {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 15px;
    line-height: 1.5;
    resize: none;
    max-height: 120px;
    min-height: 24px;
}

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

.send-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-gradient);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    color: white;
    transition: var(--transition);
    flex-shrink: 0;
}

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

.send-btn:not(:disabled):hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.send-btn svg {
    width: 20px;
    height: 20px;
}

.input-hint {
    text-align: center;
    margin-top: 12px;
    font-size: 11px;
    color: var(--text-muted);
}

/* ==================== 响应式设计 ==================== */
@media (max-width: 768px) {
    /* 移动端输入框拉满 */
    .input-container {
        width: 100% !important;
        margin: 0;
    }
    .mobile-menu-btn {
        display: flex;
    }
    
    .sidebar {
        position: fixed;
        left: -100%;
        top: 0;
        height: 100vh;
        z-index: 99;
        width: 280px;
    }
    
    .sidebar.open {
        left: 0;
    }
    
    .chat-main {
        padding-top: 0;
    }
    
    .chat-header {
        padding-left: 70px;
    }
    
    .welcome-message h2 {
        font-size: 22px;
    }
    
    .welcome-icon {
        font-size: 48px;
    }
    
    .quick-prompts {
        flex-direction: column;
    }
    
    .message {
        gap: 12px;
    }
    
    .message-avatar {
        width: 32px;
        height: 32px;
        font-size: 12px;
    }
    
    .message-bubble {
        padding: 12px 16px;
    }
    
}

/* 遮罩层 */
.overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 98;
}

.overlay.active {
    display: block;
}

/* 错误提示 */
.error-toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: #ef4444;
    color: white;
    padding: 12px 24px;
    border-radius: var(--radius-md);
    font-size: 14px;
    z-index: 1000;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* ==================== 切换助手按钮 ==================== */
.switch-assistant-btn {
    display: none; /* PC端隐藏，用侧边栏切换 */
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    flex-shrink: 0;
}

.switch-assistant-btn:hover {
    color: var(--accent-primary);
    background: var(--bg-hover);
}

.switch-assistant-btn svg {
    width: 20px;
    height: 20px;
    transform: scaleX(-1); /* 箭头朝左 */
}

/* 手机端显示切换按钮 */
@media (max-width: 768px) {
    .switch-assistant-btn {
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    /* 移动端输入框拉满 */
    .input-container {
        width: 100% !important;
        margin: 0;
    }
    .mobile-menu-btn {
        display: none !important; /* 隐藏汉堡菜单，用切换按钮替代 */
    }
}

/* ==================== 手机端助手选择器 ==================== */
.assistant-picker-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    display: flex;
    align-items: flex-end;
    animation: fadeIn 0.2s ease;
}

.assistant-picker {
    width: 100%;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding: 0;
    animation: slideUp 0.3s ease;
    max-height: 70vh;
}

.picker-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    font-weight: 600;
    font-size: 16px;
}

.picker-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}

.picker-list {
    padding: 8px 12px 24px;
    overflow-y: auto;
}

.picker-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 12px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
}

.picker-item:hover, .picker-item:active {
    background: var(--bg-hover);
}

.picker-item.active {
    background: rgba(14, 165, 233, 0.15);
}

.picker-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 16px;
    flex-shrink: 0;
}

.picker-info {
    flex: 1;
}

.picker-name {
    color: var(--text-primary);
    font-weight: 600;
    font-size: 15px;
}

.picker-desc {
    color: var(--text-secondary);
    font-size: 13px;
    margin-top: 2px;
}

.picker-check {
    color: var(--accent-primary);
    font-size: 18px;
    font-weight: 700;
}

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

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

/* ==================== 手机端底部Tab栏 ==================== */
.mobile-tab-bar {
    display: none; /* PC端隐藏 */
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 72px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    z-index: 100;
    padding-bottom: 12px;
}

.mobile-tab-bar .tab-list {
    display: flex;
    height: 100%;
    list-style: none;
    margin: 0;
    padding: 0;
}

.mobile-tab-bar .tab-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    cursor: pointer;
    transition: var(--transition);
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.mobile-tab-bar .tab-item:active {
    opacity: 0.7;
}

.mobile-tab-bar .tab-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 16px;
    transition: var(--transition);
}

.mobile-tab-bar .tab-item.active .tab-icon {
    transform: scale(1.15);
    box-shadow: 0 0 12px rgba(14, 165, 233, 0.4);
}

.mobile-tab-bar .tab-label {
    font-size: 12px;
    color: var(--text-muted);
    transition: var(--transition);
}

.mobile-tab-bar .tab-item.active .tab-label {
    color: var(--accent-primary);
    font-weight: 600;
}
@media (max-width: 768px) {
    .mobile-tab-bar {
        display: block;
    }
    
    /* 输入区域固定在Tab栏上方 */
    .chat-input-area {
        position: fixed;
        bottom: 72px;
        left: 0;
        right: 0;
        width: 100%;
        left: 0;
        right: 0;
        z-index: 99;
        padding: 8px 0 4px;
        background: var(--bg-primary);
        border-top: 1px solid var(--border-color);
    }
    
    /* 消息区域给Tab栏留空间 */
    .chat-messages {
        padding-bottom: 130px;
    }
    
    /* 隐藏切换按钮和汉堡菜单，用Tab栏替代 */
    .switch-assistant-btn {
        display: none !important;
    }
    
    /* 移动端输入框拉满 */
    .input-container {
        width: 100% !important;
        margin: 0;
    }
    .mobile-menu-btn {
        display: none !important;
    }
}
/* Logo图片样式 */
.logo-icon-img {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    object-fit: cover;
}

.welcome-icon img {
    width: 80px;
    height: 80px;
    border-radius: 16px;
    object-fit: cover;
}

@media (max-width: 768px) {
    .logo-icon-img {
        width: 32px;
        height: 32px;
        border-radius: 6px;
    }
    .welcome-icon img {
        width: 64px;
        height: 64px;
        border-radius: 12px;
    }
}
