/* ============================================
   BOOKING WIDGET - Custom booking system
   Replaces external Reenio widget
   ============================================ */

/* ============================================
   MAIN CONTAINER
   ============================================ */
.booking-widget {
  max-width: 600px;
  margin: 0 auto;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* ============================================
   TOGGLE SWITCH
   ============================================ */
.booking-toggle {
  text-align: center;
  margin-bottom: 24px;
  padding: 16px;
  background: var(--color-bg-alt);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.booking-toggle label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 14px;
  color: var(--color-muted);
  font-weight: 500;
}

.booking-toggle input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: #D4861F;
}

.booking-toggle .beta-badge {
  background: linear-gradient(135deg, #D4861F, #B8710A);
  color: white;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.5px;
}

/* ============================================
   LOADING STATE
   ============================================ */
.bw-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--color-muted);
}

.bw-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: #D4861F;
  border-radius: 50%;
  animation: bw-spin 0.8s linear infinite;
  margin-bottom: 16px;
}

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

.bw-loading-text {
  font-size: 14px;
  font-weight: 500;
}

/* ============================================
   ERROR STATE
   ============================================ */
.bw-error {
  text-align: center;
  padding: 40px 20px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--radius);
  color: #991b1b;
}

.bw-error-icon {
  font-size: 32px;
  margin-bottom: 12px;
}

.bw-error-message {
  font-size: 14px;
  margin-bottom: 16px;
}

.bw-error-retry {
  background: #991b1b;
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
  font-size: 14px;
  transition: background 0.2s;
}

.bw-error-retry:hover {
  background: #7f1d1d;
}

/* ============================================
   CALENDAR
   ============================================ */
.bw-calendar {
  background: var(--color-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.bw-calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px;
  background: linear-gradient(to bottom, #fffbf7, #ffffff);
  border-bottom: 1px solid var(--border);
}

.bw-calendar-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--color-text);
  letter-spacing: 0.02em;
}

.bw-calendar-nav {
  display: flex;
  gap: 8px;
}

