/* 移动端适配方案 - 东方香疗美学项目 */

/* 
  设备断点设置
  - 小型手机: < 576px
  - 手机: 576px - 768px
  - 平板: 768px - 1024px
  - 小型桌面: 1024px - 1200px
  - 大型桌面: > 1200px
*/

/* ===== 基础适配 ===== */

/* 确保盒模型一致性 */
* {
  box-sizing: border-box;
}

/* HTML和Body基础设置 */
html {
  font-size: 16px; /* 基础字体大小，用于rem计算 */
  scroll-behavior: smooth;
}

body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  line-height: 1.6;
  color: #2D2D2D;
  background-color: #F8F6F3;
  overflow-x: hidden; /* 防止横向滚动 */
}

/* ===== 字体大小自适应方案 ===== */

/* 根据屏幕宽度动态调整基础字体大小 */
/* 使用媒体查询逐步调整字体大小 */
@media screen and (max-width: 320px) {
  html {
    font-size: 14px; /* 小屏幕手机 */
  }
}

@media screen and (min-width: 321px) and (max-width: 375px) {
  html {
    font-size: 15px; /* 一般手机 */
  }
}

@media screen and (min-width: 376px) and (max-width: 414px) {
  html {
    font-size: 16px; /* 大屏手机 */
  }
}

@media screen and (min-width: 415px) and (max-width: 768px) {
  html {
    font-size: 17px; /* 平板竖屏 */
  }
}

@media screen and (min-width: 769px) {
  html {
    font-size: 18px; /* 平板横屏及桌面 */
  }
}

/* 文本大小调整类 */
.text-responsive-xs {
  font-size: 0.75rem; /* 12px */
}

.text-responsive-sm {
  font-size: 0.875rem; /* 14px */
}

.text-responsive-base {
  font-size: 1rem; /* 16px */
}

.text-responsive-lg {
  font-size: 1.125rem; /* 18px */
}

.text-responsive-xl {
  font-size: 1.25rem; /* 20px */
}

.text-responsive-2xl {
  font-size: 1.5rem; /* 24px */
}

.text-responsive-3xl {
  font-size: 1.875rem; /* 30px */
}

.text-responsive-4xl {
  font-size: 2.25rem; /* 36px */
}

/* ===== 响应式布局 ===== */

/* 容器布局 */
.container-responsive {
  width: 100%;
  padding: 0 1rem;
  margin: 0 auto;
}

@media screen and (min-width: 576px) {
  .container-responsive {
    max-width: 540px;
  }
}

@media screen and (min-width: 768px) {
  .container-responsive {
    max-width: 720px;
    padding: 0 2rem;
  }
}

@media screen and (min-width: 1024px) {
  .container-responsive {
    max-width: 960px;
  }
}

@media screen and (min-width: 1200px) {
  .container-responsive {
    max-width: 1140px;
  }
}

/* 网格系统 */
.grid-responsive {
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr;
}

