﻿/* ========== 全局重置 ========== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  background: #f5f6fa;
  color: #333;
  font-size: 14px;
  line-height: 1.5;
  min-height: 100%;
  overflow-x: hidden;
}

a { text-decoration: none; color: inherit; }
button { cursor: pointer; border: none; outline: none; font-family: inherit; }
input, textarea { font-family: inherit; outline: none; }

/* ========== 用户端首页 ========== */
.home-container {
  max-width: 480px;
  margin: 0 auto;
  height: 100vh;
  background: #f5f6fa;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* 顶部横幅广告位 */
.banner-ad {
  width: 100%;
  background: #fff;
  overflow: hidden;
  flex-shrink: 0;
}

.banner-ad a {
  display: block;
  width: 100%;
}

.banner-ad img {
  display: block;
  width: 100%;
  height: auto;
  object-fit: cover;
}

/* 头部 */
.home-header {
  position: relative;
  height: 200px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #fff;
  overflow: hidden;
  flex-shrink: 0;
}

.home-header::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -20%;
  width: 200px;
  height: 200px;
  background: rgba(255,255,255,0.1);
  border-radius: 50%;
}

.home-header::after {
  content: '';
  position: absolute;
  bottom: -30%;
  left: -10%;
  width: 150px;
  height: 150px;
  background: rgba(255,255,255,0.08);
  border-radius: 50%;
}

.header-logo {
  width: 64px;
  height: 64px;
  background: rgba(255,255,255,0.2);
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  backdrop-filter: blur(10px);
  z-index: 1;
}

.header-logo img {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  object-fit: cover;
  display: block;
}

.header-title {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 2px;
  z-index: 1;
}

.header-subtitle {
  font-size: 12px;
  opacity: 0.8;
  margin-top: 4px;
  z-index: 1;
}

.header-bottom {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 24px;
  background: #f5f6fa;
  border-radius: 24px 24px 0 0;
}

/* APP列表 */
.app-list {
  padding: 8px 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.app-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #fff;
  border-radius: 16px;
  padding: 14px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
  transition: transform 0.2s, box-shadow 0.2s;
}

.app-card:active {
  transform: scale(0.98);
}

.app-icon {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  object-fit: cover;
  flex-shrink: 0;
  background: #f0f0f0;
}

.app-info {
  flex: 1;
  min-width: 0;
}

.app-name {
  font-size: 16px;
  font-weight: 600;
  color: #1a1a1a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-remark {
  font-size: 12px;
  color: #999;
  margin-top: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.4;
}

.download-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 36px;
  padding: 0 16px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  border-radius: 18px;
  font-size: 13px;
  font-weight: 500;
  flex-shrink: 0;
  transition: opacity 0.2s;
}

.download-btn:active {
  opacity: 0.8;
}

.download-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.download-btn svg {
  width: 14px;
  height: 14px;
  stroke: #fff;
  fill: none;
  stroke-width: 2;
}

/* 加载/空状态 */
.loading-wrap, .empty-wrap, .error-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: #999;
}

.loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid #e0e0e0;
  border-top-color: #667eea;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 12px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.5;
}

.retry-btn {
  margin-top: 12px;
  padding: 8px 20px;
  background: #667eea;
  color: #fff;
  border-radius: 20px;
  font-size: 13px;
}

/* ========== 后台管理 ========== */
.admin-login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 20px;
}

