/* ===== Theme System ===== */
/* 三主题：亮色(ASTEM莫兰迪) / 深空赛博 / 跟随系统 */

/* 亮色主题（默认）— ASTEM 莫兰迪色系 */
:root,
[data-theme="light"] {
    --primary: #6366f1;
    --primary-light: #818cf8;
    --primary-dark: #4f46e5;
    --bg: #FDFCF5;
    --bg-card: #FFFEFA;
    --bg-input: #F5F4ED;
    --text: #4D4D4D;
    --text-muted: #B3B3B3;
    --border: #D4D4CE;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: rgba(77, 77, 77, 0.1);
    --nav-bg: rgba(253, 252, 245, 0.9);
    --overlay-bg: rgba(77, 77, 77, 0.3);
    --orb-1: rgba(99, 102, 241, 0.1);
    --orb-2: rgba(192, 132, 252, 0.06);
    --orb-3: rgba(99, 102, 241, 0.05);
    --accent-a: #FDEEF0;
    --accent-s: #EDF1F8;
    --accent-t: #FDF3EF;
    --accent-e: #F0F8E8;
    --accent-m: #F3EEF8;
}

/* 深空赛博主题（暗色） */
[data-theme="cyber"] {
    --primary: #6366f1;
    --primary-light: #818cf8;
    --primary-dark: #4f46e5;
    --accent: #22e5e5;
    --bg: #0a0a0f;
    --bg-card: #12121a;
    --bg-input: #1a1a24;
    --text: #f0f0f8;
    --text-muted: #d4d4f0;
    --border: #27272a;
    --border-light: #3a3a4a;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: rgba(0,0,0,0.5);
    --nav-bg: rgba(10, 10, 15, 0.85);
    --overlay-bg: rgba(0,0,0,0.7);
    --orb-1: rgba(99, 102, 241, 0.25);
    --orb-2: rgba(34, 229, 229, 0.15);
    --orb-3: rgba(129, 140, 248, 0.12);
}

/* 跟随系统 — 亮色端 */
@media (prefers-color-scheme: light) {
    [data-theme="system"] {
        --primary: #6366f1;
        --primary-light: #818cf8;
        --primary-dark: #4f46e5;
        --bg: #FDFCF5;
        --bg-card: #FFFEFA;
        --bg-input: #F5F4ED;
        --text: #4D4D4D;
        --text-muted: #B3B3B3;
        --border: #D4D4CE;
        --radius: 12px;
        --radius-sm: 8px;
        --shadow: rgba(77, 77, 77, 0.1);
        --nav-bg: rgba(253, 252, 245, 0.9);
        --overlay-bg: rgba(77, 77, 77, 0.3);
        --orb-1: rgba(99, 102, 241, 0.1);
        --orb-2: rgba(192, 132, 252, 0.06);
        --orb-3: rgba(99, 102, 241, 0.05);
        --accent-a: #FDEEF0;
        --accent-s: #EDF1F8;
        --accent-t: #FDF3EF;
        --accent-e: #F0F8E8;
        --accent-m: #F3EEF8;
    }
}
/* 跟随系统 — 暗色端（使用深空赛博配色） */
@media (prefers-color-scheme: dark) {
    [data-theme="system"] {
        --primary: #6366f1;
        --primary-light: #818cf8;
        --primary-dark: #4f46e5;
        --accent: #22e5e5;
        --bg: #0a0a0f;
        --bg-card: #12121a;
        --bg-input: #1a1a24;
        --text: #f0f0f8;
        --text-muted: #d4d4f0;
        --border: #27272a;
        --border-light: #3a3a4a;
        --radius: 12px;
        --radius-sm: 8px;
        --shadow: rgba(0,0,0,0.5);
        --nav-bg: rgba(10, 10, 15, 0.85);
        --overlay-bg: rgba(0,0,0,0.7);
        --orb-1: rgba(99, 102, 241, 0.25);
        --orb-2: rgba(34, 229, 229, 0.15);
        --orb-3: rgba(129, 140, 248, 0.12);
    }
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    transition: background 0.3s ease, color 0.3s ease;
}
a { color: inherit; text-decoration: none; }

