/* eztravel.love 前臺移動端與大字型安全適配 */
:root {
  --ez-safe-bottom: env(safe-area-inset-bottom, 0px);
  --ez-safe-top: env(safe-area-inset-top, 0px);
}

html {
  width: 100%;
  min-width: 320px;
  overflow-x: hidden;
  font-size: 16px !important;
  -webkit-text-size-adjust: none !important;
  text-size-adjust: none !important;
}

body {
  width: 100%;
  min-width: 320px;
  max-width: 100%;
  overflow-x: hidden;
  font-size: 14px !important;
}

img,
video,
canvas,
svg {
  max-width: 100%;
}

input,
select,
textarea,
button {
  max-width: 100%;
  font-family: inherit;
}

/* 固定表單字號：既避免iPhone聚焦放大，也不跟隨安卓系統超大字型膨脹 */
input,
select,
textarea {
  font-size: 16px !important;
}

button {
  font-size: 14px !important;
}

/* 彈性佈局的子專案允許收縮，避免撐破手機寬度 */
header,
main,
section,
article,
nav,
form,
div,
a,
button,
label,
span {
  min-width: 0;
}

/* 普通介面文字保持單行，空間不足顯示省略號 */
h1,
h2,
h3,
h4,
h5,
h6,
button,
.back,
.top a,
.page-title,
.card-title,
.section-title,
.menu-left,
.menu a,
.nickname,
.status-text,
.setting-title,
.nav-text,
.tag,
.badge {
  white-space: nowrap;
}

.page-title,
.card-title,
.section-title,
.menu-left,
.menu a,
.nickname,
.status-text,
.subtitle,
.desc,
.description,
.setting-description,
.notice-text,
.nav-text,
.tag,
.badge {
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 普通說明和表格保持整齊單行；超出部分用省略號 */
p,
th,
td {
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 長號碼和單號保持一行，由自己的區域左右檢視 */
.bank-number,
.card-number,
.order-number,
.account-number {
  white-space: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.bank-number::-webkit-scrollbar,
.card-number::-webkit-scrollbar,
.order-number::-webkit-scrollbar,
.account-number::-webkit-scrollbar {
  display: none;
}

/* 長正文輸入允許換行 */
textarea {
  white-space: pre-wrap !important;
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* APP瀏覽器、安卓Chrome、iOS Safari的可視高度 */
.full-height-page {
  min-height: 100vh;
  min-height: 100svh;
  min-height: 100dvh;
}

/* 彈窗不能超出APP當前可視區域 */
.modal,
.modal-panel,
.dialog,
.dialog-panel,
.gift-panel {
  max-width: calc(100vw - 20px);
  max-height: calc(100vh - 24px);
  max-height: calc(100dvh - 24px);
}

.modal-panel,
.dialog-panel,
.gift-panel {
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* 表格只在自身內部滑動，不撐破整個頁面 */
.table,
.table-wrap,
.table-responsive {
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* 底部導航始終保持五項單行並避開iPhone安全區 */
.bottom-nav {
  padding-bottom: calc(6px + var(--ez-safe-bottom)) !important;
}

.bottom-nav a,
.bottom-nav .nav-text {
  white-space: nowrap !important;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 會員中心：系統最大字型下仍保持頭像、姓名、會員卡的正常橫向佈局 */
.user-card .user-top {
  display: flex !important;
  align-items: center !important;
  flex-wrap: nowrap !important;
}

.user-card .user-name {
  max-width: 130px;
  font-size: 20px !important;
  line-height: 1.25 !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}

.user-card .user-id {
  font-size: 12px !important;
  line-height: 1.4 !important;
  white-space: nowrap !important;
}

.user-card .credit-badge {
  width: max-content !important;
  max-width: 130px !important;
  font-size: 11px !important;
  line-height: 1 !important;
  white-space: nowrap !important;
}

.user-card .vip-tag,
.user-card .normal-tag {
  flex: 0 0 auto !important;
  width: 96px !important;
  min-width: 96px !important;
  height: 82px !important;
  padding: 10px 7px !important;
  font-size: 13px !important;
  line-height: 1.2 !important;
  white-space: nowrap !important;
}

.user-card .stats {
  display: grid !important;
  grid-template-columns: 1fr 1fr !important;
  gap: 10px !important;
}

.user-card .stat {
  min-height: 72px !important;
}

.user-card .stat strong {
  font-size: 18px !important;
  white-space: nowrap !important;
}

.user-card .stat span,
.user-card .stat small {
  font-size: 11px !important;
  white-space: nowrap !important;
}

/* 打賞頁固定為雙列禮物，不因系統最大字型退化成單列 */
.reward-card .gift-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
}

.reward-card .gift-box {
  min-width: 0 !important;
}

.reward-card .gift-name {
  font-size: 15px !important;
  white-space: nowrap !important;
}

.reward-card .gift-description {
  font-size: 11px !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}

.page-title {
  font-size: 27px !important;
  line-height: 1.25 !important;
}

.page-subtitle {
  font-size: 13px !important;
  line-height: 1.5 !important;
}

.balance-label {
  font-size: 13px !important;
}

.balance-number {
  font-size: 32px !important;
  white-space: nowrap !important;
}

/* 定位彈窗在系統最大字型下保持完整、居中且按鈕不互相擠壓 */
.location-card {
  width: min(100%, 390px) !important;
  padding: 25px 22px !important;
}

.location-card h2 {
  font-size: 22px !important;
  line-height: 1.3 !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}

.location-card p {
  font-size: 13px !important;
  line-height: 1.7 !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}

.location-actions {
  grid-template-columns: 1fr 1.5fr !important;
}

.location-actions button {
  height: 46px !important;
  padding: 0 8px !important;
  font-size: 14px !important;
  white-space: nowrap !important;
}

/* 系統字型較大或手機較窄時，優先縮小間距而不是換行 */
@media (max-width: 430px) {
  .page,
  .wrap,
  .container {
    max-width: 100% !important;
    padding-left: max(10px, env(safe-area-inset-left, 0px)) !important;
    padding-right: max(10px, env(safe-area-inset-right, 0px)) !important;
  }

  .bottom-nav {
    padding-left: 4px !important;
    padding-right: 4px !important;
  }

  .bottom-nav a {
    padding-left: 1px;
    padding-right: 1px;
    font-size: clamp(10px, 3vw, 12px) !important;
  }

  .bottom-nav .nav-icon {
    font-size: clamp(18px, 5.2vw, 21px) !important;
  }

  h1,
  .page-title {
    font-size: clamp(20px, 6vw, 27px) !important;
  }

  h2,
  .section-title,
  .card-title {
    font-size: clamp(17px, 5vw, 22px) !important;
  }

  button,
  .button,
  .btn,
  .submit {
    padding-left: 10px !important;
    padding-right: 10px !important;
  }
}

/* 超窄屏只調整資料區；禮物仍保持雙列 */
@media (max-width: 350px) {
  .profile-grid,
  .info-grid,
  .detail-grid,
  .feature-grid {
    grid-template-columns: 1fr !important;
  }

  .reward-card .gift-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
