/* ================================================================
   管理后台 - 淄博阿尔法电气访问统计
   深蓝科技风，现代数据仪表盘
================================================================ */

/* ---------- 变量 ---------- */
:root {
  --primary:    #003580;
  --primary-light: #00A0E9;
  --accent:     #ff6b00;
  --success:    #00d4aa;
  --danger:     #e74c3c;
  --bg:         #f0f3f8;
  --card:       #ffffff;
  --text:       #1a2940;
  --text-light: #6b7a90;
  --border:     #e8ecf1;
  --shadow-sm:  0 2px 8px rgba(0,0,0,.06);
  --shadow-md:  0 8px 24px rgba(0,0,0,.08);
  --shadow-lg:  0 16px 48px rgba(0,0,0,.12);
  --radius:     12px;
  --radius-sm:  8px;
}

/* ---------- 基础 ---------- */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: 'Microsoft YaHei', 'PingFang SC', 'Noto Sans SC', sans-serif;
  background: var(--bg); color: var(--text); min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
.page { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.page.hidden { display: none; }

/* 统计页布局：头固定上，脚固定下，中间滚动 */
#statsPage:not(.hidden) {
  display: flex; flex-direction: column;
  align-items: stretch; justify-content: flex-start;
  height: 100vh; overflow: hidden;
}

/* ================================================================
   登录页
================================================================ */
.login-bg {
  position: fixed; inset: 0;
  background: linear-gradient(135deg, #001a3a 0%, #003580 50%, #0055a5 100%);
  z-index: -1;
}
.login-bg::after {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at 30% 20%, rgba(0,160,233,.15) 0%, transparent 60%),
              radial-gradient(ellipse at 70% 80%, rgba(255,107,0,.08) 0%, transparent 60%);
}

.login-box {
  background: rgba(255,255,255,.97); padding: 48px 40px; border-radius: var(--radius);
  box-shadow: var(--shadow-lg); width: 380px;
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,.3);
  animation: fadeUp .5s ease;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

.login-logo {
  width: 56px; height: 56px; border-radius: 14px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff; font-size: 1.6rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 20px; box-shadow: 0 4px 16px rgba(0,53,128,.3);
}
.login-box h2 { text-align: center; color: var(--primary); margin-bottom: 4px; font-size: 1.35rem; }
.login-box .subtitle { text-align: center; color: var(--text-light); font-size: .88rem; margin-bottom: 32px; }

.input-wrap {
  position: relative; margin-bottom: 16px;
}
.input-wrap input {
  display: block; width: 100%; padding: 11px 14px 11px 40px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: .95rem; outline: none; background: #fff;
  transition: border-color .2s, box-shadow .2s;
}
.input-wrap input:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(0,160,233,.12);
}
.input-icon {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  font-size: .9rem; color: var(--text-light); pointer-events: none;
}

.login-box button {
  width: 100%; padding: 12px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff; border: none; border-radius: var(--radius-sm);
  font-size: 1rem; font-weight: 600; cursor: pointer;
  transition: transform .2s, box-shadow .2s;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  margin-top: 8px;
}
.login-box button:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(0,53,128,.35);
}
.error { color: var(--danger); font-size: .85rem; margin-top: 14px; text-align: center; min-height: 1.2em; }

/* ================================================================
   头部
================================================================ */
.stats-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 32px; height: 56px; flex-shrink: 0;
  background: linear-gradient(90deg, var(--primary) 0%, #004494 100%);
  color: #fff;
  box-shadow: var(--shadow-md);
  z-index: 100;
}
.header-left {
  display: flex; align-items: center; gap: 14px;
}
.header-logo {
  width: 36px; height: 36px; border-radius: 10px;
  background: rgba(255,255,255,.15);
  color: #fff; font-size: 1.1rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(4px);
}
.stats-header h1 { font-size: 1.15rem; font-weight: 600; color: #fff; }
.header-sub { font-size: .78rem; color: rgba(255,255,255,.65); }

.btn-logout {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 16px; background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.2); border-radius: 6px;
  cursor: pointer; font-size: .85rem; color: rgba(255,255,255,.9);
  transition: all .2s;
}
.btn-logout:hover {
  background: rgba(255,255,255,.2);
  border-color: rgba(255,255,255,.4);
}

/* ================================================================
   主容器
================================================================ */
.stats-container {
  flex: 1; overflow-y: auto;
  padding: 24px 32px;
  max-width: 1280px; margin: 0 auto; width: 100%;
}

/* ================================================================
   统计卡片
================================================================ */
.cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; margin-bottom: 28px; }

