/* ====== Agent Studio - 白色风格 ====== */
/* 基于 legacy CSS 重构，保持设计风格一致 */

:root {
    --p: #6366f1;
    --ph: #4f46e5;
    --pl: #eef2ff;
    --d: #6b7280;
    --bc: #e5e7eb;
    --b2: #f3f4f6;
    --t: #1f2937;
    --w: #ffffff;
    --ok: #10b981;
    --err: #ef4444;
    --r: 10px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    font-size: 14px;
    color: var(--t);
    background: #f0f2f5;
    line-height: 1.6;
}

a { text-decoration: none; color: var(--p); }
a:hover { color: var(--ph); }
h1 { font-size: 18px; font-weight: 600; }
h2 { font-size: 16px; font-weight: 600; }
h3 { font-size: 14px; font-weight: 600; }

/* ====== 主布局 ====== */
.app { display: flex; min-height: 100vh; }

.side {
    width: 200px; background: #fff; color: var(--t);
    display: flex; flex-direction: column;
    position: fixed; height: 100vh; z-index: 100;
    border-right: 1px solid var(--bc);
    box-shadow: 1px 0 6px rgba(0,0,0,.04);
}

.brand { 
    padding: 18px 14px 16px; 
    border-bottom: 1px solid var(--bc); 
    display: flex; 
    align-items: center; 
    gap: 10px; 
}
.brand-logo { 
    width: 36px; 
    height: 36px; 
    border-radius: 10px; 
    background: linear-gradient(135deg, var(--p), #8b5cf6); 
    color: #fff;
    display: flex; 
    align-items: center; 
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.25);
}
.brand-text { 
    display: flex; 
    flex-direction: column; 
    gap: 2px; 
    min-width: 0;
    line-height: 1.3;
}
.brand-name { 
    font-size: 14px; 
    font-weight: 700; 
    color: var(--t);
    letter-spacing: 0.5px;
    white-space: nowrap; 
}
.brand-ver { 
    font-size: 10px; 
    color: var(--p); 
    font-weight: 500; 
    background: var(--pl);
    padding: 1px 5px;
    border-radius: 4px;
    margin-left: 6px;
}
.brand-sub { 
    font-size: 11px; 
    color: var(--d); 
    letter-spacing: 0.5px; 
    font-weight: 400; 
}

