/* ── Retreat Booking System – Frontend Styles ── */

#rbs-wrap {
  max-width: 640px;
  margin: 0 auto;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: #1a1a1a;
  /* Prevent touching viewport edge on small screens */
  padding-left: 12px;
  padding-right: 12px;
  box-sizing: border-box;
}

/* ── Welcome ── */
#rbs-welcome {
  text-align: center;
  margin-bottom: 32px;
}
#rbs-welcome h2 {
  font-size: 1.7rem;
  font-weight: 700;
  margin-bottom: 8px;
  color: #111;
}
#rbs-welcome p {
  color: #666;
  font-size: 0.97rem;
  margin: 0;
}

/* ── Calendar container ── */
#rbs-calendar-wrap {
  background: #fff;
  border: 1px solid #e4e4e7;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 1px 6px rgba(0,0,0,.06);
  /* Prevent content from overflowing container */
  overflow: hidden;
}

/* ── Month navigation ── */
#rbs-calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
#rbs-month-label {
  font-size: 1.05rem;
  font-weight: 700;
  color: #111;
}
#rbs-prev-month,
#rbs-next-month {
  background: none;
  border: 1px solid #d4d4d8;
  border-radius: 6px;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1rem;
  color: #52525b;
  transition: background .12s, border-color .12s;
  padding: 0;
}
#rbs-prev-month:hover,
#rbs-next-month:hover {
  background: #f4f4f5;
  border-color: #a1a1aa;
}

/* ── Legend ── */
#rbs-legend {
  display: flex;
  gap: 16px;
  font-size: 0.8rem;
  color: #71717a;
  margin-bottom: 16px;
  align-items: center;
  flex-wrap: wrap;
}
.rbs-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
}
.rbs-dot-open        { background: #18181b; }
.rbs-dot-unavailable { background: #d4d4d8; }
.rbs-dot-selected    { background: #2563eb; }

/* ── Weekday row ── */
#rbs-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 0.72rem;
  font-weight: 600;
  color: #a1a1aa;
  letter-spacing: .05em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

/* ── Calendar grid ── */
#rbs-calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

/* ── Base day cell ── */
.rbs-day {
  aspect-ratio: 1;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: default;
  border: 1.5px solid transparent;
  transition: background .1s, border-color .1s, transform .1s;
  min-height: 44px;
  position: relative;
  user-select: none;
}

.rbs-day.empty {
  background: transparent;
  border-color: transparent;
}

/* ── UNAVAILABLE: past, full, closed — all identical grey ── */
.rbs-day.past,
.rbs-day.closed {
  background: #f4f4f5;
  color: #c0bfc4;
  cursor: not-allowed;
  font-weight: 400;
  text-decoration: line-through;
}
.rbs-day.full {
  background: #f4f4f5;
  color: #c0bfc4;
  cursor: not-allowed;
  font-weight: 400;
}

/* ── AVAILABLE ── */
.rbs-day.open,
.rbs-day.partial {
  background: #fff;
  color: #18181b;
  cursor: pointer;
  border-color: #e4e4e7;
  font-weight: 600;
}
.rbs-day.open:hover,
.rbs-day.partial:hover {
  background: #f0f6ff;
  border-color: #93c5fd;
  transform: scale(1.05);
}

/* ── SELECTED ── */
.rbs-day.selected {
  background: #2563eb !important;
  color: #fff !important;
  border-color: #1d4ed8 !important;
  font-weight: 700 !important;
  transform: scale(1.05);
  cursor: pointer;
  text-decoration: none !important;
}
.rbs-day.selected:hover {
  background: #1d4ed8 !important;
}

/* ── Today marker dot ── */
.rbs-day.today:not(.selected)::after {
  content: '';
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #2563eb;
}

/* ── Selection counter ── */
#rbs-selection-info {
  text-align: center;
  font-size: 0.84rem;
  color: #71717a;
  margin-top: 14px;
  margin-bottom: 0;
  transition: color .2s;
}
#rbs-selection-info.rbs-shake {
  animation: rbs-shake .4s ease;
  color: #dc2626 !important;
  font-weight: 600;
}

/* ── Booking Form ── */
#rbs-form-wrap {
  margin-top: 20px;
  background: #fff;
  border: 1px solid #e4e4e7;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 1px 6px rgba(0,0,0,.06);
}
#rbs-form-wrap h3 {
  font-size: 1rem;
  font-weight: 700;
  margin: 0 0 20px;
  color: #111;
}

