/* opagent common.css — iOS 系统风格 */

/* 版本：v10-20261102 */
/* 版本：每次改动版本号 +1（缓存击破） */
:root {
  --bg: #f2f2f7;
  --bg-2: #ffffff;
  --bg-3: #fafafc;
  --card: #ffffff;
  --text: #000000;
  --text-2: #3c3c43;
  --text-3: #8e8e93;
  --text-4: #c7c7cc;
  --blue: #007aff;
  --blue-2: #0a84ff;
  --green: #34c759;
  --orange: #ff9500;
  --red: #ff3b30;
  --purple: #af52de;
  --pink: #ff2d55;
  --indigo: #5856d6;
  --sep: #e5e5ea;
  --sep-2: #d1d1d6;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow: 0 1px 3px rgba(0,0,0,0.04), 0 6px 20px rgba(0,0,0,0.06);
  --navbar-h: 44px;
  --tabbar-h: 50px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
          "Helvetica Neue", "PingFang SC", "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { color: var(--blue); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

/* ====== 导航栏 ====== */
.navbar {
  position: sticky; top: 0; z-index: 50;
  height: var(--navbar-h);
  background: rgba(255,255,255,0.85);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 0.5px solid var(--sep);
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; font-weight: 600;
  color: #000;
}
.navbar .nav-left, .navbar .nav-right {
  position: absolute; top: 0; height: 100%;
  display: flex; align-items: center; padding: 0 16px;
}
.navbar .nav-left { left: 0; }
.navbar .nav-right { right: 0; }
.navbar button.nav-btn {
  background: transparent; border: none;
  color: #000 !important;
  font-size: 15px; padding: 4px 8px;
}

/* ====== 主内容 ====== */
.page {
  max-width: 920px; margin: 0 auto;
  padding: 16px;
  padding-bottom: calc(var(--safe-bottom) + 24px);
  min-height: calc(100vh - var(--navbar-h));
}
.page-title { font-size: 28px; font-weight: 700; margin: 8px 4px 16px; }
.page-sub { font-size: 13px; color: var(--text-3); margin: -8px 4px 16px; }

/* ====== 卡片 ====== */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 14px;
}
.card-title { font-size: 17px; font-weight: 600; margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.card-sub { font-size: 13px; color: var(--text-3); margin-bottom: 8px; }
.card-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-top: 0.5px solid var(--sep); }
.card-row:first-of-type { border-top: none; }

/* ====== 按钮 ====== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--blue); color: #fff !important;
  border: none; border-radius: 10px;
  padding: 10px 18px; font-size: 15px; font-weight: 500;
  transition: opacity .15s, transform .05s;
}
.btn:hover { opacity: 0.85; }
.btn:active { transform: scale(0.97); }
.btn-secondary { background: var(--bg); color: var(--blue) !important; border: 0.5px solid var(--sep-2); }
.btn-danger { background: var(--red); }
.btn-success { background: var(--green); }
.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 8px; }
.btn-block { display: flex; width: 100%; }

/* ====== 输入 ====== */
.input, .textarea, .select {
  width: 100%;
  background: var(--bg-3);
  border: 0.5px solid var(--sep);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 15px; color: var(--text);
  font-family: inherit;
  outline: none;
  transition: border-color .15s;
}
.input:focus, .textarea:focus, .select:focus { border-color: var(--blue); }
.textarea { min-height: 90px; resize: vertical; }
.field-label { font-size: 13px; color: var(--text-2); margin-bottom: 6px; display: block; font-weight: 500; }
.field { margin-bottom: 14px; }

