/* =========================================================
   BOOKING CONFIG SCREEN - Modern UI with CSS Variables
   ========================================================= */

:root {
  /* Отступы и размеры */
  --booking-header-offset: 16px;
  --booking-section-gap: 12px;
  --booking-notes-top-margin: 24px;
  --booking-bottom-safe-area: 120px;
  
  /* Переходы и анимация */
  --booking-transition: all 0.3s ease-in-out;
  --booking-transition-fast: all 0.2s ease;
  
  /* Цвета */
  --booking-primary: #D4AF37;
  --booking-primary-light: #fff9f0;
  --booking-success: #4caf50;
  --booking-success-light: #e8f5e9;
  --booking-error: #f44336;
  --booking-error-light: #ffebee;
  --booking-info: #2196F3;
  --booking-info-light: #f0f7ff;
  --booking-text: #333;
  --booking-text-secondary: #666;
  --booking-text-tertiary: #999;
  --booking-border: #e0e0e0;
  --booking-bg-card: #ffffff;
  --booking-bg-section: #f8f9fa;
  --booking-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  --booking-shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* =========================================================
   ОСНОВНОЙ КОНТЕЙНЕР
   ========================================================= */

.booking-config-container {
  display: flex;
  flex-direction: column;
  gap: var(--booking-section-gap);
  padding: var(--booking-header-offset) 16px var(--booking-bottom-safe-area) 16px;
  min-height: 100vh;
  position: relative;
}

/* Предотвращаем наложения элементов через z-index */
.booking-config-container > * {
  position: relative;
}

/* =========================================================
   СЕКЦИЯ ПРОГРЕССА
   ========================================================= */

.progress-section {
  order: 1;
  background: var(--booking-bg-card);
  border-radius: 12px;
  padding: 16px;
  box-shadow: var(--booking-shadow);
}

.category-progress {
  margin-bottom: 8px;
}

.category-progress-list {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 8px;
  scrollbar-width: thin;
}

.category-progress-list::-webkit-scrollbar {
  height: 4px;
}

.category-progress-list::-webkit-scrollbar-thumb {
  background: var(--booking-border);
  border-radius: 2px;
}

.category-badge {
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  white-space: nowrap;
  transition: var(--booking-transition-fast);
}

.category-badge.current {
  background: var(--booking-primary);
  color: white;
  font-weight: bold;
}

.category-badge.completed {
  background: var(--booking-success);
  color: white;
  font-weight: 600;
}

.category-badge.pending {
  background: var(--booking-border);
  color: var(--booking-text-secondary);
  font-weight: normal;
}

.previous-bookings-summary {
  display: none;
  background: var(--booking-info-light);
  border: 1px solid var(--booking-info);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 8px;
}

.previous-bookings-summary.visible {
  display: block;
}

.summary-title {
  font-size: 13px;
  font-weight: 600;
  color: #1976D2;
  margin-bottom: 8px;
}

.summary-list {
  font-size: 12px;
  color: var(--booking-text);
}

.summary-item {
  margin-bottom: 6px;
}

.progress-text {
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
  font-size: 14px;
  color: var(--booking-text-secondary);
  margin-bottom: 6px;
}

.progress-bar-container {
  width: 100%;
  height: 6px;
  background: #f0f0f0;
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: var(--booking-primary);
  transition: width 0.3s ease;
}

/* =========================================================
   СЕКЦИЯ МАСТЕРА
   ========================================================= */

.master-section {
  order: 2;
  padding: 16px;
  background: var(--booking-bg-section);
  border-radius: 12px;
  box-shadow: var(--booking-shadow);
}

.section-title {
  margin-bottom: 10px;
  color: var(--booking-text);
  font-size: 16px;
}

.master-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.master-avatar {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: var(--booking-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 20px;
  font-weight: bold;
  flex-shrink: 0;
}

.master-details {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.master-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--booking-text);
}

.master-specialization {
  font-size: 14px;
  color: var(--booking-text-secondary);
}

/* =========================================================
   СЕКЦИЯ УСЛУГ
   ========================================================= */

.services-section {
  order: 3;
  background: var(--booking-bg-card);
  border-radius: 12px;
  padding: 16px;
  box-shadow: var(--booking-shadow);
}

.services-list {
  background: transparent;
  border: none;
  padding: 0;
}

.service-item {
  display: flex;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid #f0f0f0;
}

.service-item:last-child {
  border-bottom: none;
}

.service-checkbox {
  margin-right: 12px;
  width: 18px;
  height: 18px;
  accent-color: var(--booking-primary);
  cursor: pointer;
}

.service-details {
  flex: 1;
}

.service-name {
  font-size: 14px;
  color: var(--booking-text);
}

.service-meta {
  font-size: 12px;
  color: var(--booking-text-secondary);
}

/* =========================================================
   СЕКЦИЯ КАЛЕНДАРЯ И ВРЕМЕНИ
   ========================================================= */

.datetime-section {
  order: 4;
  display: flex;
  flex-direction: column;
  width: 100%;
  background: var(--booking-bg-card);
  border-radius: 12px;
  padding: 16px;
  box-shadow: var(--booking-shadow);
}

.calendar-legend {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
  font-size: 12px;
}

.legend-row {
  display: flex;
  gap: 24px;
  justify-content: flex-start;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

.legend-color {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  display: inline-block;
}

.legend-free {
  background: var(--booking-success);
}

.legend-few {
  background: #ffc107;
}

.legend-busy {
  background: var(--booking-error);
}

.legend-off {
  background: var(--booking-border);
}

.legend-text {
  color: var(--booking-text-secondary);
}

.client-calendar {
  width: 100%;
  min-height: 360px;
  max-height: 480px;
  overflow-y: auto;
  margin-bottom: 16px;
  background: white;
  border-radius: 8px;
  padding: 8px;
}

.client-calendar .fc {
  height: auto !important;
}

.client-calendar .fc-view-harness {
  height: auto !important;
  overflow: visible !important;
}

.client-calendar .fc-daygrid-body {
  width: 100% !important;
}

.client-calendar .fc-scrollgrid {
  border: none !important;
}

/* Индикатор загрузки */
.loading-slots {
  display: none;
  text-align: center;
  padding: 20px;
  color: var(--booking-text-secondary);
}

.loading-slots.visible {
  display: block;
}

.loading-icon {
  font-size: 18px;
  margin-bottom: 8px;
}

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

/* =========================================================
   ВРЕМЕННЫЕ СЛОТЫ (ДИНАМИЧЕСКИЙ БЛОК)
   ========================================================= */

.timeslots-section {
  order: 5;
  display: none;
  opacity: 0;
  width: 100%;
  min-height: 0;
  max-height: 0;
  overflow: hidden;
  transition: opacity 0.3s ease-in-out, max-height 0.3s ease-in-out, min-height 0.3s ease-in-out;
  background: var(--booking-bg-card);
  border-radius: 12px;
  padding: 0;
  margin-top: 8px;
  box-shadow: var(--booking-shadow);
}

.timeslots-section.visible {
  display: block;
  opacity: 1;
  min-height: 200px;
  max-height: 400px;
  padding: 16px;
  overflow-y: auto;
}

.timeslots-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.timeslots-title {
  color: var(--booking-text);
  font-size: 16px;
  margin: 0;
}

.slots-counter {
  font-size: 14px;
  color: var(--booking-text-secondary);
  white-space: nowrap;
}

.slots-counter strong {
  color: var(--booking-primary);
  font-weight: 600;
}

.timeslots-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 8px;
  width: 100%;
  margin-bottom: 12px;
  padding-bottom: 8px;
}

.time-slot-btn {
  padding: 10px 8px;
  border-radius: 8px;
  background: white;
  color: var(--booking-text);
  cursor: pointer;
  transition: var(--booking-transition-fast);
  font-size: 15px;
  border: 1.5px solid;
}

.time-slot-btn.full-hour {
  border-color: var(--booking-primary);
  font-weight: 600;
}

.time-slot-btn.half-hour {
  border-color: var(--booking-border);
  font-weight: 500;
}

.time-slot-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--booking-shadow-hover);
}

