/* ============================================================
 * 泓盛泽独立后台 - 访客统计样式
 * ============================================================ */
:root {
  --vis-primary: #0ea5e9;
  --vis-primary-d: #0284c7;
  --vis-warn: #f59e0b;
  --vis-danger: #ef4444;
  --vis-success: #10b981;
  --vis-bg: #f8fafc;
  --vis-panel: #ffffff;
  --vis-border: #e2e8f0;
  --vis-text: #0f172a;
  --vis-text-muted: #64748b;
  --vis-text-dim: #94a3b8;
}

#vis-root { padding: 20px; }

/* ---------- Toolbar ---------- */
.vis-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--vis-panel); border: 1px solid var(--vis-border);
  border-radius: 10px; padding: 12px 16px; margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,.04); flex-wrap: wrap; gap: 8px;
}
.vis-toolbar-l { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.vis-toolbar-l label { color: var(--vis-text-muted); font-size: 13px; margin-right: 4px; }
.vis-toolbar-l select, .vis-toolbar-l input {
  border: 1px solid var(--vis-border); border-radius: 6px; padding: 6px 10px; font-size: 13px;
  background: #fff; color: var(--vis-text); outline: none;
}
.vis-toolbar-l select:focus, .vis-toolbar-l input:focus { border-color: var(--vis-primary); }
.vis-toolbar-r { display: flex; align-items: center; gap: 12px; }
.vis-btn {
  border: 1px solid var(--vis-border); background: #fff; color: var(--vis-text);
  border-radius: 6px; padding: 6px 14px; font-size: 13px; cursor: pointer;
  transition: all .15s;
}
.vis-btn:hover { border-color: var(--vis-primary); color: var(--vis-primary); }
.vis-btn-primary { background: var(--vis-primary); color: #fff; border-color: var(--vis-primary); }
.vis-btn-primary:hover { background: var(--vis-primary-d); color: #fff; border-color: var(--vis-primary-d); }
.vis-btn-mini { padding: 3px 10px; font-size: 12px; }
.vis-btn:disabled { opacity: .4; cursor: not-allowed; }
.vis-updated { color: var(--vis-text-dim); font-size: 12px; }

/* ---------- Cards ---------- */
.vis-cards {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin-bottom: 16px;
}
.vis-card {
  background: var(--vis-panel); border: 1px solid var(--vis-border);
  border-radius: 10px; padding: 16px; box-shadow: 0 1px 3px rgba(0,0,0,.04);
  transition: all .2s;
}
.vis-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,.08); transform: translateY(-1px); }
.vis-card-primary { border-color: var(--vis-primary); background: linear-gradient(180deg, #f0f9ff, #fff); }
.vis-card-live { border-color: var(--vis-success); background: linear-gradient(180deg, #ecfdf5, #fff); }
.vis-card-label { font-size: 12px; color: var(--vis-text-muted); margin-bottom: 6px; font-weight: 500; }
.vis-card-num { font-size: 28px; font-weight: 700; color: var(--vis-text); line-height: 1; margin-bottom: 4px; }
.vis-card-sub { font-size: 12px; color: var(--vis-text-muted); }
.vis-live-dot {
  display: inline-block; width: 6px; height: 6px; background: var(--vis-success);
  border-radius: 50%; margin-right: 4px; animation: vis-blink 1.6s infinite;
}
@keyframes vis-blink { 0%,100% { opacity: 1; } 50% { opacity: .3; } }

/* ---------- Panels ---------- */
.vis-panel {
  background: var(--vis-panel); border: 1px solid var(--vis-border);
  border-radius: 10px; padding: 16px 20px; margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.vis-panel-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 14px; }
.vis-panel-head h3 { font-size: 16px; font-weight: 600; color: var(--vis-text); margin: 0; }
.vis-panel-sub { font-size: 12px; color: var(--vis-text-muted); }

/* ---------- Chart ---------- */
.vis-chart-wrap { position: relative; height: 260px; }

/* ---------- Map ---------- */
.vis-map { width: 100%; height: 360px; border-radius: 8px; background: #cce5ff; }

/* ---------- Bars ---------- */
.vis-bar-list { display: grid; gap: 6px; }
.vis-bar-row {
  display: grid; grid-template-columns: 24px 100px 1fr 60px 50px;
  align-items: center; gap: 8px; padding: 6px 8px;
  border-radius: 6px; cursor: pointer; transition: background .15s;
}
.vis-bar-row:hover { background: var(--vis-bg); }
.vis-bar-flag { font-size: 18px; }
.vis-bar-name { font-size: 13px; color: var(--vis-text); }
.vis-bar-track { height: 10px; background: var(--vis-bg); border-radius: 6px; overflow: hidden; }
.vis-bar-fill { display: block; height: 100%; border-radius: 6px; transition: width .4s ease-out; }
.vis-bar-val { text-align: right; font-size: 13px; color: var(--vis-text); font-variant-numeric: tabular-nums; }
.vis-bar-pct { text-align: right; font-size: 12px; color: var(--vis-text-muted); font-variant-numeric: tabular-nums; }

/* ---------- 2 列布局（地图 / 国家） ---------- */
.vis-cols { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; }
@media (max-width: 1100px) { .vis-cols { grid-template-columns: 1fr; } }

/* ---------- Cities ---------- */
.vis-cities { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.vis-city-chip {
  display: flex; align-items: center; gap: 6px; padding: 8px 12px;
  background: var(--vis-bg); border: 1px solid var(--vis-border); border-radius: 8px;
}
.vis-city-name { flex: 1; font-size: 13px; color: var(--vis-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vis-city-val { font-size: 13px; font-weight: 600; color: var(--vis-primary); }

/* ---------- Devices ---------- */
.vis-dev-3col { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.vis-dev-3col h4 { font-size: 13px; font-weight: 600; color: var(--vis-text-muted); margin: 0 0 8px; }
.vis-dev-row { display: grid; grid-template-columns: 80px 1fr 50px; gap: 8px; align-items: center; margin-bottom: 6px; }
.vis-dev-name { font-size: 12px; color: var(--vis-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- 列对齐 ---------- */
.vis-col-time { text-align: left; }
.vis-col-ip { text-align: left; }
.vis-col-country { text-align: center; }
.vis-col-city { text-align: left; }
.vis-col-platform { text-align: center; }
.vis-col-device { text-align: center; }
.vis-col-hits { text-align: right; }
.vis-col-op { text-align: center; }

/* ---------- Table ---------- */
.vis-table-wrap { overflow-x: auto; }
.vis-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.vis-table th {
  text-align: left; padding: 10px 12px; background: var(--vis-bg); color: var(--vis-text-muted);
  font-weight: 600; font-size: 12px; border-bottom: 1px solid var(--vis-border); white-space: nowrap;
}
.vis-table td { padding: 10px 12px; border-bottom: 1px solid var(--vis-border); color: var(--vis-text); }
.vis-table tr:hover td { background: var(--vis-bg); }
.vis-table tr[data-ip] { cursor: pointer; }
.vis-mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12px; color: var(--vis-text); }

/* ---------- Pager ---------- */
.vis-pager {
  display: flex; align-items: center; justify-content: center;
  gap: 12px; padding: 14px; font-size: 13px; color: var(--vis-text-muted);
}
.vis-pager .vis-btn { padding: 6px 16px; }

/* ---------- Detail Overlay ---------- */
.vis-detail-overlay {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .5);
  display: flex; align-items: center; justify-content: center; z-index: 9999;
  animation: vis-fadein .2s;
}
@keyframes vis-fadein { from { opacity: 0; } to { opacity: 1; } }
.vis-detail {
  width: 90%; max-width: 560px; max-height: 90vh; overflow-y: auto;
  background: var(--vis-panel); border-radius: 12px;
  box-shadow: 0 20px 50px rgba(0,0,0,.2); animation: vis-rise .2s;
}
@keyframes vis-rise { from { transform: translateY(20px); opacity: 0; } to { transform: none; opacity: 1; } }
.vis-detail-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--vis-border);
}
.vis-detail-head h3 { margin: 0; font-size: 16px; font-weight: 600; color: var(--vis-text); }
.vis-detail-head .vis-btn { padding: 4px 10px; font-size: 18px; }
.vis-detail-summary {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px;
  padding: 14px 20px; background: var(--vis-bg); border-bottom: 1px solid var(--vis-border);
}
.vis-detail-summary > div { display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.vis-detail-label { color: var(--vis-text-muted); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
.vis-detail-section { padding: 14px 20px; border-bottom: 1px solid var(--vis-border); }
.vis-detail-section:last-child { border: 0; }
.vis-detail-section h4 { font-size: 13px; font-weight: 600; color: var(--vis-text-muted); margin: 0 0 8px; }
.vis-detail-list { display: grid; gap: 4px; }
.vis-detail-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 4px 8px; background: var(--vis-bg); border-radius: 4px; font-size: 12px;
}
.vis-detail-date { font-family: monospace; color: var(--vis-text); }
.vis-detail-pages { display: grid; gap: 4px; }
.vis-detail-page {
  display: flex; justify-content: space-between; align-items: center;
  padding: 4px 8px; background: var(--vis-bg); border-radius: 4px; font-size: 12px;
}
.vis-detail-loading, .vis-detail-empty {
  background: var(--vis-panel); padding: 40px; border-radius: 12px;
  text-align: center; color: var(--vis-text-muted);
}

/* ---------- Misc ---------- */
.vis-loading, .vis-empty { text-align: center; padding: 60px; color: var(--vis-text-muted); }
.vis-loading::after { content: '...'; animation: vis-dot 1s infinite; }
@keyframes vis-dot { 0%,100% { opacity: .2; } 50% { opacity: 1; } }

@media (max-width: 700px) {
  .vis-dev-3col { grid-template-columns: 1fr; }
  .vis-detail-summary { grid-template-columns: 1fr; }
}

/* ============================================================
 * v1.1 — KPI 卡片点击 + 访客详情浮层（2026-08-26）
 * ============================================================ */

/* 卡片可点击状态 */
.vis-card[data-card] { cursor: pointer; transition: transform .15s ease, box-shadow .15s ease; }
.vis-card[data-card]:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,.18); }
.vis-card[data-card]:active { transform: translateY(0); }

/* 卡片详情浮层 */
.vis-card-overlay {
  position: fixed; inset: 0; z-index: 99990;
  background: rgba(15, 23, 42, .55);
  display: flex; align-items: center; justify-content: center;
  animation: visFadeIn .15s ease;
}
.vis-card-panel {
  background: var(--vis-card-bg, #ffffff);
  color: var(--vis-text, #1f2937);
  width: min(920px, 94vw); max-height: 86vh;
  border-radius: 14px; box-shadow: 0 24px 64px rgba(0,0,0,.35);
  display: flex; flex-direction: column; overflow: hidden;
  animation: visSlideUp .18s ease;
}
.vis-card-panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; border-bottom: 1px solid rgba(127,127,127,.18);
  background: rgba(127,127,127,.04);
}
.vis-card-panel-head h3 { margin: 0; font-size: 16px; font-weight: 700; }
.vis-card-panel-body { padding: 16px 20px; overflow-y: auto; }
.vis-card-loading, .vis-card-empty { text-align: center; padding: 48px 0; color: #6b7280; }

/* 列表元信息与标签 */
.vis-card-table-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; font-size: 12px; color: #6b7280; }
.vis-card-tag { background: rgba(59,130,246,.12); color: #2563eb; border-radius: 10px; padding: 2px 10px; font-size: 11px; }

/* 国家/城市分布面板 */
.vis-card-geo { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.vis-card-geo h4 { margin: 0 0 10px; font-size: 13px; font-weight: 700; }
.vis-card-geo-list { display: flex; flex-direction: column; gap: 4px; max-height: 52vh; overflow-y: auto; }
.vis-card-geo-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 8px; cursor: pointer;
  transition: background .12s ease;
}
.vis-card-geo-row:hover { background: rgba(59,130,246,.10); }
.vis-card-geo-name { font-size: 13px; font-weight: 600; flex: 0 0 auto; min-width: 110px; }
.vis-card-geo-val { font-size: 12px; color: #6b7280; margin-left: auto; }
@media (max-width: 720px) { .vis-card-geo { grid-template-columns: 1fr; } }

/* 动画 */
@keyframes visFadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes visSlideUp { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: translateY(0); } }

/* ============================================================
 * v1.2 — 爬虫标识 + 移动端适配（2026-08-26）
 * ============================================================ */

/* 爬虫标识 */
.vis-bot-tag { font-size: 12px; cursor: help; }

/* ---------- 移动端（≤640px） ---------- */
@media (max-width: 640px) {
  #vis-root { padding: 10px; }

  /* KPI 卡片两列 */
  .vis-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .vis-card { padding: 12px; }
  .vis-card-num { font-size: 22px; }
  .vis-card-label { font-size: 11px; }
  .vis-card-sub { font-size: 11px; }

  /* 筛选条：去标签、控件弹性换行 */
  .vis-toolbar { padding: 10px 12px; }
  .vis-toolbar-l { width: 100%; }
  .vis-toolbar-l label { display: none; }
  .vis-toolbar-l select, .vis-toolbar-l input { flex: 1 1 42%; min-width: 0; }
  .vis-toolbar-r { width: 100%; justify-content: space-between; }
  .vis-updated { font-size: 11px; }

  /* 面板与图表 */
  .vis-panel { padding: 12px; }
  .vis-panel-head h3 { font-size: 14px; }
  .vis-chart-wrap { height: 200px; }
  .vis-map { height: 240px; }

  /* 国家条形图压缩列宽 */
  .vis-bar-row { grid-template-columns: 20px 74px 1fr 44px; gap: 6px; }
  .vis-bar-pct { display: none; }
  .vis-bar-flag { font-size: 15px; }

  /* 城市芯片 */
  .vis-cities { grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 6px; }

  /* 明细表格 */
  .vis-table { font-size: 12px; }
  .vis-table th, .vis-table td { padding: 8px; }

  /* 卡片浮层：底部抽屉式全宽 */
  .vis-card-overlay { align-items: flex-end; }
  .vis-card-panel { width: 100%; max-height: 88vh; border-radius: 14px 14px 0 0; }
  .vis-card-panel-head { padding: 12px 14px; }
  .vis-card-panel-body { padding: 10px 12px; }
  .vis-card-geo-name { min-width: 80px; }
  .vis-card-geo-val { font-size: 11px; }

  /* 单 IP 详情浮层 */
  .vis-detail { width: 96vw; max-height: 88vh; }

  /* 分页按钮加大触控区 */
  .vis-pager .vis-btn { padding: 8px 14px; }
  .vis-btn { padding: 8px 14px; }
}

/* ============================================================
 * v1.3 — APP 化：访客页浮层安全区与触摸反馈（2026-08-26）
 * ============================================================ */
@media (max-width: 768px) {
  /* 浮层全面屏适配：底部留出 home 指示条空间 */
  .vis-card-panel { border-radius: 18px 18px 0 0; max-height: 88dvh; }
  .vis-card-panel-body { padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
  .vis-detail { border-radius: 18px 18px 0 0; max-height: 88dvh; width: 100%; max-width: 100%; }
  .vis-detail-overlay { align-items: flex-end; }

  /* 卡片按压反馈（APP 质感） */
  .vis-card[data-card]:active { transform: scale(.97); }

  /* 触控目标放大 */
  .vis-btn { padding: 9px 16px; font-size: 14px; }
  .vis-card-geo-row { padding: 11px 10px; }

  /* 明细表输入不触发 iOS 缩放 */
  .vis-toolbar-l select, .vis-toolbar-l input { font-size: 16px; }
}


/* ============================================================
 * v1.4 — 移动端访客统计页撑满屏幕（2026-08-26）
 * 只留顶部 topbar + 底部 btm-bar，中间 #tab-visitors 占满剩余，
 * 内部 #vis-content 可滚动，地图/趋势图自动放大。
 * ============================================================ */
@media (max-width: 768px) {
  /* 访客统计页占满 topbar 与底部菜单之间的空间 */
  #tab-visitors.active {
    display: flex;
    flex-direction: column;
    height: calc(100dvh - 62px - 58px - env(safe-area-inset-bottom));
    min-height: calc(100dvh - 62px - 58px - env(safe-area-inset-bottom));
    overflow: hidden;
    padding: 0;
  }
  #tab-visitors.active > h2 { display: none; }   /* 顶部蓝条已有标题，节省空间 */

  /* 内层包装 */
  #vis-root,
  #vis-root > .vis-dashboard {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
  }

  /* 筛选工具条固定高度 */
  .vis-toolbar {
    flex: 0 0 auto;
    margin: 10px 10px 8px;
    border-radius: 10px;
  }

  /* 内容区占满剩余并可滚动 */
  #vis-content {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0 10px calc(10px + env(safe-area-inset-bottom));
  }

  /* 内容区本身也作为 flex 列，让图表/地图优先占满 */
  #vis-content {
    display: flex;
    flex-direction: column;
    gap: 10px;
  }
  #vis-content > .vis-cards { flex: 0 0 auto; }
  #vis-content > .vis-panel {
    flex: 0 0 auto;
    margin-bottom: 0;
  }

  /* 趋势图与地图面板自动占满剩余空间 */
  #vis-content > .vis-panel:has(.vis-chart-wrap) {
    flex: 1 1 260px;
    min-height: 220px;
  }
  #vis-content > .vis-panel:has(.vis-map) {
    flex: 1 1 320px;
    min-height: 260px;
  }
  .vis-chart-wrap { height: 100%; min-height: 180px; }
  .vis-map { height: 100%; min-height: 220px; }

  /* 下方列表/设备面板保持自然高度 */
  #vis-content > .vis-panel:has(.vis-table-wrap),
  #vis-content > .vis-panel:has(.vis-dev-3col) {
    flex: 0 0 auto;
  }

  /* 两列布局在手机上单列 */
  .vis-cols { grid-template-columns: 1fr; }
}
