/* ================================================================
   Service Appointment Pro – Public / Frontend Styles
   version: 1.0.0
================================================================ */

/* ── CSS Custom Properties ─────────────────────────────────────── */
.sap-booking-root,
.sap-panel-root {
  --sap-primary: #10b981;
  --sap-primary-dark: #059669;
  --sap-primary-light: #d1fae5;
  --sap-danger: #ef4444;
  --sap-warning: #f59e0b;
  --sap-info: #3b82f6;
  --sap-text: #1f2937;
  --sap-text-light: #6b7280;
  --sap-border: #e5e7eb;
  --sap-bg: #f9fafb;
  --sap-card-bg: #ffffff;
  --sap-radius: 12px;
  --sap-radius-sm: 8px;
  --sap-shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --sap-shadow-md: 0 4px 6px -1px rgba(0,0,0,.1);
  --sap-transition: all .2s ease;

  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--sap-text);
  line-height: 1.6;
  box-sizing: border-box;
}

.sap-booking-root *,
.sap-panel-root * {
  box-sizing: border-box;
}

/* ─────────────────────────────────────────────────────────────────
   STEP PROGRESS BAR
───────────────────────────────────────────────────────────────── */
.sap-steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin: 0 0 32px;
  padding: 0;
  list-style: none;
}

.sap-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

.sap-step-circle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--sap-border);
  color: var(--sap-text-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  transition: var(--sap-transition);
}

.sap-step.active .sap-step-circle,
.sap-step.done .sap-step-circle {
  background: var(--sap-primary);
  color: #fff;
}

.sap-step-label {
  font-size: 12px;
  color: var(--sap-text-light);
  font-weight: 500;
  white-space: nowrap;
}
.sap-step.active .sap-step-label {
  color: var(--sap-primary);
  font-weight: 600;
}

.sap-step-line {
  flex: 1;
  height: 2px;
  background: var(--sap-border);
  max-width: 80px;
  min-width: 24px;
  margin-bottom: 20px;
  transition: var(--sap-transition);
}
.sap-step-line.done {
  background: var(--sap-primary);
}

/* ─────────────────────────────────────────────────────────────────
   STEP PANELS
───────────────────────────────────────────────────────────────── */
.sap-step-panel { display: none; }
.sap-step-panel.active { display: block; }

.sap-section-title {
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 20px;
  color: var(--sap-text);
}
.sap-section-sub {
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 14px;
  color: var(--sap-text);
}

/* ─────────────────────────────────────────────────────────────────
   CATEGORY TABS
───────────────────────────────────────────────────────────────── */
.sap-category-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0 0 20px;
}

.sap-cat-tab {
  padding: 8px 18px;
  border-radius: 24px;
  border: 2px solid var(--sap-border);
  background: transparent;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--sap-text-light);
  transition: var(--sap-transition);
}
.sap-cat-tab:hover {
  border-color: var(--sap-primary);
  color: var(--sap-primary);
}
.sap-cat-tab.active {
  background: var(--sap-primary);
  border-color: var(--sap-primary);
  color: #fff;
}

/* ─────────────────────────────────────────────────────────────────
   VIEW TOGGLE (Services / Packages)
───────────────────────────────────────────────────────────────── */
.sap-view-toggle {
  display: flex;
  background: var(--sap-border);
  border-radius: 8px;
  padding: 3px;
  gap: 3px;
  width: fit-content;
  margin: 0 0 20px;
}

.sap-toggle-btn {
  padding: 6px 18px;
  border: none;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--sap-text-light);
  transition: var(--sap-transition);
}
.sap-toggle-btn.active {
  background: white;
  color: var(--sap-primary);
  box-shadow: var(--sap-shadow);
}

