/* ==========================================
   Agent网页助理 - 主样式 v3
   苹果简约风 · 晨曦渐变浅色 · 毛玻璃
   ========================================== */

/* CSS变量 - 浅色主题（晨曦渐变） */
:root {
    --bg-gradient: linear-gradient(135deg, #fdf6f8 0%, #f5f7fd 25%, #f0f6ff 50%, #f8f4fd 75%, #fdf8f3 100%);
    --bg-primary: #f8f9fc;
    --bg-secondary: rgba(255,255,255,0.85);
    --bg-tertiary: rgba(255,255,255,0.6);
    --bg-hover: rgba(255,255,255,0.7);
    --text-primary: #2c2c2e;
    --text-secondary: #86868b;
    --text-muted: #c7c7cc;
    --border-color: rgba(0,0,0,0.06);
    --glass-border: rgba(255,255,255,0.6);
    --accent: #ff8a8a;
    --accent-hover: #ff6b6b;
    --accent-light: rgba(255,138,138,0.1);
    --accent2: #7ba4f0;
    --danger: #ff453a;
    --success: #30d158;
    --warning: #ffd60a;
    --shadow: 0 2px 12px rgba(0,0,0,0.04);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.06);
    --radius: 18px;
    --radius-sm: 12px;
    --sidebar-width: 240px;
    --transition: 0.2s ease;
    --blur: 40px;
}

/* 深色主题 */
[data-theme="dark"] {
    --bg-gradient: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f0f1a 100%);
    --bg-primary: #0f0f1a;
    --bg-secondary: rgba(28,28,30,0.85);
    --bg-tertiary: rgba(44,44,46,0.6);
    --bg-hover: rgba(58,58,60,0.5);
    --text-primary: #f5f5f7;
    --text-secondary: #a1a1a6;
    --text-muted: #636366;
    --border-color: rgba(255,255,255,0.08);
    --glass-border: rgba(255,255,255,0.1);
    --accent: #ff6b6b;
    --accent-hover: #ff5252;
    --accent-light: rgba(255,107,107,0.15);
    --accent2: #5b8def;
    --shadow: 0 2px 12px rgba(0,0,0,0.2);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.3);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: -apple-system, "SF Pro Display", "SF Pro Text", "Helvetica Neue", BlinkMacSystemFont, sans-serif;
    background: var(--bg-gradient);
    background-size: 400% 400%;
    animation: gradientShift 25s ease infinite;
    color: var(--text-primary);
    transition: background var(--transition), color var(--transition);
    font-size: 14px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* 背景浮动光球 */
.bg-orb {
    position: fixed;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.1;
    pointer-events: none;
    z-index: 0;
    animation: floatOrb 15s ease-in-out infinite;
}
.bg-orb-1 { width:350px; height:350px; background:#ffc4c4; top:-80px; left:15%; }
.bg-orb-2 { width:300px; height:300px; background:#b8d0ff; top:40%; right:-50px; animation-delay:-5s; }
.bg-orb-3 { width:280px; height:280px; background:#d4c4ff; bottom:-60px; left:40%; animation-delay:-10s; }
@keyframes floatOrb {
    0%,100% { transform: translate(0,0) scale(1); }
    33% { transform: translate(30px,-20px) scale(1.05); }
    66% { transform: translate(-20px,15px) scale(0.95); }
}

[data-theme="dark"] .bg-orb { opacity: 0.08; }

#app {
    height: 100vh;
    height: 100dvh;
    display: flex;
    position: relative;
    z-index: 1;
}

/* 滚动条 */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 3px;
    opacity: 0.5;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* ===== 通用按钮 ===== */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 14px;
    transition: all var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: inherit;
    font-weight: 500;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    color: #fff;
    box-shadow: 0 2px 10px rgba(255,138,138,0.25);
}
.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(255,138,138,0.35);
}

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

.btn-danger {
    background: transparent;
    color: var(--danger);
}
.btn-danger:hover {
    background: rgba(255,69,58,0.1);
}

.btn-sm {
    padding: 4px 12px;
    font-size: 12px;
}

/* 输入框 */
input, textarea, select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    transition: all var(--transition);
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-light);
}

