/* ============================================================
   KBot 全局样式
   - 用户页：Google-like 极简
   - 管理后台：卡片式、专业
   ============================================================ */

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", "PingFang SC", Arial, sans-serif; }
body { background: #fafaf9; color: #1f1f1d; line-height: 1.55; }
a { color: #2563eb; text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: #6b6b67; }
.small { font-size: 13px; }
.link-admin { color: #b45309; font-weight: 600; }
.link-mute { color: #6b6b67; margin-left: 14px; font-size: 14px; }

/* ========== 顶部栏 ========== */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px; background: #fff; border-bottom: 1px solid #e5e4e1;
  position: sticky; top: 0; z-index: 50;
}
.topbar.admin { border-bottom-color: #d6c79c; background: #fbf9f3; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.topbar-left { display: flex; align-items: center; gap: 12px; }
.topnav { display: flex; gap: 10px; flex-wrap: wrap; }
.topnav a { padding: 6px 12px; border-radius: 6px; color: #4b4b46; font-size: 14px; }
.topnav a:hover { background: #efeee9; text-decoration: none; }
.topnav a.active { background: #2c2c2b; color: #fff; }

/* ========== 按钮 / 输入 ========== */
.btn {
  cursor: pointer; border: 0; border-radius: 8px;
  padding: 9px 16px; font-size: 14px; font-weight: 500; line-height: 1.2;
}
.btn-primary { background: #2563eb; color: #fff; }
.btn-primary:hover { background: #1d4ed8; }
.btn-text { background: transparent; color: #2c2c2b; border: 1px solid #d4d3cf; }
.btn-text:hover { background: #efeee9; }
.btn-danger { background: #dc2626; color: #fff; }
.btn-danger:hover { background: #b91c1c; }

input, textarea, select {
  display: block; width: 100%;
  padding: 10px 12px; font-size: 14px;
  border: 1px solid #d4d3cf; border-radius: 8px; background: #fff;
  font-family: inherit;
}
input:focus, textarea:focus, select:focus { outline: 2px solid #93c5fd; outline-offset: 0; border-color: #93c5fd; }

label { display: block; font-size: 13px; color: #4b4b46; margin: 12px 0 6px; }

/* ========== 用户页（Google-like） ========== */
.page-user { background: #fff; min-height: 100vh; display: flex; flex-direction: column; }
.page-user .hero-main {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: flex-start;
  padding: 80px 24px 40px;
}
.brand { text-align: center; margin-bottom: 28px; }
.brand .logo {
  display: inline-flex; align-items: center; justify-content: center;
  width: 64px; height: 64px; border-radius: 16px;
  background: linear-gradient(135deg, #2563eb 0%, #14b8a6 100%);
  color: #fff; font-size: 32px; font-weight: 700;
  margin-bottom: 14px;
}
.brand h1 { font-size: 48px; margin: 6px 0; letter-spacing: -0.5px; }
.brand .tagline { color: #6b6b67; font-size: 16px; margin: 0; }

.askbox { width: min(680px, 92%); }
.askbox-row {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px 6px 18px;
  border: 1px solid #d4d3cf; border-radius: 28px;
  background: #fff; transition: box-shadow .15s;
}
.askbox-row:focus-within { box-shadow: 0 1px 6px rgba(0,0,0,0.1); border-color: #c4c3bf; }
.askbox-row .ico-search { font-size: 18px; opacity: .6; }
.askbox-row input {
  flex: 1; border: 0; font-size: 17px; padding: 12px 4px;
  box-shadow: none; outline: none; background: transparent;
}
.askbox-row input:focus { outline: none; }
.askbox-row button { border-radius: 20px; }
.hint { color: #6b6b67; font-size: 13px; margin: 14px 14px 0; }

/* 回答卡片 */
.answer { width: min(720px, 95%); margin-top: 36px; display: grid; gap: 16px; }
.ans-card, .src-card, .fb-card {
  background: #fff; border: 1px solid #e5e4e1; border-radius: 16px;
  padding: 20px 22px;
}
.ans-card header, .src-card header { margin-bottom: 8px; }
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  background: #e0e7ff; color: #3730a3; font-size: 12px; font-weight: 600;
}
.ans-body { white-space: pre-wrap; line-height: 1.7; font-size: 15px; }
.src-card ol { padding-left: 22px; margin: 8px 0 0; }
.src-card li { color: #4b4b46; font-size: 14px; margin: 4px 0; }
.fb-card { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.fb-card p { margin: 0; color: #4b4b46; }

.footer-mute { text-align: center; padding: 24px; color: #97978f; font-size: 12px; }

/* ========== 登录 / 注册 弹层 ========== */
.modal-bg {
  position: fixed; inset: 0; background: rgba(15, 15, 14, 0.45);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal {
  background: #fff; border-radius: 18px; width: min(440px, 92%);
  max-height: 92vh; overflow: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.modal header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px; border-bottom: 1px solid #e5e4e1;
}
.modal header h2 { margin: 0; font-size: 18px; }
.modal .x {
  background: transparent; border: 0; font-size: 22px; cursor: pointer; color: #97978f;
}
.modal-body { padding: 18px 22px 22px; }
.modal-body .row { display: flex; gap: 10px; align-items: center; margin-top: 16px; flex-wrap: wrap; }
.msg { font-size: 13px; min-height: 18px; margin: 4px 0 0; color: #b91c1c; }
.msg.ok { color: #047857; }

/* ========== 管理后台 ========== */
.page-admin { background: #f3f1ea; min-height: 100vh; }
.page-admin .admin-main {
  max-width: 1200px; margin: 0 auto; padding: 28px 24px 60px;
}
.tab h1 { font-size: 24px; margin: 0 0 18px; }
.card {
  background: #fff; border: 1px solid #e3dfd2; border-radius: 14px;
  padding: 22px 22px; margin-bottom: 20px;
}
.card.no-pad { padding: 0; }
.card.no-pad h2 { padding: 18px 22px; margin: 0; border-bottom: 1px solid #efebde; font-size: 16px; }
.card.no-pad .pad-h { padding: 18px 22px; margin: 0; border-bottom: 1px solid #efebde; font-size: 16px; }
.card h2 { margin: 0 0 14px; font-size: 16px; }
.toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar label { display: flex; align-items: center; gap: 8px; }
.toolbar select { width: auto; min-width: 120px; }

/* KPI */
.kpi-grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  margin-bottom: 20px;
}
.kpi {
  background: #fff; border: 1px solid #e3dfd2; border-radius: 14px;
  padding: 16px 20px;
}
.kpi .label { color: #6b6b67; font-size: 13px; }
.kpi .value { font-size: 26px; font-weight: 700; color: #2c2c2b; margin-top: 4px; }
.kpi.alert .value { color: #b91c1c; }
.kpi.ok .value { color: #047857; }

/* 表格 */
.t { width: 100%; border-collapse: collapse; }
.t th, .t td {
  padding: 11px 14px; border-bottom: 1px solid #efebde; text-align: left;
  font-size: 14px; vertical-align: middle;
}
.t th { background: #fbf9f3; color: #4b4b46; font-weight: 600; font-size: 13px; }
.t tbody tr:hover { background: #fbfaf6; }
.t .row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.t .row-actions .btn { padding: 5px 10px; font-size: 13px; }

/* 状态徽标 */
.tag { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.tag-indexed  { background: #d1fae5; color: #065f46; }
.tag-uploaded { background: #e0e7ff; color: #3730a3; }
.tag-parsing  { background: #fef3c7; color: #92400e; }
.tag-error    { background: #fee2e2; color: #991b1b; }
.tag-active   { background: #d1fae5; color: #065f46; }
.tag-disabled { background: #f3f4f6; color: #4b5563; }
.tag-useful      { background: #d1fae5; color: #065f46; }
.tag-not_useful  { background: #fee2e2; color: #991b1b; }
.tag-new         { background: #f3f4f6; color: #4b5563; }

/* 拖拽上传 */
.dropzone {
  border: 2px dashed #c4ba96; border-radius: 14px;
  padding: 26px 22px; text-align: center; background: #faf7ef;
  cursor: pointer; transition: background .15s, border-color .15s;
}
.dropzone.over { background: #f5eecf; border-color: #b0a262; }
.dropzone .link { color: #2563eb; cursor: pointer; }

/* Toast */
.toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%);
  background: #1f1f1d; color: #fff; padding: 10px 18px; border-radius: 8px;
  font-size: 14px; z-index: 200; box-shadow: 0 6px 20px rgba(0,0,0,.2);
}
.toast.err { background: #b91c1c; }

/* 弹层（通用） */
#modalBg .modal { width: min(560px, 92%); }
#modalBg .modal-body { padding: 18px 22px 22px; }
#modalBg .modal header { padding: 16px 22px; }
#modalBg textarea { min-height: 90px; font-family: inherit; }

/* 响应式 */
@media (max-width: 760px) {
  .topnav { gap: 4px; }
  .topnav a { padding: 5px 8px; font-size: 13px; }
  .brand h1 { font-size: 36px; }
  .page-user .hero-main { padding: 40px 16px 24px; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .t th, .t td { padding: 8px; font-size: 13px; }
}
