/* ============================================================
   netutil - 全局样式表
   主色：#165DFF  背景：#FFFFFF  文字：#1D2129
   ============================================================ */

/* ---------- CSS 变量 ---------- */
:root {
  --primary:       #165DFF;
  --primary-hover: #0E4FD8;
  --primary-light: #EBF0FF;
  --danger:        #F53F3F;
  --danger-light:  #FFF1F0;
  --success:       #00B42A;
  --success-light: #E8FFEA;
  --warning:       #FF7D00;
  --text-primary:  #1D2129;
  --text-secondary:#4E5969;
  --text-tertiary: #86909C;
  --border:        #E5E6EB;
  --bg-main:       #F7F8FA;
  --bg-card:       #FFFFFF;
  --radius-sm:     6px;
  --radius-md:     10px;
  --radius-lg:     14px;
  --shadow-sm:     0 1px 4px rgba(0,0,0,.06);
  --shadow-md:     0 4px 16px rgba(0,0,0,.08);
  --transition:    .18s ease;
  --navbar-h:      60px;
}

/* ---------- 重置 & 基础 ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; font-size: 15px; }

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

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

ul { padding-left: 1.4em; }
ul li { margin-bottom: .4em; }

/* ---------- 顶部导航栏 ---------- */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--navbar-h);
  background: #fff;
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.navbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  height: 100%;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 24px;
}

/* Logo */
.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  flex-shrink: 0;
}

/* 导航链接 */
.nav-links {
  display: flex;
  gap: 8px;
  flex: 1;
  justify-content: center;
  align-items: center;
}

.nav-group {
  position: relative;
}

.nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 14px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-size: .9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
}

.nav-btn:hover,
.nav-btn.active,
.nav-group.open > .nav-btn {
  background: var(--primary-light);
  color: var(--primary);
}

.nav-btn.active { font-weight: 600; }

.caret {
  transition: transform var(--transition);
}

.nav-group.open .caret {
  transform: rotate(180deg);
}

.subnav-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  min-width: 148px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 8px;
  display: none;
  flex-direction: column;
  gap: 4px;
  z-index: 120;
}

.nav-group.open .subnav-menu {
  display: flex;
}

.subnav-btn {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  text-align: left;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: .86rem;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}

.subnav-btn:hover,
.subnav-btn.active {
  background: var(--primary-light);
  color: var(--primary);
}

.subnav-btn.active {
  font-weight: 600;
}

/* 移动端汉堡菜单 */
.hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  margin-left: auto;
  flex-shrink: 0;
}

.hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text-primary);
  border-radius: 2px;
  transition: transform var(--transition), opacity var(--transition);
}

/* ---------- 广告位样式 ---------- */
.ad-placeholder {
  background: #F2F3F5;
  border: 1.5px dashed #C9CDD4;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
  font-size: .78rem;
  text-align: center;
  letter-spacing: .04em;
}

.ad-top {
  width: 100%;
  height: 90px;
  max-width: 100%;
}

.ad-bottom-banner {
  width: 100%;
  height: 90px;
}

.ad-side {
  width: 160px;
  min-height: 600px;
  padding: 8px;
  flex-shrink: 0;
  line-height: 1.6;
}

/* AdSense 真实广告容器（替换 placeholder 时用） */
.ad-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  padding: 8px 0;
}

/* ---------- 主布局 ---------- */
.main-layout {
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 28px 24px 32px;
  display: flex;
  gap: 28px;
  align-items: flex-start;
}

/* 工具主区域 */
.tool-area { flex: 1; min-width: 0; }

/* 侧边广告 */
.ad-sidebar {
  flex-shrink: 0;
  position: sticky;
  top: calc(var(--navbar-h) + 16px);
}

/* ---------- 工具面板 ---------- */
.tool-panel { display: none; }
.tool-panel.active { display: block; }

.panel-header { margin-bottom: 20px; }

.panel-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.panel-desc {
  color: var(--text-secondary);
  font-size: .9rem;
}

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

/* ---------- 表单元素 ---------- */
.form-group { margin-bottom: 16px; }
.form-group:last-child { margin-bottom: 0; }

.form-group label {
  display: block;
  font-size: .875rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.input-field {
  width: 100%;
  height: 42px;
  padding: 0 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .95rem;
  color: var(--text-primary);
  background: #fff;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.input-field:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(22,93,255,.12);
}

.input-field.error {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(245,63,63,.1);
}

/* IP 输入行 */
.input-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.input-row .input-field { flex: 1; }
.prefix-input { width: 80px !important; flex: none !important; text-align: center; }
.input-sep { font-size: 1.2rem; color: var(--text-tertiary); font-weight: 600; }

.input-hint {
  margin-top: 6px;
  font-size: .82rem;
  color: var(--danger);
  min-height: 1.2em;
}

/* Textarea */
.textarea-field {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .95rem;
  color: var(--text-primary);
  background: #fff;
  resize: vertical;
  min-height: 120px;
  line-height: 1.6;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
  font-family: inherit;
}

.textarea-field:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(22,93,255,.12);
}

