/* ═══════════════════════════════════════════════════════
   REPLAI Booking — Public SPA Styles v2.0
   Calendly-style split layout
═══════════════════════════════════════════════════════ */

:root {
  --bg-top:       #1775ed;
  --bg-bottom:    #0f62d4;
  --card:         #ffffff;
  --card-bg:      #f8fafc;
  --text:         #1d2939;
  --muted:        #667085;
  --primary:      #1775ed;
  --primary-dark: #0d5fcb;
  --primary-light:#e8f0fe;
  --line:         #e4e7ec;
  --ok:           #17b26a;
  --danger:       #d92d20;
  --warn:         #f79009;
  --radius:       16px;
  --shadow:       0 1px 4px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.06);
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
}

body {
  font-family: system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
  color: var(--text);
  background: #ffffff;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── TOPBAR (minimal — logo in panel) ─────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 1rem 12px;
  background: transparent;
}

.topbar-brand {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

/* ── Panel logo (above member name, centered) ────── */
.bk-panel-logo {
  display: block;
  height: 40px;
  width: auto;
  max-width: 80%;
  border-radius: 6px;
  margin: 0 auto 3.5rem;
  object-fit: contain;
}

.back-btn {
  background: rgba(0,0,0,0.06);
  border: none;
  border-radius: 50%;
  width: 2.25rem;
  height: 2.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #3d4466;
  cursor: pointer;
  transition: background .15s;
  flex-shrink: 0;
}
.back-btn:hover { background: rgba(0,0,0,0.12); }
.back-btn.hidden { display: flex !important; visibility: hidden; }

/* ── MAIN ──────────────────────────────────────────── */
.main-content {
  max-width: 750px;
  margin: 0 auto;
  padding: 0 1rem 4rem;
  transition: max-width .35s ease;
}

.main-content.has-slots {
  max-width: 1060px;
}

/* ── VIEWS ─────────────────────────────────────────── */
.view { display: none; }
.view.active { display: block; }

/* Loading */
.view.active.view-loading { display: flex; align-items: center; justify-content: center; min-height: 50vh; }
.spinner-wrap { display: flex; align-items: center; justify-content: center; }
.spinner {
  width: 2.5rem; height: 2.5rem;
  border: 3px solid rgba(0,0,0,0.12);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── CARD ───────────────────────────────────────────── */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem 1.25rem;
  margin-bottom: 1rem;
}

.card-center {
  text-align: center;
  padding: 2rem 1.5rem;
}

/* ── WORKSPACE HOME ────────────────────────────────── */
.workspace-hero {
  text-align: center;
  padding: 1.5rem 0 1rem;
  color: var(--text);
}
.ws-logo {
  height: 64px;
  width: auto;
  border-radius: 0;
  margin-bottom: .75rem;
  background: none;
  padding: 0;
}
.ws-subtitle { color: var(--muted); font-size: .875rem; margin: .25rem 0 0; }

.ws-name {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0 0 .25rem;
  color: var(--text);
}

.pages-list { display: flex; flex-direction: column; gap: .75rem; max-width: 600px; margin: 0 auto; }

.page-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color .15s, transform .1s;
  text-decoration: none;
  color: var(--text);
}
.page-card:hover { border-color: var(--primary); transform: translateY(-1px); }

.page-card-icon {
  width: 2.75rem; height: 2.75rem;
  background: var(--primary-light);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: var(--primary);
  font-size: 1.1rem;
  flex-shrink: 0;
}

.page-card-body { flex: 1; min-width: 0; }
.page-card-name { font-weight: 600; margin: 0 0 .2rem; }
.page-card-meta { font-size: .82rem; color: var(--muted); margin: 0; }
.page-card-arrow { color: var(--muted); }


/* ═══════════════════════════════════════════════════════
   CALENDLY-STYLE SPLIT CARD
═══════════════════════════════════════════════════════ */

.bk-split-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  overflow: hidden;
  min-height: 460px;
}

/* LEFT PANEL — event info */
.bk-split-left {
  width: 300px;
  min-width: 300px;
  border-right: 1px solid var(--line);
  padding: 1.75rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* RIGHT PANEL — calendar / slots / form */
.bk-split-right {
  flex: 1;
  padding: 1.75rem 1.5rem;
  min-width: 0;
}

/* ── LEFT: Member info ────────────────────────────── */
.bk-member-info {
  display: flex;
  align-items: center;
  gap: .65rem;
  margin-bottom: .25rem;
}

.bk-member-photo {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--line);
  flex-shrink: 0;
}

.bk-member-name {
  font-size: .875rem;
  font-weight: 600;
  color: var(--muted);
}

/* ── LEFT: Event title + meta ─────────────────────── */
.bk-event-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 .3rem;
  line-height: 1.3;
}

