/* OpkaldAI Online Booking — v2 polished design
   Inspired by Cal.com, Doctolib, EasyMe.
   Healthcare teal palette, micro-animations, skeleton loading. */

/* ─── Design Tokens ───────────────────────────────────────── */
:root {
  /* Healthcare teal palette – calming, professional */
  --primary: #0D9488;
  --primary-hover: #0F766E;
  --primary-light: #F0FDFA;
  --primary-subtle: #CCFBF1;
  --primary-ring: rgba(13,148,136,.25);

  /* Neutrals – warm gray */
  --bg: #F8FAFB;
  --card-bg: #FFFFFF;
  --text: #111827;
  --text-secondary: #4B5563;
  --text-muted: #9CA3AF;
  --border: #E5E7EB;
  --border-hover: #D1D5DB;
  --border-focus: #0D9488;

  /* Feedback */
  --success: #059669;
  --success-bg: #ECFDF5;
  --error: #DC2626;
  --error-bg: #FEF2F2;
  --warning: #D97706;
  --warning-bg: #FFFBEB;

  /* Shadows — layered for depth */
  --shadow-xs: 0 1px 2px rgba(0,0,0,.04);
  --shadow-sm: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.07), 0 2px 4px -2px rgba(0,0,0,.05);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.08), 0 4px 6px -4px rgba(0,0,0,.04);

  /* Radii */
  --radius: 14px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --radius-full: 9999px;

  /* Easings */
  --ease-out: cubic-bezier(.33,1,.68,1);
  --ease-out-back: cubic-bezier(.34,1.56,.64,1);
  --ease-in-out: cubic-bezier(.65,0,.35,1);

  /* Durations */
  --dur-fast: 100ms;
  --dur-normal: 200ms;
  --dur-slow: 300ms;
  --dur-enter: 350ms;
}

/* ─── Reset & Base ────────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Respect reduced-motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ─── Layout ──────────────────────────────────────────────── */
.booking-container {
  max-width: 480px;
  margin: 0 auto;
  padding: 20px 16px 80px;
  min-height: 100vh;
}

/* ─── Card ────────────────────────────────────────────────── */
.booking-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  /* Step entrance animation */
  animation: cardEnter var(--dur-enter) var(--ease-out) both;
}

@keyframes cardEnter {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.card-body { padding: 24px 20px; }

/* ─── Clinic Header ───────────────────────────────────────── */
.clinic-header {
  text-align: center;
  padding: 28px 20px 18px;
  background: linear-gradient(180deg, var(--primary-light) 0%, var(--card-bg) 100%);
}

.clinic-logo {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
  margin: 0 auto 12px;
  box-shadow: 0 2px 8px rgba(13,148,136,.3);
}

.clinic-name {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 2px;
  letter-spacing: -0.3px;
}

.clinic-address {
  font-size: 13px;
  color: var(--text-muted);
}

/* ─── Progress Steps ──────────────────────────────────────── */
.progress-container { padding: 16px 20px 0; }

.progress-steps {
  display: flex;
  align-items: center;
}

.progress-step {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}

.progress-dot {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  transition: all var(--dur-slow) var(--ease-out-back);
  position: relative;
  z-index: 1;
}

.progress-step.active .progress-dot {
  background: var(--primary);
  color: white;
  box-shadow: 0 0 0 4px var(--primary-ring);
  transform: scale(1.08);
}

.progress-step.completed .progress-dot {
  background: var(--success);
  color: white;
}

.progress-step.completed .progress-dot::after { content: '✓'; font-size: 14px; }
.progress-step.completed .progress-dot span { display: none; }

.progress-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
  font-weight: 500;
  white-space: nowrap;
}

.progress-step.active .progress-label { color: var(--primary); font-weight: 600; }
.progress-step.completed .progress-label { color: var(--success); }

.progress-line {
  flex: 1;
  height: 2px;
  background: var(--border);
  margin: 0 -8px;
  position: relative;
  top: -10px;
  transition: background var(--dur-slow) var(--ease-out);
}

.progress-line.filled { background: var(--success); }

/* ─── Step Title ──────────────────────────────────────────── */
.step-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 16px;
  letter-spacing: -0.2px;
}

