/* ===== 全局样式与变量定义 ===== */
:root {
    --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-bounce: 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

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

body {
    font-family: var(--font-sans);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    overflow-x: hidden;
    transition: background-color var(--transition-normal), color var(--transition-normal);
}

/* ===== 主题1：暗黑赛博 (默认) ===== */
body.theme-cyber {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121f;
    --bg-card: #1a1a2e;
    --bg-card-hover: #1f1f38;
    --accent-1: #00f5ff;
    --accent-2: #7c3aed;
    --accent-3: #ff0080;
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #475569;
    --border: rgba(0, 245, 255, 0.12);
    --border-hover: rgba(0, 245, 255, 0.45);
    --glow: 0 0 24px rgba(0, 245, 255, 0.2);
    --shadow-card: 0 8px 32px rgba(0, 0, 0, 0.6);
    --gradient-text: linear-gradient(135deg, #00f5ff 0%, #7c3aed 100%);
    --gradient-btn: linear-gradient(135deg, #00f5ff 0%, #7c3aed 100%);
    --nav-bg: rgba(10, 10, 15, 0.88);
    --modal-overlay: rgba(0, 0, 0, 0.85);
    --login-card-bg: rgba(26, 26, 46, 0.85);
}

/* ===== 主题2：星空渐变 ===== */
body.theme-nebula {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-card: #21262d;
    --bg-card-hover: #262c35;
    --accent-1: #58a6ff;
    --accent-2: #f78166;
    --accent-3: #3fb950;
    --text-primary: #c9d1d9;
    --text-secondary: #8b949e;
    --text-muted: #484f58;
    --border: rgba(88, 166, 255, 0.18);
    --border-hover: rgba(88, 166, 255, 0.5);
    --glow: 0 0 24px rgba(88, 166, 255, 0.18);
    --shadow-card: 0 8px 32px rgba(0, 0, 0, 0.5);
    --gradient-text: linear-gradient(135deg, #58a6ff 0%, #f78166 100%);
    --gradient-btn: linear-gradient(135deg, #58a6ff 0%, #3fb950 100%);
    --nav-bg: rgba(13, 17, 23, 0.88);
    --modal-overlay: rgba(0, 0, 0, 0.8);
    --login-card-bg: rgba(33, 38, 45, 0.88);
}

/* ===== 主题3：极简科技白 ===== */
body.theme-minimal {
    --bg-primary: #f8fafc;
    --bg-secondary: #f1f5f9;
    --bg-card: #ffffff;
    --bg-card-hover: #f8fafc;
    --accent-1: #6366f1;
    --accent-2: #06b6d4;
    --accent-3: #8b5cf6;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --border: rgba(99, 102, 241, 0.12);
    --border-hover: rgba(99, 102, 241, 0.45);
    --glow: 0 4px 24px rgba(99, 102, 241, 0.12);
    --shadow-card: 0 4px 24px rgba(99, 102, 241, 0.08);
    --gradient-text: linear-gradient(135deg, #6366f1 0%, #06b6d4 100%);
    --gradient-btn: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    --nav-bg: rgba(248, 250, 252, 0.92);
    --modal-overlay: rgba(15, 23, 42, 0.5);
    --login-card-bg: rgba(255, 255, 255, 0.92);
}

/* ===== 基础布局组件 ===== */
#app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.view-container {
    flex: 1;
    padding: 24px;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    animation: pageIn 0.4s ease-out both;
}

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

/* ===== 动画定义 ===== */
@keyframes pageIn {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(28px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes pulseRing {
    0% { transform: scale(1); opacity: 0.7; }
    100% { transform: scale(1.6); opacity: 0; }
}

@keyframes spinRing {
    from { stroke-dashoffset: 220; }
    to { stroke-dashoffset: 0; }
}

@keyframes gridPulse {
    0%, 100% { opacity: 0.2; }
    50% { opacity: 0.6; }
}

@keyframes nebulaDrift {
    0% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(30px, -20px) scale(1.1); }
    66% { transform: translate(-20px, 40px) scale(0.9); }
    100% { transform: translate(0, 0) scale(1); }
}

@keyframes floatUp {
    0%, 100% { transform: translateY(0) rotate(0); }
    50% { transform: translateY(-20px) rotate(5deg); }
}

/* ===== 登录页样式 ===== */
.login-view {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    padding: 20px;
}

.login-bg {
    position: absolute;
    inset: 0;
    z-index: -1;
}

/* 赛博背景网格 */
.cyber-grid {
    position: absolute;
    inset: 0;
    background-image: linear-gradient(var(--border) 1px, transparent 1px), 
                      linear-gradient(90deg, var(--border) 1px, transparent 1px);
    background-size: 50px 50px;
    mask-image: radial-gradient(circle at center, black, transparent 80%);
    animation: gridPulse 3s infinite;
}

/* 星空背景光晕 */
.nebula-glow {
    position: absolute;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.3;
}

/* 极简背景图形 */
.minimal-shape {
    position: absolute;
    opacity: 0.1;
    animation: floatUp 5s infinite ease-in-out;
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: var(--login-card-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 40px;
    text-align: center;
    box-shadow: var(--shadow-card);
    position: relative;
    z-index: 10;
}

.login-logo {
    margin-bottom: 12px;
}

.login-title {
    font-size: 22px;
    font-weight: 700;
    background: var(--gradient-text);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 4px;
}

.login-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 32px;
}

.login-form .input-group {
    margin-bottom: 20px;
    text-align: left;
}

.login-form label {
    display: block;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    margin-left: 4px;
}

.input-wrapper {
    position: relative;
}

.login-form input {
    width: 100%;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 16px;
    color: var(--text-primary);
    font-size: 15px;
    transition: var(--transition-fast);
}

.login-form input:focus {
    outline: none;
    border-color: var(--accent-1);
    box-shadow: var(--glow);
    transform: scaleX(1.01);
}

.toggle-password {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    color: var(--text-muted);
}

.login-btn {
    width: 100%;
    background: var(--gradient-btn);
    border: none;
    border-radius: 12px;
    padding: 14px;
    color: white;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-bounce);
    margin-top: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.login-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.login-btn:active {
    transform: scale(0.96);
}

.login-btn.loading {
    pointer-events: none;
    opacity: 0.8;
}

.login-footer {
    margin-top: 32px;
    font-size: 11px;
    color: var(--text-muted);
}

.error-msg {
    color: var(--accent-3);
    font-size: 12px;
    margin-top: 6px;
    display: none;
}

/* ===== 顶部导航栏 ===== */
.navbar {
    height: 64px;
    background: var(--nav-bg);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.nav-logo-group {
    display: flex;
    flex-direction: column;
}

.nav-brand {
    font-size: 15px;
    font-weight: 700;
}

.nav-brand-en {
    font-size: 11px;
    color: var(--text-secondary);
}

.breadcrumbs {
    margin-left: 24px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
}

.breadcrumb-item {
    cursor: pointer;
    transition: var(--transition-fast);
}

.breadcrumb-item:hover {
    color: var(--text-primary);
    text-decoration: underline;
}

.breadcrumb-sep { color: var(--text-muted); }

.nav-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.theme-picker {
    display: flex;
    gap: 8px;
}

.theme-btn {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform var(--transition-fast);
}

.theme-btn:hover { transform: scale(1.15); }
.theme-btn.active { border-color: white; box-shadow: 0 0 0 1px var(--text-muted); }

.nav-user {
    display: flex;
    align-items: center;
    gap: 10px;
}

.role-chip {
    padding: 2px 8px;
    border-radius: 100px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
}

.role-superadmin { background: var(--accent-2); color: white; }
.role-user { background: var(--text-muted); color: white; }

.logout-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition-fast);
}

.logout-btn:hover { color: #f87171; }

/* ===== 部门列表页 ===== */
.page-header {
    margin-bottom: 40px;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}

.welcome-msg {
    font-size: 28px;
    font-weight: 700;
    background: var(--gradient-text);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 4px;
}

.page-subtitle { font-size: 14px; color: var(--text-secondary); }

.admin-link {
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 8px 16px;
    border-radius: 100px;
    font-size: 13px;
    cursor: pointer;
    transition: var(--transition-bounce);
}

.admin-link:hover { transform: translateY(-3px); border-color: var(--accent-1); box-shadow: var(--glow); }

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
}

.dept-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 24px;
    position: relative;
    overflow: hidden;
    cursor: pointer;
    transition: all 250ms cubic-bezier(0.34, 1.56, 0.64, 1);
    animation: fadeInUp 0.45s cubic-bezier(0.22, 1, 0.36, 1) both;
    animation-delay: calc(var(--i, 0) * 0.07s);
}

.dept-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--card-gradient);
}

.dept-card:hover {
    transform: translateY(-8px);
    border-color: var(--border-hover);
    box-shadow: var(--shadow-card);
}

.card-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
}

.dept-avatar { border: 2px solid white; border-radius: 50%; box-shadow: 0 4px 12px rgba(0,0,0,0.1); }

.agent-count-badge {
    background: var(--accent-1);
    color: white;
    padding: 4px 10px;
    border-radius: 100px;
    font-size: 11px;
    font-weight: 500;
}

.dept-name { font-size: 18px; font-weight: 600; margin-bottom: 8px; }
.dept-desc {
    font-size: 14px;
    color: var(--text-secondary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 42px;
}

.card-footer {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
    font-weight: 500;
    color: var(--accent-1);
}

.arrow-icon { transition: transform var(--transition-fast); }
.dept-card:hover .arrow-icon { transform: translateX(4px); }

/* 水波纹 */
.ripple {
    position: absolute;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    transform: scale(0);
    animation: ripple 0.6s linear;
    pointer-events: none;
}

@keyframes ripple {
    to { transform: scale(4); opacity: 0; }
}

/* ===== 智能体列表页 ===== */
.dept-header {
    display: flex;
    align-items: center;
    gap: 24px;
    margin-bottom: 32px;
}

.header-info h2 { font-size: 22px; font-weight: 700; }
.header-info p { font-size: 14px; color: var(--text-secondary); }
.stats { margin-top: 8px; font-size: 12px; color: var(--text-muted); }

.search-bar {
    position: relative;
    margin-bottom: 32px;
}

.search-input {
    width: 100%;
    height: 44px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0 44px;
    color: var(--text-primary);
    transition: var(--transition-fast);
}

.search-input:focus { outline: none; border-color: var(--accent-1); transform: scaleX(1.01); background: var(--bg-card-hover); }

.search-icon { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.clear-icon { position: absolute; right: 16px; top: 50%; transform: translateY(-50%); color: var(--text-muted); cursor: pointer; }

mark { background: var(--accent-1); color: white; padding: 0 2px; border-radius: 2px; }

.agent-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
}

.agent-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    cursor: pointer;
    transition: var(--transition-bounce);
    position: relative;
    animation: fadeInUp 0.45s ease-out both;
    animation-delay: calc(var(--i, 0) * 0.05s);
}

.agent-card::before {
    content: '';
    position: absolute;
    left: 0; top: 20%; bottom: 20%;
    width: 3px;
    background: var(--accent-color);
    border-radius: 0 4px 4px 0;
    opacity: 0;
    transition: var(--transition-fast);
}

.agent-card:hover { transform: translateY(-4px); border-color: var(--border-hover); box-shadow: var(--glow); }
.agent-card:hover::before { opacity: 1; }

.agent-card-right { flex: 1; min-width: 0; }
.agent-name { font-size: 16px; font-weight: 600; margin-bottom: 4px; }
.agent-desc {
    font-size: 12px;
    color: var(--text-secondary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.agent-time { font-size: 10px; color: var(--text-muted); margin-top: 8px; }

.empty-state {
    text-align: center;
    padding: 60px 0;
}

.empty-state h3 { margin: 16px 0 8px; }
.empty-state p { color: var(--text-secondary); font-size: 13px; }

/* ===== 智能体详情页 ===== */
.agent-detail-view {
    max-width: 600px;
    margin: 40px auto;
    text-align: center;
}

.detail-avatar-wrapper {
    position: relative;
    display: inline-block;
    margin-bottom: 32px;
}

.pulse-ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid var(--accent-color);
    animation: pulseRing 2s ease-out infinite;
    z-index: -1;
}

.pulse-ring-delay { animation-delay: 0.7s; }

.agent-detail-name {
    font-size: 26px;
    font-weight: 700;
    background: var(--gradient-text);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 12px;
}

.dept-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-secondary);
    padding: 6px 12px;
    border-radius: 100px;
    font-size: 13px;
    margin-bottom: 32px;
}