/* Select */
select.input-field { cursor: pointer; appearance: auto; }

/* Range slider */
.range-slider {
  width: 100%;
  height: 6px;
  margin-top: 10px;
  accent-color: var(--primary);
  cursor: pointer;
}

.range-labels {
  display: flex;
  justify-content: space-between;
  font-size: .78rem;
  color: var(--text-tertiary);
  margin-top: 4px;
}

/* form-row 横排 */
.form-row {
  display: flex;
  gap: 16px;
}

.flex1 { flex: 1; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 20px;
  height: 40px;
  border-radius: var(--radius-sm);
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
  white-space: nowrap;
}

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

.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 4px 12px rgba(22,93,255,.3);
  transform: translateY(-1px);
}

.btn-primary:active { transform: translateY(0); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1.5px solid var(--border);
}

.btn-ghost:hover {
  background: var(--bg-main);
  border-color: #C9CDD4;
  color: var(--text-primary);
}

.btn-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 16px;
}

/* 复制按钮（结果卡片内） */
.copy-btn {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  height: 26px;
  font-size: .78rem;
  font-weight: 600;
  border: 1.5px solid var(--primary);
  border-radius: 4px;
  background: transparent;
  color: var(--primary);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
  flex-shrink: 0;
}

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

/* icon-btn（字数统计工具栏） */
.icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-size: .82rem;
  cursor: pointer;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}

.icon-btn:hover { background: var(--bg-main); color: var(--text-primary); border-color: #C9CDD4; }
.icon-btn.danger:hover { background: var(--danger-light); color: var(--danger); border-color: var(--danger); }

/* ---------- 子网结果 ---------- */
.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin-top: 4px;
}

.result-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: box-shadow var(--transition);
}

.result-card:hover { box-shadow: var(--shadow-md); }

.result-card.full-width { grid-column: 1 / -1; }

.result-label {
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: .05em;
}

.result-value {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--primary);
  word-break: break-all;
  flex: 1;
}

/* ---------- 图片压缩 ---------- */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 40px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: var(--text-secondary);
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.upload-zone .link {
  color: var(--primary);
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
}

.visually-hidden-file {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  border: 0;
  padding: 0;
  clip: rect(0 0 0 0);
  overflow: hidden;
}

.upload-hint {
  font-size: .8rem;
  color: var(--text-tertiary);
  margin-top: -6px;
}

.upload-file-meta {
  font-size: .82rem;
  color: var(--text-secondary);
  margin-top: -2px;
  min-height: 1.2em;
}

/* 对比展示 */
.img-compare-wrap {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  flex-wrap: wrap;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.img-compare-item { flex: 1; min-width: 200px; }

.compare-label {
  font-size: .82rem;
  font-weight: 600;
  color: var(--text-tertiary);
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.img-preview-box {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #f0f0f0;
  min-height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.img-preview-box img {
  max-width: 100%;
  max-height: 320px;
  display: block;
  object-fit: contain;
}

.img-meta {
  margin-top: 8px;
  font-size: .82rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.compare-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: 40px;
  flex-shrink: 0;
}

.save-rate {
  font-size: .9rem;
  font-weight: 700;
  color: var(--success);
  margin-left: 12px;
}

/* ---------- 字数统计 ---------- */
.textarea-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.textarea-header label { margin-bottom: 0; }

.textarea-actions { display: flex; gap: 8px; }

/* 统计结果网格 */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  margin-top: 4px;
}

.stat-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 16px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), transform var(--transition);
}

.stat-item:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }

.stat-num {
  font-size: 2rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1;
  margin-bottom: 6px;
}

.stat-label {
  font-size: .8rem;
  color: var(--text-tertiary);
  line-height: 1.4;
}