/* ─── Service Selection ───────────────────────────────────── */
.service-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.service-item {
  padding: 14px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--dur-normal) var(--ease-out),
              transform var(--dur-fast) var(--ease-out);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.service-item:hover {
  border-color: var(--primary);
  background: var(--primary-light);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.service-item:active { transform: scale(.98); }

.service-item.selected {
  border-color: var(--primary);
  background: var(--primary-light);
  box-shadow: 0 0 0 3px var(--primary-ring);
}

.service-name { font-size: 14px; font-weight: 600; color: var(--text); }
.service-meta { display: flex; align-items: center; gap: 10px; }
.service-duration { font-size: 12px; color: var(--text-muted); }

.service-price {
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
  background: var(--primary-subtle);
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

/* ─── Therapist Filter ────────────────────────────────────── */
.therapist-filter { margin-bottom: 14px; }

.therapist-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.therapist-chip {
  padding: 6px 12px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 500;
  border: 1.5px solid var(--border);
  background: white;
  cursor: pointer;
  transition: all var(--dur-normal) var(--ease-out);
  color: var(--text-secondary);
}

.therapist-chip:hover { border-color: var(--primary); color: var(--primary); }

.therapist-chip.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  box-shadow: 0 2px 6px rgba(13,148,136,.25);
}

/* ─── Date Chips ──────────────────────────────────────────── */
.date-chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 14px;
  margin-bottom: 12px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  scroll-snap-type: x mandatory;
}

.date-chips::-webkit-scrollbar { display: none; }

.date-chip {
  flex-shrink: 0;
  padding: 10px 8px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: white;
  cursor: pointer;
  text-align: center;
  transition: all var(--dur-normal) var(--ease-out),
              transform var(--dur-fast) var(--ease-out-back);
  min-width: 62px;
  scroll-snap-align: start;
}

.date-chip:hover { border-color: var(--primary); transform: translateY(-1px); }
.date-chip:active { transform: scale(.95); }

.date-chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
  box-shadow: 0 3px 10px rgba(13,148,136,.3);
  transform: translateY(-2px);
}

.date-chip-day {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  opacity: 0.65;
}

.date-chip.active .date-chip-day { opacity: .85; }

.date-chip-date { font-size: 16px; font-weight: 700; margin-top: 2px; }

.date-chip-slots {
  font-size: 9px;
  font-weight: 500;
  opacity: 0.55;
  margin-top: 3px;
}

/* ─── Time Slots ──────────────────────────────────────────── */
.slots-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 380px;
  overflow-y: auto;
  scroll-behavior: smooth;
}

.slot-item {
  padding: 13px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--dur-normal) var(--ease-out),
              transform var(--dur-fast) var(--ease-out);
  display: flex;
  justify-content: space-between;
  align-items: center;
  /* Staggered entrance */
  animation: slotEnter var(--dur-slow) var(--ease-out) both;
}

.slot-item:nth-child(1)  { animation-delay: 0ms; }
.slot-item:nth-child(2)  { animation-delay: 30ms; }
.slot-item:nth-child(3)  { animation-delay: 60ms; }
.slot-item:nth-child(4)  { animation-delay: 90ms; }
.slot-item:nth-child(5)  { animation-delay: 120ms; }
.slot-item:nth-child(n+6){ animation-delay: 150ms; }