.detail-desc-box {
    text-align: left;
    padding: 24px;
    background: var(--bg-card);
    border-radius: 16px;
    border-left: 4px solid var(--accent-color);
    font-size: 16px;
    line-height: 1.9;
    color: var(--text-primary);
    margin-bottom: 40px;
}

.back-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 24px;
    border: 1px solid var(--border);
    border-radius: 100px;
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition-bounce);
}

.back-btn:hover { background: var(--bg-secondary); transform: translateX(-4px); border-color: var(--accent-1); }

/* ===== 超管控制台 ===== */
.admin-view {
    display: flex;
    height: 100vh;
}

.sidebar {
    width: 220px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid var(--border);
}

.sidebar-header .version { font-size: 10px; color: var(--text-muted); margin-left: auto; }

.side-nav { flex: 1; padding: 16px 0; }
.side-nav-item {
    padding: 12px 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition-fast);
    position: relative;
}

.side-nav-item:hover { background: rgba(255,255,255,0.05); }
.side-nav-item.active { background: rgba(99, 102, 241, 0.1); color: var(--accent-1); font-weight: 500; }
.side-nav-item.active::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
    background: var(--accent-1);
}

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

.admin-content { flex: 1; overflow-y: auto; padding: 32px; background: var(--bg-primary); }

