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

:root {
  --primary: #6C5CE7;
  --primary-dark: #5A4BD1;
  --primary-light: #A29BFE;
  --accent: #00CEC9;
  --success: #00B894;
  --danger: #FF7675;
  --bg: #F8F9FE;
  --card: #FFFFFF;
  --text: #2D3436;
  --text-secondary: #636E72;
  --text-light: #B2BEC3;
  --border: #E8E8F0;
  --shadow: 0 2px 16px rgba(108, 92, 231, 0.08);
  --radius: 12px;
  --radius-sm: 8px;
}

html {
  font-size: 16px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ===== Header ===== */
.header {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  padding: 16px 20px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(108, 92, 231, 0.3);
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon {
  font-size: 28px;
}

.logo-text {
  font-size: 18px;
  font-weight: 600;
}

/* ===== Progress Bar ===== */
.progress-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px 20px;
  gap: 0;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}

.progress-step {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--border);
  color: var(--text-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.3s;
  flex-shrink: 0;
}

.progress-step.active {
  background: var(--primary);
  color: white;
  box-shadow: 0 0 0 3px var(--primary-light);
}

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

.progress-line {
  width: 48px;
  height: 3px;
  background: var(--border);
  transition: background 0.3s;
}

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

/* ===== Main Container ===== */
#app {
  max-width: 480px;
  margin: 0 auto;
  padding: 20px 16px 100px;
}

/* ===== Steps ===== */
.step {
  display: none;
  animation: fadeIn 0.3s ease;
}

.step.active {
  display: block;
}

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

h2 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 4px;
}

.step-desc {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 20px;
}

/* ===== Calendar ===== */
.calendar-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

#monthLabel {
  font-size: 16px;
  font-weight: 600;
}

.btn-icon {
  width: 40px;
  height: 40px;
  border: none;
  background: var(--card);
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow);
  transition: all 0.2s;
}

.btn-icon:active {
  transform: scale(0.95);
}

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

.calendar-header {
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 8px 0;
}

.calendar-day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
  background: transparent;
  color: var(--text);
  font-family: inherit;
}

.calendar-day:hover:not(.disabled) {
  background: var(--primary-light);
  color: white;
}

.calendar-day.selected {
  background: var(--primary);
  color: white;
  font-weight: 600;
}

.calendar-day.today {
  border: 2px solid var(--primary-light);
}

.calendar-day.other-month {
  color: var(--text-light);
}

.calendar-day.disabled {
  color: var(--text-light);
  cursor: not-allowed;
  opacity: 0.4;
}

/* ===== Subjects ===== */
.subjects {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 20px;
}

.subject-card {
  padding: 14px 12px;
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
}

.subject-card:hover {
  border-color: var(--primary-light);
}

.subject-card.selected {
  border-color: var(--primary);
  background: rgba(108, 92, 231, 0.06);
}

.subject-card .subject-icon {
  display: block;
  font-size: 24px;
  margin-bottom: 4px;
}

/* ===== Slots (Times) ===== */
.slots {
  margin-top: 4px;
}

.slots h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 10px;
}

.hint {
  color: var(--text-light);
  font-size: 14px;
  text-align: center;
  padding: 16px;
}

.slots-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.slot-btn {
  padding: 10px 8px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
}

.slot-btn:hover:not(.unavailable) {
  border-color: var(--primary-light);
  background: rgba(108, 92, 231, 0.04);
}

.slot-btn.selected {
  border-color: var(--primary);
  background: var(--primary);
  color: white;
}

.slot-btn.unavailable {
  background: #F5F5F5;
  color: var(--text-light);
  cursor: not-allowed;
  text-decoration: line-through;
}

/* ===== Form ===== */
.booking-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-group input {
  padding: 14px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-family: inherit;
  transition: border-color 0.2s;
  background: var(--card);
  outline: none;
}

.form-group input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.1);
}

.form-group input.error {
  border-color: var(--danger);
}

.error-text {
  color: var(--danger);
  font-size: 12px;
  display: none;
}

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

/* ===== Summary ===== */
.summary {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.summary-row:last-child {
  border-bottom: none;
}

.summary-label {
  color: var(--text-secondary);
  font-size: 14px;
}

.summary-value {
  font-weight: 600;
  font-size: 14px;
  text-align: right;
}

.summary-client {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

/* ===== Navigation Buttons ===== */
.nav-buttons {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

.btn {
  flex: 1;
  padding: 14px 24px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  text-align: center;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--primary);
  color: white;
  box-shadow: 0 4px 12px rgba(108, 92, 231, 0.3);
}

.btn-primary:hover {
  background: var(--primary-dark);
}

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

.btn-secondary {
  background: var(--card);
  color: var(--text);
  border: 2px solid var(--border);
}

.btn-secondary:hover {
  border-color: var(--text-light);
}

/* ===== Success Overlay ===== */
.success-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.success-overlay.visible {
  display: flex;
}

.success-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 40px 24px;
  text-align: center;
  max-width: 320px;
  width: 100%;
  animation: scaleIn 0.3s ease;
}

@keyframes scaleIn {
  from { transform: scale(0.8); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.success-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.success-card h2 {
  margin-bottom: 8px;
}

.success-card p {
  color: var(--text-secondary);
  margin-bottom: 20px;
  font-size: 14px;
}

/* ===== Loading Overlay ===== */
.loading-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.85);
  z-index: 190;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
  font-size: 14px;
  color: var(--text-secondary);
}

.loading-overlay.visible {
  display: flex;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ===== Error Banner ===== */
.error-banner {
  background: #FFF0F0;
  border: 1px solid var(--danger);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  color: var(--danger);
  font-size: 14px;
  margin-bottom: 12px;
  display: none;
}

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

/* ===== Responsive ===== */

/* ===== My Bookings Section ===== */
.my-bookings-section {
  text-align: center;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.btn-link {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  padding: 8px 16px;
  font-family: inherit;
  transition: opacity 0.2s;
}

.btn-link:hover {
  opacity: 0.7;
}

.bookings-panel {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 12px;
  box-shadow: var(--shadow);
  animation: fadeIn 0.3s ease;
}

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

.bookings-header h3 {
  font-size: 16px;
  font-weight: 600;
}

.bookings-phone-input {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.bookings-phone-input input {
  flex: 1;
  padding: 10px 12px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}

.bookings-phone-input input:focus {
  border-color: var(--primary);
}

.btn-sm {
  padding: 10px 16px;
  font-size: 14px;
  white-space: nowrap;
  flex: 0;
}

.bookings-result {
  font-size: 14px;
  line-height: 1.6;
}

.bookings-result .booking-card {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  background: var(--bg);
}

.bookings-result .booking-card.upcoming {
  border-left: 3px solid var(--success);
}

.bookings-result .booking-card.past {
  border-left: 3px solid var(--text-light);
  opacity: 0.7;
}

.bookings-result .booking-subject {
  font-weight: 600;
  font-size: 13px;
}

.bookings-result .booking-datetime {
  color: var(--text-secondary);
  font-size: 12px;
}

.bookings-result .loading-text {
  text-align: center;
  color: var(--text-light);
  padding: 12px;
}

.bookings-result .error-text {
  text-align: center;
  color: var(--danger);
  padding: 12px;
}

@media (max-width: 360px) {
  .subjects {
    grid-template-columns: 1fr;
  }

  .slots-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .progress-line {
    width: 32px;
  }
}