/* Homepage */
.homepage-nav {
    display: flex; justify-content: space-between; align-items: center;
    padding: 20px 40px; position: fixed; top: 0; left: 0; right: 0;
    z-index: 100; background: var(--nav-bg); backdrop-filter: blur(20px);
}
.nav-brand { display: flex; align-items: center; gap: 8px; font-size: 20px; font-weight: 600; }
.brand-icon { font-size: 24px; color: var(--primary-light); }
.nav-actions { display: flex; align-items: center; gap: 8px; }
.btn-login {
    padding: 8px 20px; border: 1px solid var(--border); border-radius: 20px;
    background: transparent; color: var(--text); cursor: pointer; font-size: 14px; transition: all 0.2s;
}
.btn-login:hover { background: var(--primary); border-color: var(--primary); }
.hero {
    display: flex; align-items: center; justify-content: space-between;
    min-height: 100vh; padding: 120px 80px 80px; position: relative; overflow: hidden;
}
.hero-content { max-width: 560px; z-index: 2; }
.hero-title { margin-bottom: 24px; }
.title-line { display: block; font-size: 56px; font-weight: 700; line-height: 1.15; letter-spacing: -1px; }
.title-line.accent {
    background: linear-gradient(135deg, var(--primary-light), #c084fc);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.hero-subtitle { font-size: 14px; color: var(--text-muted); margin-bottom: 16px; letter-spacing: 2px; text-transform: uppercase; }
.hero-desc { font-size: 18px; color: var(--text-muted); line-height: 1.6; margin-bottom: 40px; }
.btn-enter {
    display: inline-flex; align-items: center; gap: 10px; padding: 14px 32px;
    background: var(--primary); border: none; border-radius: 28px; color: white;
    font-size: 16px; font-weight: 500; cursor: pointer; transition: all 0.3s;
}
.btn-enter:hover { background: var(--primary-dark); transform: translateY(-2px); box-shadow: 0 8px 24px rgba(99, 102, 241, 0.3); }
.hero-visual { position: relative; width: 400px; height: 400px; }
.orb { position: absolute; border-radius: 50%; filter: blur(60px); animation: float 6s ease-in-out infinite; }
.orb:nth-child(1) { width: 300px; height: 300px; background: var(--orb-1); top: 50px; right: 0; }
.orb-2 { width: 200px; height: 200px; background: var(--orb-2); top: 150px; right: 100px; animation-delay: -2s; }
.orb-3 { width: 150px; height: 150px; background: var(--orb-3); top: 0; right: 200px; animation-delay: -4s; }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-20px); } }
.features { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; padding: 40px 80px 80px; }
.feature-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 32px; transition: transform 0.2s, background 0.3s; }
.feature-card:hover { transform: translateY(-4px); }
.feature-icon { font-size: 32px; margin-bottom: 16px; }
.feature-card h3 { font-size: 18px; margin-bottom: 8px; }
.feature-card p { font-size: 14px; color: var(--text-muted); line-height: 1.6; }