.rbs-field { margin-bottom: 16px; }
.rbs-field label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: #3f3f46;
}
.rbs-field label span { color: #dc2626; }
.rbs-field input {
  width: 100%;
  padding: 10px 13px;
  border: 1.5px solid #d4d4d8;
  border-radius: 8px;
  font-size: 0.93rem;
  color: #18181b;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  box-sizing: border-box;
  background: #fafafa;
}
.rbs-field input:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
  background: #fff;
}
.rbs-field input::placeholder { color: #a1a1aa; }

#rbs-selected-dates-review {
  background: #f8faff;
  border: 1px solid #dbeafe;
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 18px;
  font-size: 0.86rem;
  color: #3b4a6b;
  line-height: 1.7;
}

#rbs-submit-btn {
  width: 100%;
  background: #18181b;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 13px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, transform .1s;
}
#rbs-submit-btn:hover    { background: #27272a; transform: translateY(-1px); }
#rbs-submit-btn:active   { transform: translateY(0); }
#rbs-submit-btn:disabled { background: #a1a1aa; cursor: not-allowed; transform: none; }

#rbs-error-msg {
  color: #dc2626;
  font-size: 0.84rem;
  margin-top: 10px;
  text-align: center;
  display: none;
}

/* ── Success ── */
#rbs-success-wrap { margin-top: 20px; }
#rbs-success-box {
  text-align: center;
  padding: 48px 24px;
  background: #fff;
  border: 1px solid #e4e4e7;
  border-radius: 12px;
  box-shadow: 0 1px 6px rgba(0,0,0,.06);
}
.rbs-checkmark {
  width: 56px;
  height: 56px;
  background: #18181b;
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  margin: 0 auto 18px;
}
#rbs-success-box h3 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 8px;
  color: #111;
}
#rbs-success-text { color: #71717a; font-size: 0.93rem; }

/* ── Spinner ── */
.rbs-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: rbs-spin .65s linear infinite;
  vertical-align: middle;
  margin-right: 7px;
}
@keyframes rbs-spin { to { transform: rotate(360deg); } }

@keyframes rbs-shake {
  0%,100% { transform: translateX(0); }
  20%     { transform: translateX(-6px); }
  40%     { transform: translateX(6px); }
  60%     { transform: translateX(-4px); }
  80%     { transform: translateX(4px); }
}

/* ── Step panels (2, 3, 4) ── */
#rbs-step-2,
#rbs-step-3 {
  background: #fff;
  border: 1px solid #e4e4e7;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 1px 6px rgba(0,0,0,.06);
  margin-top: 20px;
}

#rbs-step-4 {
  margin-top: 20px;
}

#rbs-step2-header,
#rbs-step3-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}
#rbs-step2-header h3,
#rbs-step3-header h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: #111;
  /* Allow title to shrink so badge doesn't overflow */
  flex: 1;
  min-width: 0;
}

.rbs-back-btn {
  background: none;
  border: 1px solid #d4d4d8;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 0.84rem;
  color: #52525b;
  cursor: pointer;
  transition: background .12s;
  white-space: nowrap;
  flex-shrink: 0;
}
.rbs-back-btn:hover { background: #f4f4f5; }

/* ── Step 1 next button ── */
#rbs-step1-next-wrap {
  margin-top: 16px;
  text-align: center;
}
#rbs-to-step2 {
  background: #18181b;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 12px 32px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, transform .1s;
}
#rbs-to-step2:hover { background: #27272a; transform: translateY(-1px); }

/* ── Step 2 review button ── */
#rbs-to-step3 {
  width: 100%;
  background: #18181b;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 13px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 8px;
  transition: background .15s, transform .1s;
}
#rbs-to-step3:hover { background: #27272a; transform: translateY(-1px); }

