/**
 * H5 前端样式
 * 企业微信自建应用 - 安全微习惯打卡
 * 主题色：#1E90FF（蓝）
 */

:root {
  --primary: #1E90FF;
  --primary-light: #e8f4ff;
  --primary-dark: #0066CC;
  --success: #52c41a;
  --warning: #faad14;
  --danger: #ff4d4f;
  --bg: #f5f7fa;
  --card-bg: #fff;
  --text: #333;
  --text-secondary: #666;
  --text-light: #999;
  --border: #e8e8e8;
  --shadow: 0 2px 8px rgba(0,0,0,0.06);
  --radius: 12px;
  --radius-sm: 8px;
}

* {
  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;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ========== 布局 ========== */
.page {
  max-width: 480px;
  margin: 0 auto;
  padding-bottom: 80px;
}

.header-bar {
  background: var(--primary);
  color: #fff;
  padding: 16px 20px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: bold;
  color: #fff;
  flex-shrink: 0;
}

.header-info {
  flex: 1;
  min-width: 0;
}

.header-name {
  font-size: 16px;
  font-weight: 600;
}

.header-dept {
  font-size: 12px;
  opacity: 0.8;
  margin-top: 2px;
}

/* ========== 卡片 ========== */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  margin: 12px 16px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title .more {
  font-size: 13px;
  color: var(--primary);
  cursor: pointer;
}

/* ========== 统计 ========== */
.stats-row {
  display: flex;
  justify-content: space-around;
  padding: 8px 0;
}

.stat-item {
  text-align: center;
  flex: 1;
}

.stat-num {
  font-size: 28px;
  font-weight: bold;
  color: var(--primary);
  line-height: 1.2;
}

.stat-label {
  font-size: 12px;
  color: var(--text-light);
  margin-top: 4px;
}

.stat-divider {
  width: 1px;
  background: var(--border);
  margin: 8px 0;
}

/* ========== 列表项 ========== */
.list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.list-item {
  display: flex;
  align-items: center;
  padding: 14px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
}

.list-item:active {
  background: var(--primary-light);
  border-color: var(--primary);
}

.item-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
  margin-right: 12px;
}

.item-content {
  flex: 1;
  min-width: 0;
}

.item-name {
  font-size: 15px;
  font-weight: 500;
}

.item-desc {
  font-size: 12px;
  color: var(--text-light);
  margin-top: 2px;
}

.item-status {
  flex-shrink: 0;
  margin-left: 8px;
}

.status-tag {
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 20px;
  font-weight: 500;
}

.status-tag.success {
  background: #f6ffed;
  color: var(--success);
}

.status-tag.pending {
  background: #fff7e6;
  color: var(--warning);
}

/* ========== 打卡按钮 ========== */
.btn {
  display: inline-block;
  padding: 12px 24px;
  border-radius: 24px;
  border: none;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s;
  width: 100%;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:active {
  background: var(--primary-dark);
}

.btn-primary:disabled {
  background: #bfbfbf;
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
}

/* ========== 底部导航 ========== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #fff;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  padding: 6px 0 10px;
  z-index: 100;
  max-width: 480px;
  margin: 0 auto;
  left: 50%;
  transform: translateX(-50%);
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-decoration: none;
  color: var(--text-light);
  font-size: 11px;
  padding: 4px 16px;
}

.nav-item.active {
  color: var(--primary);
}

.nav-icon {
  font-size: 22px;
  line-height: 1;
  margin-bottom: 2px;
}

/* ========== 空状态 ========== */
.empty-state {
  text-align: center;
  padding: 40px 20px;
}

.empty-icon {
  font-size: 56px;
  margin-bottom: 12px;
}

.empty-text {
  font-size: 15px;
  color: var(--text-secondary);
}

/* ========== Toast & Loading ========== */
.app-toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0,0,0,0.75);
  color: #fff;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 1000;
  display: none;
  transition: opacity 0.3s;
  white-space: nowrap;
}

.app-loading {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255,255,255,0.8);
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  z-index: 999;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.loading-text {
  margin-top: 12px;
  font-size: 14px;
  color: var(--text-secondary);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ========== 登录提示 ========== */
.login-hint {
  text-align: center;
  padding: 60px 20px;
  background: var(--card-bg);
  margin: 16px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.hint-icon {
  font-size: 64px;
  margin-bottom: 16px;
}

.hint-text {
  font-size: 16px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 8px;
}

.hint-sub {
  font-size: 13px;
  color: var(--text-light);
}

/* ========== 表单项 ========== */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 6px;
  display: block;
}

.form-input, .form-textarea {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  background: #fff;
  outline: none;
}

.form-input:focus, .form-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-light);
}

.form-textarea {
  min-height: 100px;
  resize: vertical;
}

/* ========== 文件上传 ========== */
.upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--bg);
}

.upload-area:active {
  border-color: var(--primary);
  background: var(--primary-light);
}

.upload-icon {
  font-size: 36px;
  margin-bottom: 8px;
}

.upload-text {
  font-size: 14px;
  color: var(--text-secondary);
}

.upload-hint {
  font-size: 12px;
  color: var(--text-light);
  margin-top: 4px;
}

