/* ========================================
   WinGoal 基础样式
   主题：足球预测（绿红配色）
   ======================================== */

:root {
  /* === 主题色 === */
  --primary-green: #10b981;
  --primary-red: #ef4444;
  --dark-green: #059669;
  --dark-red: #dc2626;
  --light-green: #34d399;
  --light-red: #f87171;

  /* === 中性色 === */
  --dark: #1e293b;
  --dark-secondary: #334155;
  --ink: #0f172a;
  --ink-secondary: #334155;
  --muted: #64748b;
  --border: #e2e8f0;
  --border-light: #f1f5f9;
  --bg-light: #f8fafc;
  --bg-white: #ffffff;

  /* === 功能色 === */
  --success: var(--primary-green);
  --danger: var(--primary-red);
  --warning: #f59e0b;
  --info: #3b82f6;

  /* === 渐变 === */
  --gradient-primary: linear-gradient(135deg, var(--primary-green) 0%, var(--primary-red) 100%);
  --gradient-green: linear-gradient(135deg, var(--light-green) 0%, var(--dark-green) 100%);
  --gradient-red: linear-gradient(135deg, var(--light-red) 0%, var(--dark-red) 100%);

  /* === 阴影 === */
  --shadow-sm: 0 1px 2px rgba(0,0,0,.04);
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.07), 0 2px 4px -2px rgba(0,0,0,.05);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.08), 0 4px 6px -4px rgba(0,0,0,.04);
  --shadow-xl: 0 20px 25px -5px rgba(0,0,0,.08), 0 8px 10px -6px rgba(0,0,0,.03);

  /* === 布局 === */
  --header-height: 56px;
  --footer-height: 60px;
  --max-width: 960px;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;

  /* === 动画 === */
  --ease: cubic-bezier(.4,0,.2,1);
  --duration: .2s;
}

/* ========================================
   重置
   ======================================== */
*,*::before,*::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
               "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg-light);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; }

/* ========================================
   布局
   ======================================== */
.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.main-content {
  flex: 1;
  padding-top: var(--header-height);
  padding-bottom: calc(var(--footer-height) + env(safe-area-inset-bottom, 0px));
}

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 16px;
}

/* ========================================
   顶部导航
   ======================================== */
.app-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-height);
  background: var(--bg-white);
  border-bottom: 1px solid var(--border);
  z-index: 1000;
}

.header-content {
  max-width: var(--max-width);
  margin: 0 auto;
  height: 100%;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
  flex-shrink: 0;
  transition: opacity var(--duration) var(--ease);
}
.header-logo:hover { opacity: .8; }

.logo-img { height: 32px; width: auto; }

.logo-text {
  font-size: 18px;
  font-weight: 700;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-title {
  flex: 1;
  text-align: right;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ========================================
   底部导航
   ======================================== */
.app-footer {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--footer-height);
  background: var(--bg-white);
  border-top: 1px solid var(--border);
  z-index: 1000;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.footer-nav {
  max-width: var(--max-width);
  margin: 0 auto;
  height: 100%;
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 0 8px;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 16px;
  color: var(--muted);
  transition: color var(--duration) var(--ease);
  border-radius: var(--radius-sm);
  -webkit-tap-highlight-color: transparent;
}
.nav-item:hover { color: var(--ink); }
.nav-item.active { color: var(--primary-green); }

.nav-icon {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.nav-icon svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-label {
  font-size: 11px;
  font-weight: 500;
  line-height: 1;
}

/* ========================================
   页面内容区
   ======================================== */
.page-wrapper {
  padding: 20px 0 24px;
  min-height: calc(100vh - var(--header-height) - var(--footer-height));
}

.page-header { margin-bottom: 24px; }

.page-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 4px;
  line-height: 1.3;
}

.page-subtitle {
  font-size: 14px;
  color: var(--muted);
}

/* ========================================
   卡片
   ======================================== */
.card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--duration) var(--ease);
}

