/* ============================================================
   Layik 交友 - H5移动端样式
   底部TabBar 56px | 触控按钮 | 卡片堆叠 | 移动表单
   ============================================================ */

:root {
  --tabbar-height: 56px;
  --h5-header-height: 48px;
  --h5-safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ========== H5基础布局 ========== */
.h5-layout {
  min-height: 100vh;
  background: var(--bg-secondary);
  padding-bottom: calc(var(--tabbar-height) + var(--h5-safe-bottom));
}

.h5-page {
  min-height: 100vh;
  background: var(--bg-secondary);
  display: flex;
  flex-direction: column;
}

/* ========== H5顶栏 ========== */
.h5-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--h5-header-height);
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  padding: 0 var(--spacing-md);
}

.h5-header-title {
  flex: 1;
  text-align: center;
  font-size: var(--font-md);
  font-weight: 600;
  color: var(--text-primary);
}

.h5-header-back {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: var(--transition);
}

.h5-header-back:active {
  background: var(--bg-secondary);
  transform: scale(0.95);
}

.h5-header-action {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  cursor: pointer;
  font-size: var(--font-sm);
}

.h5-header-right {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

/* ========== 底部TabBar ========== */
.h5-tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--tabbar-height) + var(--h5-safe-bottom));
  padding-bottom: var(--h5-safe-bottom);
  background: var(--bg-primary);
  border-top: 1px solid var(--border-light);
  display: flex;
  z-index: 100;
  box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.06);
}

.h5-tabbar-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--text-tertiary);
  font-size: 10px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.2s ease;
  position: relative;
  text-decoration: none;
  user-select: none;
}

.h5-tabbar-item:active {
  transform: scale(0.95);
}

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

.h5-tabbar-icon {
  font-size: 22px;
  line-height: 1;
}

.h5-tabbar-label {
  font-size: 10px;
  font-weight: 500;
}

.h5-tabbar-badge {
  position: absolute;
  top: 4px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  background: var(--danger);
  color: var(--text-white);
  font-size: 10px;
  border-radius: var(--radius-round);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
}

.h5-tabbar-center {
  position: relative;
}

.h5-tabbar-center-btn {
  position: absolute;
  top: -20px;
  left: 50%;
  transform: translateX(-50%);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-white);
  font-size: 24px;
  box-shadow: 0 4px 12px rgba(255, 107, 107, 0.4);
  cursor: pointer;
  transition: var(--transition);
}

.h5-tabbar-center-btn:active {
  transform: translateX(-50%) scale(0.9);
}

.h5-tabbar-center-label {
  margin-top: 28px;
}

/* ========== 页面容器 ========== */
.h5-container {
  flex: 1;
  padding: var(--spacing-md);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.h5-scroll-view {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* ========== 卡片堆叠 ========== */
.h5-card {
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: var(--spacing-md);
  overflow: hidden;
}

.h5-card-header {
  padding: var(--spacing-md);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.h5-card-title {
  font-size: var(--font-md);
  font-weight: 600;
  color: var(--text-primary);
}

.h5-card-body {
  padding: var(--spacing-md);
}

.h5-card-footer {
  padding: var(--spacing-md);
  border-top: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ========== 触控按钮 ========== */
.h5-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-xs);
  padding: 12px 20px;
  font-size: var(--font-sm);
  font-weight: 500;
  border-radius: var(--radius-md);
  transition: var(--transition);
  cursor: pointer;
  border: none;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  min-height: 44px;
}

.h5-btn:active {
  transform: scale(0.97);
  opacity: 0.9;
}

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

.h5-btn-primary {
  background: var(--primary);
  color: var(--text-white);
}

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

.h5-btn-danger {
  background: var(--danger);
  color: var(--text-white);
}

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

.h5-btn-large {
  padding: 16px 28px;
  font-size: var(--font-md);
  min-height: 50px;
  border-radius: var(--radius-lg);
}

.h5-btn-small {
  padding: 8px 14px;
  font-size: var(--font-xs);
  min-height: 36px;
}

.h5-btn-icon {
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 20px;
}

.h5-btn-icon-primary {
  background: rgba(255, 107, 107, 0.1);
  color: var(--primary);
}

/* ========== 移动表单 ========== */
.h5-form {
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  padding: var(--spacing-md);
  margin-bottom: var(--spacing-md);
}

.h5-form-group {
  margin-bottom: var(--spacing-md);
}

.h5-form-label {
  display: block;
  font-size: var(--font-sm);
  color: var(--text-secondary);
  margin-bottom: var(--spacing-xs);
  font-weight: 500;
}

.h5-form-input {
  width: 100%;
  padding: 14px 16px;
  font-size: var(--font-md);
  color: var(--text-primary);
  background: var(--bg-tertiary);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  transition: var(--transition);
  min-height: 48px;
}

.h5-form-input:focus {
  background: var(--bg-primary);
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(255, 107, 107, 0.1);
}

.h5-form-input::placeholder {
  color: var(--text-tertiary);
  font-size: var(--font-sm);
}

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

.h5-form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M6 8L1 3h10z' fill='%23999'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  padding-right: 40px;
}

.h5-form-error {
  font-size: var(--font-xs);
  color: var(--danger);
  margin-top: var(--spacing-xs);
  display: block;
}

/* ========== 列表项(带缩略图) ========== */
.h5-list {
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: var(--spacing-md);
}

.h5-list-item {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  padding: var(--spacing-md);
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  transition: var(--transition);
  -webkit-tap-highlight-color: transparent;
}

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

.h5-list-item:active {
  background: var(--bg-tertiary);
}

.h5-list-thumb {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-md);
  overflow: hidden;
  flex-shrink: 0;
  background: var(--border-light);
}