.admin-tab-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.admin-tab-header h2 { font-size: 20px; font-weight: 700; }

.btn-primary {
    background: var(--gradient-btn);
    color: white; border: none; padding: 8px 16px;
    border-radius: 8px; font-weight: 600; cursor: pointer; transition: var(--transition-fast);
    display: flex; align-items: center; gap: 6px;
}

.btn-primary:hover { opacity: 0.9; transform: translateY(-1px); }

/* 表格样式 */
.admin-table { width: 100%; border-collapse: collapse; background: var(--bg-card); border-radius: 12px; overflow: hidden; }
.admin-table th { background: var(--bg-secondary); padding: 12px 16px; text-align: left; font-size: 13px; color: var(--text-secondary); font-weight: 500; }
.admin-table td { padding: 16px; border-bottom: 1px solid var(--border); font-size: 14px; }
.user-info { display: flex; align-items: center; gap: 10px; }
.tag-list { display: flex; flex-wrap: wrap; gap: 4px; }
.tag { background: var(--bg-secondary); border: 1px solid var(--border); padding: 2px 6px; border-radius: 4px; font-size: 11px; }

.action-btns { display: flex; gap: 8px; }
.btn-icon { background: none; border: none; cursor: pointer; color: var(--text-muted); transition: var(--transition-fast); }
.btn-icon:hover { color: var(--accent-1); }
.btn-icon.danger:hover { color: #f87171; }

/* 表单展开动画 */
.animate-height { overflow: hidden; transition: max-height var(--transition-normal); }

/* ===== 全局 Loading 遮罩 ===== */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg-primary);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity 300ms, visibility 300ms;
}