.card {
  background: var(--card); padding: 20px 20px 16px;
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  display: flex; align-items: center; gap: 16px;
  position: relative; overflow: hidden;
  transition: transform .25s, box-shadow .25s;
  border: 1px solid var(--border);
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

.card-icon {
  width: 48px; height: 48px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; flex-shrink: 0;
}
.card-today  .card-icon { background: rgba(0,160,233,.1); }
.card-yesterday .card-icon { background: rgba(0,212,170,.1); }
.card-total  .card-icon { background: rgba(0,53,128,.1); }
.card-unique .card-icon { background: rgba(255,107,0,.1); }

.card-body { flex: 1; }
.card-num { font-size: 1.8rem; font-weight: 700; color: var(--primary); line-height: 1.2; }
.card-label { font-size: .82rem; color: var(--text-light); margin-top: 4px; }

.card-bar {
  position: absolute; bottom: 0; left: 0; right: 0; height: 3px;
}
.card-today  .card-bar { background: linear-gradient(90deg, #00A0E9, #0077c2); }
.card-yesterday .card-bar { background: linear-gradient(90deg, #00d4aa, #00a884); }
.card-total  .card-bar { background: linear-gradient(90deg, #003580, #0055a5); }
.card-unique .card-bar { background: linear-gradient(90deg, #ff6b00, #e55a00); }

/* ================================================================
   分区卡片
================================================================ */
.section {
  background: var(--card); padding: 24px;
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  margin-bottom: 24px; border: 1px solid var(--border);
}
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
}
.section h3 { font-size: 1.05rem; font-weight: 600; color: var(--text); }
.section-badge {
  font-size: .75rem; padding: 3px 10px;
  background: rgba(0,160,233,.08); color: var(--primary-light);
  border-radius: 50px; font-weight: 500;
}

/* ================================================================
   柱状图
================================================================ */
.chart-wrap {
  display: flex; align-items: stretch; gap: 12px; height: 220px;
}
.chart-y {
  display: flex; flex-direction: column; justify-content: space-between;
  padding-bottom: 28px; width: 32px; flex-shrink: 0;
}
.chart-y span {
  font-size: .68rem; color: var(--text-light); text-align: right;
  position: relative;
}
.chart-y span::after {
  content: '';
  position: absolute; left: 36px; right: -12px; top: 50%;
  height: 1px; background: var(--border);
}

.chart {
  flex: 1; display: flex; align-items: flex-end; gap: 10px;
  padding: 0 4px 28px; position: relative;
}
.chart::before {
  content: '';
  position: absolute; left: 0; right: 0; bottom: 28px; top: 0;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0%, transparent calc(25% - 1px),
    var(--border) calc(25% - 1px), var(--border) 25%
  );
  z-index: 0; pointer-events: none;
}

.bar {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  height: 100%; justify-content: flex-end; position: relative; z-index: 1;
}
.bar-fill {
  width: 60%; background: linear-gradient(180deg, var(--primary-light), var(--primary));
  border-radius: 6px 6px 0 0; transition: height .6s cubic-bezier(.4,0,.2,1);
  min-height: 2px; position: relative;
}
.bar-fill::after {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 40%;
  background: linear-gradient(180deg, rgba(255,255,255,.25), transparent);
  border-radius: 6px 6px 0 0;
}
.bar-value {
  font-size: .78rem; color: var(--text-light); margin-bottom: 4px;
  font-weight: 600; opacity: 0; transform: translateY(4px);
  transition: opacity .3s, transform .3s;
}
.bar:hover .bar-value { opacity: 1; transform: translateY(0); }
.bar-label {
  font-size: .72rem; color: var(--text-light); margin-top: 6px;
  white-space: nowrap;
}

/* ================================================================
   两列布局
================================================================ */
.two-col { display: grid; grid-template-columns: 1.2fr 1fr; gap: 24px; }

/* ================================================================
   地域分布（横向条形图）
================================================================ */
.region-list { display: flex; flex-direction: column; gap: 10px; }
.region-tag {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  background: #f8fafc; border-radius: var(--radius-sm);
  font-size: .88rem; color: var(--text);
  border: 1px solid var(--border); transition: background .2s;
}
.region-tag:hover { background: #f0f5fa; }
.region-tag .region-name { flex: 1; }
.region-tag .region-bar-wrap {
  width: 120px; height: 6px; background: var(--border);
  border-radius: 3px; overflow: hidden; flex-shrink: 0;
}
.region-tag .region-bar {
  height: 100%; border-radius: 3px;
  background: linear-gradient(90deg, var(--primary-light), var(--primary));
  transition: width .6s ease;
}
.region-tag .region-count {
  min-width: 28px; text-align: right;
  font-weight: 600; color: var(--primary); font-size: .85rem;
}

/* ================================================================
   数据说明
================================================================ */
.section-tip { background: linear-gradient(135deg, #f8fafc, #f0f5fa); }
.tip-body { display: flex; flex-direction: column; gap: 12px; }
.tip-item {
  display: flex; align-items: center; gap: 10px;
  font-size: .85rem; color: var(--text-light);
}
.tip-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}

/* ================================================================
   明细表格
================================================================ */
.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); border: 1px solid var(--border); }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .86rem; }

th {
  text-align: left; padding: 12px 14px;
  background: #f8fafc; color: var(--text-light);
  font-weight: 600; font-size: .8rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
th:first-child { border-radius: var(--radius-sm) 0 0 0; }
th:last-child { border-radius: 0 var(--radius-sm) 0 0; }

td { padding: 11px 14px; border-bottom: 1px solid var(--border); color: #444; }
tr:last-child td { border-bottom: none; }
tr:last-child td:first-child { border-radius: 0 0 0 var(--radius-sm); }
tr:last-child td:last-child { border-radius: 0 0 var(--radius-sm) 0; }

tr:hover td { background: #f8fafc; }
tbody tr { transition: background .15s; }

.referrer { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-light); }

/* ================================================================
   页脚
================================================================ */
.stats-footer {
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; gap: 16px;
  padding: 0 32px; height: 44px;
  font-size: .78rem; color: rgba(255,255,255,.7);
  background: linear-gradient(90deg, var(--primary) 0%, #004494 100%);
}
.footer-sep { margin: 0 10px; color: var(--border); }

/* ================================================================
   响应式
================================================================ */
@media (max-width: 992px) {
  .cards { grid-template-columns: repeat(2, 1fr); }
  .two-col { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .stats-header { padding: 0 16px; }
  .stats-container { padding: 16px; }
  .cards { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .card { padding: 16px 14px 12px; gap: 12px; }
  .card-num { font-size: 1.4rem; }
  .chart-wrap { height: 180px; }
  .login-box { width: 90%; max-width: 360px; padding: 36px 28px; }
}
@media (max-width: 480px) {
  .cards { grid-template-columns: 1fr; }
  .stats-header h1 { font-size: 1rem; }
  .header-sub { display: none; }
}