.h5-list-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.h5-list-thumb-sm {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
}

.h5-list-thumb-lg {
  width: 72px;
  height: 72px;
  border-radius: var(--radius-lg);
}

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

.h5-list-title {
  font-size: var(--font-md);
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.h5-list-desc {
  font-size: var(--font-sm);
  color: var(--text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.h5-list-meta {
  font-size: var(--font-xs);
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
}

.h5-list-action {
  flex-shrink: 0;
  color: var(--text-tertiary);
  font-size: 18px;
}

.h5-list-badge {
  background: var(--danger);
  color: var(--text-white);
  font-size: 10px;
  padding: 2px 6px;
  border-radius: var(--radius-round);
  min-width: 18px;
  text-align: center;
}

/* ========== 用户卡片(H5) ========== */
.h5-user-card {
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  margin-bottom: var(--spacing-md);
}

.h5-user-cover {
  width: 100%;
  height: 200px;
  background: linear-gradient(135deg, var(--primary-light), var(--secondary));
  position: relative;
}

.h5-user-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.h5-user-avatar {
  position: absolute;
  bottom: -32px;
  left: var(--spacing-md);
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 4px solid var(--bg-primary);
  overflow: hidden;
  background: var(--border-light);
}

.h5-user-info {
  padding: 40px var(--spacing-md) var(--spacing-md);
}

.h5-user-name-row {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-xs);
}

.h5-user-name {
  font-size: var(--font-lg);
  font-weight: 600;
  color: var(--text-primary);
}

.h5-user-gender {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: 12px;
  color: var(--text-white);
}

.h5-user-gender.male { background: var(--info); }
.h5-user-gender.female { background: var(--primary); }

.h5-user-meta {
  font-size: var(--font-sm);
  color: var(--text-tertiary);
  margin-bottom: var(--spacing-sm);
}

.h5-user-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.h5-user-actions {
  display: flex;
  gap: var(--spacing-sm);
  padding: 0 var(--spacing-md) var(--spacing-md);
}

.h5-user-actions .btn {
  flex: 1;
}

/* ========== 轮播图/图片 ========== */
.h5-swiper {
  width: 100%;
  height: 280px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  position: relative;
  margin-bottom: var(--spacing-md);
}

.h5-swiper-track {
  display: flex;
  height: 100%;
  transition: transform 0.4s ease;
}

.h5-swiper-slide {
  min-width: 100%;
  height: 100%;
  flex-shrink: 0;
}

.h5-swiper-slide img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.h5-swiper-dots {
  position: absolute;
  bottom: var(--spacing-sm);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
}

.h5-swiper-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
  transition: var(--transition);
}

.h5-swiper-dot.active {
  background: var(--text-white);
  width: 18px;
  border-radius: 3px;
}

/* ========== 标签页 ========== */
.h5-tabs {
  display: flex;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-light);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.h5-tab {
  flex-shrink: 0;
  padding: 14px var(--spacing-md);
  font-size: var(--font-sm);
  color: var(--text-tertiary);
  cursor: pointer;
  position: relative;
  white-space: nowrap;
  transition: var(--transition);
}

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

.h5-tab.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 24px;
  height: 3px;
  background: var(--primary);
  border-radius: 2px;
}

/* ========== 下拉刷新 ========== */
.h5-refresh-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-md);
  color: var(--text-tertiary);
  font-size: var(--font-sm);
}

/* ========== 安全区域 ========== */
.h5-safe-bottom {
  padding-bottom: var(--h5-safe-bottom);
}

.h5-safe-top {
  padding-top: env(safe-area-inset-top, 0px);
}

/* ========== 工具类 ========== */
.h5-hidden {
  display: none !important;
}

.h5-section-title {
  font-size: var(--font-md);
  font-weight: 600;
  color: var(--text-primary);
  margin: var(--spacing-md) 0 var(--spacing-sm);
  padding: 0 var(--spacing-xs);
}

.h5-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--spacing-md);
}

.h5-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--spacing-sm);
}

/* ========== 响应式 ========== */
@media (min-width: 769px) {
  .h5-layout {
    max-width: 480px;
    margin: 0 auto;
    background: var(--bg-primary);
    box-shadow: var(--shadow-lg);
    min-height: 100vh;
  }
}

@media (max-width: 360px) {
  .h5-user-actions {
    flex-direction: column;
  }
}