/* ---------- HTTP请求测试 & JSON格式化 ---------- */
.http-result-wrap {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.http-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.code-view {
  border: 1px solid var(--border);
  background: #0F172A;
  color: #E2E8F0;
  border-radius: var(--radius-md);
  padding: 14px 16px;
  line-height: 1.7;
  font-size: .86rem;
  overflow: auto;
  max-height: 460px;
  white-space: pre;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

.code-view .code-key { color: #93C5FD; }
.code-view .code-string { color: #86EFAC; }
.code-view .code-literal { color: #FCA5A5; }
.code-view .code-number { color: #FDE68A; }

.json-input {
  min-height: 240px;
}

/* ---------- 图片格式转换 & PDF工具 ---------- */
.subsection-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 12px;
}

.task-progress {
  margin-top: 12px;
}

.task-progress-bar {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: #EEF1F6;
}

.task-progress-bar span {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, #165DFF 0%, #69B1FF 100%);
  transition: width var(--transition);
}

.task-progress-text {
  margin-top: 6px;
  font-size: .82rem;
  color: var(--text-tertiary);
}

.convert-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.convert-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: #fff;
  padding: 10px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.convert-card img {
  width: 100%;
  height: 160px;
  object-fit: contain;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #F9FAFC;
}

.convert-title {
  font-size: .84rem;
  font-weight: 600;
  color: var(--text-primary);
  word-break: break-word;
}

.convert-meta {
  font-size: .78rem;
  color: var(--text-tertiary);
}

.convert-actions {
  display: flex;
  justify-content: flex-end;
}

/* ---------- 二维码生成器 ---------- */
.qr-output-wrap {
  display: flex;
  align-items: flex-start;
  gap: 32px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow-sm);
  flex-wrap: wrap;
}

.qr-canvas-box {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  background: #fff;
  display: inline-flex;
}

.qr-canvas-box canvas {
  display: block;
  max-width: 100%;
}

.qr-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 8px;
}

.qr-tip {
  font-size: .82rem;
  color: var(--text-tertiary);
}

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 200;
  display: flex !important;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn .18s ease;
}

/* 隐藏时覆盖（兼容 style 序列化为 "display:none" / "display: none"） */
.modal-overlay[style*="display:none"],
.modal-overlay[style*="display: none"] { display: none !important; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-box {
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
  max-width: 580px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  animation: slideUp .2s ease;
}

@keyframes slideUp {
  from { transform: translateY(16px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 { font-size: 1.1rem; font-weight: 700; }

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-tertiary);
  cursor: pointer;
  line-height: 1;
  padding: 0 4px;
  transition: color var(--transition);
}

.modal-close:hover { color: var(--text-primary); }

.modal-body {
  padding: 20px 24px 24px;
  line-height: 1.75;
  color: var(--text-secondary);
  font-size: .9rem;
}

.modal-body h3 {
  font-size: .95rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 16px 0 6px;
}

.modal-body p { margin-bottom: 10px; }

/* ---------- Toast ---------- */
.toast-container {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  pointer-events: none;
}

.toast {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 24px;
  font-size: .875rem;
  font-weight: 600;
  color: #fff;
  box-shadow: 0 8px 24px rgba(0,0,0,.18);
  animation: toastIn .22s ease forwards;
  pointer-events: auto;
  max-width: 340px;
}

.toast.success { background: var(--success); }
.toast.error   { background: var(--danger); }
.toast.info    { background: var(--primary); }
.toast.warning { background: var(--warning); }

.toast.hide {
  animation: toastOut .22s ease forwards;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px) scale(.92); }
  to   { opacity: 1; transform: translateY(0)    scale(1); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to   { opacity: 0; transform: translateY(8px) scale(.92); }
}

/* ---------- 页脚 ---------- */
.footer {
  background: #fff;
  border-top: 1px solid var(--border);
  padding: 20px 24px;
}

.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  text-align: center;
}

.footer-links {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.footer-links a {
  font-size: .875rem;
  color: var(--text-secondary);
  transition: color var(--transition);
}

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

.footer-sep { color: var(--border); }

.footer-copy {
  font-size: .8rem;
  color: var(--text-tertiary);
}

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
  .ad-sidebar { display: none; } /* 移动端隐藏侧边广告 */
  .main-layout { padding: 20px 16px 24px; }
}

@media (max-width: 700px) {
  .navbar-inner { padding: 0 16px; }

  .nav-links {
    display: none;
    position: absolute;
    top: var(--navbar-h);
    left: 0;
    right: 0;
    background: #fff;
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    padding: 10px 16px;
    box-shadow: 0 8px 24px rgba(0,0,0,.08);
    z-index: 99;
    align-items: stretch;
    gap: 6px;
  }

  .nav-links.open { display: flex; }

  .nav-group { width: 100%; }

  .nav-btn {
    width: 100%;
    justify-content: space-between;
    padding: 10px 14px;
    font-size: .95rem;
  }

  .subnav-menu {
    position: static;
    margin-top: 6px;
    box-shadow: none;
    border: 1px solid var(--border);
    background: #fff;
  }

  .subnav-btn {
    font-size: .9rem;
    padding: 9px 10px;
  }

  .hamburger { display: flex; }

  .panel-title { font-size: 1.2rem; }

  .result-grid { grid-template-columns: 1fr 1fr; }

  .stats-grid { grid-template-columns: repeat(3, 1fr); }

  .img-compare-wrap { flex-direction: column; }
  .compare-arrow { transform: rotate(90deg); padding: 0; align-self: center; }

  .form-row { flex-direction: column; gap: 12px; }

  .qr-output-wrap { flex-direction: column; align-items: center; }

  .code-view {
    max-height: 340px;
    font-size: .82rem;
  }
}


@media (max-width: 420px) {
  .result-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .card { padding: 16px; }
}