.time-slot-btn.selected {
  border-color: #4caf50;
  background: rgba(76, 175, 80, 0.15);
  color: #4caf50;
  font-weight: bold;
}

.timeslots-timestamp {
  display: none;
  font-size: 11px;
  color: var(--booking-text-tertiary);
  margin-top: 8px;
  text-align: center;
}

.timeslots-timestamp.visible {
  display: block;
}

/* =========================================================
   ПАНЕЛЬ "ВЫБРАНО"
   ========================================================= */

.selected-panel {
  order: 6;
  display: none;
  background: var(--booking-success-light);
  border: 2px solid var(--booking-success);
  border-radius: 16px;
  padding: 16px;
  width: 100%;
  margin-top: 12px;
  box-shadow: 0 2px 8px rgba(76, 175, 80, 0.2);
  animation: slideDown 0.3s ease-out;
  position: relative;
  z-index: 10;
}

.selected-panel.visible {
  display: block;
}

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

.selected-title {
  font-weight: 600;
  color: #2e7d32;
  margin-bottom: 12px;
  font-size: 15px;
}

.selected-datetime {
  font-size: 14px;
  color: var(--booking-text);
  font-weight: 500;
  margin-bottom: 8px;
}

.selected-hint {
  font-size: 12px;
  color: var(--booking-text-secondary);
  margin-top: 8px;
}

