/* ─── 368 智能指令工作台 - 响应式深色主题 ─── */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --bg: #0f1923; --bg2: #1a2332; --bg3: #243447; --bg4: #2d3f54;
  --text: #e8edf2; --text2: #8899aa; --text3: #5a6a7a;
  --accent: #4fc3f7; --accent2: #29b6f6;
  --success: #66bb6a; --warning: #ffa726; --danger: #ef5350;
  --border: #2a3a4a; --radius: 8px; --shadow: 0 2px 12px rgba(0,0,0,.3);
}
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--accent); text-decoration: none; cursor: pointer; }

/* ─── 登录页 ─── */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, #0f1923 0%, #1a2332 50%, #0d2137 100%); }
.login-card { background: var(--bg2); border: 1px solid var(--border); border-radius: 16px; padding: 48px 40px; width: 400px; max-width: 90vw; box-shadow: var(--shadow); }
.login-logo { font-size: 48px; font-weight: 800; color: var(--accent); text-align: center; margin-bottom: 8px; }
.login-title { text-align: center; color: var(--text2); margin-bottom: 32px; font-size: 14px; }

/* ─── 表单 ─── */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; color: var(--text2); margin-bottom: 6px; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 10px 12px; background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text); font-size: 14px; outline: none;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { border-color: var(--accent); }
.error-msg { color: var(--danger); font-size: 13px; margin-bottom: 12px; }

/* ─── 按钮 ─── */
.btn { padding: 8px 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg3); color: var(--text); cursor: pointer; font-size: 13px; transition: all .2s; }
.btn:hover { background: var(--bg4); }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent2); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-block { width: 100%; padding: 12px; font-size: 15px; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-icon { background: none; border: none; color: var(--text2); cursor: pointer; font-size: 18px; padding: 4px 8px; }

/* ─── 布局 ─── */
.main-layout { display: flex; height: 100vh; overflow: hidden; }
.sidebar { width: 220px; background: var(--bg2); border-right: 1px solid var(--border); display: flex; flex-direction: column; transition: width .2s; flex-shrink: 0; }
.sidebar.collapsed { width: 60px; }
.sidebar-header { display: flex; align-items: center; justify-content: space-between; padding: 16px; border-bottom: 1px solid var(--border); height: 56px; }
.logo-text { font-size: 20px; font-weight: 800; color: var(--accent); }
.sidebar-nav { flex: 1; padding: 8px; overflow-y: auto; }
.sidebar-nav a { display: flex; align-items: center; padding: 10px 12px; border-radius: var(--radius); color: var(--text2); margin-bottom: 2px; transition: all .15s; }
.sidebar-nav a:hover { background: var(--bg3); color: var(--text); }
.sidebar-nav a.active { background: var(--accent); color: #fff; }
.nav-icon { font-size: 18px; margin-right: 10px; flex-shrink: 0; }
.sidebar-footer { padding: 12px 16px; border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.user-name { font-size: 13px; font-weight: 600; }
.user-role { font-size: 11px; color: var(--text3); }
.main-content { flex: 1; overflow-y: auto; padding: 24px; background: var(--bg); }
.page { max-width: 1200px; margin: 0 auto; }
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
h2 { font-size: 22px; margin-bottom: 20px; }
h3 { font-size: 16px; margin-bottom: 12px; }
h4 { font-size: 14px; margin: 12px 0 8px; color: var(--text2); }

/* ─── 统计卡片 ─── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.stat-value { font-size: 28px; font-weight: 700; color: var(--accent); }
.stat-label { font-size: 13px; color: var(--text2); margin-top: 4px; }
.stat-sub { font-size: 12px; color: var(--text3); margin-top: 8px; }

/* ─── 卡片 ─── */
.card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 20px; }

/* ─── 表格 ─── */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); font-size: 13px; }
.table th { color: var(--text2); font-weight: 600; font-size: 12px; text-transform: uppercase; }
.table tr:hover { background: var(--bg3); }

