/* ============================================
   瓶盖集市 H5 - 公共样式
   主题色：#FF6B35（橙色）
   版本：v2.0.0
   ============================================ */

/* CSS 变量 */
:root {
  --primary: #FF6B35;
  --primary-dark: #E55A2B;
  --primary-light: #FF8C5A;
  --primary-bg: #FFF5F0;
  --white: #FFFFFF;
  --black: #333333;
  --gray-1: #666666;
  --gray-2: #999999;
  --gray-3: #CCCCCC;
  --gray-4: #EEEEEE;
  --gray-5: #F5F5F5;
  --red: #E74C3C;
  --green: #27AE60;
  --gold: #F0AD4E;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 4px 20px rgba(0, 0, 0, 0.12);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --tabbar-height: 56px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* 全局重置 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100%;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  font-size: 14px;
  color: var(--black);
  background: var(--gray-5);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

/* 页面容器 */
.page-container {
  min-height: 100vh;
  padding-bottom: calc(var(--tabbar-height) + var(--safe-bottom) + 20px);
  background: var(--gray-5);
}

/* 页面头部 */
.page-header {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  padding: 20px 16px;
  color: var(--white);
  position: sticky;
  top: 0;
  z-index: 100;
}

.page-header__title {
  font-size: 20px;
  font-weight: 600;
  text-align: center;
}

.page-header__subtitle {
  font-size: 12px;
  opacity: 0.8;
  text-align: center;
  margin-top: 4px;
}

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

.card--no-margin {
  margin: 0;
  border-radius: 0;
}

/* 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 24px;
  border: none;
  border-radius: 24px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

.btn:active {
  transform: scale(0.96);
  opacity: 0.9;
}

.btn--primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: var(--white);
  box-shadow: 0 4px 12px rgba(255, 107, 53, 0.3);
}

.btn--primary:active {
  box-shadow: 0 2px 6px rgba(255, 107, 53, 0.2);
}

.btn--outline {
  background: var(--white);
  color: var(--primary);
  border: 1.5px solid var(--primary);
}

.btn--block {
  display: flex;
  width: 100%;
}

.btn--lg {
  padding: 14px 32px;
  font-size: 16px;
  border-radius: 28px;
}

.btn--sm {
  padding: 6px 16px;
  font-size: 13px;
  border-radius: 16px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* 底部导航栏 (TabBar) */
.tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--tabbar-height);
  padding-bottom: var(--safe-bottom);
  background: var(--white);
  display: flex;
  align-items: center;
  justify-content: space-around;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.06);
  z-index: 999;
}

.tabbar__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  height: 100%;
  color: var(--gray-2);
  text-decoration: none;
  font-size: 11px;
  transition: color 0.2s ease;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

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

.tabbar__icon {
  width: 24px;
  height: 24px;
  margin-bottom: 2px;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  opacity: 0.5;
  transition: opacity 0.2s ease;
}

.tabbar__item--active .tabbar__icon {
  opacity: 1;
}

.tabbar__label {
  font-size: 11px;
  line-height: 1;
}

/* 加载状态 */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 0;
  color: var(--gray-2);
  font-size: 14px;
}

.loading::before {
  content: '';
  width: 20px;
  height: 20px;
  border: 2px solid var(--gray-4);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-right: 8px;
}

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

/* 空状态 */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--gray-2);
}

.empty-state__icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.4;
}

.empty-state__text {
  font-size: 14px;
}

/* Toast 提示 */
.toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.75);
  color: var(--white);
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 9999;
  pointer-events: none;
  animation: toastIn 0.3s ease;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.8);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

/* 弹窗遮罩 */
.modal-mask {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-content {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 85%;
  max-width: 360px;
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 标签 */
.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
}

.tag--primary {
  background: var(--primary-bg);
  color: var(--primary);
}

.tag--gold {
  background: #FFF8E1;
  color: #F57F17;
}

.tag--green {
  background: #E8F5E9;
  color: #2E7D32;
}

.tag--red {
  background: #FFEBEE;
  color: #C62828;
}

/* 分割线 */
.divider {
  height: 1px;
  background: var(--gray-4);
  margin: 12px 0;
}

/* 文本省略 */
.text-ellipsis {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Flex 工具 */
.flex {
  display: flex;
}

.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.flex-col {
  display: flex;
  flex-direction: column;
}

/* 间距工具 */
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.p-16 { padding: 16px; }

/* 响应式 - 大屏居中 */
@media (min-width: 768px) {
  .page-container {
    max-width: 480px;
    margin: 0 auto;
    box-shadow: var(--shadow-lg);
  }
  
  .tabbar {
    max-width: 480px;
    left: 50%;
    transform: translateX(-50%);
  }
}
