/* ===== H5 移动端自适应修复 ===== */

/* 基础：禁止水平滚动 */
@media screen and (max-width: 767px) {
  html, body {
    overflow-x: hidden !important;
    max-width: 100vw !important;
    box-sizing: border-box !important;
  }
  * {
    box-sizing: border-box !important;
  }
  body > * {
    max-width: 100% !important;
  }
}

/* 移动端全局响应式修复 */
@media screen and (max-width: 767px) {
  .container, .page, .main-container {
    max-width: 100% !important;
    padding: 10px !important;
    margin: 0 !important;
  }
  .flex, .flex-row, .product-list, .cards-grid {
    flex-wrap: wrap !important;
    max-width: 100% !important;
  }
  .card, .product-card, .order-item, .address-card {
    width: 100% !important;
    min-width: 0 !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
  }
  .el-button, button, .btn {
    max-width: 100% !important;
    white-space: normal !important;
    word-break: break-word !important;
    overflow: visible !important;
    padding: 8px 12px !important;
    font-size: 14px !important;
  }
  .el-input, .el-input__inner, input, textarea {
    max-width: 100% !important;
    font-size: 14px !important;
  }
  img {
    max-width: 100% !important;
    height: auto !important;
    object-fit: contain !important;
  }
  .text, p, span, div {
    word-break: break-word !important;
    overflow-wrap: break-word !important;
  }
  .banner, .large-image {
    display: none !important;
  }
  .el-tabs__nav, .tab-nav {
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
  }
  .form-item, .el-form-item {
    flex-direction: column !important;
    width: 100% !important;
  }
  .el-form-item__label {
    width: 100% !important;
    text-align: left !important;
  }
  .el-form-item__content {
    width: 100% !important;
    margin-left: 0 !important;
  }
  .cart-page, .cart-item {
    padding: 10px !important;
  }
  .cart-item .product-info {
    width: calc(100% - 90px) !important;
  }
  .member-page, .profile-page {
    padding: 10px !important;
  }
  .member-page .pricing-cards {
    grid-template-columns: 1fr !important;
  }
  .product-detail .product-gallery,
  .product-detail .product-info {
    width: 100% !important;
  }
  .order-list, .order-item {
    width: 100% !important;
  }
  .tabbar, .tab-bar {
    width: 100% !important;
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
  }
  .el-empty, .el-loading {
    padding: 20px !important;
  }
  .el-dialog, .el-drawer, .popup {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
  }
}

/* 超小屏额外修复 */
@media screen and (max-width: 480px) {
  body {
    font-size: 12px !important;
  }
  .el-button {
    padding: 6px 10px !important;
    font-size: 12px !important;
  }
  .page {
    padding: 8px !important;
  }
  h1, h2, h3 {
    font-size: 16px !important;
  }
}

/* 按钮文字不超出 */
@media screen and (max-width: 767px) {
  .el-button {
    white-space: normal !important;
    overflow: visible !important;
    line-height: 1.4 !important;
    height: auto !important;
    min-height: 32px !important;
  }
  .el-button--medium {
    padding: 8px 15px !important;
  }
  .el-button--small {
    padding: 6px 12px !important;
  }
  .el-button--mini {
    padding: 4px 8px !important;
  }
}

/* 键盘弹起时页面不乱 */
@media screen and (max-width: 767px) {
  input:focus, textarea:focus {
    max-height: 50vh !important;
    overflow-y: auto !important;
  }
}