/* ─── 标签/状态 ─── */
.tag { display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 11px; background: var(--bg3); color: var(--text2); }
.tag.custom { background: #1b5e20; color: #a5d6a7; }
.tag.agency-agents { background: #0d47a1; color: #90caf9; }
.status-pending { color: var(--text2); }
.status-running { color: var(--accent); font-weight: 600; }
.status-paused { color: var(--warning); }
.status-completed { color: var(--success); }
.status-failed, .status-cancelled { color: var(--danger); }
.status-online { color: var(--success); }
.status-offline { color: var(--text3); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }

/* ─── 进度条 ─── */
.progress-bar { height: 6px; background: var(--bg); border-radius: 3px; overflow: hidden; flex: 1; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 3px; transition: width .3s; }
.progress-text { font-size: 12px; color: var(--text2); margin-left: 8px; }

/* ─── 任务卡片 ─── */
.task-list { display: grid; gap: 12px; }
.task-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; cursor: pointer; transition: border-color .2s; }
.task-card:hover { border-color: var(--accent); }
.task-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.task-title { font-weight: 600; font-size: 14px; }
.task-card-body { margin-bottom: 8px; }
.task-meta { display: flex; gap: 16px; font-size: 12px; color: var(--text3); margin-top: 6px; }
.task-card-actions { display: flex; gap: 8px; margin-top: 8px; }

/* ─── 角色卡片 ─── */
.roles-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.role-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.role-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.role-name { font-weight: 600; font-size: 15px; }
.role-desc { font-size: 13px; color: var(--text2); margin-bottom: 8px; line-height: 1.5; }
.role-meta { display: flex; gap: 16px; font-size: 12px; color: var(--text3); }
.role-workflow { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); }
.role-workflow small { color: var(--text3); font-size: 11px; }

/* ─── 弹窗 ─── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal { background: var(--bg2); border: 1px solid var(--border); border-radius: 12px; padding: 24px; width: 480px; max-width: 90vw; max-height: 80vh; overflow-y: auto; }
.modal-lg { width: 700px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

/* ─── 日志 ─── */
.log-list { max-height: 300px; overflow-y: auto; font-size: 12px; font-family: monospace; }
.log-list > div { padding: 4px 0; border-bottom: 1px solid var(--border); }
.log-time { color: var(--text3); margin-right: 8px; }
.log-info { color: var(--text); }
.log-warn { color: var(--warning); }
.log-error { color: var(--danger); }

