/* Ping0.me — IP 工具站样式
   主题：默认跟随系统（prefers-color-scheme），也可手动切换浅色/深色 */

:root {
  --font-stack: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue",
    Helvetica, Arial, sans-serif;
}

/* ---------- 浅色主题 ---------- */
:root,
:root[data-theme="light"] {
  --bg: #f3f5f9;
  --card: #ffffff;
  --row-alt: #eef3fa;
  --text: #1f2a37;
  --muted: #66788f;
  --border: #e2e8f2;
  --link: #1a73e8;
  --link-hover: #0f5fd0;
  --header-bg: rgba(255, 255, 255, 0.88);
  --input-bg: #ffffff;
  --btn-bg: #1a73e8;
  --btn-text: #ffffff;
  --pill-green-bg: #1f9d61;
  --pill-green-text: #ffffff;
  --pill-gray-bg: #e8edf4;
  --pill-gray-text: #66788f;
  --tooltip-bg: #ffffff;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.08), 0 4px 14px rgba(16, 24, 40, 0.06);
}

/* ---------- 深色主题 ---------- */
:root[data-theme="dark"] {
  --bg: #0d1219;
  --card: #141b26;
  --row-alt: #18202e;
  --text: #e8edf5;
  --muted: #93a1b5;
  --border: #232e40;
  --link: #5b9dff;
  --link-hover: #7db3ff;
  --header-bg: rgba(13, 18, 25, 0.88);
  --input-bg: #1b2432;
  --btn-bg: #2f7de1;
  --btn-text: #ffffff;
  --pill-green-bg: #1f9d61;
  --pill-green-text: #ffffff;
  --pill-gray-bg: #232e40;
  --pill-gray-text: #93a1b5;
  --tooltip-bg: #1b2432;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 4px 14px rgba(0, 0, 0, 0.35);
}

/* 跟随系统：未手动选择时交给媒体查询（由 JS 设置 data-theme，这里兜底） */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) {
    --bg: #0d1219;
    --card: #141b26;
    --row-alt: #18202e;
    --text: #e8edf5;
    --muted: #93a1b5;
    --border: #232e40;
    --link: #5b9dff;
    --link-hover: #7db3ff;
    --header-bg: rgba(13, 18, 25, 0.88);
    --input-bg: #1b2432;
    --btn-bg: #2f7de1;
    --btn-text: #ffffff;
    --pill-gray-bg: #232e40;
    --pill-gray-text: #93a1b5;
    --tooltip-bg: #1b2432;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 4px 14px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-stack);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  transition: background 0.25s ease, color 0.25s ease;
}

.wrap {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ---------- 顶栏 ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--header-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 28px;
  height: 60px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}
.logo .logo-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--text);
  color: #fff;
  font-size: 16px;
  filter: grayscale(1);
}
.logo small { font-weight: 400; color: var(--muted); }

.main-nav {
  display: flex;
  gap: 4px;
  flex: 1;
  overflow-x: auto;
}
.main-nav a {
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  white-space: nowrap;
}
.main-nav a:hover { background: var(--row-alt); color: var(--text); }
.main-nav a.active { color: var(--link); font-weight: 600; }
.main-nav a .tag-new {
  font-size: 10px;
  color: #e5484d;
  border: 1px solid #e5484d;
  border-radius: 4px;
  padding: 0 3px;
  margin-left: 4px;
  vertical-align: 1px;
}
.main-nav a .tag-hot {
  font-size: 10px;
  color: #e8890c;
  border: 1px solid #e8890c;
  border-radius: 4px;
  padding: 0 3px;
  margin-left: 4px;
  vertical-align: 1px;
}

