/* ═══════════════════════════════════════════
   BOOKING MODAL — Fixed CSS
   Key fixes:
   - Both cols scroll independently
   - Works at 100%–200% zoom (uses dvh)
   - Mobile bar always visible at bottom
   ═══════════════════════════════════════════ */

/* ── Overlay ── */
.bm-overlay {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
}
.bm-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.78); backdrop-filter: blur(6px);
}

/* ── Shell — the modal box ── */
.bm-shell {
  position: relative; z-index: 1;
  display: flex;
  width: min(98vw, 1080px);
  /* Use dvh (dynamic viewport height) — respects mobile browser chrome */
  height: min(92dvh, 820px);
  background: white; border-radius: 1.5rem;
  overflow: hidden;
  box-shadow: 0 40px 100px rgba(0,0,0,0.55);
  animation: bmSlideUp 0.3s ease;
}
@keyframes bmSlideUp {
  from { opacity:0; transform:translateY(24px); }
  to   { opacity:1; transform:none; }
}
@media(max-width:767px) {
  .bm-overlay { padding: 0; align-items: flex-end; }
  .bm-shell {
    width: 100%; height: 96dvh;
    border-radius: 1.25rem 1.25rem 0 0;
    flex-direction: column;
  }
}

/* ── Left column — scrollable ── */
.bm-form-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  /* THIS is the fix: col itself is NOT overflow-hidden */
  overflow: hidden;
  background: #f8fafc;
}

/* Sticky top bar */
.bm-top-bar {
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.75rem;
  padding: 0.9rem 1.5rem;
  background: white; border-bottom: 1px solid #e7e5e4;
  z-index: 10;
}
.bm-back-btn {
  background: none; border: none; color: #0d9488;
  font-size: 0.85rem; font-weight: 700; cursor: pointer;
  padding: 0; white-space: nowrap; font-family: inherit;
  display: flex; align-items: center; gap: 0.3rem;
}
.bm-close-btn {
  background: none; border: none; font-size: 1.2rem;
  cursor: pointer; color: #78716c; padding: 0; line-height: 1;
}
.bm-top-bar-trip {
  font-size: 0.85rem; font-weight: 600; color: #1c1917;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  flex: 1; text-align: center;
}

