/* Royal Bali SPA 櫃台：外框元件
 * BETA 標示、雲端登入頁（#gate）、網路中斷提示（#net-bar）、加入主畫面提示（#install-hint）、
 * 「不確定有沒有完成」的錯誤提示。行為在 public/js/device.js、gate.js、core.js。
 * 手機與平板的版面在 mobile.css（接在這個檔案後面載入）。
 */

/* ---------- BETA 測試版 ---------- */
#beta-strip {
  background: #7a1f1a; color: #fff; text-align: center; font-weight: 700; font-size: .86rem;
  letter-spacing: .04em; line-height: 1.5;
  padding: calc(3px + env(safe-area-inset-top, 0px)) calc(12px + env(safe-area-inset-right, 0px)) 3px calc(12px + env(safe-area-inset-left, 0px));
}
body.beta .test-badge { background: #b3261e; color: #fff; letter-spacing: .03em; }

/* ---------- 雲端登入頁 ---------- */
#gate {
  position: fixed; inset: 0; z-index: 95; overflow-y: auto; -webkit-overflow-scrolling: touch;
  background: linear-gradient(160deg, #0f5c55 0%, #0a4640 60%, #082f2b 100%);
  display: flex; align-items: flex-start; justify-content: center;
  padding: calc(6vh + env(safe-area-inset-top, 0px)) 16px calc(24px + env(safe-area-inset-bottom, 0px));
}
body.gated { overflow: hidden; }
.gate-card {
  width: 100%; max-width: 420px; background: var(--panel); border-radius: 14px; padding: 24px 22px 18px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .35);
}
.gate-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 10px; }
.gate-brand img { border-radius: 12px; flex: none; }
.gate-brand h1 { font-size: 1.3rem; margin: 0 0 4px; }
.gate-beta { display: inline-block; background: #b3261e; color: #fff; font-weight: 700; font-size: .82rem; padding: 2px 10px; border-radius: 999px; }
.gate-sub { color: var(--muted); font-size: .92rem; margin: 6px 0 16px; }
.gate-note { background: #fff6e0; border: 1px solid #f1c376; border-radius: 8px; padding: 10px 12px; font-size: .9rem; margin: 0 0 14px; }
.gate-form { display: flex; flex-direction: column; gap: 14px; }
.gate-field { display: flex; flex-direction: column; gap: 6px; font-weight: 600; }
.gate-field small { font-weight: 400; color: var(--muted); }
.gate-field input {
  font-size: 16px; /* iOS 小於 16px 會自動放大畫面 */
  min-height: 46px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff;
}
.gate-field input:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: var(--brand); }
.gate-ok { min-height: 48px; font-size: 1.05rem; width: 100%; justify-content: center; }
.gate-error { color: var(--danger); font-weight: 600; margin: 0; }
.gate-foot { color: var(--muted); font-size: .85rem; margin: 16px 0 0; }
.gate-foot:empty { display: none; }

/* ---------- 網路中斷提示 ---------- */
#net-bar {
  position: fixed; left: 12px; right: 12px; z-index: 92; margin: 0 auto; max-width: 760px;
  bottom: calc(12px + var(--bottom-nav-h, 0px) + env(safe-area-inset-bottom, 0px));
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
  background: #3d2600; color: #fff; border-radius: 10px; padding: 10px 16px; box-shadow: 0 6px 24px rgba(0, 0, 0, .3);
  font-size: .92rem;
}
#net-bar strong { color: #f1c376; }
body.net-down .sync::before { background: #f1c376; }

/* ---------- 加入主畫面提示 ---------- */
#install-hint {
  position: fixed; left: 12px; right: 12px; z-index: 85; margin: 0 auto; max-width: 560px;
  bottom: calc(12px + var(--bottom-nav-h, 0px) + env(safe-area-inset-bottom, 0px));
  display: flex; align-items: center; gap: 12px;
  background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; box-shadow: 0 8px 28px rgba(0, 0, 0, .22);
}
#install-hint img { border-radius: 10px; flex: none; }
#install-hint .install-text { flex: 1; min-width: 0; font-size: .92rem; }
#install-hint .install-text p { margin: 0 0 4px; }
#install-hint .install-text .hint { color: var(--muted); font-size: .84rem; margin: 0; }
#install-hint .install-text .btn { margin-top: 6px; min-height: 44px; }
#install-hint > .btn { flex: none; min-height: 44px; }
body.gated #install-hint { z-index: 96; } /* 第一次打開時先教加入主畫面，再登入 */