nav { flex: 1; padding: 10px 0; overflow-y: auto; }
.nav-sec { padding: 12px 16px 4px; font-size: 10px; text-transform: uppercase; color: #c5c8ce; letter-spacing: .8px; font-weight: 600; }

.nav-item {
    display: flex; align-items: center; padding: 9px 14px;
    color: #8b8fa3; transition: all .15s; cursor: pointer;
    font-size: 13px; border-radius: 8px; margin: 1px 8px;
    gap: 10px;
}
.nav-item:hover { background: var(--b2); color: var(--t); }
.nav-item.active { background: var(--pl); color: var(--p); font-weight: 500; }
.nav-icon { 
    display: inline-flex; align-items: center; justify-content: center;
    opacity: .6; flex-shrink: 0; width: 18px; height: 18px;
}
.nav-icon svg { width: 100%; height: 100%; stroke-width: 2; }
.nav-item.active .nav-icon { opacity: 1; color: var(--p); }

.main { margin-left: 200px; flex: 1; min-height: 100vh; background: #f5f7fa; }

.topbar {
    display: flex; justify-content: space-between; align-items: center;
    background: var(--w); border-bottom: 1px solid var(--bc);
    padding: 12px 24px; box-shadow: 0 1px 3px rgba(0,0,0,.03);
}
.top-title { font-size: 18px; font-weight: 600; margin: 0; }
.top-actions { display: flex; gap: 8px; align-items: center; }
.body { padding: 20px 24px; }

/* ====== 通用组件 ====== */
.card {
    background: var(--w); border-radius: var(--r); padding: 20px;
    border: 1px solid var(--bc); box-shadow: 0 1px 4px rgba(0,0,0,.04);
    transition: box-shadow .15s;
}
.card:hover { box-shadow: 0 3px 12px rgba(0,0,0,.07); }
.card.highlight { border-color: var(--p); box-shadow: 0 2px 8px rgba(99,102,241,.08); }
.card-h { font-size: 15px; font-weight: 600; margin-bottom: 12px; color: var(--t); display: flex; justify-content: space-between; align-items: center; }
.card-d { font-size: 13px; color: var(--d); line-height: 1.6; }

.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: 1fr 1fr; }
.g3 { grid-template-columns: 1fr 1fr 1fr; }
.g4 { grid-template-columns: 1fr 1fr 1fr 1fr; }

.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 7px 14px; border-radius: 8px; border: 1px solid var(--bc);
    background: var(--w); cursor: pointer; font-size: 13px;
    transition: all .15s; color: var(--t); font-weight: 500; white-space: nowrap;
    gap: 6px;
}
.btn:hover { background: var(--b2); border-color: #d1d5db; }
.btn:active { transform: scale(.97); }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 6px; }
.btn-xs { padding: 3px 8px; font-size: 11px; border-radius: 5px; }
.btn-lg { padding: 10px 20px; font-size: 14px; border-radius: 10px; }
.btn-primary { background: var(--p); color: #fff; border-color: var(--p); }
.btn-primary:hover { background: var(--ph); border-color: var(--ph); }
.btn-danger { background: var(--err); color: #fff; border-color: var(--err); }
.btn-danger:hover { background: #dc2626; }
.btn-success { background: var(--ok); color: #fff; border-color: var(--ok); }
.btn-success:hover { background: #059669; }

.fi {
    width: 100%; padding: 9px 12px; border-radius: 8px;
    border: 1px solid var(--bc); background: var(--w);
    font-size: 13px; color: var(--t); transition: all .15s; font-family: inherit;
}
.fi:focus { outline: none; border-color: var(--p); box-shadow: 0 0 0 3px rgba(99,102,241,.1); }
textarea.fi { resize: vertical; }

.fg { margin-bottom: 14px; }
.fg label { display: block; font-size: 12px; color: var(--d); margin-bottom: 4px; font-weight: 500; }

.tag { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 11px; background: var(--b2); color: var(--d); margin: 2px 4px 2px 0; }
.tag-p { background: var(--pl); color: var(--p); }

.badge { display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 11px; font-weight: 500; }
.badge-ok { background: #d1fae5; color: #059669; }
.badge-d { background: var(--b2); color: var(--d); }
.badge-p { background: var(--pl); color: var(--p); }

.empty { padding: 60px 24px; text-align: center; color: var(--d); }
.empty h3 { font-size: 15px; margin-top: 8px; color: var(--t); }

.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 1000; display: flex; align-items: center; justify-content: center; backdrop-filter: blur(4px); }
.modal-box { background: var(--w); border-radius: 14px; width: 520px; max-width: 92vw; max-height: 88vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.15); }
.modal-h { display: flex; justify-content: space-between; align-items: center; padding: 18px 20px; border-bottom: 1px solid var(--bc); font-size: 15px; font-weight: 600; }
.modal-x { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--d); width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; border-radius: 6px; transition: all .15s; }
.modal-x:hover { background: var(--b2); color: var(--t); }

.spinner { display: inline-block; width: 16px; height: 16px; border: 2.5px solid var(--bc); border-top-color: var(--p); border-radius: 50%; animation: spin .6s linear infinite; margin-right: 8px; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }

.loading { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 40px; color: var(--d); font-size: 14px; }

.stat-card { display: flex; flex-direction: column; align-items: flex-start; padding: 16px 20px; background: var(--w); border-radius: var(--r); border: 1px solid var(--bc); box-shadow: 0 1px 4px rgba(0,0,0,.04); }
.stat-icon { color: var(--p); opacity: .6; display: flex; align-items: center; justify-content: center; }
.stat-icon svg { width: 20px; height: 20px; stroke-width: 1.5; }
.stat-num { font-size: 24px; font-weight: 700; color: var(--t); line-height: 1.2; }
.stat-lbl { font-size: 12px; color: var(--d); margin-top: 2px; }

.tools-hero { padding: 0 0 16px; }
.tools-hero h1 { font-size: 18px; font-weight: 600; margin-bottom: 4px; }
.tools-hero p { color: var(--d); font-size: 13px; }

.tools-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; margin-bottom: 24px; }
.tool-card {
    background: var(--w); border: 1px solid var(--bc); border-radius: 14px;
    padding: 24px; cursor: pointer; transition: all .2s;
    display: flex; flex-direction: column; gap: 12px;
    position: relative; overflow: hidden;
}
.tool-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px; }
.tool-card:hover { transform: translateY(-3px); box-shadow: 0 8px 24px rgba(0,0,0,.1); }

.tool-card-icon { font-size: 40px; display: flex; align-items: center; justify-content: center; }
.tool-card-icon svg { width: 40px; height: 40px; stroke-width: 1.5; }
.tool-card-name { font-size: 16px; font-weight: 600; }
.tool-card-desc { font-size: 13px; color: var(--d); line-height: 1.6; flex: 1; }
.tool-card-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.tool-card-tag { font-size: 11px; padding: 2px 8px; border-radius: 12px; background: var(--b2); color: var(--d); }

/* ====== Agent 工作台 ====== */
.agent-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.agent-card {
    background: var(--w); border: 1px solid var(--bc); border-radius: 14px;
    padding: 20px; transition: all .2s; position: relative; overflow: hidden;
}
.agent-card::after {
    content: ''; position: absolute; top: 0; right: 0;
    width: 8px; height: 8px; border-radius: 50%; margin: 16px;
}
.agent-card.status-idle::after { background: #d1d5db; }
.agent-card.status-working::after { background: #f59e0b; animation: pulse 1.5s infinite; }
.agent-card.status-done::after { background: #10b981; }
@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: .5; transform: scale(1.5); }
}
.agent-header { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.agent-icon { width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 24px; background: var(--b2); }
.agent-info { flex: 1; }
.agent-name { font-size: 15px; font-weight: 600; }
.agent-desc { font-size: 12px; color: var(--d); line-height: 1.5; margin-bottom: 8px; }
.agent-status-badge { display: inline-block; padding: 2px 10px; border-radius: 12px; font-size: 11px; font-weight: 500; }
.agent-status-badge.idle { background: #f3f4f6; color: #9ca3af; }
.agent-status-badge.working { background: #fef3c7; color: #92400e; }
.agent-status-badge.done { background: #d1fae5; color: #059669; }

/* ====== 数字流 ====== */
.flow-canvas {
    width: 100%; height: 600px;
    background: #f8f9fb; border: 1px solid var(--bc);
    border-radius: var(--r); position: relative; overflow: hidden;
}
.flow-node {
    position: absolute; min-width: 160px; padding: 12px;
    background: var(--w); border: 2px solid var(--bc);
    border-radius: 10px; cursor: move; z-index: 10;
    box-shadow: 0 2px 8px rgba(0,0,0,.08);
}
.flow-node:hover { border-color: var(--p); }
.flow-node.active { border-color: var(--p); box-shadow: 0 4px 16px rgba(99,102,241,.2); }
.flow-node-header { font-size: 13px; font-weight: 600; margin-bottom: 6px; display: flex; align-items: center; gap: 6px; }
.flow-node-body { font-size: 11px; color: var(--d); }

/* ====== 代码输出 ====== */
.code-output {
    background: #1e1e2e; border-radius: 12px; padding: 20px;
    min-height: 300px; color: #cdd6f4;
    font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
    font-size: 13px; line-height: 1.7; overflow: auto; white-space: pre-wrap;
}

/* ====== 响应式 ====== */
@media (max-width: 768px) {
    /* ===== 侧边栏 → 底部导航 ===== */
    .side { 
        width: 100% !important; 
        height: auto !important;
        min-height: 60px;
        max-height: 60px;
        bottom: 0 !important;
        top: auto !important;
        left: 0 !important;
        flex-direction: column !important;
        border-right: none !important;
        border-top: 1px solid var(--bc);
        border-radius: 0;
        box-shadow: 0 -2px 10px rgba(0,0,0,.06);
        position: fixed !important;
        z-index: 200 !important;
        padding: 0 !important;
        overflow: visible !important;
    }
    .brand { display: none !important; }
    
    nav { 
        display: flex !important;
        flex-direction: row !important;
        overflow-x: auto !important;
        overflow-y: hidden !important;
        padding: 0 !important;
        margin: 0 !important;
        flex: 1;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    nav::-webkit-scrollbar { display: none; }
    
    .nav-sec { display: none !important; }
    
    .nav-item {
        flex-direction: column !important;
        justify-content: center !important;
        align-items: center !important;
        padding: 6px 10px !important;
        margin: 0 2px !important;
        border-radius: 8px !important;
        gap: 1px !important;
        min-width: 60px !important;
        max-width: 80px !important;
        font-size: 9px !important;
        text-align: center !important;
    }
    .nav-item span:last-child { 
        display: block !important; 
        font-size: 9px !important;
        line-height: 1.1 !important;
        margin-top: 1px !important;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .nav-icon {
        width: 22px !important;
        height: 22px !important;
        margin-bottom: 2px !important;
    }
    
    /* ===== 主内容区 ===== */
    .main { 
        margin-left: 0 !important; 
        margin-bottom: 64px !important;
        min-height: calc(100vh - 64px) !important;
    }
    
    /* ===== 顶部栏 ===== */
    .topbar { 
        padding: 10px 14px !important; 
        flex-wrap: wrap;
        gap: 8px;
        position: sticky;
        top: 0;
        z-index: 100;
        box-shadow: 0 2px 6px rgba(0,0,0,.06);
    }
    .top-title { font-size: 16px !important; }
    .top-actions { gap: 6px; }
    
    /* ===== 内容区 ===== */
    .body { padding: 12px !important; }
    
    /* ===== 网格系统 ===== */
    .g2, .g3, .g4 { grid-template-columns: 1fr !important; gap: 12px !important; }
    
    /* ===== 英雄区 ===== */
    .tools-hero { padding: 16px 0 12px !important; }
    .tools-hero h1 { font-size: 20px !important; }
    .tools-hero p { font-size: 12px !important; }
    
    /* ===== 统计卡片 ===== */
    .stat-card { padding: 14px !important; }
    .stat-num { font-size: 20px !important; }
    .stat-icon svg { width: 20px !important; height: 20px !important; }
    
    /* ===== 通用卡片 ===== */
    .card { padding: 14px !important; margin-bottom: 10px !important; }
    .card-h { font-size: 14px !important; padding-bottom: 8px !important; margin-bottom: 10px !important; }
    
    /* ===== 工具卡片 ===== */
    .tools-grid { grid-template-columns: 1fr !important; gap: 10px !important; }
    .tool-card { padding: 16px !important; }
    .tool-card-icon svg { width: 32px !important; height: 32px !important; }
    .tool-card-name { font-size: 14px !important; }
    
    /* ===== Agent 卡片 ===== */
    .agent-grid { grid-template-columns: 1fr !important; gap: 10px !important; }
    .agent-card { padding: 14px !important; }
    
    /* ===== 表单 ===== */
    .fg { margin-bottom: 12px !important; }
    .fg label { font-size: 12px !important; margin-bottom: 4px !important; }
    .fi { font-size: 14px !important; padding: 8px 10px !important; }
    
    /* ===== 按钮 ===== */
    .btn { 
        padding: 8px 12px !important; 
        font-size: 12px !important; 
        min-height: 38px !important;
        touch-action: manipulation;
    }
    .btn-sm { padding: 6px 10px !important; font-size: 11px !important; min-height: 32px !important; }
    .btn-xs { padding: 4px 8px !important; font-size: 10px !important; min-height: 28px !important; }
    .btn-lg { padding: 12px 16px !important; font-size: 14px !important; min-height: 44px !important; }
    
    /* ===== 表格 ===== */
    table { font-size: 12px; display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    th, td { padding: 8px 10px !important; white-space: nowrap; }
    
    /* ===== 标签和徽章 ===== */
    .tag, .badge { font-size: 10px !important; padding: 3px 8px !important; }
    
    /* ===== 数字流画布 ===== */
    .flow-canvas { height: 350px !important; }
    .flow-node { min-width: 140px !important; }
    
    /* ===== 视频引擎 ===== */
    .ve-controls { padding: 8px 10px !important; gap: 4px !important; flex-wrap: wrap !important; }
    .ve-progress-wrap { min-width: 80px !important; margin: 0 6px !important; }
    .ve-preview { min-height: 200px !important; }
    #ve-preview { height: 200px !important; }
    .ve-time-display { font-size: 11px !important; }
    .ve-scene-item { padding: 6px 8px !important; font-size: 11px !important; }
    .ve-ai-output { padding: 10px !important; font-size: 11px !important; }
    .ve-code-block { padding: 10px !important; font-size: 10px !important; }
    
    /* ===== 代码输出 ===== */
    .code-output { padding: 10px !important; font-size: 11px !important; }
    
    /* ===== 空状态 ===== */
    .empty { padding: 30px 20px !important; }
    .empty h3 { font-size: 15px !important; }
    .empty p { font-size: 12px !important; }
    
    /* ===== 模态框 ===== */
    .modal-box { width: 90% !important; max-width: 400px !important; }
}

@media (max-width: 480px) {
    .body { padding: 10px !important; }
    .topbar { padding: 8px 12px !important; }
    .top-title { font-size: 15px !important; }
    
    .card { padding: 12px !important; }
    .card-h { font-size: 13px !important; }
    
    .nav-item { min-width: 54px !important; padding: 5px 6px !important; }
    .nav-icon { width: 20px !important; height: 20px !important; }
    .nav-item span:last-child { font-size: 8px !important; }
    
    .stat-card { padding: 12px !important; }
    .stat-num { font-size: 18px !important; }
    .stat-icon svg { width: 18px !important; height: 18px !important; }
    
    .flow-canvas { height: 280px !important; }
    
    .ve-preview { min-height: 160px !important; }
    #ve-preview { height: 160px !important; }
}
