/* TradeBook Booking Portal */

.tradebook-booking-portal {
  --tb-primary: #3b82f6;
  --tb-primary-ring: #dbeafe;
  --tb-primary-ring: color-mix(in srgb, var(--tb-primary) 18%, white);
  font-family: inherit;
  max-width: 700px;
  margin: 0 auto;
  padding: 1rem;
}

.tb-booking-app {
  position: relative;
}

/* ---- Step Progress Indicator ---- */

.tb-steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin-bottom: 2rem;
  counter-reset: steps;
}

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

.tb-step-dot::before {
  content: '';
  position: absolute;
  top: 14px;
  left: calc(-50% + 14px);
  right: calc(50% + 14px);
  height: 2px;
  background: #e5e7eb;
}

.tb-step-dot:first-child::before {
  display: none;
}

.tb-step-dot--done::before,
.tb-step-dot--active::before {
  background: var(--tb-primary);
}

.tb-step-dot__num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #e5e7eb;
  color: #9ca3af;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  position: relative;
  z-index: 1;
}

.tb-step-dot--done .tb-step-dot__num {
  background: var(--tb-primary);
  color: #fff;
}

.tb-step-dot--active .tb-step-dot__num {
  background: var(--tb-primary);
  color: #fff;
  box-shadow: 0 0 0 4px var(--tb-primary-ring);
}

.tb-step-dot__label {
  font-size: 0.7rem;
  color: #9ca3af;
  margin-top: 4px;
}

.tb-step-dot--active .tb-step-dot__label,
.tb-step-dot--done .tb-step-dot__label {
  color: var(--tb-primary);
}

/* ---- Back Button ---- */

.tb-back {
  background: none;
  border: none;
  color: var(--tb-primary);
  cursor: pointer;
  font-size: 0.9rem;
  margin-bottom: 1rem;
  padding: 0;
}

.tb-back:hover {
  text-decoration: underline;
}

/* ---- Steps ---- */

.tb-step h2 {
  font-size: 1.4rem;
  margin-bottom: 1.25rem;
}

/* ---- Job Type List ---- */

.tb-job-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.75rem;
}

.tb-job-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.15s;
}

.tb-job-item:hover,
.tb-job-item--selected {
  border-color: var(--tb-primary);
}

.tb-job-color {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
}

.tb-job-name {
  font-weight: 600;
  flex: 1;
}

.tb-job-duration,
.tb-job-price {
  font-size: 0.85rem;
  color: #6b7280;
}

/* ---- Calendar ---- */

.tb-calendar-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.tb-calendar-nav button {
  background: none;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  color: #374151;
  cursor: pointer;
  font-size: 1.2rem;
  padding: 0.25rem 0.6rem;
}

.tb-calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.tb-calendar-header {
  text-align: center;
  font-size: 0.75rem;
  color: #6b7280;
  font-weight: 600;
  padding: 0.25rem;
}

.tb-calendar-day {
  aspect-ratio: 1;
  background: none;
  border: 1px solid transparent;
  border-radius: 50%;
  color: #111827;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.1s;
}

.tb-calendar-day--available {
  background: var(--tb-primary-ring);
  border-color: #93c5fd;
  border-color: color-mix(in srgb, var(--tb-primary) 55%, white);
}

.tb-calendar-day--available:hover {
  background: #bfdbfe;
  background: color-mix(in srgb, var(--tb-primary) 33%, white);
}

.tb-calendar-day--selected {
  background: var(--tb-primary) !important;
  border-color: var(--tb-primary) !important;
  color: #fff !important;
}

.tb-calendar-day--unavailable {
  color: #d1d5db;
  cursor: default;
}

.tb-calendar-day--today {
  font-weight: 700;
}

/* ---- Time Slots ---- */

.tb-slot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 0.5rem;
}

.tb-slot {
  border: 2px solid #e5e7eb;
  border-radius: 6px;
  background: #fff;
  color: #111827;
  cursor: pointer;
  padding: 0.6rem;
  font-size: 0.95rem;
  transition: border-color 0.15s;
}

.tb-slot:hover {
  border-color: var(--tb-primary);
}

.tb-slot--selected {
  background: var(--tb-primary);
  border-color: var(--tb-primary);
  color: #fff;
}

/* ---- Customer Form ---- */

.tb-customer-form {
  display: grid;
  gap: 1rem;
}

.tb-customer-form label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-weight: 500;
}