/* ─────────────────────────────────────────────────────────────────
   SERVICE CARDS
───────────────────────────────────────────────────────────────── */
.sap-service-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.sap-service-card {
  background: var(--sap-card-bg);
  border: 2px solid var(--sap-border);
  border-radius: var(--sap-radius);
  padding: 0;
  cursor: pointer;
  transition: var(--sap-transition);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.sap-service-card:hover {
  border-color: var(--sap-primary);
  box-shadow: var(--sap-shadow-md);
  transform: translateY(-2px);
}
.sap-service-card.selected {
  border-color: var(--sap-primary);
  background: var(--sap-primary-light);
}

.sap-service-img {
  width: 100%;
  height: 140px;
  object-fit: cover;
  background: var(--sap-bg);
}

.sap-service-img-placeholder {
  width: 100%;
  height: 140px;
  background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
}

.sap-card-body {
  padding: 14px;
  flex: 1;
}

.sap-service-name {
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 6px;
}
.sap-service-short-desc {
  font-size: 13px;
  color: var(--sap-text-light);
  margin: 0 0 10px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.sap-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.sap-service-price {
  font-size: 16px;
  font-weight: 700;
  color: var(--sap-primary);
}
.sap-service-duration {
  font-size: 12px;
  color: var(--sap-text-light);
  background: var(--sap-bg);
  padding: 3px 8px;
  border-radius: 12px;
}

.sap-card-check {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 26px;
  height: 26px;
  background: var(--sap-primary);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  opacity: 0;
  transition: var(--sap-transition);
}
.sap-service-card.selected .sap-card-check { opacity: 1; }
.sap-service-card { position: relative; }

/* ─────────────────────────────────────────────────────────────────
   STAFF CARDS
───────────────────────────────────────────────────────────────── */
.sap-staff-select-wrap {
  margin-bottom: 24px;
}

.sap-staff-cards {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.sap-staff-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 16px;
  border: 2px solid var(--sap-border);
  border-radius: var(--sap-radius-sm);
  cursor: pointer;
  transition: var(--sap-transition);
  min-width: 100px;
  text-align: center;
}
.sap-staff-card:hover { border-color: var(--sap-primary); }
.sap-staff-card.selected { border-color: var(--sap-primary); background: var(--sap-primary-light); }

.sap-staff-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--sap-bg);
}
.sap-staff-avatar-placeholder {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--sap-primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: var(--sap-primary);
  font-weight: 600;
}
.sap-staff-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--sap-text);
}

/* ─────────────────────────────────────────────────────────────────
   CALENDAR
───────────────────────────────────────────────────────────────── */
.sap-cal-wrapper {
  background: var(--sap-card-bg);
  border: 1px solid var(--sap-border);
  border-radius: var(--sap-radius);
  padding: 20px;
  max-width: 380px;
  margin: 0 0 24px;
}

.sap-cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.sap-cal-title {
  font-weight: 600;
  font-size: 15px;
}
.sap-cal-nav {
  background: none;
  border: 1px solid var(--sap-border);
  border-radius: 6px;
  width: 32px;
  height: 32px;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--sap-transition);
}
.sap-cal-nav:hover { background: var(--sap-bg); }

.sap-pub-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.sap-pub-cal-grid .day-header {
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--sap-text-light);
  padding: 4px 0;
}

.sap-cal-day-cell {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  font-size: 13px;
  cursor: default;
  transition: var(--sap-transition);
}
.sap-cal-day-cell.other-month { color: #d1d5db; }
.sap-cal-day-cell.today { font-weight: 700; outline: 2px solid var(--sap-primary); }
.sap-cal-day-cell.available {
  cursor: pointer;
  color: var(--sap-text);
}
.sap-cal-day-cell.available:hover {
  background: var(--sap-primary-light);
  color: var(--sap-primary);
}
.sap-cal-day-cell.selected {
  background: var(--sap-primary);
  color: #fff;
  font-weight: 700;
}
.sap-cal-day-cell.unavailable {
  color: #d1d5db;
  text-decoration: line-through;
}
.sap-cal-day-cell.past { color: #d1d5db; }

/* ─────────────────────────────────────────────────────────────────
   TIME SLOTS
───────────────────────────────────────────────────────────────── */
.sap-slots-grid {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px 0 24px;
}

.sap-slot-btn {
  padding: 8px 16px;
  border: 2px solid var(--sap-border);
  border-radius: 8px;
  background: white;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: var(--sap-transition);
  color: var(--sap-text);
}
.sap-slot-btn:hover:not(:disabled) {
  border-color: var(--sap-primary);
  color: var(--sap-primary);
}
.sap-slot-btn.selected {
  background: var(--sap-primary);
  border-color: var(--sap-primary);
  color: white;
}
.sap-slot-btn:disabled {
  background: var(--sap-bg);
  color: #d1d5db;
  cursor: not-allowed;
  text-decoration: line-through;
}

/* ─────────────────────────────────────────────────────────────────
   FORM FIELDS
───────────────────────────────────────────────────────────────── */
.sap-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

.sap-field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.sap-field-group.full-width {
  grid-column: 1 / -1;
}

.sap-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--sap-text);
}

.sap-field {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--sap-border);
  border-radius: 8px;
  font-size: 14px;
  color: var(--sap-text);
  outline: none;
  transition: var(--sap-transition);
  background: white;
  font-family: inherit;
}
.sap-field:focus { border-color: var(--sap-primary); box-shadow: 0 0 0 3px rgba(16,185,129,.1); }
.sap-field.error { border-color: var(--sap-danger); }
textarea.sap-field { resize: vertical; }

.sap-field-error {
  font-size: 12px;
  color: var(--sap-danger);
  display: none;
}
.sap-field-error.visible { display: block; }

