/* ╔══════════════════════════════════════════════════════════╗
   ║   Settings Module — Polished v2                          ║
   ║   实验室智能台账 · 系统设置页美化                          ║
   ║   Design language: soft cards, glassy sidebar, micro-motion ║
   ╚══════════════════════════════════════════════════════════╝ */

/* ──────────────────────────────────────────────────────────────
   两栏布局
   ────────────────────────────────────────────────────────────── */
.settings-layout {
  display: flex;
  gap: 32px;
  align-items: flex-start;
  max-width: 1240px;
  margin: 0 auto;
  padding: 8px 24px 60px;
}

/* ──────────────────────────────────────────────────────────────
   左侧分类栏 — Glassy sticky nav
   ────────────────────────────────────────────────────────────── */
.settings-sidebar {
  flex: 0 0 232px;
  position: sticky;
  top: 84px;
  height: calc(100vh - 120px);
  overflow-y: auto;
  overflow-x: visible;
  scrollbar-width: thin;
}
.settings-sidebar::-webkit-scrollbar { width: 5px; }
.settings-sidebar::-webkit-scrollbar-thumb {
  background: var(--border-color, #e5e7eb);
  border-radius: 4px;
}

.sidebar-sticky {
  background: var(--bg-card, #ffffff);
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: 14px;
  padding: 18px 10px 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 8px 24px -12px rgba(0,0,0,0.08);
  /* 顶部渐变高光 */
  position: relative;
  overflow: hidden;
}
.sidebar-sticky::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg,
    var(--accent-primary, #3b82f6),
    var(--accent-primary-hover, #2563eb) 50%,
    var(--accent-success, #10b981));
  opacity: 0.7;
}

.sidebar-title {
  font-size: .72rem;
  font-weight: 700;
  color: var(--text-muted, #9ca3af);
  text-transform: uppercase;
  letter-spacing: .12em;
  padding: 6px 14px 12px;
  margin-top: 2px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 0 6px;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  text-decoration: none;
  color: var(--text-secondary, #374151);
  font-size: .85rem;
  font-weight: 500;
  transition: all .2s cubic-bezier(.2,.8,.2,1);
  border: 1px solid transparent;
  position: relative;
}

.sidebar-item:hover {
  background: var(--bg-secondary, #f3f4f6);
  color: var(--text-primary, #111827);
  transform: translateX(2px);
}

.sidebar-item.active {
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--accent-primary, #3b82f6) 12%, transparent),
    color-mix(in srgb, var(--accent-primary, #3b82f6) 4%, transparent));
  color: var(--accent-primary, #3b82f6);
  font-weight: 600;
  border-color: color-mix(in srgb, var(--accent-primary, #3b82f6) 18%, transparent);
  box-shadow: 0 2px 8px -3px color-mix(in srgb, var(--accent-primary, #3b82f6) 40%, transparent);
}
/* active 左侧小竖条 */
.sidebar-item.active::before {
  content: '';
  position: absolute;
  left: -6px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 20px;
  border-radius: 2px;
  background: var(--accent-primary, #3b82f6);
}

.sidebar-icon {
  font-size: 1.05rem;
  line-height: 1;
  width: 22px;
  text-align: center;
  flex: 0 0 auto;
  filter: grayscale(0%);
  transition: transform .2s;
}
.sidebar-item:hover .sidebar-icon,
.sidebar-item.active .sidebar-icon {
  transform: scale(1.1);
}

.sidebar-label {
  white-space: nowrap;
}

/* ──────────────────────────────────────────────────────────────
   右侧主内容区
   ────────────────────────────────────────────────────────────── */
.settings-main {
  flex: 1;
  min-width: 0;
}

.settings-category {
  margin-bottom: 36px;
  scroll-margin-top: 96px;
}

.category-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary, #111827);
  margin: 0 0 6px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-color, #e5e7eb);
  letter-spacing: -.01em;
}
.category-title::first-letter {
  /* 保持 emoji 原样，不加特殊效果 */
}

.category-desc {
  font-size: .82rem;
  color: var(--text-muted, #6b7280);
  margin: -2px 0 20px;
  line-height: 1.55;
}

.admin-standalone {
  margin-top: 12px;
}

/* ──────────────────────────────────────────────────────────────
   设置卡片 — Soft elevation
   ────────────────────────────────────────────────────────────── */
.settings-section {
  background: var(--bg-card, #ffffff);
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: 14px;
  padding: 26px 28px;
  margin-bottom: 22px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03), 0 8px 20px -14px rgba(0,0,0,0.06);
  transition: box-shadow .25s, transform .25s;
}
.settings-section:hover {
  box-shadow: 0 2px 4px rgba(0,0,0,0.04), 0 14px 30px -14px rgba(0,0,0,0.1);
}

.settings-section h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary, #111827);
  margin: 0 0 18px;
  padding-bottom: 14px;
  border-bottom: 1px dashed var(--border-color, #e5e7eb);
  display: flex;
  align-items: center;
  gap: 8px;
}
.settings-section h3::before {
  content: '';
  width: 4px;
  height: 16px;
  border-radius: 3px;
  background: linear-gradient(180deg,
    var(--accent-primary, #3b82f6),
    var(--accent-primary-hover, #2563eb));
  display: inline-block;
}

/* ──────────────────────────────────────────────────────────────
   设置项行 — 更舒适的间距
   ────────────────────────────────────────────────────────────── */
.setting-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--border-color, #e5e7eb);
  gap: 20px;
}
.setting-item:last-child {
  border-bottom: none;
}

.setting-label {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  min-width: 0;
}

.setting-title {
  font-weight: 600;
  font-size: .9rem;
  color: var(--text-primary, #111827);
  letter-spacing: -.005em;
}

.setting-desc {
  font-size: .78rem;
  color: var(--text-muted, #6b7280);
  line-height: 1.5;
}

/* ──────────────────────────────────────────────────────────────
   主题选择网格
   ────────────────────────────────────────────────────────────── */
.theme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(156px, 1fr));
  gap: 14px;
  margin-top: 4px;
}

.theme-option {
  border: 2px solid var(--border-color, #e5e7eb);
  border-radius: 12px;
  padding: 16px 12px 14px;
  cursor: pointer;
  transition: all .25s cubic-bezier(.2,.8,.2,1);
  text-align: center;
  background: var(--bg-input, #fff);
}
.theme-option:hover {
  border-color: var(--accent-primary, #3b82f6);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px -6px color-mix(in srgb, var(--accent-primary, #3b82f6) 35%, transparent);
}
.theme-option.active {
  border-color: var(--accent-primary, #3b82f6);
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--accent-primary, #3b82f6) 10%, transparent),
    color-mix(in srgb, var(--accent-primary, #3b82f6) 2%, transparent));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-primary, #3b82f6) 15%, transparent),
              0 4px 14px -4px color-mix(in srgb, var(--accent-primary, #3b82f6) 40%, transparent);
  transform: translateY(-1px);
}

.theme-preview {
  height: 64px;
  border-radius: 8px;
  margin-bottom: 10px;
  border: 1px solid rgba(0,0,0,0.06);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.5);
}

.theme-name {
  font-size: .88rem;
  font-weight: 600;
  color: var(--text-primary, #111827);
}

.theme-desc {
  font-size: .7rem;
  color: var(--text-muted, #6b7280);
  margin-top: 3px;
  line-height: 1.4;
}

/* ──────────────────────────────────────────────────────────────
   输入框 / 下拉 — 统一风格
   ────────────────────────────────────────────────────────────── */
.form-input,
.form-select,
.fc-input,
select[id$="Input"],
input[id$="Input"] {
  font-family: inherit !important;
  font-size: .88rem !important;
  padding: 10px 14px !important;
  border-radius: 10px !important;
  border: 1px solid var(--border-color, #e5e7eb) !important;
  background: var(--bg-input, #fff) !important;
  color: var(--text-primary, #111827) !important;
  transition: border-color .18s, box-shadow .18s;
  outline: none;
  box-sizing: border-box;
}
.form-input:focus,
.form-select:focus,
.fc-input:focus,
select[id$="Input"]:focus,
input[id$="Input"]:focus {
  border-color: var(--accent-primary, #3b82f6) !important;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-primary, #3b82f6) 18%, transparent);
}

/* ──────────────────────────────────────────────────────────────
   统一按钮样式（覆盖 header.css 基础）
   ────────────────────────────────────────────────────────────── */
.btn,
button.btn,
a.btn {
  font-family: inherit !important;
  font-weight: 600;
  font-size: .84rem;
  padding: 10px 18px !important;
  border-radius: 10px !important;
  border: none !important;
  cursor: pointer;
  transition: all .2s cubic-bezier(.2,.8,.2,1) !important;
  text-decoration: none;
  display: inline-flex !important;
  align-items: center;
  gap: 6px;
  line-height: 1;
  letter-spacing: .01em;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.btn-primary {
  background: linear-gradient(180deg,
    var(--accent-primary, #3b82f6),
    var(--accent-primary-hover, #2563eb)) !important;
  color: #fff !important;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1), 0 4px 12px -4px color-mix(in srgb, var(--accent-primary, #3b82f6) 50%, transparent) !important;
}
.btn-primary:hover {
  transform: translateY(-1px) !important;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1), 0 8px 18px -4px color-mix(in srgb, var(--accent-primary, #3b82f6) 60%, transparent) !important;
  filter: brightness(1.04);
}
.btn-primary:active {
  transform: translateY(0) !important;
  filter: brightness(.97);
}

.btn-secondary {
  background: var(--bg-secondary, #f3f4f6) !important;
  color: var(--text-primary, #111827) !important;
  border: 1px solid var(--border-color, #e5e7eb) !important;
}
.btn-secondary:hover {
  background: var(--bg-tertiary, #e5e7eb) !important;
  border-color: var(--accent-primary, #3b82f6) !important;
  color: var(--accent-primary, #3b82f6) !important;
  transform: translateY(-1px) !important;
}

.btn-warning {
  background: linear-gradient(180deg, #d97706, #b45309) !important;
  color: #fff !important;
}
.btn-warning:hover {
  transform: translateY(-1px) !important;
  box-shadow: 0 6px 14px -4px rgba(180,83,9,0.45) !important;
}

.btn-danger {
  background: linear-gradient(180deg, #dc2626, #b91c1c) !important;
  color: #fff !important;
}
.btn-danger:hover {
  transform: translateY(-1px) !important;
  box-shadow: 0 6px 14px -4px rgba(185,28,28,0.45) !important;
}

/* 内联/小按钮 */
button[onclick] {
  font-family: inherit;
}

/* ──────────────────────────────────────────────────────────────
   Switch 开关 — 美化
   ────────────────────────────────────────────────────────────── */
.switch {
  position: relative;
  width: 48px;
  height: 26px;
  flex: 0 0 auto;
}
.switch input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
  z-index: 2;
}
.slider {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: var(--border-color, #cbd5e1);
  transition: .25s cubic-bezier(.2,.8,.2,1);
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.1);
}
.slider::before {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  left: 3px;
  top: 3px;
  border-radius: 50%;
  background: #fff;
  transition: .25s cubic-bezier(.2,.8,.2,1);
  box-shadow: 0 1px 3px rgba(0,0,0,0.2), 0 1px 0 rgba(0,0,0,0.08);
}
.switch input:checked + .slider {
  background: linear-gradient(135deg,
    var(--accent-success, #10b981),
    #059669);
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.12),
              0 0 0 3px color-mix(in srgb, var(--accent-success, #10b981) 20%, transparent);
}
.switch input:checked + .slider::before {
  transform: translateX(22px);
}
.switch input:focus-visible + .slider {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-primary, #3b82f6) 25%, transparent);
}

/* ──────────────────────────────────────────────────────────────
   模块列表（mr-* 系列）— 从内嵌 style 接管
   ────────────────────────────────────────────────────────────── */
.mr-preset {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.mr-preset button {
  padding: 8px 14px !important;
  border-radius: 10px !important;
  border: 1px solid var(--border-color, #e5e7eb) !important;
  background: var(--bg-secondary, #f3f4f6) !important;
  color: var(--text-primary, #111827) !important;
  font-size: .82rem !important;
  font-weight: 500 !important;
  cursor: pointer;
  transition: all .2s !important;
  font-family: inherit !important;
}
.mr-preset button:hover {
  border-color: var(--accent-primary, #3b82f6) !important;
  color: var(--accent-primary, #3b82f6) !important;
  transform: translateY(-1px);
  box-shadow: 0 4px 10px -4px color-mix(in srgb, var(--accent-primary, #3b82f6) 35%, transparent);
}

.mr-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 8px;
}
.mr-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 6px;
  border-bottom: 1px solid var(--border-color, #e5e7eb);
  transition: background .15s;
  border-radius: 6px;
}
.mr-item:hover {
  background: var(--bg-secondary, #f3f4f6);
}
.mr-item:last-child { border-bottom: none; }

.mr-ico {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: var(--bg-secondary, #f3f4f6);
  font-size: 18px;
  transition: transform .2s;
}
.mr-item:hover .mr-ico {
  transform: scale(1.08);
}

.mr-txt { flex: 1; min-width: 0; }
.mr-name {
  display: block;
  font-size: .9rem;
  font-weight: 600;
  color: var(--text-primary, #111827);
}
.mr-desc {
  display: block;
  font-size: .75rem;
  color: var(--text-muted, #6b7280);
  line-height: 1.5;
  margin-top: 2px;
}

.mr-switch {
  position: relative;
  width: 48px;
  height: 26px;
  flex: 0 0 48px;
}
.mr-switch input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
  z-index: 2;
}
.mr-slider {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: var(--border-color, #cbd5e1);
  transition: .22s;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.1);
}
.mr-slider::before {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  left: 3px;
  top: 3px;
  border-radius: 50%;
  background: #fff;
  transition: .22s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.mr-switch input:checked + .mr-slider {
  background: linear-gradient(135deg, var(--accent-success, #10b981), #059669);
}
.mr-switch input:checked + .mr-slider::before {
  transform: translateX(22px);
}

/* ──────────────────────────────────────────────────────────────
   fc-* 系列（页脚配置）— 清理，交给通用输入/按钮
   ────────────────────────────────────────────────────────────── */
.fc-input { box-shadow: none; }
.fc-row {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.fc-row .fc-input {
  flex: 1 1 116px;
  min-width: 96px;
  padding: 9px 12px !important;
  font-size: .85rem !important;
}
.fc-row select {
  padding: 8px 12px !important;
  background: var(--bg-input, #fff);
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: 10px;
  color: var(--text-primary);
  font-size: .84rem;
  font-family: inherit;
}
.fc-check {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: .8rem;
  color: var(--text-secondary);
  white-space: nowrap;
}
.fc-mini {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  border: 1px solid var(--border-color, #e5e7eb);
  background: var(--bg-secondary, #f3f4f6);
  color: var(--text-secondary, #6b7280);
  border-radius: 8px;
  cursor: pointer;
  font-size: .9rem;
  line-height: 1;
  padding: 0;
  transition: all .18s;
}
.fc-mini:hover:not(:disabled) {
  background: var(--accent-primary, #3b82f6);
  color: #fff;
  border-color: var(--accent-primary, #3b82f6);
  transform: scale(1.06);
}
.fc-mini:disabled { opacity: .35; cursor: not-allowed; }
.fc-empty { font-size: .82rem; color: var(--text-muted, #9ca3af); padding: 8px 0; }
.fc-hint { font-size: .78rem; color: var(--text-muted, #6b7280); line-height: 1.7; }
.fc-hint code {
  background: var(--bg-secondary, #f3f4f6);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: .92em;
  border: 1px solid var(--border-color, #e5e7eb);
}
.fc-bad {
  display: none;
  font-size: .76rem;
  color: #dc2626;
  margin: -2px 0 8px;
}

/* pendingBadge 红点 */
#pendingBadge {
  background: #ef4444 !important;
  color: #fff !important;
  border-radius: 10px !important;
  padding: 1px 8px !important;
  font-size: .72rem !important;
  font-weight: 600;
  margin-left: 8px;
  animation: pulse-badge 2s ease-in-out infinite;
}
@keyframes pulse-badge {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,0.5); }
  50% { box-shadow: 0 0 0 4px rgba(239,68,68,0); }
}

/* ──────────────────────────────────────────────────────────────
   响应式
   ────────────────────────────────────────────────────────────── */
@media (max-width: 860px) {
  .settings-layout {
    flex-direction: column;
    gap: 22px;
    padding: 0 14px 40px;
  }
  .settings-sidebar {
    position: static;
    flex: none;
    height: auto;
    overflow: visible;
  }
  .sidebar-sticky {
    padding: 14px 10px;
  }
  .sidebar-title {
    padding: 4px 12px 10px;
  }
  .sidebar-nav {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 4px;
  }
  .sidebar-item {
    padding: 8px 14px;
    font-size: .82rem;
    white-space: nowrap;
  }
  .sidebar-icon { display: none; }
  .sidebar-item.active::before { display: none; }

  .settings-section {
    padding: 20px 18px;
    border-radius: 12px;
  }
  .setting-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
}