/* ── Step 3: Review box ── */
.rbs-review-intro {
  font-size: 0.88rem;
  color: #71717a;
  margin: 0 0 16px;
}

#rbs-review-box {
  border: 1px solid #e4e4e7;
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 20px;
}
.rbs-review-row {
  display: flex;
  padding: 12px 16px;
  font-size: 0.9rem;
  border-bottom: 1px solid #f4f4f5;
  /* Allow wrapping on very narrow screens */
  flex-wrap: wrap;
  gap: 4px;
}
.rbs-review-row:last-child { border-bottom: none; }
.rbs-review-label {
  width: 80px;
  flex-shrink: 0;
  font-weight: 600;
  color: #71717a;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding-top: 1px;
}
.rbs-review-value {
  color: #18181b;
  font-weight: 500;
  line-height: 1.5;
  /* Take remaining space, allow wrapping */
  flex: 1;
  min-width: 0;
  word-break: break-word;
}

#rbs-submit-error {
  color: #dc2626;
  font-size: 0.84rem;
  margin-top: 10px;
  text-align: center;
  display: none;
}

/* ── Spots remaining on day cells ── */
.rbs-day-num {
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1;
}
.rbs-spots {
  font-size: 0.6rem;
  font-weight: 500;
  opacity: 0.75;
  line-height: 1;
  letter-spacing: .01em;
}
.rbs-day.open     .rbs-spots,
.rbs-day.partial  .rbs-spots  { color: #374151; }
.rbs-day.selected .rbs-spots  { color: rgba(255,255,255,.85); }
.rbs-day.full     .rbs-spots  { color: #ef4444; font-weight: 700; opacity: 1; }

/* ── Spots panel below calendar ── */
#rbs-spots-panel {
  margin-top: 16px;
  border: 1px solid #e4e4e7;
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
}
.rbs-spots-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #71717a;
  padding: 10px 14px 8px;
  background: #fafafa;
  border-bottom: 1px solid #f0f0f0;
}
.rbs-spot-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid #f4f4f5;
  font-size: 0.85rem;
}
.rbs-spot-row:last-child { border-bottom: none; }
.rbs-spot-date {
  width: 120px;
  flex-shrink: 0;
  color: #374151;
  font-weight: 500;
}
.rbs-spot-bar-wrap {
  flex: 1;
  height: 6px;
  background: #f0f0f0;
  border-radius: 99px;
  overflow: hidden;
}
.rbs-spot-bar {
  height: 100%;
  border-radius: 99px;
  transition: width .3s ease;
}
.rbs-spot-count {
  flex-shrink: 0;
  color: #52525b;
  font-size: 0.82rem;
  white-space: nowrap;
}
.rbs-spot-count strong {
  font-size: 0.95rem;
  color: #18181b;
}

/* ── Client changes ────────────────────────────────────────────────────── */

/* First/Last name row */
.rbs-field-row {
  display: flex;
  gap: 12px;
}
.rbs-field-row .rbs-field { flex: 1; min-width: 0; }

/* Field notes */
.rbs-field-note {
  font-size: 0.78rem;
  color: #71717a;
  margin: 4px 0 0;
  line-height: 1.4;
}
.rbs-whatsapp-note {
  color: #065f46;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  border-radius: 6px;
  padding: 6px 10px;
  margin-top: 6px;
}

/* Diocese error */
.rbs-diocese-error {
  color: #dc2626;
  font-size: 0.82rem;
  margin-top: 4px;
  font-weight: 500;
}

/* Error message */
.rbs-error-msg {
  color: #dc2626;
  font-size: 0.84rem;
  margin: 8px 0;
  padding: 8px 12px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 6px;
}

/* Step 2 actions row */
.rbs-step2-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
}
.rbs-step2-actions > button { flex: 1; min-width: 140px; }

/* Step 3 actions row */
.rbs-step3-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.rbs-step3-actions > button { flex: 1; min-width: 140px; }