@keyframes slotEnter {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.slot-item:hover {
  border-color: var(--primary);
  background: var(--primary-light);
  transform: translateX(3px);
}

.slot-item:active { transform: scale(.98); }

.slot-item.selected {
  border-color: var(--primary);
  background: var(--primary-light);
  box-shadow: 0 0 0 3px var(--primary-ring);
}

.slot-time { font-size: 15px; font-weight: 700; color: var(--text); }

.slot-end-time {
  font-size: 13px;
  color: var(--text-muted);
  margin-left: 4px;
  font-weight: 400;
}

.slot-therapist {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
  background: var(--bg);
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.no-slots {
  text-align: center;
  padding: 40px 16px;
  color: var(--text-muted);
  font-size: 14px;
}

/* ─── Forms ───────────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.form-input {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xs);
  font-size: 15px;
  color: var(--text);
  transition: border-color var(--dur-normal) var(--ease-out),
              box-shadow var(--dur-normal) var(--ease-out);
  background: white;
  font-family: inherit;
}

.form-input:hover { border-color: var(--border-hover); }

.form-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-ring);
}

.form-input::placeholder { color: var(--text-muted); }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

textarea.form-input { resize: vertical; min-height: 72px; }

select.form-input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

/* ─── Checkboxes ──────────────────────────────────────────── */
.form-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 10px;
}

.form-check input[type="checkbox"] {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  accent-color: var(--primary);
  flex-shrink: 0;
  margin-top: 2px;
  cursor: pointer;
}

.form-check label {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.4;
  cursor: pointer;
}

.form-check a { color: var(--primary); text-decoration: none; }

/* ─── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 13px 24px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--dur-normal) var(--ease-out),
              transform var(--dur-fast) var(--ease-out);
  border: none;
  font-family: inherit;
  gap: 8px;
  width: 100%;
}

.btn-primary {
  background: var(--primary);
  color: white;
  box-shadow: 0 2px 6px rgba(13,148,136,.25);
}

.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(13,148,136,.3);
}

.btn-primary:active { transform: translateY(0) scale(.98); box-shadow: var(--shadow-xs); }

.btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-outline {
  background: white;
  color: var(--text-secondary);
  border: 1.5px solid var(--border);
}

.btn-outline:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

.btn-group { display: flex; gap: 10px; margin-top: 20px; }
.btn-group .btn { flex: 1; }

.btn-back {
  background: transparent;
  color: var(--text-muted);
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  padding: 8px 0;
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: inherit;
  transition: color var(--dur-fast) var(--ease-out);
}

.btn-back:hover { color: var(--text); }

/* ─── Summary Card ────────────────────────────────────────── */
.summary-card {
  background: var(--primary-light);
  border: 1px solid var(--primary-subtle);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-bottom: 18px;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 13px;
}

.summary-label { color: var(--text-muted); font-weight: 500; }
.summary-value { color: var(--text); font-weight: 600; text-align: right; }

/* ─── Success / Confirmation ──────────────────────────────── */
.success-container {
  text-align: center;
  padding: 36px 16px;
}

.success-icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--success-bg);
  color: var(--success);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  margin: 0 auto 18px;
  animation: successPop 0.5s var(--ease-out-back) both;
  box-shadow: 0 4px 12px rgba(5,150,105,.15);
}

@keyframes successPop {
  0%   { transform: scale(0); opacity: 0; }
  60%  { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); }
}

.success-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
  animation: fadeUp var(--dur-enter) var(--ease-out) 0.2s both;
}

.success-message {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 28px;
  line-height: 1.6;
  animation: fadeUp var(--dur-enter) var(--ease-out) 0.3s both;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─── Error Banner ────────────────────────────────────────── */
.error-banner {
  background: var(--error-bg);
  border: 1px solid #FCA5A5;
  border-radius: var(--radius-xs);
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--error);
  display: flex;
  align-items: center;
  gap: 8px;
  animation: shakeBanner 0.4s var(--ease-out);
}

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

/* ─── Loading ─────────────────────────────────────────────── */
.loading-spinner {
  display: inline-block;
  width: 22px;
  height: 22px;
  border: 2.5px solid var(--primary-subtle);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
}

.loading-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 44px 16px;
  gap: 14px;
}

.loading-text { font-size: 14px; color: var(--text-muted); }

@keyframes spin { to { transform: rotate(360deg); } }

/* Skeleton loading */
.skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e8e8e8 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-xs);
}

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ─── Footer ──────────────────────────────────────────────── */
.booking-footer {
  text-align: center;
  padding: 28px 16px;
  font-size: 12px;
  color: var(--text-muted);
}

.booking-footer a { color: var(--text-muted); text-decoration: none; }
.booking-footer a:hover { color: var(--primary); }

/* ─── Section Divider ─────────────────────────────────────── */
.section-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 18px 0;
}

/* ─── Responsive ──────────────────────────────────────────── */
@media (max-width: 480px) {
  .booking-container { padding: 8px 8px 60px; }
  .card-body { padding: 20px 16px; }
  .clinic-header { padding: 24px 16px 14px; }
  .progress-label { font-size: 10px; }
  .form-row { grid-template-columns: 1fr; }
  .form-input { font-size: 16px; /* prevent zoom on iOS */ }
}

@media (min-width: 640px) {
  .booking-container { padding: 32px 16px 80px; }
}

/* ─── Focus Visible (accessibility) ───────────────────────── */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.service-item:focus-visible,
.slot-item:focus-visible,
.date-chip:focus-visible,
.therapist-chip:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