.theme-toggle {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  border-radius: 10px;
  width: 38px;
  height: 38px;
  font-size: 17px;
  cursor: pointer;
  flex-shrink: 0;
}
.theme-toggle:hover { border-color: var(--link); }
.lang-toggle {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

/* ---------- 卡片 ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  margin: 22px 0;
  overflow: hidden;
}

.search-card { padding: 30px 28px; text-align: center; }
.search-card h1 { margin: 0 0 6px; font-size: 24px; }
.search-card .sub { margin: 0 0 20px; color: var(--muted); font-size: 14px; }

.search-form {
  display: flex;
  gap: 10px;
  max-width: 560px;
  margin: 0 auto;
}
.search-form input {
  flex: 1;
  padding: 12px 16px;
  font-size: 15px;
  font-family: var(--font-stack);
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--input-bg);
  color: var(--text);
  outline: none;
}
.search-form input:focus { border-color: var(--link); box-shadow: 0 0 0 3px color-mix(in srgb, var(--link) 18%, transparent); }
.search-form button {
  padding: 12px 26px;
  font-size: 15px;
  font-family: var(--font-stack);
  border: none;
  border-radius: 10px;
  background: var(--btn-bg);
  color: var(--btn-text);
  cursor: pointer;
  font-weight: 600;
}
.search-form button:hover { filter: brightness(1.08); }
.search-form button:disabled { opacity: 0.6; cursor: wait; }

/* ---------- 结果表 ---------- */
.info-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.info-table tr:nth-child(odd) td { background: var(--card); }
.info-table tr:nth-child(even) td { background: var(--row-alt); }
.info-table td { padding: 13px 18px; vertical-align: middle; }
.info-table td.label {
  width: 200px;
  text-align: center;
  color: var(--text);
  font-weight: 500;
  border-right: 1px solid var(--border);
}
.info-table td.value { text-align: center; }
.info-table td.side { width: 210px; text-align: right; }

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

.q-link {
  font-size: 12px;
  color: var(--link);
  cursor: help;
  margin-left: 6px;
  position: relative;
  white-space: nowrap;
}
.q-link::after {
  content: attr(data-tip);
  display: none;
  position: absolute;
  bottom: 130%;
  left: 50%;
  transform: translateX(-50%);
  width: 230px;
  white-space: normal;
  background: var(--tooltip-bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
  line-height: 1.6;
  box-shadow: var(--shadow);
  z-index: 20;
}
.q-link:hover::after { display: block; }

.icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 15px;
  color: var(--muted);
  padding: 2px 6px;
}
.icon-btn:hover { color: var(--link); }

/* 地图定位图标（CSS 绘制，不依赖外部图片） */
.p0-pin-wrap { background: none; border: none; }
.p0-pin { width: 30px; height: 34px; position: relative; }
.p0-pin::before {
  content: "";
  position: absolute;
  left: 3px;
  top: 0;
  width: 24px;
  height: 24px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  background: #2563eb;
  border: 2.5px solid #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
}
.p0-pin::after {
  content: "";
  position: absolute;
  left: 11.5px;
  top: 8.5px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #fff;
}

/* 国旗图片（Windows 版 Chrome/Edge 不支持 flag emoji，用图片代替） */
.flag-img {
  width: 22px;
  height: 15px;
  object-fit: cover;
  border-radius: 2px;
  vertical-align: -2px;
  margin-right: 4px;
  box-shadow: 0 0 1px rgba(0, 0, 0, 0.35);
}

/* 悬浮位置卡片 */
.loc-wrap { position: relative; display: inline-block; }
.loc-card {
  display: none;
  position: absolute;
  top: 135%;
  left: 50%;
  transform: translateX(-50%);
  width: 300px;
  background: var(--tooltip-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 12px 14px;
  text-align: left;
  z-index: 30;
  font-size: 13px;
  line-height: 1.9;
}
.loc-wrap:hover .loc-card { display: block; }
.loc-card .conf-bar {
  display: inline-block;
  width: 34px;
  height: 6px;
  border-radius: 3px;
  background: var(--pill-gray-bg);
  margin-right: 5px;
  vertical-align: 1px;
}
.loc-card .conf-bar.on { background: #1f9d61; }

/* 徽章 */
.pill {
  display: inline-block;
  padding: 5px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  margin: 2px 4px;
  white-space: nowrap;
}
.pill-idx-idc { background: #f0a13c; color: #ffffff; font-size: 11px; padding: 2px 8px; margin-right: 8px; vertical-align: 2px; }
.pill-idx-isp { background: #1f9d61; color: #ffffff; font-size: 11px; padding: 2px 8px; margin-right: 8px; vertical-align: 2px; }
.pill-bw-home { background: #1f9d61; color: #ffffff; }
.pill-bw-dc { background: #f0a13c; color: #ffffff; }
.pill-native { background: #1f9d61; color: #ffffff; }
.pill-bcast { background: #f6cfa8; color: #a05a1a; }
.pill-red { background: #e5484d; color: #ffffff; }
.pill-green { background: var(--pill-green-bg); color: var(--pill-green-text); }
.pill-gray { background: var(--pill-gray-bg); color: var(--pill-gray-text); }
.est-tag {
  font-size: 10px;
  color: var(--muted);
  border: 1px dashed var(--muted);
  border-radius: 4px;
  padding: 0 4px;
  margin-left: 6px;
  vertical-align: 2px;
}

/* 风控值条 */
.risk-wrap {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 16px 6px 8px;
}
.risk-dot { width: 14px; height: 14px; border-radius: 50%; background: #1f9d61; flex-shrink: 0; }
.risk-bar {
  width: 190px;
  height: 26px;
  border-radius: 999px;
  background: var(--pill-gray-bg);
  position: relative;
  overflow: hidden;
}
.risk-fill {
  height: 100%;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  min-width: 64px;
  transition: width 0.6s ease;
}
.risk-dots { display: inline-flex; gap: 7px; }
.risk-dots i { width: 15px; height: 15px; border-radius: 50%; display: block; }

/* AI 检测 chips */
.ai-chips { display: inline-flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.ai-chip {
  font-size: 12px;
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--pill-gray-bg);
  color: var(--muted);
}
.ai-chip.ok { background: rgba(31, 157, 97, 0.14); border-color: #1f9d61; color: #1f9d61; }
.ai-chip.fail { background: rgba(229, 72, 77, 0.12); border-color: #e5484d; color: #e5484d; }
.ai-chip.wait { opacity: 0.7; }

.link-btn {
  background: none;
  border: none;
  color: var(--link);
  font-size: 14px;
  font-family: var(--font-stack);
  cursor: pointer;
}
.link-btn:hover { text-decoration: underline; }

/* ---------- 地图 ---------- */
.map-head {
  padding: 14px 20px;
  font-size: 15px;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  background: var(--row-alt);
}
#map { height: 380px; width: 100%; z-index: 1; }
:root[data-theme="dark"] .leaflet-tile-pane {
  filter: invert(1) hue-rotate(185deg) brightness(0.92) contrast(0.92);
}

/* ---------- 页脚 ---------- */
.site-footer {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  padding: 26px 0 40px;
  line-height: 2;
}

/* ---------- Toast ---------- */
#toast {
  position: fixed;
  left: 50%;
  bottom: 34px;
  transform: translateX(-50%) translateY(20px);
  background: var(--text);
  color: var(--bg);
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s ease;
  z-index: 100;
  max-width: 80vw;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.loading-row td { text-align: center; color: var(--muted); padding: 30px !important; }

@media (max-width: 720px) {
  /* 移动端：表格改为上下堆叠，标签在上、内容在下，不再横向挤压 */
  .info-table, .info-table tbody, .info-table tr, .info-table td { display: block; width: auto; }
  .info-table td { padding: 8px 16px; border: none; }
  .info-table td.label {
    width: auto;
    text-align: left;
    font-size: 12px;
    color: var(--muted);
    font-weight: 500;
    border-right: none;
    padding-bottom: 0;
    border-radius: 8px 8px 0 0;
  }
  .info-table td.value {
    text-align: left;
    padding-top: 4px;
    overflow-wrap: anywhere;
    word-break: break-word;
    border-radius: 0 0 8px 8px;
  }
  .info-table td.side { display: none; }
  .main-nav { display: none; }
  .risk-bar { width: 130px; }
  .search-card { padding: 24px 18px; }
  .search-form { flex-direction: column; }
  .search-form button { width: 100%; }
}
