/* ===== 极限词查询系统 全局样式 ===== */

:root {
  /* ===== 品牌色（对齐朝霖晟官网品牌蓝）===== */
  --primary: #1a5cff;        /* 官网 brand */
  --primary-dark: #2563eb;   /* 官网 brand-dark */
  --primary-light: #3b82f6;  /* 官网 brand-light */
  --primary-soft: rgba(26, 92, 255, 0.06);    /* 品牌蓝淡底 */
  --primary-border: rgba(26, 92, 255, 0.22);  /* 品牌蓝浅边框 */
  /* ===== 中性色（对齐官网 ink / paper）===== */
  --bg: #f8f9fa;             /* 官网 paper-soft */
  --card: #ffffff;
  --border: #e5e7eb;
  --text: #1a1a1a;           /* 官网 ink-soft */
  --muted: #6c757d;
  --danger-bg: #fee2e2;
  --danger-text: #b91c1c;
  --warn-bg: #fef3c7;
  --warn-text: #b45309;
  --info-bg: #dbeafe;
  --info-text: #1d4ed8;
  --radius: 16px;         /* 对齐官网 rounded-2xl */
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.06);  /* 对齐官网 shadow-card */
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container {
  width: 100%;
  max-width: 880px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ===== 页头 ===== */
.site-header {
  background: var(--card);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
  font-size: 17px;
}

.brand-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font-size: 16px;
}

.header-nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
}

.header-nav a:hover {
  color: var(--primary);
}

/* ===== 主区 ===== */
main {
  flex: 1;
  padding: 28px 0 40px;
}

.hero {
  text-align: center;
  margin-bottom: 24px;
}

.hero h1 {
  font-size: 26px;
  font-weight: 700;
}

.hero-sub {
  color: var(--muted);
  margin-top: 8px;
  font-size: 15px;
}

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

.field-label {
  display: block;
  font-weight: 600;
  margin-bottom: 10px;
}

.hint {
  color: var(--muted);
  font-weight: 400;
  font-size: 13px;
}

/* ===== 查询卡片：宽度为屏幕 1/2，居中 ===== */
.query-card {
  width: min(50vw, 100%);
  margin: 0 auto;
}

textarea {
  width: 100%;
  height: 60px; /* 默认高度约 2 行文本（原 200-300px 区间已按需求调整为 2 行） */
  padding: 14px;
  border: 1px solid var(--primary-border);
  border-radius: 8px;
  background: var(--primary-soft); /* 品牌蓝淡底，与页面主背景区分 */
  font: inherit;
  font-size: 15px;
  resize: vertical;
  transition: border-color 0.15s, box-shadow 0.15s;
}

/* 占位文字颜色调淡（浅灰 #ccc；opacity:1 保证 Firefox 下颜色精确显示） */
textarea::placeholder {
  color: #ccc;
  opacity: 1;
}

textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(47, 111, 237, 0.15);
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
}

.char-count {
  color: var(--muted);
  font-size: 13px;
}

.examples {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.example-label {
  color: var(--muted);
  font-size: 13px;
}

.chip {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: 999px;
  padding: 4px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}

.chip:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.toolbar-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}

.btn {
  border: none;
  border-radius: 8px;
  padding: 11px 26px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-dark);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  color: var(--text);
  border-color: var(--muted);
}

.form-error {
  margin-top: 14px;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--danger-bg);
  color: var(--danger-text);
  font-size: 14px;
}

/* ===== 结果区 ===== */
.result-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.result-head h2 {
  font-size: 18px;
}

.result-meta {
  color: var(--muted);
  font-size: 13px;
}