/* ─────────────────────────────────────────────────────────────────
   SUMMARY CARD
───────────────────────────────────────────────────────────────── */
.sap-summary-card {
  background: var(--sap-card-bg);
  border: 1px solid var(--sap-border);
  border-radius: var(--sap-radius);
  padding: 20px;
  margin-bottom: 24px;
}

.sap-summary-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 8px 0;
  font-size: 14px;
}
.sap-summary-label { color: var(--sap-text-light); }
.sap-summary-value { font-weight: 500; text-align: right; max-width: 60%; }
.sap-summary-row.total .sap-summary-label,
.sap-summary-row.total .sap-summary-value {
  font-size: 17px;
  font-weight: 700;
  color: var(--sap-text);
}
.sap-summary-row.deposit .sap-summary-value {
  color: var(--sap-primary);
  font-size: 16px;
  font-weight: 700;
}
.sap-summary-divider {
  border-top: 1px solid var(--sap-border);
  margin: 8px 0;
}

/* ─────────────────────────────────────────────────────────────────
   PAYMENT METHODS
───────────────────────────────────────────────────────────────── */
.sap-payment-section {
  margin-bottom: 24px;
}

.sap-payment-methods {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.sap-payment-method-card {
  flex: 1;
  min-width: 150px;
  padding: 16px;
  border: 2px solid var(--sap-border);
  border-radius: var(--sap-radius-sm);
  cursor: pointer;
  transition: var(--sap-transition);
  text-align: center;
}
.sap-payment-method-card:hover { border-color: var(--sap-primary); }
.sap-payment-method-card.selected {
  border-color: var(--sap-primary);
  background: var(--sap-primary-light);
}

.sap-pay-logo {
  height: 32px;
  object-fit: contain;
  margin-bottom: 8px;
}
.sap-pay-name {
  font-size: 13px;
  font-weight: 600;
}
.sap-pay-desc {
  font-size: 11px;
  color: var(--sap-text-light);
  margin-top: 4px;
}

/* ─────────────────────────────────────────────────────────────────
   BUTTONS
───────────────────────────────────────────────────────────────── */
.sap-step-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 16px;
  border-top: 1px solid var(--sap-border);
  margin-top: 16px;
}

.sap-btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 11px 24px;
  background: var(--sap-primary);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--sap-transition);
  text-decoration: none;
  font-family: inherit;
}
.sap-btn-primary:hover { background: var(--sap-primary-dark); }
.sap-btn-primary:disabled {
  background: #9ca3af;
  cursor: not-allowed;
}

.sap-btn-outline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 11px 24px;
  background: transparent;
  color: var(--sap-text-light);
  border: 2px solid var(--sap-border);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--sap-transition);
  text-decoration: none;
  font-family: inherit;
}
.sap-btn-outline:hover { border-color: var(--sap-primary); color: var(--sap-primary); }

.sap-btn-danger {
  display: inline-flex;
  align-items: center;
  padding: 7px 14px;
  background: #fee2e2;
  color: var(--sap-danger);
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--sap-transition);
  font-family: inherit;
}
.sap-btn-danger:hover { background: var(--sap-danger); color: white; }

.sap-btn-sm { padding: 6px 12px; font-size: 12px; }

/* ─────────────────────────────────────────────────────────────────
   NOTICE BANNER
───────────────────────────────────────────────────────────────── */
.sap-notice {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 14px;
}
.sap-notice.error, .sap-notice[data-type="error"] { background: #fee2e2; color: #b91c1c; border: 1px solid #fca5a5; }
.sap-notice.success, .sap-notice[data-type="success"] { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.sap-notice.warning { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }

/* ─────────────────────────────────────────────────────────────────
   BOOKING CONFIRMATION SCREEN
───────────────────────────────────────────────────────────────── */
.sap-confirm-wrap {
  text-align: center;
  padding: 48px 24px;
}

.sap-confirm-icon {
  width: 72px;
  height: 72px;
  background: var(--sap-primary-light);
  color: var(--sap-primary);
  font-size: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
}
.sap-confirm-title {
  font-size: 26px;
  font-weight: 700;
  margin: 0 0 10px;
}
.sap-confirm-sub {
  color: var(--sap-text-light);
  margin: 0 0 24px;
}
.sap-confirm-detail {
  background: var(--sap-bg);
  border-radius: var(--sap-radius-sm);
  padding: 16px 20px;
  display: inline-block;
  text-align: left;
  min-width: 280px;
  margin-bottom: 24px;
  font-size: 14px;
  line-height: 1.8;
}
.sap-confirm-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

/* ─────────────────────────────────────────────────────────────────
   LOADING STATES
───────────────────────────────────────────────────────────────── */
.sap-loading-sm {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--sap-text-light);
  font-size: 14px;
}
.sap-loading-sm::before {
  content: '';
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--sap-border);
  border-top-color: var(--sap-primary);
  border-radius: 50%;
  animation: sap-spin .6s linear infinite;
}