.login-box {
  width: 100%;
  max-width: 380px;
  background: #fff;
  border-radius: 20px;
  padding: 36px 28px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.login-logo {
  width: 60px;
  height: 60px;
  margin: 0 auto 16px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-logo svg {
  width: 30px;
  height: 30px;
  stroke: #fff;
  fill: none;
  stroke-width: 1.5;
}

.login-title {
  text-align: center;
  font-size: 20px;
  font-weight: 700;
  color: #1a1a1a;
  margin-bottom: 24px;
}

.form-group {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: #555;
  margin-bottom: 6px;
}

.form-input, .form-textarea, .form-select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid #e0e0e0;
  border-radius: 10px;
  font-size: 14px;
  color: #333;
  background: #fafafa;
  transition: border-color 0.2s, background 0.2s;
}

.form-input:focus, .form-textarea:focus, .form-select:focus {
  border-color: #667eea;
  background: #fff;
}

.form-textarea {
  resize: vertical;
  min-height: 70px;
}

.btn-primary {
  width: 100%;
  height: 44px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: opacity 0.2s;
}

.btn-primary:active { opacity: 0.85; }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.login-hint {
  text-align: center;
  font-size: 12px;
  color: #bbb;
  margin-top: 16px;
}

/* 后台主界面 */
.admin-layout {
  min-height: 100vh;
  background: #f5f6fa;
}

.admin-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: #fff;
  border-bottom: 1px solid #eee;
  padding: 0 20px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.admin-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.admin-header-logo {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.admin-header-logo svg {
  width: 18px;
  height: 18px;
  stroke: #fff;
  fill: none;
  stroke-width: 1.5;
}

.admin-header-title {
  font-size: 16px;
  font-weight: 700;
  color: #1a1a1a;
}

.btn-logout {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 14px;
  background: #f5f5f5;
  color: #666;
  border-radius: 8px;
  font-size: 13px;
  transition: background 0.2s;
}

.btn-logout:active { background: #eee; }
.btn-logout svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2; }

.admin-content {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px;
}

/* Tab切换 */
.admin-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  background: #fff;
  padding: 6px;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.admin-tab {
  flex: 1;
  padding: 10px;
  text-align: center;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  color: #888;
  background: transparent;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.admin-tab svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; }

.admin-tab.active {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
}

/* 统计卡片 */
.stats-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card {
  background: #fff;
  border-radius: 14px;
  padding: 20px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.05);
}

.stat-card-label {
  font-size: 13px;
  color: #999;
  margin-bottom: 8px;
}

.stat-card-value {
  font-size: 28px;
  font-weight: 700;
  color: #1a1a1a;
}

.stat-card-value.primary { color: #667eea; }
.stat-card-value.success { color: #52c41a; }
.stat-card-value.warning { color: #faad14; }

/* 图表区域 */
.chart-card {
  background: #fff;
  border-radius: 14px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.05);
}

.chart-title {
  font-size: 15px;
  font-weight: 600;
  color: #333;
  margin-bottom: 16px;
}

/* 柱状图 */
.bar-chart {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  height: 180px;
  gap: 8px;
  padding: 0 8px;
}

.bar-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
}

.bar-fill {
  width: 100%;
  max-width: 36px;
  background: linear-gradient(180deg, #667eea 0%, #764ba2 100%);
  border-radius: 6px 6px 0 0;
  min-height: 2px;
  transition: height 0.5s ease;
  position: relative;
}

.bar-value {
  font-size: 11px;
  color: #667eea;
  font-weight: 600;
  margin-bottom: 4px;
}

.bar-label {
  font-size: 11px;
  color: #999;
  margin-top: 6px;
  white-space: nowrap;
}

/* 表格 */
.data-table-wrap {
  background: #fff;
  border-radius: 14px;
  padding: 20px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.05);
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  text-align: left;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 600;
  color: #888;
  border-bottom: 2px solid #f0f0f0;
  white-space: nowrap;
}

.data-table td {
  padding: 12px;
  font-size: 14px;
  color: #333;
  border-bottom: 1px solid #f5f5f5;
}

.data-table tr:last-child td { border-bottom: none; }

.table-app-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.table-app-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  object-fit: cover;
  background: #f0f0f0;
  flex-shrink: 0;
}

.table-app-name {
  font-weight: 500;
  color: #1a1a1a;
}

.table-app-remark {
  font-size: 12px;
  color: #999;
  margin-top: 2px;
  max-width: 200px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.download-count {
  display: inline-block;
  padding: 2px 10px;
  background: #f0f0ff;
  color: #667eea;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
}

/* 操作按钮 */
.btn-action {
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  margin-right: 6px;
  transition: opacity 0.2s;
}

.btn-action:active { opacity: 0.8; }
.btn-edit { background: #e6f7ff; color: #1890ff; }
.btn-delete { background: #fff1f0; color: #ff4d4f; }

/* 新增按钮 */
.btn-add {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 16px;
}

.btn-add svg { width: 16px; height: 16px; stroke: #fff; fill: none; stroke-width: 2; }

/* 弹窗 */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-box {
  width: 100%;
  max-width: 460px;
  background: #fff;
  border-radius: 16px;
  padding: 24px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
  color: #1a1a1a;
  margin-bottom: 20px;
}

.modal-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

.btn-cancel {
  flex: 1;
  height: 42px;
  background: #f5f5f5;
  color: #666;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
}

.btn-confirm {
  flex: 1;
  height: 42px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
}

.btn-confirm:disabled { opacity: 0.6; cursor: not-allowed; }

/* 上传区域 */
.upload-area {
  border: 2px dashed #d0d0d0;
  border-radius: 10px;
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  background: #fafafa;
}

.upload-area:hover, .upload-area.dragover {
  border-color: #667eea;
  background: #f5f5ff;
}

.upload-area svg {
  width: 32px;
  height: 32px;
  stroke: #bbb;
  fill: none;
  stroke-width: 1.5;
  margin-bottom: 8px;
}

.upload-area p {
  font-size: 13px;
  color: #999;
}

.upload-preview {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  background: #fafafa;
  border-radius: 10px;
}

.upload-preview img {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  object-fit: cover;
}

.upload-preview-info {
  flex: 1;
  font-size: 13px;
  color: #666;
}

.upload-remove {
  color: #ff4d4f;
  font-size: 13px;
  background: none;
}

/* Toast提示 */
.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  color: #fff;
  z-index: 2000;
  animation: toastIn 0.3s ease;
  max-width: 90%;
}

.toast.success { background: #52c41a; }
.toast.error { background: #ff4d4f; }
.toast.info { background: #1890ff; }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(-20px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* 日期选择 */
.date-picker-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.date-picker-row label {
  font-size: 13px;
  color: #666;
  white-space: nowrap;
}

.date-picker-row input {
  padding: 6px 12px;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  font-size: 13px;
}

/* 响应式 */
@media (max-width: 640px) {
  .admin-content { padding: 12px; }
  .stats-cards { grid-template-columns: repeat(2, 1fr); }
  .stat-card-value { font-size: 22px; }
  .data-table-wrap { padding: 12px; }
  .data-table th, .data-table td { padding: 8px 6px; font-size: 13px; }
  .table-app-remark { display: none; }
}