@media screen and (min-width: 768px) {
  .grid-responsive {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media screen and (min-width: 1024px) {
  .grid-responsive {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* 灵活布局 */
.flex-responsive {
  display: flex;
  flex-wrap: wrap;
}

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

@media screen and (min-width: 768px) {
  .flex-col-mobile {
    flex-direction: row;
  }
}

/* ===== 图片适配 ===== */

/* 图片响应式基础 */
.img-responsive {
  max-width: 100%;
  height: auto;
  object-fit: cover;
  border-radius: 0.5rem;
}

/* 特定比例的图片容器 */
.img-container-16-9 {
  position: relative;
  width: 100%;
  padding-top: 56.25%; /* 16:9 比例 */
}

.img-container-4-3 {
  position: relative;
  width: 100%;
  padding-top: 75%; /* 4:3 比例 */
}

.img-container-1-1 {
  position: relative;
  width: 100%;
  padding-top: 100%; /* 1:1 比例 */
}

.img-container-inner {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.img-container-inner img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* 针对不同设备像素密度的图片 */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .img-hd {
    /* 高分辨率设备使用的样式 */
    image-rendering: -webkit-optimize-contrast;
  }
}

/* ===== 触摸交互优化 ===== */

/* 触摸目标最小尺寸(44px×44px苹果推荐) */
.touch-target {
  min-height: 44px;
  min-width: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* 按钮触摸优化 */
.btn-touch {
  padding: 0.75rem 1.5rem;
  border-radius: 0.5rem;
  font-size: 1rem;
  min-height: 44px;
  touch-action: manipulation; /* 优化触摸响应 */
  transition: transform 0.2s, box-shadow 0.2s;
}

.btn-touch:active {
  transform: scale(0.98);
}

/* 导航栏触摸优化 */
.nav-touch li {
  margin: 0.5rem 0;
}

.nav-touch a {
  padding: 0.75rem 1rem;
  display: block;
  border-radius: 0.5rem;
}

/* 表单元素触摸优化 */
.form-input {
  font-size: 16px; /* 防止iOS缩放 */
  padding: 0.75rem;
  border: 1px solid #EAD2BE;
  border-radius: 0.5rem;
  width: 100%;
  margin: 0.5rem 0;
}

/* ===== 导航与布局 ===== */

/* 移动端导航菜单 */
.mobile-menu {
  display: block;
  position: fixed;
  top: 0;
  left: -100%;
  width: 80%;
  max-width: 300px;
  height: 100vh;
  background-color: #F4EFEB;
  box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
  transition: left 0.3s ease;
  z-index: 1000;
  overflow-y: auto;
}

.mobile-menu.active {
  left: 0;
}

.mobile-menu-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 999;
  display: none;
}

.mobile-menu-overlay.active {
  display: block;
}

/* 移动端头部 */
.header-mobile {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  background-color: #F4EFEB;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  z-index: 998;
  padding: 0.75rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* 确保内容不会被固定头部遮挡 */
.main-content {
  padding-top: 60px;
}

/* ===== 特定组件适配 ===== */

/* 卡片响应式 */
.card-responsive {
  background: white;
  border-radius: 0.75rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  padding: 1.5rem;
  margin: 1rem 0;
}

@media screen and (min-width: 768px) {
  .card-responsive {
    padding: 2rem;
    margin: 1.5rem 0;
  }
}

/* 表格响应式 */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table-responsive table {
  width: 100%;
  min-width: 500px; /* 确保表格有最小宽度 */
}

/* ===== 辅助工具类 ===== */

/* 隐藏/显示元素 */
.hide-mobile {
  display: none;
}

.show-mobile {
  display: block;
}

@media screen and (min-width: 768px) {
  .hide-mobile {
    display: block;
  }
  
  .show-mobile {
    display: none;
  }
  
  .hide-tablet {
    display: none;
  }
}

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

.text-ellipsis-2 {
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.text-ellipsis-3 {
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

/* ===== 安全区域适配 ===== */

/* 适配iPhone X系列的底部安全区域 */
.safe-bottom {
  padding-bottom: env(safe-area-inset-bottom);
}

/* 适配顶部刘海 */
.safe-top {
  padding-top: env(safe-area-inset-top);
}

/* ===== 性能优化 ===== */

/* 硬件加速 */
.gpu-accelerated {
  transform: translateZ(0);
  backface-visibility: hidden;
  perspective: 1000px;
}

/* 减少重绘 */
.will-change-transform {
  will-change: transform;
}

/* ===== 打印适配 ===== */
@media print {
  .no-print {
    display: none !important;
  }
  
  body {
    font-size: 12pt;
    line-height: 1.4;
  }
  
  .print-break-before {
    page-break-before: always;
  }
  
  .print-break-after {
    page-break-after: always;
  }
  
  .print-break-inside-avoid {
    page-break-inside: avoid;
  }
}