/* Secondary button */
.rbs-secondary-btn {
  background: #fff !important;
  color: #18181b !important;
  border: 1.5px solid #d4d4d8 !important;
  border-radius: 8px !important;
  padding: 12px 16px !important;
  font-size: 0.88rem !important;
  font-weight: 600 !important;
  cursor: pointer !important;
  transition: background .12s, border-color .12s !important;
}
.rbs-secondary-btn:hover {
  background: #f4f4f5 !important;
  border-color: #a1a1aa !important;
}

/* Dates summary banner on step 2 */
.rbs-dates-summary {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.86rem;
  color: #1e40af;
  margin-bottom: 18px;
  word-break: break-word;
}
.rbs-dates-summary-label {
  font-weight: 700;
  margin-right: 6px;
}

/* Global success msg */
#rbs-global-msg {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #166534;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.88rem;
  font-weight: 500;
  margin-bottom: 16px;
}

/* Success actions */
.rbs-success-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 20px;
}
.rbs-success-actions button {
  padding: 11px 24px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: opacity .15s;
}
#rbs-book-again {
  background: #2563eb;
  color: #fff;
}
#rbs-book-again:hover { opacity: 0.88; }

/* ── Multi-person review ── */
.rbs-review-dates-row {
  background: #fafafa;
  border-bottom: 2px solid #e4e4e7!important;
}
.rbs-review-person {
  border-bottom: 1px solid #f0f0f0;
}
.rbs-review-person + .rbs-review-person {
  border-top: 2px dashed #e4e4e7;
}
.rbs-review-person-num {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #2563eb;
  padding: 10px 16px 2px;
}

/* ── Queue badge (step 2) ── */
.rbs-queue-badge {
  margin-left: auto;
  background: #2563eb;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 99px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ════════════════════════════════════════════
   RESPONSIVE BREAKPOINTS
   ════════════════════════════════════════════ */

/* ── Tablet / narrow desktop (max 600px) ── */
@media (max-width: 600px) {
  #rbs-wrap {
    padding-left: 8px;
    padding-right: 8px;
  }
}

/* ── Mobile (max 480px) ── */
@media (max-width: 480px) {
  /* All card panels */
  #rbs-calendar-wrap,
  #rbs-step-2,
  #rbs-step-3,
  #rbs-success-box {
    padding: 16px;
    border-radius: 10px;
  }

  /* Welcome header */
  #rbs-welcome { margin-bottom: 20px; }
  #rbs-welcome h2 { font-size: 1.3rem; }
  #rbs-welcome p  { font-size: 0.9rem; }

  /* Calendar cells */
  .rbs-day {
    font-size: 0.78rem;
    min-height: 36px;
    border-radius: 6px;
  }
  #rbs-calendar-grid { gap: 3px; }

  /* Step 2 header: wrap badge below title on small screens */
  #rbs-step2-header {
    flex-wrap: wrap;
  }
  .rbs-queue-badge {
    /* When wrapping, let badge sit on its own row */
    margin-left: 0;
    order: 3;
    width: 100%;
    text-align: center;
  }

  /* Name fields: stack vertically */
  .rbs-field-row {
    flex-direction: column;
    gap: 0;
  }

  /* Action buttons: full-width stack */
  .rbs-step2-actions,
  .rbs-step3-actions {
    flex-direction: column;
  }
  .rbs-step2-actions > button,
  .rbs-step3-actions > button {
    width: 100%;
    min-width: unset;
  }

  /* Success buttons */
  .rbs-success-actions {
    flex-direction: column;
    align-items: stretch;
  }
  .rbs-success-actions button {
    width: 100%;
  }

  /* Review box: let label/value wrap on very narrow phones */
  .rbs-review-label {
    width: 70px;
    font-size: 0.78rem;
  }

  /* Step 3 header padding */
  #rbs-step2-header,
  #rbs-step3-header {
    margin-bottom: 16px;
  }

  /* Spots panel */
  .rbs-spot-date   { width: 90px; font-size: 0.78rem; }
  .rbs-spot-count  { font-size: 0.75rem; }
}