/* 标签 */
.tag {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
    background: var(--accent-light);
    color: var(--accent);
    margin: 2px;
}
.tag-person {
    background: rgba(123,164,240,0.1);
    color: var(--accent2);
}

/* 空状态 */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}
.empty-state .icon {
    font-size: 48px;
    margin-bottom: 16px;
}

/* 加载动画 */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    display: inline-block;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== 侧边栏 ===== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    backdrop-filter: blur(var(--blur)) saturate(1.5);
    -webkit-backdrop-filter: blur(var(--blur)) saturate(1.5);
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    box-shadow: 4px 0 30px rgba(0,0,0,0.03);
    z-index: 50;
    transition: width 0.3s ease, transform 0.3s ease, opacity 0.3s ease;
    overflow: hidden;
}

.sidebar.collapsed {
    width: 0;
    border-right: none;
    opacity: 0;
}

.sidebar-header {
    padding: 20px 18px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.3px;
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.sidebar-nav {
    flex: 1;
    padding: 8px 10px;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 10px 12px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-secondary);
    transition: all 0.2s ease;
    margin-bottom: 3px;
}

.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    transform: translateX(2px);
}

.nav-item.active {
    background: var(--bg-secondary);
    color: var(--accent);
    font-weight: 600;
    box-shadow: var(--shadow);
}

.nav-item .icon {
    font-size: 17px;
    width: 22px;
    text-align: center;
    transition: transform 0.2s;
}
.nav-item:hover .icon {
    transform: scale(1.15);
}

.nav-text {
    flex: 1;
}

.nav-arrow {
    font-size: 12px;
    color: var(--text-muted);
    transition: transform 0.2s;
}

.sidebar-footer {
    padding: 12px 14px;
    border-top: 1px solid var(--border-color);
}

.person-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #c4b5ff, #ffb4b4);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    flex-shrink: 0;
}

/* ===== 主内容区 ===== */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.top-bar {
    height: 52px;
    background: var(--bg-secondary);
    backdrop-filter: blur(var(--blur)) saturate(1.5);
    -webkit-backdrop-filter: blur(var(--blur)) saturate(1.5);
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    flex-shrink: 0;
    z-index: 10;
}

.top-bar .title {
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -0.4px;
}

.top-bar .actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.theme-toggle {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: none;
    background: var(--bg-tertiary);
    cursor: pointer;
    font-size: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.18s;
}
.theme-toggle:hover {
    background: var(--bg-hover);
    transform: scale(1.05);
}

.mobile-menu-btn {
    display: none;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: none;
    background: var(--bg-tertiary);
    cursor: pointer;
    font-size: 16px;
    align-items: center;
    justify-content: center;
}

.sidebar-toggle-btn {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    border: none;
    background: var(--bg-tertiary);
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.sidebar-toggle-btn:hover {
    background: var(--bg-hover);
    color: var(--accent);
}

.content-area {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

/* 对话视图时内容区不滚动，由聊天组件内部管理 */
.content-area:has(.wechat-chat),
.content-area-chat {
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* ===== 响应式 ===== */
/* iPad 及以上屏幕：主内容区域居中约束宽度 */
@media (min-width: 769px) {
    .main-content {
        max-width: 100%;
    }
    .content-area {
        max-width: 1200px;
        margin: 0 auto;
        width: 100%;
    }
    /* 对话页面也居中约束 */
    .content-area-chat {
        max-width: 800px;
        margin: 0 auto;
        width: 100%;
    }
    /* 管理后台面板也居中 */
    .admin-panel {
        max-width: 900px;
        margin: 0 auto;
    }
}

@media (max-width: 768px) {
    :root {
        --sidebar-width: 0px;
    }
    .sidebar {
        position: fixed;
        z-index: 100;
        width: 240px;
        height: 100vh;
        height: 100dvh;
        transform: translateX(-100%);
        transition: transform 0.3s;
        opacity: 1;
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .sidebar.collapsed {
        width: 240px;
        opacity: 1;
    }
    .mobile-menu-btn {
        display: flex !important;
    }
    .sidebar-toggle-btn {
        display: none;
    }
}