.sap-full-loader {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,.9);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
}
.sap-spinner-large {
  width: 48px;
  height: 48px;
  border: 4px solid var(--sap-border);
  border-top-color: var(--sap-primary);
  border-radius: 50%;
  animation: sap-spin .7s linear infinite;
}

@keyframes sap-spin {
  to { transform: rotate(360deg); }
}

/* ─────────────────────────────────────────────────────────────────
   CUSTOMER PANEL
───────────────────────────────────────────────────────────────── */
.sap-panel-card {
  background: var(--sap-card-bg);
  border: 1px solid var(--sap-border);
  border-radius: var(--sap-radius);
  padding: 32px;
  max-width: 440px;
  margin: 0 auto;
}
.sap-verify-card { text-align: center; }
.sap-verify-icon { font-size: 48px; margin-bottom: 12px; }
.sap-verify-card h2 { margin: 0 0 8px; }
.sap-verify-card p { color: var(--sap-text-light); margin: 0 0 24px; }
.sap-verify-form .sap-field-group { text-align: left; margin-bottom: 16px; }
.sap-submit-btn { width: 100%; }

.sap-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
}
.sap-panel-header h2 { margin: 0; }
.sap-panel-header p { margin: 4px 0 0; color: var(--sap-text-light); }

.sap-panel-empty {
  text-align: center;
  padding: 48px;
  color: var(--sap-text-light);
}
.sap-empty-icon { font-size: 48px; margin-bottom: 12px; }
.sap-panel-empty p { margin: 0 0 16px; }

/* Appointment list cards */
.sap-appt-list { display: flex; flex-direction: column; gap: 14px; }

.sap-appt-card {
  background: var(--sap-card-bg);
  border: 1px solid var(--sap-border);
  border-radius: var(--sap-radius-sm);
  padding: 16px;
  display: flex;
  gap: 16px;
  align-items: flex-start;
}
.sap-appt-left { flex: 0 0 auto; }
.sap-appt-date {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--sap-bg);
  border-radius: 8px;
  padding: 8px 12px;
  min-width: 60px;
  text-align: center;
}
.sap-appt-day { font-size: 22px; font-weight: 700; line-height: 1; }
.sap-appt-month { font-size: 11px; color: var(--sap-text-light); margin-top: 2px; }
.sap-appt-body { flex: 1; }
.sap-appt-service { margin: 0 0 4px; font-size: 15px; }
.sap-appt-meta { margin: 0 0 4px; font-size: 13px; color: var(--sap-text-light); }
.sap-appt-booking { margin: 0; font-size: 12px; color: var(--sap-text-light); }
.sap-appt-right {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}
.sap-appt-amount { font-weight: 700; font-size: 15px; }
.sap-appt-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

/* Appointment detail */
.sap-detail-card {
  background: var(--sap-card-bg);
  border: 1px solid var(--sap-border);
  border-radius: var(--sap-radius);
  padding: 24px;
}
.sap-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  font-size: 18px;
}
.sap-detail-table { width: 100%; border-collapse: collapse; margin-bottom: 16px; }
.sap-detail-table th, .sap-detail-table td { padding: 8px 12px; font-size: 14px; border-bottom: 1px solid var(--sap-border); }
.sap-detail-table th { background: var(--sap-bg); font-weight: 600; width: 35%; color: var(--sap-text-light); text-align: left; }
.sap-detail-actions { display: flex; gap: 12px; margin-top: 16px; flex-wrap: wrap; }

/* Status badge (reuse) */
.sap-status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

/* ─────────────────────────────────────────────────────────────────
   RESPONSIVE
───────────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .sap-service-cards { grid-template-columns: 1fr 1fr; }
  .sap-form-grid { grid-template-columns: 1fr; }
  .sap-field-group.full-width { grid-column: 1; }
  .sap-steps { gap: 0; }
  .sap-step-label { display: none; }
  .sap-step-line { min-width: 16px; }
  .sap-appt-card { flex-direction: column; }
  .sap-appt-left { display: flex; align-items: center; gap: 12px; }
  .sap-appt-date { flex-direction: row; gap: 6px; }
  .sap-appt-right { flex-direction: row; align-items: center; justify-content: space-between; width: 100%; }
  .sap-panel-header { flex-direction: column; gap: 12px; }
  .sap-cal-wrapper { max-width: 100%; }
}

@media (max-width: 400px) {
  .sap-service-cards { grid-template-columns: 1fr; }
}