/* Modal */
.modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: var(--overlay-bg); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.modal-box { background: var(--bg-card); border: 1px solid var(--border); border-radius: 16px; width: 400px; max-width: 90vw; max-height: 85vh; display: flex; flex-direction: column; overflow: hidden; transition: background 0.3s; }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 24px 24px 0; }
.modal-header h2 { font-size: 22px; font-weight: 600; }
.modal-close { background: none; border: none; color: var(--text-muted); font-size: 24px; cursor: pointer; padding: 4px 8px; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 24px; overflow-y: auto; flex: 1; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; color: var(--text-muted); margin-bottom: 6px; }
.form-group input { width: 100%; padding: 12px 14px; background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text); font-size: 15px; outline: none; transition: border-color 0.2s; }
.form-group input:focus { border-color: var(--primary); }
.form-error { color: #f87171; font-size: 13px; margin-bottom: 12px; }
.btn-submit { width: 100%; padding: 12px; background: var(--primary); border: none; border-radius: var(--radius-sm); color: white; font-size: 15px; font-weight: 500; cursor: pointer; transition: background 0.2s; }
.btn-submit:hover { background: var(--primary-dark); }
.form-footer { text-align: center; margin-top: 16px; font-size: 14px; color: var(--text-muted); }
.form-footer a { color: var(--primary-light); margin-left: 4px; }
.form-footer a:hover { text-decoration: underline; }
.homepage-footer { text-align: center; padding: 40px; color: var(--text-muted); font-size: 13px; border-top: 1px solid var(--border); }

/* Chat Page */
.chat-page { display: flex; flex-direction: column; height: 100vh; }
.chat-header { display: flex; justify-content: space-between; align-items: center; padding: 12px 24px; background: var(--bg-card); border-bottom: 1px solid var(--border); transition: background 0.3s; }
.header-home { font-size: 18px; font-weight: 600; color: var(--primary-light); }
.header-user { display: flex; align-items: center; gap: 12px; }
.header-user span { font-size: 14px; color: var(--text-muted); }
.btn-logout { padding: 6px 14px; background: transparent; border: 1px solid var(--border); border-radius: 16px; color: var(--text-muted); font-size: 13px; cursor: pointer; }
.btn-logout:hover { color: #f87171; border-color: #f87171; }
.chat-container { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.chat-messages { flex: 1; overflow-y: auto; padding: 24px; }
.welcome-msg { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.welcome-msg h2 { font-size: 28px; color: var(--text); margin-bottom: 12px; }
.welcome-msg p { font-size: 15px; line-height: 1.6; }
.message { margin-bottom: 16px; display: flex; gap: 12px; animation: fadeIn 0.3s; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.typing { color: var(--text-muted); animation: pulse 1.5s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
.message.user { flex-direction: row-reverse; }
.message-avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--primary); display: flex; align-items: center; justify-content: center; font-size: 16px; flex-shrink: 0; }
.message.user .message-avatar { background: var(--bg-input); }
.message-bubble { max-width: 70%; padding: 12px 16px; border-radius: var(--radius); font-size: 15px; line-height: 1.6; word-break: break-word; }
.message.assistant .message-bubble { background: var(--bg-card); border: 1px solid var(--border); }
.message.user .message-bubble { background: var(--primary); color: white; }
.chat-input-area { padding: 16px 24px 24px; background: var(--bg); transition: background 0.3s; }
.input-wrapper { display: flex; align-items: flex-end; gap: 12px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 8px 8px 16px; transition: border-color 0.2s, background 0.3s; }
.input-wrapper:focus-within { border-color: var(--primary); }
.input-wrapper textarea { flex: 1; background: transparent; border: none; color: var(--text); font-size: 15px; resize: none; outline: none; max-height: 120px; line-height: 1.5; }
#sendBtn { width: 36px; height: 36px; border-radius: 50%; background: var(--primary); border: none; color: white; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; transition: background 0.2s; }
#sendBtn:hover { background: var(--primary-dark); }
#sendBtn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Responsive */
@media (max-width: 768px) {
    .hero { padding: 100px 24px 60px; flex-direction: column; }
    .title-line { font-size: 36px; }
    .hero-visual { width: 200px; height: 200px; margin-top: 40px; }
    .features { grid-template-columns: 1fr; padding: 20px 24px 60px; }
    .homepage-nav { padding: 16px 24px; }
    /* Chat页面移动端适配 */
    .chat-page { height: 100dvh; height: 100vh; }
    .chat-header { padding: 10px 14px; }
    .header-home { font-size: 16px; }
    .header-user span { display: none; }
    .header-user { gap: 6px; }
    .chat-toolbar { padding: 6px 12px; gap: 12px; overflow-x: auto; }
    .chat-messages { padding: 14px 12px; }
    .welcome-msg { padding: 40px 16px; }
    .welcome-msg h2 { font-size: 22px; }
    .welcome-msg p { font-size: 14px; }
    .message { gap: 8px; margin-bottom: 12px; }
    .message-avatar { width: 30px; height: 30px; font-size: 13px; }
    .message-bubble { max-width: 82%; padding: 10px 13px; font-size: 14px; line-height: 1.5; }
    .chat-input-area { padding: 10px 12px 14px; }
    .input-wrapper { padding: 6px 6px 6px 12px; gap: 8px; }
    .input-wrapper textarea { font-size: 14px; max-height: 100px; }
    #sendBtn { width: 32px; height: 32px; }
    .btn-logout { padding: 4px 10px; font-size: 12px; }
}

/* Profile */
.user-avatar-small { width: 32px; height: 32px; border-radius: 50%; background: var(--primary); display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 600; color: white; overflow: hidden; flex-shrink: 0; }
.profile-avatar-section { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-bottom: 20px; }
.profile-avatar { width: 80px; height: 80px; border-radius: 50%; background: var(--bg-input); display: flex; align-items: center; justify-content: center; font-size: 36px; overflow: hidden; }
.btn-upload { padding: 6px 16px; background: var(--primary); border: none; border-radius: 16px; color: white; font-size: 13px; cursor: pointer; }
.btn-upload:hover { background: var(--primary-dark); }

/* Chat Toolbar */
.chat-toolbar { display: flex; align-items: center; gap: 20px; padding: 8px 24px; background: var(--bg-card); border-bottom: 1px solid var(--border); }
.toolbar-group { display: flex; align-items: center; gap: 8px; }
.toolbar-group label { font-size: 13px; color: var(--text-muted); }
.toolbar-group select { background: var(--bg-input); border: 1px solid var(--border); border-radius: 6px; color: var(--text); padding: 4px 8px; font-size: 13px; outline: none; cursor: pointer; }
.toolbar-group select:focus { border-color: var(--primary); }
.mode-switch { display: flex; gap: 4px; background: var(--bg-input); border-radius: 8px; padding: 2px; }
.mode-btn { padding: 4px 12px; border: none; border-radius: 6px; background: transparent; color: var(--text-muted); font-size: 13px; cursor: pointer; transition: all 0.2s; }
.mode-btn:hover { color: var(--text); }
.mode-btn.active { background: var(--primary); color: white; }

/* Agent Settings */
.btn-agent-settings { padding: 6px 14px; background: transparent; border: 1px solid var(--primary); border-radius: 20px; color: var(--primary); font-size: 13px; cursor: pointer; transition: all 0.2s; white-space: nowrap; }
.btn-agent-settings:hover { background: var(--primary); color: white; }
.agent-badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; background: var(--primary-light, rgba(99,102,241,0.1)); border-radius: 12px; font-size: 12px; color: var(--primary); }
.modal-wide { max-width: 520px; }
.agent-avatar-section { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-bottom: 24px; }
.agent-avatar { width: 80px; height: 80px; border-radius: 50%; background: linear-gradient(135deg, var(--primary-light, rgba(99,102,241,0.1)), var(--bg-input)); display: flex; align-items: center; justify-content: center; font-size: 36px; overflow: hidden; border: 2px dashed var(--border); }
.form-hint { display: block; font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.form-group textarea { width: 100%; background: var(--bg-input); border: 1px solid var(--border); border-radius: 8px; color: var(--text); padding: 10px 12px; font-size: 14px; resize: vertical; outline: none; font-family: inherit; line-height: 1.5; }
.form-group textarea:focus { border-color: var(--primary); }
.form-group textarea::placeholder { color: var(--text-muted); }
.agent-actions { display: flex; gap: 12px; margin-top: 8px; }
.btn-reset { padding: 10px 20px; background: transparent; border: 1px solid var(--border); border-radius: 8px; color: var(--text-muted); font-size: 14px; cursor: pointer; transition: all 0.2s; }
.btn-reset:hover { border-color: #ef4444; color: #ef4444; }

/* Hide scrollbar but keep scroll */
.modal-body::-webkit-scrollbar { display: none; }
.modal-body { -ms-overflow-style: none; scrollbar-width: none; }

/* Form example hint */
.form-example { display: block; font-size: 12px; color: var(--text-muted); margin-top: 4px; padding: 8px 10px; background: rgba(99,102,241,0.06); border-radius: 6px; border-left: 2px solid var(--primary-light, #818cf8); opacity: 0.8; }

/* ===== Theme Toggle Button ===== */
.theme-toggle-btn {
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--bg-input); border: 1px solid var(--border);
    color: var(--text-muted); cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px; transition: all 0.2s;
}
.theme-toggle-btn:hover { background: var(--primary); color: white; border-color: var(--primary); }

/* ===== Theme Settings Modal ===== */
.theme-modal-overlay {
    position: fixed; inset: 0; z-index: 9999;
    background: var(--overlay-bg);
    backdrop-filter: blur(8px);
    display: flex; align-items: center; justify-content: center;
    animation: themeFadeIn 0.2s ease;
}
@keyframes themeFadeIn { from { opacity: 0; } to { opacity: 1; } }
.theme-modal {
    width: 360px; max-width: calc(100vw - 32px);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 24px 80px var(--shadow);
    overflow: hidden;
    animation: themeSlideUp 0.25s ease;
}
@keyframes themeSlideUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
.theme-modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 20px 24px 0;
}
.theme-modal-header h3 { font-size: 18px; font-weight: 600; color: var(--text); }
.theme-modal-close {
    width: 28px; height: 28px; border-radius: 6px;
    background: transparent; border: none; color: var(--text-muted);
    font-size: 18px; cursor: pointer; display: flex;
    align-items: center; justify-content: center;
}
.theme-modal-close:hover { background: var(--bg-input); color: var(--text); }
.theme-modal-body { padding: 20px 24px 24px; }
.theme-modal-body p { font-size: 13px; color: var(--text-muted); margin-bottom: 16px; }

/* Theme option cards */
.theme-options { display: flex; flex-direction: column; gap: 10px; }
.theme-option {
    display: flex; align-items: center; gap: 14px;
    padding: 14px 16px; border-radius: 12px;
    border: 1.5px solid var(--border);
    background: var(--bg-input);
    cursor: pointer; transition: all 0.2s;
}
.theme-option:hover { border-color: var(--primary-light); }
.theme-option.active { border-color: var(--primary); background: rgba(99,102,241,0.08); }
.theme-option-icon {
    width: 40px; height: 40px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px; flex-shrink: 0;
}
.theme-option-icon.light-icon { background: #fef3c7; }
.theme-option-icon.dark-icon { background: #1e1b4b; color: #c4b5fd; }
.theme-option-icon.system-icon { background: linear-gradient(135deg, #fef3c7 50%, #1e1b4b 50%); }
.theme-option-text h4 { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 2px; }
.theme-option-text span { font-size: 12px; color: var(--text-muted); }
.theme-option-check {
    margin-left: auto; width: 22px; height: 22px; border-radius: 50%;
    border: 2px solid var(--border); flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s;
}
.theme-option.active .theme-option-check {
    background: var(--primary); border-color: var(--primary);
}
.theme-option.active .theme-option-check::after {
    content: '✓'; color: white; font-size: 12px; font-weight: 700;
}