.tb-customer-form input,
.tb-customer-form textarea {
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 1rem;
  padding: 0.5rem 0.75rem;
  width: 100%;
  box-sizing: border-box;
}

.tb-customer-form input:focus,
.tb-customer-form textarea:focus {
  border-color: var(--tb-primary);
  outline: none;
}

/* ---- Recurrence Options ---- */

.tb-recurrence {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 1rem;
  background: #f9fafb;
}

.tb-recurrence__heading {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0 0 0.75rem;
  color: #374151;
}

.tb-recurrence__frequencies {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.tb-recurrence__freq {
  background: #fff;
  border: 2px solid #e5e7eb;
  border-radius: 20px;
  color: #111827;
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0.3rem 0.9rem;
  transition: border-color 0.15s, background 0.15s;
}

.tb-recurrence__freq:hover {
  border-color: #93c5fd;
  border-color: color-mix(in srgb, var(--tb-primary) 55%, white);
}

.tb-recurrence__freq--active {
  background: var(--tb-primary);
  border-color: var(--tb-primary);
  color: #fff;
}

.tb-recurrence__end {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  border-top: 1px solid #e5e7eb;
  padding-top: 0.75rem;
}

.tb-recurrence__end-heading {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #6b7280;
  margin-bottom: 0.1rem;
}

.tb-recurrence__end-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  font-weight: normal;
  cursor: pointer;
}

.tb-recurrence__end-option input[type="radio"] {
  width: auto;
  margin: 0;
  cursor: pointer;
}

.tb-recurrence__count {
  width: 60px !important;
  padding: 0.25rem 0.5rem !important;
  text-align: center;
}

.tb-recurrence__end-date {
  padding: 0.25rem 0.5rem !important;
  font-size: 0.9rem;
}

/* ---- Buttons ---- */

.tb-btn-primary {
  background: var(--tb-primary);
  border: none;
  border-radius: 6px;
  color: #fff;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 600;
  padding: 0.75rem 1.5rem;
  width: 100%;
}

.tb-btn-primary:disabled {
  opacity: 0.5;
  cursor: default;
}

.tb-btn-secondary {
  background: none;
  border: 2px solid var(--tb-primary);
  border-radius: 6px;
  color: var(--tb-primary);
  cursor: pointer;
  font-size: 1rem;
  padding: 0.6rem 1.25rem;
}

/* ---- Confirmation ---- */

.tb-step--confirmation {
  text-align: center;
}

.tb-confirmation-icon {
  background: #22c55e;
  border-radius: 50%;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  height: 60px;
  width: 60px;
  margin-bottom: 1rem;
}

.tb-confirmation-number {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  margin: 0.5rem 0 0.5rem;
}

.tb-confirmation-recurring {
  font-size: 0.95rem;
  color: #6b7280;
  margin-bottom: 1rem;
}

/* ---- Utilities ---- */

.tb-error {
  background: #fee2e2;
  border: 1px solid #fca5a5;
  border-radius: 6px;
  color: #dc2626;
  padding: 0.6rem 1rem;
}

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

@keyframes tb-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.tb-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid #e5e7eb;
  border-top-color: var(--tb-primary);
  border-radius: 50%;
  animation: tb-spin 0.65s linear infinite;
  flex-shrink: 0;
  display: inline-block;
}

.tb-loading {
  color: #6b7280;
  font-style: italic;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.tb-calendar-grid--loading .tb-calendar-day {
  animation: tb-pulse 1.4s ease-in-out infinite;
}

/* ---- Mobile ---- */

@media (max-width: 480px) {
  .tradebook-booking-portal {
    padding: 0.75rem;
  }

  .tb-step h2 {
    font-size: 1.2rem;
  }

  .tb-step-dot__label {
    display: none;
  }

  .tb-steps {
    margin-bottom: 1.25rem;
  }

  .tb-calendar-day {
    font-size: 0.75rem;
  }

  .tb-slot-grid {
    grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
  }

  .tb-slot {
    padding: 0.5rem 0.25rem;
    font-size: 0.85rem;
  }

  .tb-recurrence__frequencies {
    gap: 0.4rem;
  }

  .tb-recurrence__freq {
    font-size: 0.8rem;
    padding: 0.25rem 0.7rem;
  }

  .tb-recurrence__end-option {
    flex-wrap: wrap;
  }

  .tb-btn-primary {
    padding: 0.65rem 1rem;
  }

  .tb-job-item {
    padding: 0.75rem;
  }
}