.bk-event-desc {
  margin: 0 0 .5rem;
  line-height: 1.5;
}

.bk-event-meta {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  margin-top: .5rem;
}

.bk-meta-row {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .875rem;
  color: var(--muted);
}

.bk-meta-row i {
  width: 1rem;
  text-align: center;
  color: var(--muted);
  font-size: .8rem;
}

/* ── LEFT: Member step ────────────────────────────── */
.bk-member-step {
  border-top: 1px solid var(--line);
  padding-top: 1rem;
}

.bk-member-step-label {
  font-size: .82rem;
  font-weight: 600;
  color: var(--muted);
  margin: 0 0 .75rem;
  text-transform: uppercase;
  letter-spacing: .03em;
}

/* ── RIGHT: Title ─────────────────────────────────── */
.bk-right-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 1rem;
}

/* ── RIGHT: Inner wrapper (side-by-side when slots visible) */
.bk-right-inner {
  display: flex;
  gap: 0;
  transition: gap .3s ease;
}

.bk-right-inner.show-slots {
  gap: 1.5rem;
}

.bk-right-inner.show-slots .bk-calendar-section {
  flex: 3 1 0%;
  min-width: 280px;
}

.bk-right-inner.show-slots .bk-slots-section {
  flex: 2 1 0%;
  min-width: 160px;
  border-left: 1px solid var(--line);
  padding-left: 1.5rem;
}

/* ── RIGHT: Calendar section ──────────────────────── */
.bk-calendar-section {
  min-width: 350px;
  max-width: 380px;
}

/* ── RIGHT: Slots section ─────────────────────────── */
.bk-slots-section {
  margin-top: 0;
}

.bk-slots-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: .75rem;
}

.bk-slots-header .bk-right-title {
  margin: 0;
}

/* ── RIGHT: Form section ──────────────────────────── */
.bk-form-right {
  overflow-y: auto;
  max-height: 600px;
}


/* ── MEMBERS GRID ──────────────────────────────────── */
.members-grid { display: flex; flex-wrap: wrap; gap: .5rem; }
.member-chip {
  display: flex; align-items: center; gap: .45rem;
  padding: .4rem .75rem .4rem .4rem;
  border-radius: 100px;
  border: 2px solid var(--line);
  cursor: pointer;
  background: var(--card-bg);
  transition: border-color .15s;
  font-size: .82rem;
  font-weight: 500;
}
.member-chip:hover { border-color: var(--primary); }
.member-chip.selected { border-color: var(--primary); background: var(--primary-light); color: var(--primary); }
.member-chip img {
  width: 1.6rem; height: 1.6rem; border-radius: 50%; object-fit: cover;
}
.member-chip-avatar {
  width: 1.6rem; height: 1.6rem; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: .65rem; font-weight: 700;
}

/* ── CALENDAR ──────────────────────────────────────── */
.calendar-nav {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1rem;
}
.cal-month-label { font-weight: 600; font-size: .95rem; }
.cal-nav-btn {
  background: none; border: none;
  width: 2rem; height: 2rem;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text);
  transition: background .15s;
}
.cal-nav-btn:hover { background: var(--line); }
.cal-nav-btn:disabled { opacity: .3; pointer-events: none; }

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
}
.cal-day-header {
  text-align: center; font-size: .7rem; font-weight: 600;
  color: var(--muted); padding: .25rem 0;
}
.cal-day {
  aspect-ratio: 1;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  font-size: .82rem;
  cursor: pointer;
  transition: background .12s, color .12s;
  position: relative;
}
.cal-day.empty { pointer-events: none; }
.cal-day.unavailable { color: var(--line); pointer-events: none; }
.cal-day.past { color: var(--line); pointer-events: none; }
.cal-day.available { font-weight: 600; color: var(--primary); background: var(--primary-light); }
.cal-day.available:hover { background: #c9dbf8; }
.cal-day.selected {
  background: var(--primary); color: #fff; font-weight: 700;
}
.cal-day.today::after {
  content: '';
  position: absolute; bottom: 3px; left: 50%; transform: translateX(-50%);
  width: 4px; height: 4px; border-radius: 50%; background: currentColor;
}

/* ── SLOTS ─────────────────────────────────────────── */
.selected-date-label {
  font-weight: 600; color: var(--text); margin: -.5rem 0 .75rem;
}
.link-btn {
  background: none; border: none; padding: 0; cursor: pointer;
  color: var(--muted); font-size: .85rem; margin-left: auto;
}
.link-btn:hover { color: var(--danger); }

.slots-grid {
  display: flex;
  flex-direction: column;
  gap: .45rem;
  max-height: 360px;
  overflow-y: auto;
  padding-right: 4px;
}

.slots-grid::-webkit-scrollbar {
  width: 4px;
}
.slots-grid::-webkit-scrollbar-track {
  background: transparent;
}
.slots-grid::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 4px;
}