/* ========================================
   按钮
   ======================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--duration) var(--ease);
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  line-height: 1.4;
}
.btn:active { transform: scale(.97); }
.btn:disabled {
  opacity: .45;
  cursor: not-allowed;
  transform: none !important;
}

.btn-primary {
  background: var(--primary-green);
  color: #fff;
}
.btn-primary:hover:not(:disabled) { background: var(--dark-green); }

.btn-danger {
  background: var(--primary-red);
  color: #fff;
}
.btn-danger:hover:not(:disabled) { background: var(--dark-red); }

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--primary-green);
  color: var(--primary-green);
}
.btn-outline:hover:not(:disabled) {
  background: var(--primary-green);
  color: #fff;
}

.btn-ghost {
  background: var(--bg-light);
  color: var(--ink-secondary);
  border: 1px solid var(--border);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--border);
}

/* ========================================
   徽章
   ======================================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
}

.badge-success {
  background: #dcfce7;
  color: var(--dark-green);
}
.badge-danger {
  background: #fee2e2;
  color: var(--dark-red);
}
.badge-warning {
  background: #fef3c7;
  color: #92400e;
}
.badge-info {
  background: #dbeafe;
  color: #1e40af;
}

/* ========================================
   加载动画
   ======================================== */
.loading {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--primary-green);
  border-radius: 50%;
  animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ========================================
   section 标题
   ======================================== */
.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 12px;
  line-height: 1.3;
}
.section-title .section-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  color: var(--primary-green);
}
.section-title .section-icon svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ========================================
   统计数值
   ======================================== */
.stat-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.2;
}
.stat-label {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}

/* ========================================
   输入框
   ======================================== */
.form-input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  color: var(--ink);
  background: var(--bg-white);
  transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
  -webkit-appearance: none;
}
.form-input:focus {
  outline: none;
  border-color: var(--primary-green);
  box-shadow: 0 0 0 3px rgba(16,185,129,.1);
}
.form-input::placeholder { color: var(--muted); }

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-secondary);
  margin-bottom: 6px;
}

/* ========================================
   空状态
   ======================================== */
.empty-state {
  text-align: center;
  padding: 32px 16px;
  color: var(--muted);
}
.empty-state .empty-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 12px;
  color: var(--border);
}
.empty-state .empty-icon svg {
  width: 48px; height: 48px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.2;
}
.empty-state .empty-text {
  font-size: 14px;
  line-height: 1.5;
}

/* ========================================
   比赛卡片
   ======================================== */
.match-card {
  display: block;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: inherit;
  transition: border-color var(--duration) var(--ease),
              box-shadow var(--duration) var(--ease),
              transform var(--duration) var(--ease);
}
.match-card:hover {
  border-color: var(--primary-green);
  box-shadow: var(--shadow-md);
}
.match-card:active { transform: scale(.99); }
.match-card.ended { background: var(--bg-light); }

.match-meta {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
  line-height: 1.4;
}
.match-teams {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.4;
}
.match-teams .vs {
  color: var(--muted);
  font-weight: 400;
  margin: 0 2px;
}
.match-result {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border-light);
  font-size: 13px;
  color: var(--ink-secondary);
  line-height: 1.6;
}
.match-result .result-tag {
  display: inline-block;
  margin-right: 6px;
}
.match-result .result-score {
  color: var(--primary-green);
  font-weight: 600;
}

/* ========================================
   周期选择器
   ======================================== */
.period-bar {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}
.period-bar .period-label {
  font-size: 13px;
  color: var(--muted);
  margin-right: 4px;
}
.period-bar .period-info {
  margin-left: auto;
  font-size: 12px;
  color: var(--muted);
}
.period-btn {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-white);
  color: var(--ink-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--duration) var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.period-btn:hover { background: var(--bg-light); }
.period-btn.active {
  background: var(--primary-green);
  color: #fff;
  border-color: var(--primary-green);
}

/* ========================================
   响应式
   ======================================== */
@media (max-width: 640px) {
  :root {
    --header-height: 50px;
    --footer-height: 56px;
  }

  .logo-text { font-size: 16px; }
  .header-title { font-size: 14px; }

  .page-wrapper { padding: 16px 0 20px; }
  .page-title { font-size: 20px; }

  .card { padding: 14px; }

  .nav-item { padding: 6px 10px; }
  .nav-icon svg { width: 20px; height: 20px; }
  .nav-label { font-size: 10px; }

  .stat-value { font-size: 22px; }

  .period-bar .period-info {
    width: 100%;
    margin-left: 0;
    margin-top: 4px;
  }
}

@media (max-width: 380px) {
  .container { padding: 0 12px; }
  .header-content { padding: 0 12px; }
  .logo-img { height: 28px; }
}

/* ========================================
   工具类
   ======================================== */
.text-center { text-align: center; }
.text-muted { color: var(--muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.hidden { display: none; }