/* 统一由 JS 同步视口变量，规避微信/安卓软键盘对 100vh 的不稳定影响 */
:root {
  --app-height: 100vh;
  --app-visible-height: 100vh;
  --keyboard-offset: 0px;
}

@supports (height: 100dvh) {
  :root {
    --app-height: 100dvh;
    --app-visible-height: 100dvh;
  }
}

/* Index Page Styles - Converted from miniprogram WXSS */

/* ========================================
   Content Section
   ======================================== */

/* Page container - ensures proper responsive behavior (Requirements 5.5, 6.4) */
.page-container {
  width: 100%;
  min-height: var(--app-height);
  overflow-x: hidden; /* Prevent horizontal scrolling */
  position: relative;
}

.content {
  /* 为顶部固定 Tab 预留空间，具体高度由 JS 按真实渲染结果同步 */
  padding-top: var(--course-tabs-offset, 64px);
  padding-bottom: 100px; /* Space for bottom bar (78px + margin) */
  font-size: 0;
  width: 100%;
}

.detailimg {
  width: 100%;
  display: block;
}


/* ========================================
   Footer Section
   ======================================== */

.footerbox {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  background-color: white;
  box-sizing: border-box;
  z-index: 997;
}

.kefubox {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.kefu_base {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 0 0 42px;
  min-width: 42px;
}

.kefu {
  width: 24px;
  height: 24px;
}

.kefutext {
  display: block;
  color: rgba(0, 0, 0, 0.6);
  font-size: 12px;
  margin-top: 2px;
  white-space: nowrap;
  writing-mode: horizontal-tb;
}

.kefubtn {
  border: none;
  outline: none;
  width: 0;
  height: 0;
  opacity: 0;
  margin: 0 !important;
  padding: 0 !important;
}

.right_box {
  display: flex;
  align-items: center;
}

.footerbox .right_box {
  flex: 1;
  min-width: 0;
  justify-content: flex-end;
}

.tips {
  position: relative;
  width: 132px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 8px;
  flex: 0 1 132px;
}

.tipsicon {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
}

.tips span {
  position: relative;
  z-index: 1;
  font-size: 12px;
  color: white;
  white-space: nowrap;
}

.btn1 {
  min-width: 116px;
  max-width: 44vw;
  height: 44px;
  line-height: 44px;
  background: linear-gradient(to bottom, #FED331, #FBAE25);
  border-radius: 22px;
  font-size: 13px;
  text-align: center;
  color: white;
  font-weight: bold;
  padding: 0 14px;
  cursor: pointer;
  white-space: nowrap;
  flex: 0 1 auto;
}

.btn1 span:first-child {
  font-size: 18px;
  margin-right: 2px;
}


/* ========================================
   Popup Section - Rewritten for H5
   ======================================== */

/* 遮罩层 */
.popup-mask {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 998;
  display: none;
}

.popup-mask.show {
  display: block;
}

/* 弹窗容器 */
.popupbox {
  position: fixed;
  left: 0;
  bottom: var(--keyboard-offset);
  width: 100%;
  max-height: calc(var(--app-visible-height) - 16px);
  background-color: white;
  border-radius: 16px 16px 0 0;
  padding: 32px 16px;
  padding-bottom: calc(32px + env(safe-area-inset-bottom, 0px));
  box-sizing: border-box;
  z-index: 999;
  transform: translateY(100%);
  visibility: hidden; /* 初始隐藏，避免闪烁 */
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.popupbox.show {
  transform: translateY(0);
  visibility: visible;
  transition: transform 0.3s ease;
}

/* 弹窗标题 */
.title {
  font-size: 16px;
  font-weight: bold;
  color: #333;
  margin-bottom: 8px;
}

/* 手机号输入 */
.phone {
  display: flex;
  align-items: center;
  margin-bottom: 12px;
  border: 1px solid #e5e5e5;
  border-radius: 8px;
  padding: 0 12px;
  box-sizing: border-box;
  width: 100%;
}

#phoneNumber {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 16px;
  color: #333;
  padding: 10px 0;
  min-width: 0;
}

#phoneNumber::placeholder {
  color: #999;
}

/* 购课类型标题 */
.typetext {
  font-size: 16px;
  font-weight: bold;
  color: #333;
  margin-bottom: 12px;
}

/* 商品选择容器 */
.twotype {
  display: flex;
  flex-direction: row;
  gap: 8px;
  margin-bottom: 20px;
}

/* 商品卡片 */
.typeitem {
  flex: 1;
  position: relative;
  border: 2px solid #DADADA;
  border-radius: 8px;
  padding: 12px 8px;
  text-align: center;
  cursor: pointer;
  box-sizing: border-box;
  background: white;
}

.typeitem.active {
  border-color: #FED231;
  background-color: #FFF5E5;
}

/* 推荐标签 */
.openicon {
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
}

.openimg {
  width: 50px;
  height: 22px;
}

/* 商品名称 */
.textbox {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
}

.item_title {
  font-size: 12px;
  font-weight: bold;
  color: #333;
  line-height: 1.3;
  word-break: break-word;
}

/* 原价 */
.oldp {
  font-size: 11px;
  color: rgba(141, 66, 43, 0.63);
  text-decoration: line-through;
  margin-bottom: 4px;
}

/* 折扣价 */
.newp {
  font-size: 12px;
  color: #EC5E74;
  font-weight: bold;
}

.newp span:first-child {
  font-size: 20px;
}

/* 支付按钮 */
.btn2 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  height: 57px; /* 44px * 1.3 ≈ 57px */
  background: linear-gradient(to bottom, #FED331, #FBAE25);
  border-radius: 29px;
  padding: 0 16px;
  box-sizing: border-box;
  color: white;
  font-weight: bold;
  cursor: pointer;
}

.oldprice {
  font-size: 11px;
  color: rgba(141, 66, 43, 0.63);
  text-decoration: line-through;
}

.btn2 .right_box {
  display: flex;
  align-items: center;
}

.tips2 {
  position: relative;
  width: 100px; /* 80px * 1.25 */
  height: 31px; /* 24px * 1.3 */
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 8px;
}

.tipsicon2 {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
}

.tips2 span {
  position: relative;
  z-index: 1;
  font-size: 11px;
  color: white;
}

.price {
  display: flex;
  align-items: baseline;
}

.price span:first-child {
  font-size: 20px;
  margin-right: 2px;
}

.price span:last-child {
  font-size: 12px;
}

/* 单个商品时的样式 */
.onetype-container {
  margin-bottom: 20px;
}

.onetype {
  font-size: 14px;
  color: #333;
}

.pay-channel-tip {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #666;
  margin-bottom: 12px;
}

.pay-channel-label {
  flex-shrink: 0;
}

.pay-channel-alipay-icon {
  display: block;
  height: 22px;
  width: auto;
}


/* ========================================
   Responsive Styles - Desktop
   ======================================== */

/* Tablet and Desktop: Center content with fixed width */
@media (min-width: 769px) {
  body {
    background-color: #f5f5f5;
  }
  
  .page-container {
    max-width: 720px;
    margin: 0 auto;
    background-color: white;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
    min-height: 100vh;
    position: relative;
  }
  
  /* Footer stays within centered container */
  .footerbox {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    width: 720px;
    max-width: 720px;
  }
  
  /* Popup stays within centered container */
  .popupbox {
    position: fixed;
    left: 50%;
    width: 720px;
    max-width: 720px;
    transform: translateX(-50%) translateY(100%);
  }
  
  .popupbox.show {
    transform: translateX(-50%) translateY(0);
  }
  
  /* Mask covers entire viewport */
  .popup-mask {
    left: 0;
    right: 0;
  }

  /* 顶部 Tab 与居中内容区同宽 */
  .course-tabs {
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    width: 720px;
    max-width: 100%;
  }
}

/* Mobile optimization: Ensure no horizontal scrolling */
@media (max-width: 768px) {
  body, html {
    overflow-x: hidden;
    width: 100%;
  }
  
  .page-container {
    width: 100%;
    overflow-x: hidden;
  }
}

/* ========================================
   消息弹窗（接口/校验提示，仅按钮关闭）
   ======================================== */

.msg-modal-mask {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  box-sizing: border-box;
  background-color: rgba(0, 0, 0, 0.5);
  -webkit-tap-highlight-color: transparent;
}

.msg-modal-mask[hidden] {
  display: none !important;
}

.msg-modal {
  width: 100%;
  max-width: 300px;
  background: linear-gradient(180deg, #fffdf8 0%, #fff5e6 100%);
  border-radius: 14px;
  border: 1px solid #f0d4a8;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
  padding: 22px 20px 18px;
  box-sizing: border-box;
}

.msg-modal-text {
  color: #5c3d1e;
  font-size: 15px;
  line-height: 1.55;
  text-align: center;
  margin-bottom: 20px;
  word-break: break-word;
}

.msg-modal-btn {
  display: block;
  width: 100%;
  margin: 0;
  padding: 12px 16px;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(180deg, #ff9f59 0%, #ff7d3f 100%);
  box-shadow: 0 4px 12px rgba(255, 125, 63, 0.35);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.msg-modal-btn:active {
  opacity: 0.92;
}

/* ========================================
   Toast（自动消失）
   ======================================== */

.toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background-color: rgba(0, 0, 0, 0.78);
  color: #fff;
  padding: 12px 22px;
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.45;
  text-align: center;
  max-width: 82%;
  z-index: 10050;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  box-sizing: border-box;
}

.toast.show {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.28s ease;
}

/* 内容区顶部 Tab（固定在视口顶部，不随页面滚动） */
.course-tabs {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 997;
  display: flex;
  width: 100%;
  margin: 0;
  padding: 10px 12px 8px;
  box-sizing: border-box;
  gap: 8px;
  background: linear-gradient(180deg, #fff8de 0%, #ffe7a3 100%);
  border-bottom: 1px solid #f4d06b;
  box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.45);
}

.course-tab {
  flex: 1;
  min-height: 40px;
  padding: 8px 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  line-height: 1.25;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid #efc863;
  border-radius: 12px;
  background: linear-gradient(180deg, #fffdf5 0%, #fff1c8 100%);
  color: #9b6521;
  box-shadow: 0 3px 8px rgba(228, 172, 44, 0.14);
  cursor: pointer;
  transition: all 0.2s ease;
}

.course-tab.active {
  background: linear-gradient(180deg, #ff9f59 0%, #ff7d3f 100%);
  color: #fff;
  border-color: #ff8a49;
  font-weight: 600;
  box-shadow: 0 6px 14px rgba(255, 125, 63, 0.3);
}

.course-tab-transfer {
  font-size: 11px;
  padding-left: 4px;
  padding-right: 4px;
}

@media (max-width: 360px) {
  .footerbox {
    gap: 8px;
    padding-left: 10px;
    padding-right: 10px;
  }

  .footerbox .tips {
    width: 108px;
    height: 30px;
    margin-right: 6px;
    flex-basis: 108px;
  }

  .footerbox .tips span {
    font-size: 11px;
  }

  .footerbox .btn1 {
    min-width: 104px;
    max-width: 42vw;
    height: 40px;
    line-height: 40px;
    font-size: 12px;
    padding: 0 12px;
  }

  .footerbox .btn1 span:first-child {
    font-size: 16px;
  }

  .kefutext {
    font-size: 11px;
  }
}

@media (min-width: 769px) {
  .course-tabs {
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    width: 720px;
    max-width: 720px;
  }
}

.sms-row {
  display: flex;
  align-items: stretch;
  gap: 8px;
  margin: 0 0 20px;
  width: 100%;
  box-sizing: border-box;
}

.sms-code-input {
  flex: 1;
  min-width: 0;
  height: 44px;
  padding: 0 12px;
  border: 1px solid #e5e5e5;
  border-radius: 8px;
  font-size: 16px;
  box-sizing: border-box;
}

.sms-send-btn {
  flex-shrink: 0;
  min-width: 100px;
  height: 44px;
  padding: 0 12px;
  border: none;
  border-radius: 8px;
  background: #ff6b35;
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  align-self: center;
  box-sizing: border-box;
}

.sms-send-btn:disabled {
  background: #ccc;
  cursor: not-allowed;
}