.summary-badges {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.summary-badge {
  padding: 4px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
}

.badge {
  display: inline-block;
  padding: 3px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-high {
  background: var(--danger-bg);
  color: var(--danger-text);
}

.badge-warn {
  background: var(--warn-bg);
  color: var(--warn-text);
}

.badge-info {
  background: var(--info-bg);
  color: var(--info-text);
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

th {
  background: var(--bg);
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}

tr:last-child td {
  border-bottom: none;
}

.word-cell {
  white-space: nowrap;
  color: var(--danger-text);
}

.suggestion-cell {
  color: var(--muted);
  min-width: 220px;
}

.empty-tip {
  margin-top: 14px;
  padding: 16px;
  border-radius: 8px;
  background: #ecfdf5;
  color: #047857;
  font-size: 14px;
}

.loading {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  color: var(--muted);
  font-size: 14px;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ===== 使用提示 ===== */
.notice {
  background: var(--info-bg);
  border-radius: var(--radius);
  padding: 18px 22px;
  font-size: 14px;
  margin-top: 20px; /* 与上方卡片间距 20px；与上方 margin-bottom 相邻时自动合并取 20px */
  margin-bottom: 20px; /* 与下方反馈卡片间距 20px */
}

.notice h3 {
  font-size: 15px;
  color: var(--info-text);
  margin-bottom: 8px;
}

.notice p {
  color: var(--text);
  line-height: 1.7;
  margin: 0 0 10px;
}

.notice ul {
  padding-left: 20px;
  color: var(--text);
}

.notice li {
  margin: 4px 0;
}

/* ===== 反馈遗漏词表单 ===== */
/* 半透明背景：仅背景色改为 rgba(255,255,255,0.2)（白色 20% 不透明度），
   不使用 opacity 属性，确保区域内文字/输入框/按钮保持完全不透明 */
.card.feedback-card {
  background: rgba(255, 255, 255, 0.2);
  margin-top: 20px; /* 与上方卡片间距 20px；与上方 .notice 的 margin-bottom 相邻时会自动合并，不会产生双倍间距 */
}

.feedback-card h2 {
  font-size: 17px;
  margin-bottom: 6px;
}

.feedback-card .muted {
  margin-bottom: 4px;
}

.feedback-row {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.feedback-row input {
  flex: 1;
  min-width: 0;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  font-size: 14px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.feedback-row input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(47, 111, 237, 0.15);
}

.msg-error {
  background: var(--danger-bg);
  color: var(--danger-text);
}

.msg-success {
  background: #ecfdf5;
  color: #047857;
}

/* ===== 管理员后台 ===== */
.btn-sm {
  padding: 6px 14px;
  font-size: 13px;
}

.actions-cell {
  white-space: nowrap;
}

/* ===== 免责声明页 ===== */
.disclaimer h1 {
  font-size: 22px;
  margin-bottom: 6px;
}

.disclaimer h2 {
  font-size: 16px;
  margin: 20px 0 8px;
}

.disclaimer p {
  font-size: 14px;
  color: var(--text);
  margin-bottom: 8px;
}

.disclaimer .note {
  margin-top: 18px;
}

/* ===== 页脚 ===== */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--card);
  padding: 18px 0;
}

.footer-inner {
  text-align: center;
  font-size: 13px;
  color: var(--text);
}

.footer-inner a {
  color: var(--primary);
  text-decoration: none;
}

.muted {
  color: var(--muted);
}

/* ===== 移动端适配（统一断点 768px）===== */
@media (max-width: 768px) {
  .container {
    padding: 0 14px;
  }

  main {
    padding-top: 18px;
  }

  /* 字体大小适中 */
  .hero h1 {
    font-size: 21px;
  }

  .hero-sub {
    font-size: 14px;
  }

  .hero-stats {
    font-size: 12px;
  }

  /* 卡片宽度自适应 + 内边距收紧 */
  .card {
    padding: 16px;
  }

  .query-card {
    width: 100%; /* 查询框恢复全宽 */
  }

  /* 卡片间距统一 20px（.card 基类 margin-bottom: 20px 已保证） */

  /* 工具栏纵向排列，操作区保持一行 */
  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar-right {
    justify-content: space-between;
  }

  .toolbar .btn {
    width: auto;
  }

  .feedback-row {
    flex-direction: column;
  }

  .feedback-row .btn {
    width: 100%;
  }

  /* 按钮触摸区域 ≥ 44px */
  .btn {
    min-height: 44px;
  }

  /* 轮播图高度适当缩小 */
  .carousel {
    height: 140px;
  }

  /* 广告位窄屏保持隐藏（基类 .ad-slot { display: none } 已保证） */
}

/* ===== 顶部轮播图 ===== */
.carousel {
  position: relative;
  width: 100%;
  height: 200px;
  overflow: hidden;
  background: #eef1f6;
}

.carousel-track {
  display: flex;
  height: 100%;
  transition: transform 0.5s ease;
}

.carousel-slide {
  min-width: 100%;
  height: 100%;
}

.carousel-slide a {
  display: block;
  width: 100%;
  height: 100%;
}

.carousel-slide img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.carousel-dots {
  position: absolute;
  bottom: 10px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  gap: 8px;
}

.carousel-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  padding: 0;
}

.carousel-dot.active {
  background: #ffffff;
}

/* ===== 左右广告位：固定悬浮于屏幕左右边缘，独立于主内容区 ===== */
.ad-slot {
  display: none; /* 默认隐藏，仅在宽屏（有足够留白）时显示 */
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  width: 300px;
  height: 300px;
  z-index: 5;
}

.ad-left {
  left: 0;
}

.ad-right {
  right: 0;
}

.ad-slot img {
  width: 300px;
  height: 300px;
  object-fit: cover;
  display: block;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.ad-slot[hidden] {
  display: none !important;
}

/* ===== 底部信息区 ===== */
.footer-links {
  margin-bottom: 6px;
}

.footer-links a {
  margin: 0 4px;
}

#footer-info {
  font-size: 13px; /* 小号灰色文字，与页脚整体一致 */
}

/* ===== 管理后台：导航与面板 ===== */
.admin-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.admin-nav button {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s;
}

.admin-nav button.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.admin-panel {
  display: none;
}

.admin-panel.active {
  display: block;
}

.thumb {
  width: 80px;
  height: 48px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
  vertical-align: middle;
}

.form-field {
  margin-bottom: 14px;
}

.form-field label {
  display: block;
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 6px;
}

.form-field input[type="text"],
.form-field input[type="url"],
.form-field input[type="password"],
.form-field input[type="file"] {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  font-size: 14px;
}

.form-field input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(47, 111, 237, 0.15);
}

.ad-edit {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
}

.friend-link-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.friend-link-row input {
  flex: 1;
  min-width: 0;
}

.sort-btn {
  padding: 2px 8px;
  font-size: 12px;
}

tr.dragging {
  opacity: 0.5;
}

tr.drag-over {
  outline: 2px dashed var(--primary);
}

/* ===== 移动端适配补充 ===== */
/* 宽屏（留白足够容纳 300px 广告位）时显示悬浮广告；窄屏由基类 display:none 保持隐藏 */
@media (min-width: 1500px) {
  .ad-slot {
    display: block;
  }
}

/* ===== 描述文字下方的累计查询提示（页面唯一展示位置）===== */
.hero-stats {
  font-size: 13px; /* 比描述文字(15px)小一号 */
  color: #6c757d;  /* 灰色，与描述文字对齐 */
  margin-top: 6px;
}

/* ===== 管理后台：批量导入（原内联样式迁移为 CSS 类，支持严格 CSP）===== */
.import-hint {
  margin-top: 6px;
  font-size: 13px;
}

.import-report-title {
  font-size: 15px;
  margin: 14px 0 8px;
}

/* ===== 管理后台导航：词库总数（次要信息，靠右显示）===== */
.admin-nav .nav-wordcount {
  margin-left: auto;
  align-self: center;
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}

/* ===== 管理后台：IP 黑名单弹窗 ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

/* 关键修复：hidden 属性必须压过 display:flex（否则弹窗在页面加载时自动可见） */
.modal-overlay[hidden] {
  display: none !important;
}

.modal {
  width: 92%;
  max-width: 420px;
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--shadow);
}