/* ── Very small phones (max 360px) ── */
@media (max-width: 360px) {
  #rbs-wrap {
    padding-left: 4px;
    padding-right: 4px;
  }

  #rbs-calendar-wrap,
  #rbs-step-2,
  #rbs-step-3,
  #rbs-success-box {
    padding: 12px;
  }

  /* Tighter calendar on 320px devices */
  .rbs-day {
    font-size: 0.72rem;
    min-height: 32px;
    border-radius: 4px;
  }
  #rbs-calendar-grid { gap: 2px; }
  #rbs-weekdays { font-size: 0.62rem; letter-spacing: 0; }

  /* Compact review */
  .rbs-review-row { padding: 10px 12px; }
  .rbs-review-label { width: 60px; }

  /* Success box: more compact */
  #rbs-success-box { padding: 32px 12px; }
  .rbs-checkmark { width: 48px; height: 48px; font-size: 1.3rem; }
  #rbs-success-box h3 { font-size: 1.1rem; }
}

/* ── Check-in / Check-out in dates summary (Step 2) ─────────────────────── */
.rbs-checkin-summary {
  font-size: 0.82em;
  color: #555;
  margin-top: 4px;
}
.rbs-ci-label {
  font-weight: 600;
  color: #444;
  display: inline-block;
  min-width: 72px;
}

/* ── Review: check-in / check-out rows ──────────────────────────────────── */
.rbs-review-checkin-row {
  background: #f0f7f4;
  border-left: 3px solid #4caf92;
}
.rbs-review-checkin-row .rbs-review-label {
  color: #2e7d5e;
}

/* ── Success screen check-in/out ─────────────────────────────────────────── */
#rbs-success-checkin {
  margin: 12px auto 0;
  max-width: 360px;
  text-align: left;
  font-size: 0.9em;
  color: #444;
}
.rbs-success-ci {
  margin-bottom: 4px;
}
.rbs-success-ci .rbs-ci-label {
  font-weight: 600;
  display: inline-block;
  min-width: 80px;
}

/* ── Priest checkbox ──────────────────────────────────────────────────────── */
.rbs-field-checkbox { margin-bottom: 16px; }
.rbs-checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-weight: 500;
}
.rbs-checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

/* ── Arabic success message ──────────────────────────────────────────────── */
.rbs-success-arabic {
  margin: 16px auto;
  max-width: 420px;
  text-align: right;
  direction: rtl;
  font-size: 1.05em;
  line-height: 1.9;
  color: #2d4a3e;
  background: #f0f9f4;
  border-radius: 10px;
  padding: 16px 20px;
}
.rbs-success-arabic p { margin: 0; }

/* ── Priest badge in review ──────────────────────────────────────────────── */
.rbs-priest-yes { color: #16a34a; font-weight: 600; }

/* ── RTL / LTR direction ─────────────────────────────────────────────────── */
#rbs-wrap.rbs-dir-ltr #rbs-calendar-wrap,
#rbs-wrap.rbs-dir-ltr #rbs-weekdays,
#rbs-wrap.rbs-dir-ltr #rbs-calendar-grid {
  direction: ltr;
}
#rbs-wrap.rbs-dir-rtl #rbs-calendar-wrap,
#rbs-wrap.rbs-dir-rtl #rbs-weekdays,
#rbs-wrap.rbs-dir-rtl #rbs-calendar-grid {
  direction: rtl;
}

/* ── Priest checkbox ─────────────────────────────────────────────────────── */
.rbs-field-priest {
  margin-top: 8px;
}
.rbs-checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.95em;
  cursor: pointer;
  font-weight: 500;
}
.rbs-checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
}
.rbs-priest-badge {
  color: #2e7d5e;
  font-weight: 600;
}

/* ── Arabic success message ──────────────────────────────────────────────── */
.rbs-success-arabic {
  direction: rtl;
  text-align: right;
  font-size: 1em;
  line-height: 1.8;
  color: #374151;
  margin: 16px auto;
  max-width: 420px;
  padding: 16px 20px;
  background: #f0f7f4;
  border-radius: 8px;
  border-right: 4px solid #4caf92;
}
.rbs-success-arabic p {
  margin: 0 0 4px;
}