.bw-nav-btn {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: white;
  cursor: pointer;
  font-size: 18px;
  color: var(--color-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.bw-nav-btn:hover:not(:disabled) {
  background: linear-gradient(135deg, #D4861F, #B8710A);
  border-color: #D4861F;
  color: white;
}

.bw-nav-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.bw-calendar-grid {
  padding: 16px;
}

.bw-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 8px;
}

.bw-weekday {
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-muted);
  padding: 8px 0;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

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

.bw-day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 500;
  border-radius: 8px;
  border: none;
  background: none;
  color: var(--color-text);
  cursor: default;
  transition: all 0.15s;
}

.bw-day.other-month {
  color: var(--color-muted);
  opacity: 0.4;
}

.bw-day.today {
  border: 2px solid var(--border-strong);
}

.bw-day.available {
  background: linear-gradient(135deg, rgba(212, 134, 31, 0.1), rgba(184, 113, 10, 0.1));
  color: #B8710A;
  cursor: pointer;
  font-weight: 600;
}

.bw-day.available:hover {
  background: linear-gradient(135deg, #D4861F, #B8710A);
  color: white;
  transform: scale(1.05);
}

.bw-day.selected {
  background: linear-gradient(135deg, #D4861F, #B8710A);
  color: white;
  box-shadow: 0 4px 12px rgba(212, 134, 31, 0.3);
}

.bw-day.past {
  opacity: 0.3;
}

/* ============================================
   DATE NAVIGATION (horizontal strip)
   ============================================ */
.bw-slots-view {
  animation: bw-fadeIn 0.3s ease;
}

.bw-date-nav {
  background: var(--color-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

/* Month tabs */
.bw-month-strip {
  display: flex;
  gap: 0;
  background: linear-gradient(to bottom, #fffbf7, #ffffff);
  border-bottom: 1px solid var(--border);
  padding: 0;
}

.bw-month-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px 16px;
  background: none;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  border-bottom: 3px solid transparent;
  margin-bottom: -1px;
}

.bw-month-tab:hover {
  background: rgba(212, 134, 31, 0.05);
}

.bw-month-tab.active {
  background: rgba(212, 134, 31, 0.1);
  border-bottom-color: #D4861F;
}

.bw-month-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text);
}

.bw-month-tab.active .bw-month-name {
  color: #D4861F;
}

.bw-month-year {
  font-size: 11px;
  color: var(--color-muted);
  margin-top: 2px;
}

/* Day strip container */
.bw-day-strip-container {
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(212, 134, 31, 0.3) transparent;
  -webkit-overflow-scrolling: touch;
}

.bw-day-strip-container::-webkit-scrollbar {
  height: 6px;
}

.bw-day-strip-container::-webkit-scrollbar-track {
  background: transparent;
}

.bw-day-strip-container::-webkit-scrollbar-thumb {
  background: rgba(212, 134, 31, 0.3);
  border-radius: 3px;
}

.bw-day-strip-container::-webkit-scrollbar-thumb:hover {
  background: rgba(212, 134, 31, 0.5);
}

/* Day strip */
.bw-day-strip {
  display: flex;
  gap: 4px;
  padding: 12px 16px;
  min-width: max-content;
}

/* Day item */
.bw-day-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  height: 64px;
  padding: 6px 8px;
  background: none;
  border: 2px solid transparent;
  border-radius: 10px;
  cursor: default;
  transition: all 0.15s;
  position: relative;
}

.bw-day-item:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.bw-day-item.past {
  opacity: 0.25;
}

.bw-day-item.available {
  cursor: pointer;
  background: linear-gradient(135deg, rgba(212, 134, 31, 0.08), rgba(184, 113, 10, 0.08));
  border-color: rgba(212, 134, 31, 0.2);
}

.bw-day-item.available:hover {
  background: linear-gradient(135deg, rgba(212, 134, 31, 0.15), rgba(184, 113, 10, 0.15));
  border-color: rgba(212, 134, 31, 0.4);
  transform: translateY(-2px);
}

.bw-day-item.selected {
  background: linear-gradient(135deg, #D4861F, #B8710A);
  border-color: #D4861F;
  box-shadow: 0 4px 12px rgba(212, 134, 31, 0.35);
  transition: none; /* Instant selection change */
}

.bw-day-item.selected .bw-day-name,
.bw-day-item.selected .bw-day-num {
  color: white;
}

/* Month label on first day */
.bw-day-month-label {
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 9px;
  font-weight: 600;
  color: #D4861F;
  background: var(--color-bg);
  padding: 1px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.bw-day-item.first-of-month {
  margin-left: 8px;
}

.bw-day-item.first-of-month:first-child {
  margin-left: 0;
}

.bw-day-name {
  font-size: 10px;
  font-weight: 500;
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.bw-day-num {
  font-size: 16px;
  font-weight: 600;
  color: var(--color-text);
  margin-top: 2px;
}

.bw-day-item.available .bw-day-num {
  color: #B8710A;
}

/* Override for selected state (higher specificity) */
.bw-day-item.available.selected .bw-day-name,
.bw-day-item.available.selected .bw-day-num {
  color: white;
}

/* ============================================
   SLOTS LIST
   ============================================ */
.bw-slots {
  margin-top: 16px;
}

.bw-slots-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.bw-back-btn {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: white;
  cursor: pointer;
  font-size: 18px;
  color: var(--color-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.bw-back-btn:hover {
  background: var(--color-bg-alt);
  color: var(--color-text);
}

.bw-slots-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--color-text);
}

.bw-slots-loading {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 40px 20px;
  min-height: 120px;
}

.bw-slots-date {
  color: #D4861F;
}

.bw-slots-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.bw-slot-card {
  background: var(--color-bg);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  transition: all 0.2s;
}

.bw-slot-card:hover {
  border-color: rgba(212, 134, 31, 0.5);
  box-shadow: 0 4px 16px rgba(212, 134, 31, 0.1);
}

.bw-slot-card.selected {
  border-color: #D4861F;
  background: linear-gradient(to bottom, #fffbf7, #ffffff);
  box-shadow: 0 4px 16px rgba(212, 134, 31, 0.15);
}

.bw-slot-time {
  font-size: 20px;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 8px;
}

.bw-slot-service {
  font-size: 15px;
  color: var(--color-text);
  margin-bottom: 4px;
}

.bw-slot-price {
  font-weight: 600;
  color: #D4861F;
}

.bw-slot-staff {
  font-size: 13px;
  color: var(--color-muted);
  margin-top: 8px;
}

.bw-slot-capacity {
  display: inline-block;
  margin-top: 8px;
  font-size: 12px;
  padding: 4px 8px;
  background: var(--color-bg-alt);
  border-radius: 4px;
  color: var(--color-muted);
}

.bw-no-slots {
  text-align: center;
  padding: 40px 20px;
  color: var(--color-muted);
}

.bw-no-slots-icon {
  font-size: 32px;
  margin-bottom: 12px;
  opacity: 0.5;
}

.bw-no-slots-text {
  font-size: 14px;
}

/* ============================================
   BOOKING FORM
   ============================================ */
.bw-form {
  margin-top: 24px;
  background: var(--color-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.bw-form-header {
  padding: 20px;
  background: linear-gradient(to bottom, #fffbf7, #ffffff);
  border-bottom: 1px solid var(--border);
}

.bw-form-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 4px;
}

.bw-form-description {
  font-size: 14px;
  line-height: 1.5;
  color: var(--color-muted);
  margin: 8px 0;
  white-space: pre-line;
}

.bw-form-subtitle {
  font-size: 16px;
  font-weight: 600;
  color: var(--color-text);
  margin-top: 12px;
}

.bw-form-price {
  margin-top: 8px;
  font-size: 24px;
  font-weight: 700;
  color: #D4861F;
}

.bw-form-price-note {
  font-size: 13px;
  font-weight: 400;
  color: var(--color-muted);
}

.bw-form-body {
  padding: 24px;
}

.bw-form-group {
  margin-bottom: 20px;
}

.bw-form-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 8px;
}

.bw-form-label .required {
  color: #dc2626;
  margin-left: 2px;
}

.bw-form-input,
.bw-form-select,
.bw-form-textarea {
  width: 100%;
  padding: 12px 14px;
  font-size: 15px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: white;
  color: var(--color-text);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.bw-form-input:focus,
.bw-form-select:focus,
.bw-form-textarea:focus {
  outline: none;
  border-color: #D4861F;
  box-shadow: 0 0 0 3px rgba(212, 134, 31, 0.1);
}

.bw-form-input::placeholder,
.bw-form-textarea::placeholder {
  color: var(--color-muted);
  opacity: 0.6;
}

.bw-form-input.error,
.bw-form-select.error,
.bw-form-textarea.error {
  border-color: #dc2626;
}

.bw-form-error {
  font-size: 12px;
  color: #dc2626;
  margin-top: 4px;
}

.bw-form-textarea {
  min-height: 80px;
  resize: vertical;
}

.bw-form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%235b6275' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

/* Honeypot - hidden from users */
.bw-form-hp {
  position: absolute;
  left: -9999px;
  opacity: 0;
  pointer-events: none;
}

/* GDPR Checkbox */
.bw-form-checkbox {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.bw-form-checkbox input[type="checkbox"] {
  width: 20px;
  height: 20px;
  margin-top: 2px;
  cursor: pointer;
  accent-color: #D4861F;
  flex-shrink: 0;
}

.bw-form-checkbox label {
  font-size: 13px;
  line-height: 1.5;
  color: var(--color-text);
  cursor: pointer;
}

.bw-form-checkbox a {
  color: #D4861F;
  text-decoration: underline;
}

/* Submit Button */
.bw-form-submit {
  width: 100%;
  padding: 16px 24px;
  font-size: 16px;
  font-weight: 600;
  color: white;
  background: linear-gradient(135deg, #D4861F, #B8710A);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 12px rgba(212, 134, 31, 0.3);
}

.bw-form-submit:hover:not(:disabled) {
  background: linear-gradient(135deg, #C27A1C, #A56409);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(212, 134, 31, 0.4);
}

.bw-form-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.bw-form-submit.loading {
  position: relative;
  color: transparent;
}

.bw-form-submit.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2px solid white;
  border-top-color: transparent;
  border-radius: 50%;
  animation: bw-spin 0.8s linear infinite;
}

/* ============================================
   CONFIRMATION
   ============================================ */
.bw-confirmation {
  text-align: center;
  padding: 40px 24px;
  background: var(--color-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.bw-confirmation-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 20px;
  background: linear-gradient(135deg, #22c55e, #16a34a);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  color: white;
}

.bw-confirmation-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 8px;
}

.bw-confirmation-ref {
  font-size: 14px;
  color: var(--color-muted);
  margin-bottom: 24px;
}

.bw-confirmation-ref code {
  background: var(--color-bg-alt);
  padding: 4px 10px;
  border-radius: 6px;
  font-family: monospace;
  font-size: 15px;
  font-weight: 600;
  color: #D4861F;
}

.bw-confirmation-details {
  background: var(--color-bg-alt);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 24px;
  text-align: left;
}

.bw-confirmation-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  font-size: 14px;
}

.bw-confirmation-row:not(:last-child) {
  border-bottom: 1px solid var(--border);
}

.bw-confirmation-label {
  color: var(--color-muted);
}

.bw-confirmation-value {
  font-weight: 600;
  color: var(--color-text);
}

.bw-confirmation-total {
  font-size: 16px;
}

.bw-confirmation-total .bw-confirmation-value {
  color: #D4861F;
}

.bw-confirmation-note {
  font-size: 14px;
  color: var(--color-muted);
  line-height: 1.6;
}

.bw-confirmation-note strong {
  color: var(--color-text);
}

.bw-new-booking {
  margin-top: 24px;
  padding: 12px 24px;
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text);
  background: white;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.bw-new-booking:hover {
  background: var(--color-bg-alt);
  border-color: #D4861F;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 480px) {
  .bw-calendar-header {
    padding: 16px;
  }

  .bw-calendar-title {
    font-size: 16px;
  }

  .bw-day {
    font-size: 13px;
  }

  /* Date navigation responsive */
  .bw-month-tab {
    padding: 10px 8px;
  }

  .bw-month-name {
    font-size: 13px;
  }

  .bw-month-year {
    font-size: 10px;
  }

  .bw-day-strip {
    padding: 10px 12px;
    gap: 3px;
  }

  .bw-day-item {
    min-width: 44px;
    height: 58px;
    padding: 4px 6px;
  }

  .bw-day-num {
    font-size: 15px;
  }

  .bw-day-name {
    font-size: 9px;
  }

  .bw-day-month-label {
    font-size: 8px;
    padding: 1px 4px;
  }

  .bw-slot-time {
    font-size: 18px;
  }

  .bw-form-body {
    padding: 20px 16px;
  }

  .bw-confirmation {
    padding: 32px 16px;
  }
}

/* ============================================
   ANIMATIONS
   ============================================ */
@keyframes bw-fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.bw-form,
.bw-confirmation {
  animation: bw-fadeIn 0.3s ease;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .bw-spinner {
    animation: none;
  }

  .bw-form-submit.loading::after {
    animation: none;
  }

  .bw-slots-view,
  .bw-form,
  .bw-confirmation {
    animation: none;
  }

  .bw-day.available:hover,
  .bw-day-item.available:hover {
    transform: none;
  }
}