/* ─── 步骤 ─── */
.step-item { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.step-role { color: var(--text3); font-size: 12px; }

/* ─── 筛选栏 ─── */
.filter-bar { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.filter-bar select { padding: 6px 12px; background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); font-size: 13px; }
.filter-bar button { padding: 6px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg2); color: var(--text2); cursor: pointer; font-size: 13px; }
.filter-bar button.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ─── 知识库 ─── */
.role-actions { margin-top: 10px; }
.kb-hint { font-size: 12px; color: var(--text3); margin-bottom: 16px; }
.kb-upload-area { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.kb-tabs { display: flex; gap: 8px; margin-bottom: 12px; }
.kb-tabs button { padding: 6px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg2); color: var(--text2); cursor: pointer; font-size: 13px; }
.kb-tabs button.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.kb-empty { text-align: center; color: var(--text3); padding: 24px; font-size: 13px; }
.kb-entry { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; margin-bottom: 8px; }
.kb-entry-header { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.kb-entry-title { font-weight: 600; font-size: 13px; flex: 1; }
.kb-entry-time { font-size: 11px; color: var(--text3); }
.kb-entry-preview { font-size: 12px; color: var(--text2); line-height: 1.5; max-height: 60px; overflow: hidden; margin-bottom: 6px; }
.kb-entry-actions { display: flex; gap: 6px; }

/* ─── 响应式 ─── */
@media (max-width: 768px) {
  .sidebar { position: fixed; z-index: 50; height: 100vh; }
  .sidebar.collapsed { width: 0; overflow: hidden; border: none; }
  .main-content { padding: 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .roles-grid { grid-template-columns: 1fr; }
  .modal { width: 95vw; padding: 16px; }
  .table { font-size: 12px; }
  .table th, .table td { padding: 6px 8px; }
}

/* ─── 通知面板 ─── */
.notification-panel {
  position: fixed; top: 16px; right: 16px; width: 320px; max-height: 400px;
  background: var(--bg2); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0,0,0,.4); z-index: 200; overflow-y: auto;
}
.notification-header { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.notification-header h4 { margin: 0; font-size: 14px; }
.notification-item { padding: 10px 16px; border-bottom: 1px solid var(--border); font-size: 13px; }
.notification-item:last-child { border-bottom: none; }
.notif-time { color: var(--text3); font-size: 11px; margin-right: 8px; }
.notif-success { border-left: 3px solid var(--success); }
.notif-error { border-left: 3px solid var(--danger); }
.notif-info { border-left: 3px solid var(--accent); }

/* ─── 浅色主题 ─── */
[data-theme="light"] {
  --bg: #f5f7fa; --bg2: #ffffff; --bg3: #e8ecf1; --bg4: #d5dbe3;
  --text: #1a2332; --text2: #5a6a7a; --text3: #8899aa;
  --border: #d0d7de; --shadow: 0 2px 12px rgba(0,0,0,.08);
}
[data-theme="light"] .login-page { background: linear-gradient(135deg, #f5f7fa 0%, #e8ecf1 50%, #d5dbe3 100%); }
[data-theme="light"] .login-card { box-shadow: 0 4px 24px rgba(0,0,0,.1); }

/* ─── 图表 ─── */
.chart-bar-group { display: flex; flex-direction: column; gap: 10px; }
.chart-bar-item { display: flex; align-items: center; gap: 12px; }
.chart-bar { height: 20px; border-radius: 4px; min-width: 4px; transition: width .5s; }
.chart-label { font-size: 12px; color: var(--text2); min-width: 80px; }

/* ─── 微信对话 ─── */
.wechat-sessions { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.wechat-chat { background: var(--bg2); border-radius: var(--radius); padding: 16px; max-height: 70vh; overflow-y: auto; }
.wechat-msg { display: flex; gap: 12px; margin-bottom: 16px; align-items: flex-start; }
.wechat-msg-user { flex-direction: row-reverse; }
.wechat-msg-avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--bg3); display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; }
.wechat-msg-body { max-width: 70%; }
.wechat-msg-user .wechat-msg-body { text-align: right; }
.wechat-msg-header { display: flex; gap: 8px; align-items: center; margin-bottom: 4px; }
.wechat-msg-user .wechat-msg-header { flex-direction: row-reverse; }
.wechat-msg-name { font-size: 12px; color: var(--text2); font-weight: 500; }
.wechat-msg-time { font-size: 11px; color: var(--text3); }
.wechat-msg-content { padding: 10px 14px; border-radius: 12px; font-size: 14px; line-height: 1.5; word-break: break-word; white-space: pre-wrap; }
.wechat-msg-user .wechat-msg-content { background: var(--accent); color: #fff; border-top-right-radius: 4px; }
.wechat-msg-bot .wechat-msg-content { background: var(--bg3); color: var(--text); border-top-left-radius: 4px; }

/* ─── 移动端响应式 ─── */
@media (max-width: 768px) {
  .mobile-menu-btn { display: block !important; }
  
  .main-layout { position: relative; }
  
  /* 侧边栏 - 抽屉式 */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 280px !important;
    height: 100dvh;
    height: 100vh;
    z-index: 1000;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: none;
    border-right: none;
  }
  
  .sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,0.6);
  }
  
  .sidebar.collapsed {
    width: 280px !important;
  }
  
  /* 移动端侧边栏始终显示文字 */
  .sidebar .nav-text { display: inline !important; }
  .sidebar .logo-text { display: inline !important; }
  .sidebar .user-info { display: flex !important; }
  
  /* 遮罩层 */
  .sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.6);
    z-index: 999;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
  }
  
  .sidebar-overlay.show {
    display: block;
    opacity: 1;
  }
  
  /* 主内容区 */
  .main-content {
    padding: 60px 16px 16px;
    width: 100%;
    min-height: 100dvh;
  }
  
  /* 移动端菜单按钮 */
  .mobile-menu-btn {
    display: block !important;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 500;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 20px;
    cursor: pointer;
    color: var(--text);
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    -webkit-tap-highlight-color: transparent;
  }
  
  .mobile-menu-btn:active {
    transform: scale(0.95);
  }
  
  /* 页面标题 */
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  
  /* 统计卡片 */
  .stats-grid {
    grid-template-columns: 1fr 1fr !important;
    gap: 12px;
  }
  
  .stat-card {
    padding: 16px;
  }
  
  /* 功能卡片 */
  .features-grid {
    grid-template-columns: 1fr !important;
    padding: 20px 16px;
    gap: 16px;
  }
  
  /* Hero区域 */
  .hero-title {
    font-size: 28px !important;
  }
  
  .hero-subtitle {
    font-size: 16px !important;
  }
  
  /* 登录卡片 */
  .login-card {
    padding: 32px 24px;
    margin: 16px;
  }
  
  /* 表格 */
  table {
    font-size: 12px;
  }
  
  table th, table td {
    padding: 6px 4px;
  }
  
  /* 按钮触摸优化 */
  .btn, .btn-icon, .sidebar-nav a {
    min-height: 44px;
    -webkit-tap-highlight-color: transparent;
  }
  
  /* 输入框优化 - 防止iOS缩放 */
  input, select, textarea {
    font-size: 16px !important;
  }
}