/* =========================================================
   СЕКЦИЯ ПОЖЕЛАНИЙ (АДАПТИВНАЯ)
   ========================================================= */

.notes-section {
  order: 7;
  display: block;
  width: 100%;
  margin-top: 16px;
  padding: 16px;
  position: relative;
  clear: both;
  background: var(--booking-bg-card);
  border-radius: 12px;
  box-shadow: var(--booking-shadow);
  z-index: 5;
}

.notes-section.slots-shown {
  margin-top: 24px;
}

.optional-label {
  font-size: 12px;
  color: var(--booking-text-tertiary);
  font-weight: normal;
}

.booking-notes {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--booking-border);
  border-radius: 8px;
  font-size: 14px;
  resize: vertical;
  box-sizing: border-box;
  min-height: 100px;
  display: block;
  font-family: inherit;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.booking-notes:focus {
  outline: none;
  border-color: var(--booking-primary);
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.1);
}

/* =========================================================
   ИНДИКАТОР ОШИБКИ
   ========================================================= */

.error-indicator {
  order: 8;
  display: none;
  background: var(--booking-error-light);
  border: 1px solid var(--booking-error);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
}

.error-indicator.visible {
  display: block;
}

.error-title {
  font-weight: 500;
  color: #c62828;
  margin-bottom: 4px;
}

.error-message {
  font-size: 14px;
  color: #d32f2f;
}

/* =========================================================
   ФИКСИРОВАННАЯ ПАНЕЛЬ ДЕЙСТВИЙ
   ========================================================= */

.actions-panel {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--booking-bg-card);
  border-top: 1px solid var(--booking-border);
  padding: 16px;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
  z-index: 100;
}

.actions-wrapper {
  display: flex;
  gap: 12px;
}

.btn-primary {
  flex: 1;
  padding: 14px;
  font-size: 16px;
  font-weight: bold;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: var(--booking-transition-fast);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* =========================================================
   АДАПТИВНОСТЬ
   ========================================================= */

@media (max-width: 480px) {
  .timeslots-list {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }
  
  .notes-section {
    margin-top: 16px;
    padding: 12px;
  }
  
  .slots-counter {
    font-size: 12px;
  }
  
  .progress-text {
    font-size: 13px;
  }
  
  .progress-section {
    margin-bottom: 6px;
  }
  
  .master-section,
  .services-section,
  .datetime-section {
    margin-bottom: 10px;
  }
  
  .client-calendar {
    min-height: 320px;
    max-height: 400px;
  }
  
  .timeslots-section.visible {
    min-height: 180px;
    max-height: 360px;
  }
}

/* Обеспечение минимальной высоты для touch-устройств */
@media (pointer: coarse) {
  .time-slot-btn {
    min-height: 44px;
  }
  
  .service-checkbox {
    min-width: 44px;
    min-height: 44px;
  }
}