.ip-hint {
  font-size: 12px;
  color: var(--muted);
}

/* ===== 管理后台：子标签页与可疑IP提示 ===== */
.sub-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.sub-tabs button {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
}

.sub-tabs button.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.subtab-hint {
  margin-bottom: 8px;
  font-size: 13px;
}

.thumb-large {
  width: 160px;
  height: auto;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.modal-title {
  font-size: 16px;
  margin-bottom: 12px;
}

/* ===== 免责声明富文本（前台「使用提示」区域，支持标题/正文/列表）===== */
.disclaimer-rich {
  color: var(--text);
  line-height: 1.7;
}
.disclaimer-rich h1,
.disclaimer-rich h2 {
  font-size: 17px;
  font-weight: 600;
  margin: 10px 0 6px;
}
.disclaimer-rich h3 {
  font-size: 15px;
  font-weight: 600;
  margin: 8px 0 4px;
}
.disclaimer-rich p {
  margin: 0 0 8px;
}
.disclaimer-rich ul,
.disclaimer-rich ol {
  margin: 6px 0;
  padding-left: 20px;
}
.disclaimer-rich li {
  margin: 2px 0;
}
.disclaimer-rich blockquote {
  margin: 8px 0;
  padding-left: 12px;
  border-left: 3px solid var(--primary-border);
  color: var(--muted);
}
.disclaimer-rich a {
  color: var(--primary);
}

/* ===== 后台 Quill 编辑器（免责声明编辑）===== */
#disclaimer-editor {
  background: #fff;
}
#disclaimer-editor .ql-toolbar {
  border-color: var(--border);
  border-radius: 8px 8px 0 0;
}
#disclaimer-editor .ql-container {
  border-color: var(--border);
  border-radius: 0 0 8px 8px;
  font-size: 14px;
  font-family: inherit;
}
#disclaimer-editor .ql-editor {
  min-height: 160px;
  line-height: 1.75;
}
#disclaimer-editor .ql-editor h1 { font-size: 20px; }
#disclaimer-editor .ql-editor h2 { font-size: 17px; }
#disclaimer-editor .ql-editor h3 { font-size: 15px; }
