/* ============================================================ * DaveAI 助手 · 深色商务风全局样式 * ============================================================ */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { min-height: 100vh; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif; background: #f3f4f6; color: #1f2937; }
a { color: #818cf8; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- 登录页 ---------- */
body.login-body { margin: 0; min-height: 100vh; display: flex; align-items: center; justify-content: center; background: #f3f4f6; }
.login-card { width: 100%; max-width: 420px; background: #ffffff; border-radius: 12px; padding: 36px 32px 28px; box-shadow: 0 10px 40px rgba(0,0,0,.45); color: #0f172a; }
.login-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.login-brand .logo-icon { width: 38px; height: 38px; border-radius: 8px; background: linear-gradient(135deg, #4f46e5, #06b6d4); display: flex; align-items: center; justify-content: center; color: #fff; font-size: 18px; font-weight: 700; }
.login-brand .title { font-size: 20px; font-weight: 700; color: #0f172a; }
.login-subtitle { color: #64748b; font-size: 13px; margin-bottom: 24px; }
.login-card .form-group { margin-bottom: 16px; }
.login-card .form-group label { display: block; margin-bottom: 6px; color: #334155; font-size: 13px; font-weight: 500; }
.login-card .form-group input { width: 100%; padding: 10px 12px; border: 1px solid #cbd5e1; border-radius: 8px; font-size: 14px; background: #f8fafc; color: #0f172a; transition: border-color .15s, box-shadow .15s, background .15s; }
.login-card .form-group input:focus { outline: none; background: #fff; border-color: #4f46e5; box-shadow: 0 0 0 3px rgba(79,70,229,.15); }
.btn-login { width: 100%; background: #4f46e5; color: #fff; border: none; padding: 12px; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer; margin-top: 8px; transition: background .15s; }
.btn-login:hover { background: #4338ca; }
.btn-login:active { transform: translateY(1px); }
.btn-login:disabled { background: #94a3b8; cursor: not-allowed; }
.error-msg { color: #dc2626; font-size: 13px; margin-top: 12px; text-align: center; min-height: 18px; }
.login-hint { text-align: center; margin-top: 20px; padding-top: 16px; border-top: 1px solid #e2e8f0; color: #64748b; font-size: 12px; line-height: 1.6; }
.login-hint code { background: #f1f5f9; padding: 1px 6px; border-radius: 4px; color: #334155; font-size: 12px; }

/* ---------- 整体布局 ---------- */
.layout { display: flex; min-height: 100vh; }

/* ---------- 侧边栏：PC固定 / 手机可滑出 ---------- */
.sidebar {
  width: 260px;
  background: #0f172a;
  color: #cbd5e1;
  border-right: 1px solid #374151;
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  overflow-y: auto;
  transform: translateX(0);
  transition: transform .25s ease;
  z-index: 1001;
  box-shadow: 2px 0 12px rgba(0,0,0,.12);
}

/* PC端：始终显示，不隐藏 */
@media (min-width: 768px) {
  .sidebar { transform: translateX(0) !important; }
  .main { margin-left: 260px; }
}

/* 手机端：默认隐藏，open 才显示 */
@media (max-width: 767px) {
  .sidebar { transform: translateX(-100%); width: 260px; padding: 16px; }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0 !important; padding: 16px; width: 100%; }
  .overlay.show { display: block; }
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
  padding: 0 6px;
}
.brand-logo {
  width: 36px; height: 36px; border-radius: 8px;
  background: linear-gradient(135deg, #4f46e5, #06b6d4);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 15px; flex-shrink: 0;
}
.brand-meta { line-height: 1.2; }
.brand-title { font-size: 16px; font-weight: 700; color: #f9fafb; }
.brand-sub { font-size: 11px; color: #9ca3af; margin-top: 2px; }

.nav-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-nav a.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 8px;
  color: #e5e7eb; text-decoration: none; font-size: 14px;
}
.nav-nav a.nav-item:hover { background: #1e293b; color: #f1f5f9; }
.nav-nav a.nav-item.active {
  background: linear-gradient(90deg, rgba(79,70,229,.18), rgba(79,70,229,.04));
  color: #4f46e5; font-weight: 600;
}
.nav-icon { font-size: 16px; width: 22px; text-align: center; flex-shrink: 0; }
.nav-label { white-space: nowrap; }

.sidebar-foot { margin-top: auto; padding-top: 8px; border-top: 1px solid #1e293b; }
.nav-item.logout { color: #fca5a5; }
.nav-item.logout:hover { background: rgba(220,38,38,.15); color: #fecaca; }

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; background: #0f172a; border-bottom: 1px solid #374151;
  position: sticky; top: 0; z-index: 900;
}
.topbar-title { font-size: 15px; font-weight: 600; color: #f1f5f9; }
.topbar-right { display: flex; align-items: center; gap: 8px; }

/* ---------- 主区域：预留顶部 topbar 高度 ---------- */
.main {
  padding: 56px 20px 20px 20px; /* topbar 约 45px 高，预留顶部 56px 防止内容被遮住 */
  min-height: calc(100vh - 45px);
}

@media (max-width: 767px) {
  .main { padding: 56px 16px 16px 16px; }
}

/* ---------- 右上角用户 chip ---------- */
/* ---------- 深色圆角 chip（侧栏开关） ---------- */
.user-chip {
  display: inline-flex; align-items: center; gap: 8px;
  border-radius: 10px; padding: 6px 12px 6px 6px; font-size: 13px;
  border: 1px solid rgba(255,255,255,0.18);
  background: #0f172a;
  user-select: none; cursor: pointer;
  box-shadow: 0 1px 0 rgba(255,255,255,0.06) inset, 0 4px 10px rgba(0,0,0,.35);
}
.user-chip:hover { background: #111827; }
.user-avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: linear-gradient(135deg, #4f46e5, #06b6d4);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: #fff;
}
.user-name { font-weight: 600; color: #f1f5f9; }
.user-role {
  font-size: 11px; padding: 1px 7px; border-radius: 999px; font-weight: 600;
}
.role-admin { background: rgba(79,70,229,.22); color: #a5b4fc; border: 1px solid rgba(79,70,229,.35); }
.role-user { background: rgba(14,165,233,.18); color: #7dd3fc; border: 1px solid rgba(14,165,233,.30); }

/* ---------- 白卡片 ---------- */
.card { background: #ffffff; color: #0f172a; border-radius: 10px; padding: 22px 24px; margin-bottom: 16px; box-shadow: 0 1px 3px rgba(0,0,0,.12), 0 4px 16px rgba(0,0,0,.06); }

/* ---------- 标题 ---------- */
h1 { font-size: 22px; font-weight: 600; margin-bottom: 20px; color: #0f172a; }
h2 { font-size: 18px; font-weight: 600; margin: 16px 0 10px; color: #0f172a; }

/* ---------- 按钮 ---------- */
.btn { background: #4f46e5; color: #fff; border: none; padding: 8px 16px; border-radius: 6px; cursor: pointer; font-size: 14px; transition: background .15s, transform .05s; }
.btn:hover { background: #4338ca; }
.btn:active { transform: translateY(1px); }
.btn:disabled { background: #94a3b8; cursor: not-allowed; }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 5px; }
.btn-danger { background: #dc2626; }
.btn-danger:hover { background: #b91c1c; }
.btn-outline { background: transparent; color: #4f46e5; border: 1px solid #4f46e5; }
.btn-outline:hover { background: #eef2ff; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { padding: 11px 12px; text-align: left; border-bottom: 1px solid #e2e8f0; vertical-align: middle; }
.table th { background: #f8fafc; font-weight: 600; color: #334155; white-space: nowrap; user-select: none; }
.table tbody tr:hover { background: #f1f5f9; }
.table .icon { font-size: 15px; margin-right: 4px; }
.table .cell-time { color: #64748b; white-space: nowrap; }
.table .cell-size { color: #64748b; white-space: nowrap; text-align: right; }
.table .cell-action { white-space: nowrap; }

/* ---------- 表单 ---------- */
.form-control { width: 100%; padding: 9px 12px; border: 1px solid #cbd5e1; border-radius: 6px; font-size: 14px; background: #fff; color: #0f172a; transition: border-color .15s, box-shadow .15s; }
.form-control:focus { outline: none; border-color: #4f46e5; box-shadow: 0 0 0 3px rgba(79,70,229,.15); }
textarea.form-control { resize: vertical; min-height: 80px; }

/* ---------- Toast ---------- */
.toast { position: fixed; bottom: 20px; right: 20px; background: #1f2937; color: #f9fafb; padding: 12px 16px; border-radius: 8px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .25s; z-index: 2000; box-shadow: 0 4px 12px rgba(0,0,0,.4); border: 1px solid #6b7280; }
.toast.show { opacity: 1; }
.toast-error { background: #7f1d1d; color: #fecaca; border-color: #991b1b; }
.toast-success { background: #064e3b; color: #a7f3d0; border-color: #065f46; }

/* ---------- 蒙层 ---------- */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: none; z-index: 1500; }

/* ---------- 脚本终端区 ---------- */
.console-area { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; font-size: 13px; white-space: pre-wrap; background: #0f172a; color: #86efac; padding: 14px; border-radius: 8px; min-height: 180px; max-height: 280px; overflow-y: auto; border: 1px solid #1e293b; }

/* ---------- 搜索 ---------- */
.search-input { padding: 7px 10px; width: 100%; border: 1px solid #cbd5e1; border-radius: 6px; font-size: 13px; margin: 8px 0; }

/* ---------- 占位 ---------- */
.placeholder { color: #94a3b8; }
.empty-hint { color: #64748b; font-size: 13px; padding: 12px 0; }

/* ---------- 响应式 ---------- */
@media (max-width: 767px) {
  .table { font-size: 13px; }
  .table th, .table td { padding: 8px 6px; }
  .card { overflow-x: visible; }
}

/* ---------- 手机端主区域时不重复左侧占位 ---------- */
@media (max-width: 767px) {
  .main { margin-left: 0 !important; }
}