@media (max-width: 480px) {
  .hero-title {
    font-size: 24px !important;
  }
  
  .feature-card {
    padding: 20px;
  }
  
  .cta-buttons {
    flex-direction: column;
  }
  
  .stats-grid {
    grid-template-columns: 1fr !important;
  }
}

/* ── 聊天窗口 ── */
.chat-page {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 120px);
  max-width: 900px;
  margin: 0 auto;
}

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.chat-header h2 {
  margin: 0;
  font-size: 20px;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.chat-welcome {
  text-align: center;
  padding: 40px 20px;
  color: var(--text2);
}

.welcome-icon {
  font-size: 64px;
  margin-bottom: 16px;
}

.chat-welcome h3 {
  font-size: 20px;
  color: var(--text);
  margin-bottom: 8px;
}

.chat-welcome p {
  margin-bottom: 24px;
}

.quick-prompts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.quick-prompt {
  padding: 8px 16px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

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

.chat-message {
  display: flex;
  gap: 12px;
  max-width: 80%;
}

.chat-message.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.chat-message.bot {
  align-self: flex-start;
}

.message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.message-bubble {
  background: var(--bg2);
  padding: 12px 16px;
  border-radius: 12px;
  max-width: 100%;
}

.chat-message.user .message-bubble {
  background: var(--accent);
  color: #fff;
}

.message-text {
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.message-time {
  font-size: 11px;
  color: var(--text3);
  margin-top: 4px;
}

.chat-message.user .message-time {
  color: rgba(255,255,255,0.7);
}

.thinking {
  display: flex;
  gap: 4px;
  padding: 16px;
}

.thinking-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text3);
  animation: thinking 1.4s infinite;
}

.thinking-dot:nth-child(2) { animation-delay: 0.2s; }
.thinking-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes thinking {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-8px); opacity: 1; }
}

.chat-input-area {
  display: flex;
  gap: 12px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  align-items: flex-end;
}

.chat-input {
  flex: 1;
  padding: 12px 16px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-size: 14px;
  resize: none;
  max-height: 120px;
  font-family: inherit;
  line-height: 1.5;
}

.chat-input:focus {
  outline: none;
  border-color: var(--accent);
}

.chat-send-btn {
  padding: 12px 24px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.chat-send-btn:hover:not(:disabled) {
  background: var(--accent2);
}

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

@media (max-width: 768px) {
  .chat-page {
    height: calc(100dvh - 140px);
  }
  
  .chat-message {
    max-width: 90%;
  }
  
  .quick-prompts {
    flex-direction: column;
  }
  
  .quick-prompt {
    width: 100%;
  }
}