.slot-btn {
  padding: .55rem .5rem;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: var(--card-bg);
  font-weight: 600; font-size: .85rem;
  cursor: pointer;
  text-align: center;
  transition: border-color .12s, background .12s, color .12s;
  color: var(--text);
}
.slot-btn:hover { border-color: var(--primary); background: var(--primary-light); color: var(--primary); }
.slot-btn.selected { border-color: var(--primary); background: var(--primary); color: #fff; }

/* ── BOOKING FORM ──────────────────────────────────── */
.booking-summary {
  background: var(--primary-light);
  border-radius: 8px;
  padding: .85rem 1rem;
  font-size: .875rem;
}
.booking-summary-row { display: flex; align-items: center; gap: .6rem; margin-bottom: .35rem; color: var(--primary); }
.booking-summary-row:last-child { margin-bottom: 0; }
.booking-summary-row i { width: 1rem; text-align: center; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 1rem;
}
.form-row-stretch {
  align-items: stretch;
}
.form-row-stretch > .field {
  flex: 1;
}
.form-row-stretch .field-input,
.form-row-stretch .guest-emails-container {
  flex: 1;
  height: 120px;
}
.form-row-stretch textarea.field-input {
  resize: none;
}
.form-row-stretch .guest-emails-container {
  overflow-y: auto;
}
@media (max-width: 500px) {
  .form-row { grid-template-columns: 1fr; }
}
.field { display: flex; flex-direction: column; }
.field-label { font-size: .85rem; font-weight: 600; margin-bottom: .35rem; }
.field-input {
  border: 1.5px solid var(--line);
  border-radius: 8px;
  padding: .65rem .75rem;
  font-size: .9rem;
  font-family: inherit;
  color: var(--text);
  transition: border-color .15s;
  outline: none;
  resize: vertical;
}
.field-input:focus { border-color: var(--primary); }
.field-input.error { border-color: var(--danger); }
.text-muted-label { font-weight: 400; color: var(--muted); }

.form-error {
  background: #fef3f2; border: 1px solid #fecdca;
  color: var(--danger); border-radius: 8px;
  padding: .65rem .85rem; font-size: .85rem;
}

/* ── BUTTONS ───────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  font-weight: 600; font-size: .9rem;
  padding: .7rem 1.25rem;
  border-radius: 8px;
  border: none; cursor: pointer;
  transition: opacity .15s, transform .1s;
  font-family: inherit;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .55; pointer-events: none; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--line);
  color: var(--text);
}
.btn-outline:hover { border-color: var(--text); }

.btn-danger-outline { border-color: var(--danger); color: var(--danger); }
.btn-danger-outline:hover { background: #fef3f2; }

.btn-block { width: 100%; margin-top: 1.5rem; }

.btn-spinner {
  width: 1rem; height: 1rem;
  border: 2px solid rgba(255,255,255,.45);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .6s linear infinite;
  display: inline-block;
}

.mt-2 { margin-top: .5rem; }
.mt-4 { margin-top: 1rem; }
.mb-1 { margin-bottom: .25rem; }
.mb-3 { margin-bottom: .75rem; }
.mb-4 { margin-bottom: 1rem; }
.my-3 { margin-top: .75rem; margin-bottom: .75rem; }
.me-1 { margin-right: .25rem; }
.hidden { display: none !important; }
.text-muted { color: var(--muted); }
.text-danger { color: var(--danger); }
.small { font-size: .85rem; }

/* ── CONFIRMATION ──────────────────────────────────── */
.confirm-icon {
  font-size: 3.5rem;
  color: var(--ok);
  margin-bottom: .75rem;
}
.confirm-details {
  background: var(--card-bg);
  border-radius: 10px;
  padding: 1rem;
  text-align: left;
  font-size: .875rem;
  width: 100%;
}
.confirm-detail-row {
  display: flex; align-items: flex-start; gap: .6rem;
  padding: .35rem 0;
  border-bottom: 1px solid var(--line);
}
.confirm-detail-row:last-child { border-bottom: none; }
.confirm-detail-row i { color: var(--primary); margin-top: .1rem; width: 1rem; text-align: center; }
.confirm-detail-label { font-size: .78rem; color: var(--muted); display: block; }
.confirm-detail-value { font-weight: 600; }

/* ── BOOKING TOKEN STATUS ──────────────────────────── */
.status-chip {
  display: inline-flex; align-items: center; gap: .3rem;
  font-size: .78rem; font-weight: 600;
  padding: .2rem .7rem;
  border-radius: 100px;
}
.status-confirmed  { background: #ecfdf3; color: #067647; }
.status-pending    { background: #fefce8; color: #854d0e; }
.status-cancelled  { background: #fef2f2; color: #991b1b; }
.status-completed  { background: #eff6ff; color: #1e40af; }
.status-rescheduled{ background: #f0fdf4; color: #166534; }
.status-no_show    { background: #f9fafb; color: #374151; }

hr { border: none; border-top: 1px solid var(--line); }
h2 { margin: 0 0 .5rem; font-size: 1.3rem; }
h3 { margin: 0 0 .75rem; font-size: 1rem; font-weight: 600; }
p { margin: 0 0 .5rem; line-height: 1.5; }

/* ── CANCEL MODAL ──────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
  animation: fadeIn .15s ease;
}
.modal-overlay.hidden { display: none; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-box {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0,0,0,.2);
  padding: 2rem 1.5rem 1.5rem;
  max-width: 380px; width: 100%;
  text-align: center;
  animation: slideUp .2s ease;
}
@keyframes slideUp { from { transform: translateY(12px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.modal-icon {
  width: 3rem; height: 3rem;
  background: #fef3f2;
  color: var(--danger);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.25rem;
  margin: 0 auto 1rem;
}
.modal-title { font-size: 1.1rem; font-weight: 700; margin-bottom: .5rem; color: var(--text); }
.modal-body { color: var(--muted); font-size: .9rem; margin-bottom: 1rem; }
.modal-actions { display: flex; gap: .75rem; justify-content: center; margin-top: 1.25rem; }
.modal-actions .btn { flex: 1; }
.btn-danger { background: var(--danger); color: #fff; border: none; }
.btn-danger:hover { background: #b91c1c; }


/* ═══════════════════════════════════════════════════════
   RESPONSIVE — Stack on mobile
═══════════════════════════════════════════════════════ */

@media (max-width: 700px) {
  .main-content,
  .main-content.has-slots {
    max-width: 100%;
    padding: 0 .75rem 3rem;
  }

  .bk-split-card {
    flex-direction: column;
    min-height: auto;
  }

  .bk-split-left {
    width: 100%;
    min-width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--line);
    padding: 1.25rem 1.25rem 1rem;
  }

  .bk-split-right {
    padding: 1.25rem;
  }

  .bk-right-inner {
    flex-direction: column;
  }

  .bk-right-inner.show-slots .bk-slots-section {
    border-left: none;
    padding-left: 0;
    border-top: 1px solid var(--line);
    padding-top: 1rem;
    margin-top: 1rem;
  }

  .bk-calendar-section {
    min-width: 0;
    max-width: 100%;
  }

  .bk-form-right {
    max-height: none;
  }

  .bk-member-photo {
    width: 40px;
    height: 40px;
  }

  .bk-event-title {
    font-size: 1.15rem;
  }

  .slots-grid {
    max-height: none;
  }
}

/* ── GUEST EMAILS ──────────────────────────────────── */
.guest-emails-container {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  align-content: flex-start;
  gap: 6px;
  min-height: 72px;
  padding: 10px 12px;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: #fff;
  cursor: text;
  transition: border-color .15s;
}
.guest-emails-container:focus-within {
  border-color: var(--primary);
}
#guestEmailHint {
  padding-top: .5rem;
}
.guest-email-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.guest-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--primary-light);
  color: var(--text);
  border-radius: 20px;
  font-size: .85rem;
  line-height: 1.3;
}
.guest-tag-remove {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(0,0,0,.1);
  font-size: .7rem;
  color: var(--text);
  line-height: 1;
  transition: background .15s;
}
.guest-tag-remove:hover {
  background: rgba(0,0,0,.2);
}
.guest-email-input {
  flex: 1 1 180px;
  min-width: 180px;
  border: none;
  outline: none;
  font-size: .95rem;
  padding: 4px 0;
  background: transparent;
  color: var(--text);
}
.guest-email-input::placeholder {
  color: var(--muted);
}

/* ── LEGAL NOTICE (inline, before/after button) ───── */
.legal-notice {
  text-align: center;
  font-size: .78rem;
  color: var(--muted);
  line-height: 1.55;
  margin: 1.25rem 0 .5rem;
  padding: 0 .5rem;
}
.legal-notice a {
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
}
.legal-notice a:hover {
  text-decoration: underline;
}

/* ── FOOTER ────────────────────────────────────────── */
.site-footer {
  text-align: center;
  padding: 1.5rem 1rem 2rem;
  font-size: .78rem;
  color: var(--muted);
}
.footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px;
  margin-bottom: .5rem;
}
.footer-links a {
  color: var(--muted);
  text-decoration: none;
}
.footer-links a:hover {
  color: var(--text);
  text-decoration: underline;
}
.footer-sep {
  color: var(--line);
}
.footer-copy {
  color: var(--muted);
  opacity: .7;
}
.footer-copy a {
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
}
.footer-copy a:hover {
  color: var(--text);
}