/* Step indicators */
.bm-steps {
  flex-shrink: 0;
  display: flex; align-items: center;
  padding: 0.85rem 1.5rem;
  background: white; border-bottom: 1px solid #e7e5e4;
  gap: 0.5rem;
}
.bm-step {
  display: flex; align-items: center; gap: 0.5rem;
  font-size: 0.8rem; color: #a8a29e; font-weight: 500;
}
.bm-step.active { color: #0d9488; }
.bm-step.done { color: #10b981; }
.bm-step-num {
  width: 24px; height: 24px; border-radius: 50%;
  background: #e7e5e4; color: #78716c;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem; font-weight: 800; flex-shrink: 0;
}
.bm-step.active .bm-step-num { background: #0d9488; color: white; }
.bm-step.done   .bm-step-num { background: #10b981; color: white; }
.bm-step-divider {
  flex: 1; height: 1px; background: #e7e5e4; min-width: 20px;
}
.bm-step-label { white-space: nowrap; }
@media(max-width:400px) { .bm-step-label { display: none; } }

/* ── Scrollable body inside left col ── */
.bm-panel-body {
  flex: 1;
  overflow-y: auto;
  /* Extra bottom padding so content clears the mobile bar */
  padding: 1.5rem 1.75rem 5rem;
  -webkit-overflow-scrolling: touch;
}
@media(max-width:640px) {
  .bm-panel-body { padding: 1.25rem 1.25rem 5rem; }
}

.bm-panel-sub {
  font-size: 0.85rem; color: #78716c; margin-bottom: 1.25rem; line-height: 1.6;
}

/* ── Calendar ── */
.bm-cal-legend {
  display: flex; gap: 1.1rem; flex-wrap: wrap; margin-bottom: 1rem;
}
.bm-cal-legend span {
  display: flex; align-items: center; gap: 0.35rem;
  font-size: 0.78rem; color: #57534e;
}
.bm-dot { width:10px; height:10px; border-radius:50%; flex-shrink:0; }
.bm-dot.green  { background:#22c55e; }
.bm-dot.yellow { background:#f59e0b; }
.bm-dot.red    { background:#ef4444; }

.bm-cal-nav {
  display: flex; justify-content: space-between; margin-bottom: 1rem;
}
.bm-cal-nav-btn {
  background: white; border: 1.5px solid #e7e5e4; border-radius: 0.5rem;
  padding: 0.4rem 1rem; font-size: 0.82rem; cursor: pointer;
  color: #57534e; transition: border-color 0.2s; font-family: inherit;
}
.bm-cal-nav-btn:hover { border-color: #0d9488; color: #0d9488; }
.bm-cal-loading {
  text-align: center; padding: 0.75rem; font-size: 0.82rem; color: #78716c;
}

/* Two-month grid */
.bm-cal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  transition: opacity 0.2s;
}
@media(max-width:600px) {
  .bm-cal-grid { grid-template-columns: 1fr; }
}

.bm-cal-month-title {
  font-family: 'Noto Serif TC', serif;
  font-size: 1rem; font-weight: 700; color: #0d9488;
  text-align: center; margin-bottom: 0.6rem;
}
.bm-cal-weekdays {
  display: grid; grid-template-columns: repeat(7,1fr);
  text-align: center; background: #0d9488;
  border-radius: 0.5rem 0.5rem 0 0; padding: 0.35rem 0;
}
.bm-cal-weekdays div { color: white; font-size: 0.65rem; font-weight: 700; }
.bm-cal-days {
  display: grid; grid-template-columns: repeat(7,1fr);
  border: 1px solid #e7e5e4; border-top: none;
  border-radius: 0 0 0.5rem 0.5rem; overflow: hidden;
}
.bm-cal-day {
  padding: 0.3rem 0.1rem; text-align: center;
  border-right: 1px solid #f0f0f0; border-bottom: 1px solid #f0f0f0;
  min-height: 54px; display: flex; flex-direction: column;
  align-items: center; justify-content: flex-start; gap: 0.1rem;
  background: white;
}
@media(max-width:400px) { .bm-cal-day { min-height: 46px; } }
.bm-cal-day.available       { cursor: pointer; background: #f0fdf9; }
.bm-cal-day.available:hover { background: #ccfbf1; }
.bm-cal-day.low             { cursor: pointer; background: #fffbeb; }
.bm-cal-day.low:hover       { background: #fef3c7; }
.bm-cal-day.full            { background: #fef2f2; cursor: not-allowed; }
.bm-cal-day.past            { background: #fafaf9; cursor: not-allowed; }
.bm-cal-day.empty           { background: #fafaf9; }
.bm-cal-day.selected        { background: #0d9488 !important; }
.bm-cal-day.selected .bm-cal-num   { color: white !important; font-weight: 800; }
.bm-cal-day.selected .bm-cal-label { color: rgba(255,255,255,0.85) !important; }
.bm-cal-day.selected .bm-dot       { outline: 1.5px solid white; }

.bm-cal-num {
  font-size: 0.82rem; font-weight: 600; color: #1c1917; margin-top: 0.25rem;
}
.bm-cal-day.past .bm-cal-num { color: #d6d3d1; }
.bm-cal-label { font-size: 0.52rem; line-height: 1; }
.bm-cal-label.ok   { color: #059669; }
.bm-cal-label.low  { color: #d97706; font-weight: 700; }
.bm-cal-label.full { color: #dc2626; }

/* ── Form ── */
.bm-pcard {
  background: white; border-radius: 1rem;
  border: 1px solid #e7e5e4; overflow: hidden;
  margin-bottom: 1rem;
  box-shadow: 0 1px 5px rgba(0,0,0,0.04);
  animation: bmFadeIn 0.25s ease;
}
@keyframes bmFadeIn { from{opacity:0;transform:translateY(6px)} to{opacity:1;transform:none} }

.bm-pcard-header {
  background: #f8fafc; border-bottom: 1px solid #e7e5e4;
  padding: 0.75rem 1.25rem;
  display: flex; justify-content: space-between; align-items: center;
}
.bm-pidx { font-weight: 700; font-size: 0.88rem; color: #1c1917; }
.bm-lead-tag {
  display: inline-block; margin-left: 0.6rem;
  background: #ccfbf1; color: #065f46;
  font-size: 0.68rem; font-weight: 700; letter-spacing: 0.06em;
  padding: 0.15rem 0.6rem; border-radius: 20px;
}
.bm-del {
  background: none; border: none; cursor: pointer;
  color: #a8a29e; font-size: 1rem; transition: color 0.2s; padding: 0;
}
.bm-del:hover { color: #ef4444; }
.bm-del.hidden { visibility: hidden; }

.bm-pcard-section-title {
  font-size: 0.75rem; font-weight: 700; letter-spacing: 0.08em;
  color: #0d9488; text-transform: uppercase;
  padding: 0.75rem 0 0.25rem; border-top: 1px solid #f0f0f0;
  margin-top: 0.25rem;
}
.bm-pcard-section-title:first-child { border-top: none; margin-top: 0; padding-top: 0; }

.bm-pgrid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 0.75rem; padding: 1.25rem;
}
@media(max-width:520px) {
  .bm-pgrid { grid-template-columns: 1fr; }
  .bm-field.span2 { grid-column: span 1; }
}

.bm-field { display: flex; flex-direction: column; gap: 0.28rem; }
.bm-field.span2 { grid-column: span 2; }
.bm-field label {
  font-size: 0.7rem; font-weight: 700; color: #78716c;
  text-transform: uppercase; letter-spacing: 0.06em;
}
.bm-field input, .bm-field select {
  padding: 0.6rem 0.85rem; border-radius: 0.6rem;
  border: 1.5px solid #e7e5e4; background: #fafaf9;
  font-size: 0.88rem; color: #1c1917; outline: none;
  transition: border-color 0.2s; font-family: inherit; width: 100%;
}
.bm-field input:focus, .bm-field select:focus { border-color: #0d9488; }

/* Add participant */
.bm-add-btn {
  width: 100%; padding: 0.9rem; border: 2px dashed #d6d3d1;
  border-radius: 1rem; background: transparent; color: #78716c;
  font-size: 0.88rem; font-weight: 600; cursor: pointer;
  transition: all 0.2s; margin: 0.75rem 0; font-family: inherit;
}
.bm-add-btn:hover { border-color: #0d9488; color: #0d9488; background: rgba(13,148,136,0.04); }

/* Agree */
.bm-agree {
  display: flex; align-items: flex-start; gap: 0.75rem;
  cursor: pointer; margin-top: 0.75rem; padding-bottom: 1rem;
}
.bm-agree input { margin-top: 0.15rem; accent-color: #0d9488; flex-shrink: 0; }
.bm-agree span  { font-size: 0.82rem; color: #78716c; line-height: 1.6; }

/* ── Right summary ── */
.bm-summary-col {
  width: 300px; flex-shrink: 0;
  background: white; border-left: 1px solid #e7e5e4;
  display: flex; flex-direction: column;
  /* Scroll independently */
  overflow: hidden;
}
@media(max-width:860px) { .bm-summary-col { display: none; } }

.bm-summary-header {
  flex-shrink: 0;
  padding: 1.1rem 1.4rem; border-bottom: 1px solid #e7e5e4;
  display: flex; justify-content: space-between; align-items: center;
  font-weight: 700; color: #1c1917; font-size: 0.9rem;
}
.bm-summary-header button {
  background: none; border: none; cursor: pointer; color: #78716c; font-size: 1.1rem;
}
.bm-summary-body { flex: 1; overflow-y: auto; padding: 1.4rem; }
.bm-sum-img {
  width: 100%; aspect-ratio: 16/9; object-fit: cover;
  border-radius: 0.75rem; margin-bottom: 1rem; display: block;
}
.bm-sum-trip-title {
  font-family: 'Noto Serif TC', serif; font-size: 1rem;
  font-weight: 700; color: #1c1917; margin-bottom: 0.9rem;
}
.bm-sum-meta, .bm-sum-price { display: flex; flex-direction: column; gap: 0.45rem; }
.bm-sum-meta {
  padding-bottom: 0.9rem; border-bottom: 1px solid #e7e5e4; margin-bottom: 0.9rem;
}
.bm-sum-meta div, .bm-sum-price div {
  display: flex; justify-content: space-between; font-size: 0.8rem; color: #78716c;
}
.bm-sum-meta span:last-child, .bm-sum-price span:last-child {
  font-weight: 600; color: #1c1917;
}
.bm-sum-total-row {
  padding-top: 0.65rem; border-top: 1px solid #e7e5e4; margin-top: 0.3rem;
  display: flex; justify-content: space-between; align-items: center;
}
.bm-sum-total-row span:first-child { font-size: 0.82rem; color: #78716c; }
.bm-sum-total-row span:last-child  { font-size: 1.25rem; font-weight: 800; color: #0f766e; }

.bm-summary-footer {
  flex-shrink: 0;
  padding: 1.1rem 1.4rem; border-top: 1px solid #e7e5e4; background: #fafaf9;
}

/* ── Submit button (shared) ── */
.bm-submit-btn {
  width: 100%; padding: 0.95rem; background: #0d9488; color: white;
  border: none; border-radius: 0.875rem; font-size: 0.95rem; font-weight: 700;
  cursor: pointer; font-family: inherit; transition: background 0.2s;
}
.bm-submit-btn:hover:not(:disabled) { background: #0f766e; }
.bm-submit-btn:disabled { cursor: not-allowed; }

/* ── Mobile bottom bar ── */
.bm-mobile-bar {
  /* Hidden on desktop */
  display: none;
  flex-shrink: 0;
  background: white; border-top: 1px solid #e7e5e4;
  padding: 0.85rem 1.25rem;
  gap: 1rem; align-items: center;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.08);
  /* Stick to bottom of .bm-shell on mobile */
}
@media(max-width:767px) { .bm-mobile-bar { display: flex; } }

.bm-mob-info { flex-shrink: 0; }
.bm-mob-count { font-size: 0.72rem; color: #78716c; }
.bm-mob-total { font-size: 1.1rem; font-weight: 800; color: #0f766e; }
.bm-mob-btn   { flex: 1; width: auto; padding: 0.8rem 0.75rem; font-size: 0.85rem; }

/* ── Mobile form: single column, no label wrap issues ── */
@media(max-width:540px) {
  .bm-pgrid {
    grid-template-columns: 1fr !important;
  }
  .bm-field.span2 {
    grid-column: span 1 !important;
  }
  .bm-pcard-section-title.span2 {
    grid-column: span 1 !important;
  }
  .bm-grid2 {
    grid-template-columns: 1fr !important;
  }
  .bm-field.span2 {
    grid-column: span 1 !important;
  }
  .bm-field label {
    /* Prevent label from squishing input */
    white-space: normal;
    word-break: keep-all;
  }
  .bm-panel-body {
    padding: 1rem 1rem 5rem;
  }
  .bm-pcard-header {
    padding: 0.65rem 1rem;
  }
  .bm-pgrid {
    padding: 1rem;
  }
  .bm-top-bar {
    padding: 0.75rem 1rem;
  }
  .bm-steps {
    padding: 0.6rem 1rem;
    gap: 0.35rem;
  }
  .bm-step-label {
    font-size: 0.72rem;
  }
}

/* ── Responsive at high zoom (e.g. 150-200%) ──
   At high zoom, max-height tightens. Make sure content is still scrollable. */
@media(max-height:600px) {
  .bm-shell { height: 98dvh; border-radius: 0; }
  .bm-steps { padding: 0.5rem 1.5rem; }
  .bm-panel-body { padding: 1rem 1.5rem 5rem; }
}