.load-logo-container { position: relative; margin-bottom: 24px; }
.load-ring {
    position: absolute;
    inset: -10px;
    border: 3px solid transparent;
    border-top-color: var(--accent-1);
    border-radius: 50%;
    animation: spin 1.2s linear infinite;
}

.load-title { font-size: 20px; font-weight: 700; background: var(--gradient-text); -webkit-background-clip: text; -webkit-text-fill-color: transparent; margin-bottom: 12px; }
.load-text { font-size: 14px; color: var(--text-secondary); }

/* ===== Toast & Modal ===== */
#toast-container { position: fixed; top: 24px; right: 24px; z-index: 3000; display: flex; flex-direction: column; gap: 12px; }
.toast {
    min-width: 240px;
    padding: 12px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
    animation: toastIn 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55) both;
}

@keyframes toastIn { from { transform: translateX(100%); } to { transform: translateX(0); } }

.toast.success { border-left: 4px solid #10b981; }
.toast.error { border-left: 4px solid #ef4444; }

.modal-overlay {
    position: fixed; inset: 0;
    background: var(--modal-overlay);
    backdrop-filter: blur(4px);
    z-index: 2100;
    display: flex; align-items: center; justify-content: center;
    animation: fadeIn 0.2s both;
}

.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    width: 90%; max-width: 500px;
    padding: 32px;
    box-shadow: var(--shadow-card);
    animation: modalIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes modalIn { from { transform: scale(0.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.modal-header h3 { font-size: 18px; margin-bottom: 12px; }
.modal-body { margin-bottom: 24px; color: var(--text-secondary); font-size: 14px; line-height: 1.6; }
.modal-footer { display: flex; justify-content: flex-end; gap: 12px; }

.btn { padding: 8px 20px; border-radius: 8px; font-weight: 600; cursor: pointer; transition: var(--transition-fast); border: 1px solid transparent; }
.btn-outline { background: none; border-color: var(--border); color: var(--text-primary); }
.btn-danger { background: #ef4444; color: white; border: none; }
.btn-confirm { background: var(--accent-1); color: white; border: none; }
