/* Public schedule — phone, tablet, and desktop layouts */

html.public-schedule-page {
  -webkit-text-size-adjust: 100%;
}

.public-schedule-page button,
.public-schedule-page a {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.public-schedule-theme-toggle {
  top: max(1rem, env(safe-area-inset-top, 0px));
  right: max(1rem, env(safe-area-inset-right, 0px));
}

.public-schedule-shell {
  padding-top: max(1rem, env(safe-area-inset-top, 0px));
  padding-bottom: max(1rem, env(safe-area-inset-bottom, 0px));
}

.public-schedule-card {
  width: 100%;
}

/* Time slot grid — responsive columns with finger-friendly targets */
.slot-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
}

@media (min-width: 380px) {
  .slot-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 640px) {
  .slot-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.625rem;
  }
}

@media (min-width: 768px) {
  .slot-grid {
    grid-template-columns: repeat(5, minmax(5.5rem, 1fr));
  }
}

@media (min-width: 1024px) {
  .slot-grid {
    grid-template-columns: repeat(auto-fill, minmax(5.75rem, 1fr));
  }
}

.slot-pick-btn {
  min-height: 44px;
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: visible;
  line-height: 1.2;
  letter-spacing: 0.02em;
  box-sizing: border-box;
}

#slot-picker {
  max-height: min(22rem, 48vh);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

@media (min-width: 640px) {
  #slot-picker {
    max-height: min(26rem, 52vh);
  }
}

@media (min-width: 768px) {
  #slot-picker {
    max-height: 24rem;
  }
}

/* Mobile date strip — snap-scroll chips for the booking window */
.date-strip {
  display: flex;
  gap: 0.625rem;
  overflow-x: auto;
  padding: 0.25rem 0.125rem 0.75rem;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}