/* ---------- 不確定有沒有完成的錯誤提示：留著，按「知道了」才關 ---------- */
.toast.uncertain {
  pointer-events: auto; display: flex; flex-direction: column; align-items: flex-end; gap: 8px;
  max-width: min(560px, calc(100vw - 24px)); border: 2px solid #fff;
}
.toast-close {
  flex: none; background: #fff; color: var(--danger); border: 0; border-radius: 6px; font-weight: 700;
  padding: 6px 12px; min-height: 36px; cursor: pointer; pointer-events: auto;
}

/* ---------- 直接開單：今日預約選單（public/js/billstart.js，第十四輪） ---------- */
.bill-start .bs-top { display: flex; gap: 10px; align-items: stretch; flex-wrap: wrap; margin-bottom: 6px; }
.bill-start .bs-top input[type="search"] {
  flex: 1 1 260px; min-width: 0; min-height: 44px; font-size: 16px; padding: 8px 12px;
  border: 1px solid #bdb5a8; border-radius: 8px; background: #fff; -webkit-appearance: none; appearance: none;
}
.bill-start .bs-top .btn { flex: 0 0 auto; }
.bill-start .bs-head { font-size: 1rem; margin: 14px 0 8px; color: var(--muted); }
.bill-start .bs-cards { display: flex; flex-direction: column; gap: 8px; }
.bill-start .bs-card {
  display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; gap: 12px; align-items: center;
  border: 1px solid var(--line); border-left: 4px solid var(--booking-bd); border-radius: 8px; padding: 10px 12px; background: var(--panel);
}
.bill-start .bs-card.billed { border-left-color: var(--billed-bd); background: #fffaf0; }
.bill-start .bs-time { font-size: 1.25rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.bill-start .bs-name { display: flex; gap: 10px; flex-wrap: wrap; align-items: baseline; }
.bill-start .bs-name strong { font-size: 1.05rem; }
.bill-start .bs-phone { color: var(--muted); font-variant-numeric: tabular-nums; }
.bill-start .bs-items { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-direction: column; gap: 3px; }
.bill-start .bs-notes { margin-top: 4px; font-size: .9rem; color: #6b3d06; }
.bill-start .bs-flags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.bill-start .bs-flags:empty { display: none; }
.bill-start .bs-action .btn { min-height: 44px; white-space: nowrap; }
@media (max-width: 700px) {
  .bill-start .bs-top .btn { flex: 1 1 100%; }
  .bill-start .bs-card { grid-template-columns: 52px minmax(0, 1fr); }
  .bill-start .bs-time { font-size: 1.1rem; align-self: start; }
  .bill-start .bs-action { grid-column: 1 / -1; }
  .bill-start .bs-action .btn { width: 100%; justify-content: center; }
}
/* 對話框開著時先不顯示「加入主畫面」提示（不蓋住開單、收款的按鈕）；關掉對話框後再出現 */
body:has(#modal-root > .overlay) #install-hint { display: none; }

/* ---------- 客人選單（public/js/custpick.js，第十四輪）：預約、開單表單打姓名或電話時列出新舊客人 ---------- */
.cust-picker { margin: -4px 0 10px; }
.cust-picker .cp-info:empty { display: none; }
.cust-picker .cp-info { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; padding: 6px 10px; background: #f3f8f6; border: 1px solid #cfe3dd; border-radius: 8px; font-size: .92rem; }
.cust-picker .cp-list { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); box-shadow: var(--shadow); max-height: 320px; overflow-y: auto; }
.cust-picker .cp-row {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; width: 100%;
  padding: 8px 12px; min-height: 44px; border: 0; border-bottom: 1px solid var(--line-soft); background: transparent; cursor: pointer; font: inherit; color: inherit;
}
.cust-picker .cp-row:last-child { border-bottom: 0; }
.cust-picker .cp-row:hover, .cust-picker .cp-row.active { background: #eef6f3; }
.cust-picker .cp-facts { font-size: .86rem; color: var(--muted); }
.cust-facts { margin: 0 0 10px; color: var(--muted); }