.upload-preview {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.preview-item {
  width: 80px;
  height: 80px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  border: 1px solid var(--border);
}

/* ========== 选中态（报名页） ========== */
.selectable-item {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  background: #fff;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.selectable-item.selected {
  border-color: var(--primary);
  background: var(--primary-light);
  border-width: 2px;
}

.selectable-item .checkbox {
  width: 24px;
  height: 24px;
  border: 2px solid var(--border);
  border-radius: 50%;
  margin-right: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s;
}

.selectable-item.selected .checkbox {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.selectable-item .checkbox::after {
  content: '';
}

.selectable-item.selected .checkbox::after {
  content: '✓';
  font-size: 14px;
}

/* ========== 排行榜 ========== */
.rank-item {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.rank-item:last-child {
  border-bottom: none;
}

.rank-num {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 14px;
  flex-shrink: 0;
  margin-right: 12px;
}

.rank-num.top {
  background: var(--primary);
  color: #fff;
}

.rank-num.normal {
  background: var(--bg);
  color: var(--text-secondary);
}

/* ========== 勋章 ========== */
.medal-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.medal-item {
  text-align: center;
  padding: 12px 8px;
  background: var(--bg);
  border-radius: var(--radius-sm);
}

.medal-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 8px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
}

.medal-icon.level-1 { background: linear-gradient(135deg, #e6f7ff, #b3e0ff); }
.medal-icon.level-2 { background: linear-gradient(135deg, #fff7e6, #ffd8a6); }
.medal-icon.level-3 { background: linear-gradient(135deg, #fff0f6, #ffc9de); }

.medal-name {
  font-size: 13px;
  font-weight: 500;
}

.medal-date {
  font-size: 11px;
  color: var(--text-light);
  margin-top: 2px;
}

/* ========== 响应式 ========== */
@media (max-width: 480px) {
  .page {
    max-width: 100%;
  }
}

/* ========== 菜单列表 ========== */
.menu-list {
  display: flex;
  flex-direction: column;
}

.menu-item {
  display: flex;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

.menu-item:last-child {
  border-bottom: none;
}

.menu-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  margin-right: 12px;
  flex-shrink: 0;
}

.menu-text {
  flex: 1;
  font-size: 15px;
}

.menu-arrow {
  color: var(--text-light);
  font-size: 14px;
}

/* ========== 头像 ========== */
.avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #00BFFF);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: bold;
  color: #fff;
  margin: 0 auto;
}

/* ========== 图标按钮 ========== */
.btn-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--bg);
  font-size: 20px;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-icon:active {
  background: var(--primary-light);
  color: var(--primary);
}

/* ========== Tab切换 ========== */
.tab-bar {
  display: flex;
  margin: 12px 16px;
  background: #fff;
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.tab {
  flex: 1;
  text-align: center;
  padding: 12px;
  font-size: 14px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
  border-bottom: 2px solid transparent;
}

.tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

/* ========== 打卡记录项 ========== */
.record-item {
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.record-item:last-child {
  border-bottom: none;
}

.record-header {
  display: flex;
  align-items: center;
  margin-bottom: 8px;
}

.record-icon {
  font-size: 20px;
  margin-right: 8px;
}

.record-name {
  flex: 1;
  font-size: 15px;
  font-weight: 500;
}

.record-time {
  font-size: 12px;
  color: var(--text-light);
}

.record-content {
  font-size: 14px;
  color: var(--text-secondary);
  background: var(--bg);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
}

.record-photo {
  width: 100%;
  max-height: 240px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  margin-top: 4px;
}

/* ========== 排行榜扩展 ========== */
.rank-info {
  flex: 1;
  min-width: 0;
}

.rank-name {
  font-size: 15px;
  font-weight: 500;
}

.rank-dept {
  font-size: 12px;
  color: var(--text-light);
  margin-top: 2px;
}

.rank-score {
  text-align: right;
  flex-shrink: 0;
  margin-left: 8px;
}

.score-num {
  font-size: 18px;
  font-weight: bold;
  color: var(--primary);
}

.score-label {
  font-size: 11px;
  color: var(--text-light);
}

.rank-item.top {
  background: linear-gradient(90deg, #fffbf0, transparent);
}

/* ========== 统计网格 ========== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.stats-cell {
  text-align: center;
  padding: 12px;
  background: var(--bg);
  border-radius: var(--radius-sm);
}

/* ========== 轮廓按钮 ========== */
.btn-outline {
  background: #fff;
  color: var(--primary);
  border: 1px solid var(--primary);
}

.btn-outline:active {
  background: var(--primary-light);
}

/* ========== 弹窗 ========== */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 999;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background: #fff;
  border-radius: var(--radius);
  padding: 24px;
  max-width: 320px;
  width: 90%;
  text-align: center;
}

.modal-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 16px;
}

.modal-body {
  font-size: 14px;
  color: var(--text-secondary);
  text-align: left;
  margin-bottom: 20px;
  line-height: 1.8;
}

/* ========== 勋章锁定态 ========== */
.medal-item.locked {
  opacity: 0.5;
}

.locked-icon {
  background: var(--bg) !important;
  filter: grayscale(1);
}

/* ========== 上传占位 ========== */
.upload-placeholder {
  padding: 20px 0;
}

/* ========== 通用 ========== */
.rank-list {
  display: flex;
  flex-direction: column;
}