.date-chip {
  flex: 0 0 auto;
  width: 4.5rem;
  min-height: 5.25rem;
  scroll-snap-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.125rem;
  border-radius: 0.9rem;
  border: 1px solid #bfdbfe;
  background: #eff6ff;
  color: #1e3a8a;
  padding: 0.625rem 0.375rem;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.date-chip-weekday {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  opacity: 0.8;
}

.date-chip-day {
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.date-chip-month {
  font-size: 0.7rem;
  font-weight: 600;
}

.date-chip-count {
  margin-top: 0.2rem;
  font-size: 0.65rem;
  opacity: 0.75;
}

.date-chip.is-selected,
.date-chip[aria-selected="true"] {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
  box-shadow: 0 0 0 3px rgb(147 197 253 / 0.55);
}

/* Desktop month calendar */
.date-calendar-weekdays,
.date-calendar-grid {
  display: grid !important;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.375rem;
  width: 100%;
}

.date-calendar-weekdays {
  margin-bottom: 0.375rem;
}

.date-calendar-weekdays span {
  text-align: center;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #94a3b8;
  padding: 0.25rem 0;
}

.date-cal-btn,
.date-cal-empty {
  min-height: 3.25rem;
  min-width: 0;
  border-radius: 0.75rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  padding: 0.35rem 0.2rem;
  box-sizing: border-box;
}

.date-cal-btn {
  border: 1px solid #bfdbfe;
  background: #eff6ff;
  color: #1e3a8a;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.date-cal-btn:hover {
  background: #dbeafe;
  border-color: #93c5fd;
}

.date-cal-btn.is-selected,
.date-cal-btn[aria-pressed="true"] {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
  box-shadow: 0 0 0 3px rgb(147 197 253 / 0.45);
}

.date-cal-num {
  font-size: 0.95rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.date-cal-mark {
  width: 0.35rem;
  height: 0.35rem;
  border-radius: 9999px;
  background: currentColor;
  opacity: 0.55;
}

.date-cal-btn.is-selected .date-cal-mark,
.date-cal-btn[aria-pressed="true"] .date-cal-mark {
  opacity: 0.95;
  background: #fff;
}

.date-cal-empty {
  color: #cbd5e1;
  font-size: 0.85rem;
}

.date-cal-empty.is-outside {
  visibility: hidden;
}

html.dark .date-chip {
  background: rgb(30 64 175 / 0.22);
  border-color: #1d4ed8;
  color: #bfdbfe;
}

html.dark .date-chip.is-selected,
html.dark .date-chip[aria-selected="true"] {
  background: #2563eb;
  border-color: #60a5fa;
  color: #fff;
}

html.dark .date-cal-btn {
  background: rgb(30 64 175 / 0.22);
  border-color: #1d4ed8;
  color: #bfdbfe;
}

html.dark .date-cal-btn:hover {
  background: rgb(30 64 175 / 0.35);
}

html.dark .date-cal-btn.is-selected,
html.dark .date-cal-btn[aria-pressed="true"] {
  background: #2563eb;
  border-color: #60a5fa;
  color: #fff;
}

html.dark .date-cal-empty {
  color: #475569;
}

html.dark .date-calendar-weekdays span {
  color: #94a3b8;
}

.account-code-card {
  border-radius: 0.75rem;
  border: 1px solid rgb(243 244 246);
  background: rgb(249 250 251);
  padding: 0.875rem 1rem;
}

html.dark .account-code-card {
  border-color: #334155 !important;
  background-color: rgb(15 23 42 / 0.45) !important;
}

.contact-notify-card {
  background-color: rgb(249 250 251 / 0.9);
}

html.dark .contact-notify-card {
  border-color: #334155 !important;
  background-color: rgb(15 23 42 / 0.55) !important;
}

html.dark .contact-notify-card .contact-notify-hint,
html.dark .contact-notify-card .text-gray-500 {
  color: #cbd5e1 !important;
}

html.dark .contact-notify-card input[type="checkbox"] {
  background-color: #0f172a;
  border-color: #64748b;
}

html.dark .scheduled-appt-card {
  border-color: #1d4ed8 !important;
  background-color: rgb(30 64 175 / 0.28) !important;
}

/* Light mode — clearer chips and nested cards on the public booking page */
html:not(.dark) .date-chip {
  border-color: #93c5fd;
  box-shadow: 0 1px 2px rgb(30 64 175 / 0.08);
}

html:not(.dark) .account-code-card,
html:not(.dark) .contact-notify-card,
html:not(.dark) .scheduled-appt-card {
  border-color: #e2e8f0;
}

/* Confirm sheet — always opaque (dark theme must not wash it out) */
.slot-confirm-sheet,
#slot-confirm-panel {
  background-color: #eff6ff !important;
  border-color: #bfdbfe !important;
}

html.dark .slot-confirm-sheet,
html.dark #slot-confirm-panel {
  background-color: #1e3a8a !important;
  border-color: #3b82f6 !important;
}

html.dark #slot-confirm-panel .text-blue-600 {
  color: #93c5fd !important;
}

html.dark #slot-confirm-panel .text-gray-900,
html.dark #slot-confirm-panel #slot-confirm-label {
  color: #f8fafc !important;
}

html.dark #slot-confirm-panel .text-gray-500 {
  color: #cbd5e1 !important;
}

html.dark #slot-confirm-cancel {
  background-color: #1e3a8a !important;
  border-color: #93c5fd !important;
  color: #f8fafc !important;
}

html.dark #slot-confirm-cancel:hover {
  background-color: #1e40af !important;
}

@media (min-width: 640px) {
  .account-code-card {
    border: 0;
    background: transparent;
    padding: 0;
    text-align: right;
  }
}