/* ====== 列表组（iOS Inset Grouped） ====== */
.list-group {
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.list-section-header {
  font-size: 13px; color: var(--text-3);
  padding: 16px 4px 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.list-item {
  display: flex; align-items: center;
  padding: 12px 16px;
  border-bottom: 0.5px solid var(--sep);
  min-height: 44px;
}
.list-item:last-child { border-bottom: none; }
.list-item .li-main { flex: 1; min-width: 0; }
.list-item .li-title { font-size: 15px; font-weight: 500; }
.list-item .li-sub { font-size: 13px; color: var(--text-3); margin-top: 2px; }
.list-item .li-right { color: var(--text-3); font-size: 13px; }

/* ====== 徽章 ====== */
.badge {
  display: inline-block;
  padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 600;
  background: var(--bg); color: var(--text-2);
}
.badge-blue   { background: rgba(0,122,255,0.12);  color: var(--blue); }
.badge-green  { background: rgba(52,199,89,0.14);  color: var(--green); }
.badge-orange { background: rgba(255,149,0,0.16);  color: var(--orange); }
.badge-red    { background: rgba(255,59,48,0.14);  color: var(--red); }
.badge-purple { background: rgba(175,82,222,0.14); color: var(--purple); }
.badge-gray   { background: var(--bg); color: var(--text-3); }

/* ====== 切换开关 ====== */
.switch { position: relative; width: 51px; height: 31px; }
.switch input { display: none; }
.switch .slider {
  position: absolute; cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--sep-2); border-radius: 999px;
  transition: 0.2s;
}
.switch .slider::before {
  content: ""; position: absolute; height: 27px; width: 27px;
  left: 2px; top: 2px; background: #fff; border-radius: 50%;
  transition: 0.2s; box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.switch input:checked + .slider { background: var(--green); }
.switch input:checked + .slider::before { transform: translateX(20px); }

/* ====== Modal ====== */
.modal-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 16px;
}
.modal {
  background: #fff; border-radius: 14px;
  width: 100%; max-width: 520px; max-height: 90vh; overflow: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.modal-header {
  padding: 14px 16px; border-bottom: 0.5px solid var(--sep);
  display: flex; align-items: center; justify-content: space-between;
  font-weight: 600;
}
.modal-body { padding: 16px; }
.modal-footer {
  padding: 12px 16px; border-top: 0.5px solid var(--sep);
  display: flex; gap: 8px; justify-content: flex-end;
}

/* ====== Toast ====== */
.toast {
  position: fixed; left: 50%; bottom: 80px; transform: translateX(-50%);
  background: rgba(0,0,0,0.78); color: #fff;
  padding: 10px 16px; border-radius: 10px;
  font-size: 14px; z-index: 200;
  animation: fadein .2s;
  max-width: 80vw;
}
@keyframes fadein { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ====== 表格 ====== */
.table-wrap { overflow-x: auto; }
.table {
  width: 100%; border-collapse: collapse; background: #fff;
  border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow); font-size: 13px;
}
.table th, .table td {
  padding: 10px 12px; text-align: left;
  border-bottom: 0.5px solid var(--sep);
  white-space: nowrap;
}
.table th { background: var(--bg); font-weight: 600; color: var(--text-2); }
.table tr:hover td { background: var(--bg-3); }
.table td .truncate { max-width: 280px; overflow: hidden; text-overflow: ellipsis; }

/* ====== 工具 ====== */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.text-3 { color: var(--text-3); }
.text-2 { color: var(--text-2); }
.text-sm { font-size: 13px; }
.text-xs { font-size: 11px; }
.mt-2 { margin-top: 8px; } .mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; } .mb-4 { margin-bottom: 16px; }
.text-center { text-align: center; }
.fw-6 { font-weight: 600; }
.fw-7 { font-weight: 700; }
.divider { height: 0.5px; background: var(--sep); margin: 12px 0; }
.empty { padding: 40px 16px; text-align: center; color: var(--text-3); font-size: 14px; }
.loading { padding: 40px 16px; text-align: center; color: var(--text-3); }

/* ====== 危险标记 ====== */
.sensitive-tag {
  display: inline-block;
  background: var(--red); color: #fff;
  padding: 2px 8px; border-radius: 6px;
  font-size: 11px; font-weight: 700;
  margin: 2px 4px 2px 0;
}
.sensitive-tag.s2 { background: var(--orange); }
.sensitive-tag.s1 { background: #ffd60a; color: #000; }

/* ====== 响应式 ====== */
@media (max-width: 600px) {
  .page { padding: 12px; }
  .page-title { font-size: 22px; }
  .table th, .table td { padding: 8px; font-size: 12px; }
}

/* ===== details 美化 ===== */
details summary { list-style: none; }
details summary::-webkit-details-marker { display: none; }
details summary::before { content: '▶'; display: inline-block; margin-right: 6px; font-size: 10px; transition: transform .15s; }
details[open] summary::before { transform: rotate(90deg); }


/* ====== Rich Text Editor (RTE) ====== */
.rte-wrap { border: 0.5px solid var(--sep); border-radius: 10px; overflow: hidden; background: #fff; }
.rte-toolbar {
  display: flex; flex-wrap: wrap; gap: 4px; align-items: center;
  padding: 8px 10px; background: var(--bg-3); border-bottom: 0.5px solid var(--sep);
}
.rte-sel {
  border: 0.5px solid var(--sep); border-radius: 6px;
  padding: 4px 8px; font-size: 12px; background: #fff; color: var(--text-1);
  cursor: pointer; height: 28px;
}
.rte-btn {
  border: 0.5px solid transparent; background: transparent;
  padding: 4px 8px; border-radius: 6px; font-size: 13px;
  cursor: pointer; color: var(--text-1); min-width: 28px; height: 28px;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.rte-btn:hover { background: rgba(0,0,0,0.06); border-color: var(--sep); }
.rte-btn:active { background: rgba(0,0,0,0.12); }
.rte-btn b, .rte-btn i, .rte-btn u, .rte-btn s { font-size: 13px; }
.rte-sep { width: 1px; height: 18px; background: var(--sep); margin: 0 4px; }
.rte-editor {
  min-height: 220px; max-height: 480px; overflow-y: auto;
  padding: 14px 16px; font-size: 14px; line-height: 1.7;
  outline: none;
}
.rte-editor:empty::before {
  content: attr(data-placeholder); color: var(--text-3);
  pointer-events: none;
}
.rte-editor h1 { font-size: 22px; font-weight: 700; margin: 14px 0 8px; }
.rte-editor h2 { font-size: 18px; font-weight: 700; margin: 12px 0 6px; color: var(--text-1); border-bottom: 0.5px solid var(--sep); padding-bottom: 4px; }
.rte-editor h3 { font-size: 15px; font-weight: 700; margin: 10px 0 4px; color: var(--text-1); }
.rte-editor p { margin: 6px 0; }
.rte-editor ul, .rte-editor ol { margin: 6px 0; padding-left: 24px; }
.rte-editor li { margin: 3px 0; }
.rte-editor blockquote {
  border-left: 3px solid var(--blue); padding: 6px 12px;
  margin: 8px 0; background: var(--bg-3); border-radius: 0 6px 6px 0;
  color: var(--text-2); font-style: italic;
}
.rte-editor pre {
  background: #1e1e1e; color: #d4d4d4; padding: 10px 14px;
  border-radius: 8px; font-family: 'SF Mono', Menlo, Consolas, monospace;
  font-size: 12.5px; overflow-x: auto; margin: 8px 0;
}
.rte-editor code {
  background: rgba(0,122,255,0.1); color: var(--blue);
  padding: 1px 5px; border-radius: 3px;
  font-family: 'SF Mono', Menlo, Consolas, monospace; font-size: 13px;
}
.rte-editor img {
  max-width: 100%; border-radius: 8px;
  margin: 6px 0; box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.rte-editor a { color: var(--blue); text-decoration: underline; }
.rte-editor table { border-collapse: collapse; width: 100%; margin: 8px 0; }
.rte-editor table td {
  border: 0.5px solid var(--sep); padding: 6px 10px;
  vertical-align: top;
}
.rte-editor u { text-decoration: underline; }
.rte-editor s { text-decoration: line-through; }
.rte-source {
  display: block; width: 100%; border: 0; outline: none;
  padding: 12px 16px; font-family: 'SF Mono', Menlo, Consolas, monospace;
  font-size: 12.5px; min-height: 240px; max-height: 480px; overflow: auto;
  resize: vertical; background: #fff;
}
.rte-preview {
  padding: 14px 16px; min-height: 180px; max-height: 480px; overflow-y: auto;
  background: var(--bg); font-size: 14px; line-height: 1.7;
}
.rte-preview h1 { font-size: 22px; font-weight: 700; margin: 14px 0 8px; }
.rte-preview h2 { font-size: 18px; font-weight: 700; margin: 12px 0 6px; border-bottom: 0.5px solid var(--sep); padding-bottom: 4px; }
.rte-preview h3 { font-size: 15px; font-weight: 700; margin: 10px 0 4px; }
.rte-preview blockquote {
  border-left: 3px solid var(--blue); padding: 6px 12px;
  margin: 8px 0; background: var(--bg-3); border-radius: 0 6px 6px 0;
}
.rte-preview img { max-width: 100%; border-radius: 8px; margin: 6px 0; }
.rte-preview pre {
  background: #1e1e1e; color: #d4d4d4; padding: 10px 14px;
  border-radius: 8px; font-family: monospace; font-size: 12.5px;
}
.rte-preview code {
  background: rgba(0,122,255,0.1); color: var(--blue);
  padding: 1px 5px; border-radius: 3px;
}
.rte-preview a { color: var(--blue); }


/* ===== KB 参考资料卡（用户端）===== */
.kb-ref {
  margin: 8px 16px 4px;
  padding: 14px 16px;
  background: #ffffff;
  border-radius: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  font-size: 14px;
  color: var(--text-1);
  border: 0.5px solid rgba(0,0,0,0.06);
}
.kb-ref-title {
  font-weight: 600;
  color: var(--blue);
  margin-bottom: 10px;
  font-size: 13px;
  letter-spacing: 0.2px;
}
.kb-ref-body {
  font-size: 14px;
  line-height: 1.65;
  color: var(--text-1);
}
.kb-doc { margin: 0 0 10px; }
.kb-doc:last-child { margin-bottom: 0; }
.kb-doc-sep {
  height: 0.5px;
  background: rgba(0,0,0,0.06);
  margin: 10px 0;
}

/* KB 文档内部排版继承 renderMd 样式，仅微调 */
.kb-ref-body h1, .kb-ref-body h2, .kb-ref-body h3 {
  margin: 8px 0 4px;
  font-weight: 600;
  color: var(--text-1);
}
.kb-ref-body h1 { font-size: 16px; }
.kb-ref-body h2 { font-size: 15px; }
.kb-ref-body h3 { font-size: 14px; }
.kb-ref-body p { margin: 6px 0; }
.kb-ref-body ul, .kb-ref-body ol {
  margin: 6px 0; padding-left: 20px;
}
.kb-ref-body li { margin: 2px 0; }
.kb-ref-body blockquote {
  margin: 6px 0; padding: 6px 10px;
  border-left: 3px solid var(--blue);
  background: rgba(0,122,255,0.05);
  border-radius: 4px;
  color: var(--text-2);
  font-size: 13px;
}
.kb-ref-body code {
  background: rgba(0,0,0,0.05);
  padding: 1px 5px; border-radius: 4px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 12.5px;
}
.kb-ref-body pre {
  background: #1c1c1e; color: #f5f5f7;
  padding: 10px 12px; border-radius: 8px;
  overflow-x: auto; font-size: 12.5px;
  margin: 6px 0;
}
.kb-ref-body pre code {
  background: none; padding: 0; color: inherit;
}
.kb-ref-body table {
  border-collapse: collapse; margin: 6px 0;
  width: 100%; font-size: 13px;
}
.kb-ref-body table th, .kb-ref-body table td {
  border: 0.5px solid rgba(0,0,0,0.1);
  padding: 6px 10px; text-align: left;
}
.kb-ref-body table th {
  background: #f5f5f7; font-weight: 600;
}
.kb-ref-body a {
  color: var(--blue); text-decoration: none;
}
.kb-ref-body img {
  max-width: 100%;
  max-height: 320px;
  width: auto;
  height: auto;
  border-radius: 10px;
  margin: 8px 0;
  display: block;
  border: 0.5px solid rgba(0,0,0,0.08);
  cursor: zoom-in;
  transition: transform .2s;
}
.kb-ref-body img:hover {
  transform: scale(1.01);
}
.kb-ref-body strong { font-weight: 600; }
.kb-ref-body em { font-style: italic; }
.kb-ref-body del { color: var(--text-3); }


html, body { min-height: 100%; }

/* ---- 备案信息页脚：右下角低调展示（DOM 可被自动化抓取，视觉上不显眼） ---- */
.icp-footer {
  position: fixed;
  right: 14px;
  bottom: 10px;
  z-index: 5;
  text-align: right;
  font-size: 11px;
  line-height: 1.4;
  opacity: 0.3;
  white-space: nowrap;
}
.icp-footer a {
  color: var(--text-3);
  text-decoration: none;
}
.icp-footer a:hover {
  opacity: 1;
  color: var(--blue);
  text-decoration: underline;
}