/* Sticky confirmation sheet on phones */
@media (max-width: 639px) {
  .public-schedule-page {
    font-size: 17px;
  }

  .public-schedule-shell {
    padding-left: 0.125rem;
    padding-right: 0.125rem;
    padding-top: 0.75rem;
    padding-bottom: 1.25rem;
  }

  .public-schedule-shell > .text-center {
    margin-bottom: 1.5rem;
  }

  .public-schedule-shell > .text-center > p {
    font-size: 1rem;
    line-height: 1.45;
    margin-top: 0.4rem;
  }

  .public-schedule-title {
    font-size: 1.75rem;
    line-height: 1.2;
  }

  .public-schedule-card {
    padding: 1.35rem !important;
  }

  .public-schedule-card h2 {
    font-size: 1.375rem;
    line-height: 1.3;
  }

  .public-schedule-card h3,
  #selected-day-label {
    font-size: 1.125rem;
    line-height: 1.35;
  }

  .public-schedule-card p,
  .public-schedule-card label,
  .public-schedule-card .text-sm,
  .account-code-card,
  .contact-notify-hint {
    font-size: 1rem;
    line-height: 1.5;
  }

  .public-schedule-card .text-xs,
  .public-schedule-section-label {
    font-size: 0.875rem;
    line-height: 1.4;
    letter-spacing: 0.06em;
  }

  .public-schedule-flash {
    font-size: 1rem;
    line-height: 1.5;
    padding: 0.95rem 1rem;
  }

  .public-schedule-confirmed {
    padding: 1.5rem !important;
  }

  .public-schedule-confirmed h2,
  .public-schedule-confirmed #scheduled-heading {
    font-size: 1.5rem;
    line-height: 1.3;
  }

  .public-schedule-account {
    margin-top: 0.15rem;
  }

  .public-schedule-address,
  .public-schedule-appt-meta {
    font-size: 1.0625rem;
    line-height: 1.55;
  }

  .scheduled-appt-card {
    padding: 1.25rem !important;
  }

  .public-schedule-actions {
    gap: 0.85rem;
    padding-top: 0.35rem;
  }

  .public-schedule-actions a,
  .public-schedule-actions button {
    font-size: 1.0625rem;
    min-height: 54px;
  }

  #confirmation_code {
    min-height: 54px;
    font-size: 1.3rem;
    letter-spacing: 0.28em;
  }

  .slot-pick-btn {
    min-height: 50px;
    font-size: 1.0625rem;
    font-weight: 600;
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
  }

  .date-chip {
    width: 4.85rem;
    min-height: 5.75rem;
    padding: 0.75rem 0.4rem;
  }

  .date-chip-weekday,
  .date-chip-month {
    font-size: 0.8rem;
  }

  .date-chip-day {
    font-size: 1.55rem;
  }

  .date-chip-count {
    font-size: 0.75rem;
  }

  .public-schedule-continue,
  #slot-confirm-submit,
  #slot-confirm-cancel,
  #contact-save-form button[type="submit"] {
    min-height: 52px;
    font-size: 1.0625rem;
  }

  #slot-confirm-label {
    font-size: 1.2rem;
    line-height: 1.35;
  }

  #slot-confirm-panel.is-open {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    margin: 0;
    border-radius: 1rem 1rem 0 0;
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
    padding: 1.15rem 1.15rem calc(1.15rem + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -10px 30px rgba(15, 23, 42, 0.35);
    background-color: #eff6ff !important;
  }

  html.dark #slot-confirm-panel.is-open {
    background-color: #1e3a8a !important;
    box-shadow: 0 -12px 32px rgba(0, 0, 0, 0.55);
  }

  #slot-picker.has-confirm-open {
    padding-bottom: 11rem;
  }

  #slot-picker {
    max-height: min(20rem, 42vh);
  }

  .contact-notify-card,
  .account-code-card {
    padding: 1.1rem 1.15rem;
  }

  .test-code-btn {
    padding-top: 0.85rem;
    padding-bottom: 0.85rem;
  }

  .test-code-btn .font-mono {
    font-size: 1rem;
  }
}

/* Touch tablet (iPad) — matches base.html data-device detection */
[data-device="tablet"] .slot-pick-btn {
  min-height: 52px;
  font-size: 1.0625rem;
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
}

[data-device="tablet"] .slot-grid {
  grid-template-columns: repeat(4, minmax(5.75rem, 1fr));
  gap: 0.75rem;
}

[data-device="tablet"] #slot-picker {
  max-height: min(36rem, 62vh);
}

[data-device="tablet"] #slot-confirm-submit,
[data-device="tablet"] #slot-confirm-cancel,
[data-device="tablet"] .public-schedule-continue {
  min-height: 52px;
  font-size: 1.0625rem;
}

[data-device="tablet"] #confirmation_code {
  min-height: 56px;
  font-size: 1.25rem;
}

[data-device="tablet"] .public-schedule-card {
  padding: 1.75rem !important;
}

[data-device="tablet"] h1.public-schedule-title {
  font-size: 2rem;
  line-height: 2.25rem;
}
