/**
 * Модуль онлайн-записи — стили
 * Использует переменные из styles.css (--primary, --secondary и т.д.)
 */

/* === Переменные модуля === */
.booking-page {
  --bkg-green: #e8f8e9;
  --bkg-green-border: #91c89d;
  --bkg-yellow: #fff4d3;
  --bkg-yellow-border: #ebbe4d;
  --bkg-red: #ffe1e1;
  --bkg-red-border: #e99a9a;
  --bkg-gray: #eff3f8;
  --bkg-gray-border: #cad4e1;
  --bkg-urgent: #fff1f1;
}

html.booking-embed-root {
  height: auto;
  min-height: 0;
}

.booking-page.booking-embed {
  background: transparent;
  min-height: 0 !important;
  height: auto !important;
}

/* === Layout === */
.booking-main {
  padding: 0 0 40px;
  min-height: 60vh;
}

.booking-page.booking-embed .booking-main {
  padding: 0;
  min-height: auto;
}

.booking-page-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 20px 80px;
}

.booking-page.booking-embed .booking-page-inner {
  max-width: none;
  padding: 0;
}

@media (max-width: 520px) {
  .booking-page-inner { padding: 16px 12px 100px; }
}

/* === Topbar === */
.booking-topbar {
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

.booking-page.booking-embed .header,
.booking-page.booking-embed .footer,
.booking-page.booking-embed .booking-topbar,
.booking-page.booking-embed .booking-footer-info,
.booking-page.booking-embed .mobile-sticky {
  display: none !important;
}

.booking-eyebrow {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--primary-light);
  color: var(--primary-on-light);
  font-weight: 800;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.booking-topbar h1 {
  margin: 12px 0 8px;
  font-size: clamp(24px, 3.5vw, 36px);
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.booking-muted {
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.5;
  max-width: 720px;
}

.booking-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.booking-legend .legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-dark);
}

.swatch {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1px solid transparent;
}

.swatch-green { background: var(--bkg-green); border-color: var(--bkg-green-border); }
.swatch-yellow { background: var(--bkg-yellow); border-color: var(--bkg-yellow-border); }
.swatch-red { background: var(--bkg-red); border-color: var(--bkg-red-border); }
.swatch-gray { background: var(--bkg-gray); border-color: var(--bkg-gray-border); }

/* Demo toolbar — только при ?demo=1 */
.booking-demo-toolbar {
  display: none;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.booking-demo-toolbar.visible {
  display: flex;
}

.booking-demo-toolbar label { margin: 0; font-size: 12px; }
.booking-demo-toolbar input, .booking-demo-toolbar select {
  min-height: 38px;
  padding: 8px 10px;
  font-size: 14px;
}

.btn-sm { min-height: 36px; padding: 8px 12px; font-size: 13px; }

.btn-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: booking-spin 0.6s linear infinite;
  margin-right: 6px;
  vertical-align: middle;
}

/* === Progress bar === */
.booking-progress-wrap {
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
}

.booking-progress {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.progress-step {
  display: grid;
  gap: 4px;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--background);
  min-height: 70px;
  transition: 0.18s ease;
}

.progress-step strong { font-size: 14px; }
.progress-step small { font-size: 11px; color: var(--text-muted); }

.progress-step.is-active {
  background: linear-gradient(180deg, #FFFEF8 0%, var(--primary-light) 100%);
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(255, 215, 0, 0.2);
}

.progress-step.is-done {
  background: linear-gradient(180deg, #f0fdf4 0%, #dcfce7 100%);
  border-color: var(--success);
}

.step-no {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 800;
  background: var(--background-alt);
  color: var(--text-muted);
}

.progress-step.is-active .step-no {
  background: var(--primary);
  color: var(--secondary);
}

.progress-step.is-done .step-no {
  background: var(--success);
  color: #fff;
}

@media (max-width: 720px) {
  .booking-progress {
    grid-template-columns: repeat(5, minmax(100px, 1fr));
    overflow-x: auto;
  }
  .progress-step { min-width: 100px; }
}

@media (max-width: 520px) {
  .booking-progress { grid-template-columns: repeat(5, minmax(64px, 1fr)); gap: 6px; }
  .progress-step { min-height: 54px; padding: 8px; }
  .progress-step small { display: none; }
}

/* === Wizard layout === */
.booking-wizard-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 20px;
  align-items: start;
}

.booking-page.booking-embed .booking-wizard-layout {
  grid-template-columns: 1fr;
  gap: 0;
}

@media (max-width: 980px) {
  .booking-wizard-layout { grid-template-columns: 1fr; }
  .booking-side { display: none; }
}

/* === Panels === */
.booking-panel {
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  min-height: 420px;
  box-shadow: var(--shadow-sm);
}

.booking-page.booking-embed .booking-progress-wrap {
  margin-bottom: 14px;
}

.booking-page.booking-embed .booking-panel {
  min-height: auto;
}

.booking-panel.hidden { display: none !important; }

.booking-panel h2 {
  margin: 0 0 8px;
  font-size: clamp(22px, 2.5vw, 28px);
  letter-spacing: -0.02em;
}

.step-helper {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  padding: 10px 12px;
  background: var(--background-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.step-helper-title {
  font-size: 11px;
  font-weight: 800;
  color: var(--primary-on-light);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.step-helper-text {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-size: 14px;
  color: var(--text-dark);
  line-height: 1.4;
}

.selected-branch-box {
  padding: 14px;
  background: var(--background-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 14px;
}

/* === Branches grid === */
.booking-branches {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.branch-card {
  position: relative;
  border: 1px solid var(--border);
  background: var(--background);
  border-radius: var(--radius-lg);
  padding: 18px;
  cursor: pointer;
  transition: 0.18s ease;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.branch-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--primary) 0%, var(--primary-light) 100%);
}

.branch-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: var(--primary);
}

.branch-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.branch-head .branch-name {
  font-size: 18px;
  font-weight: 800;
  margin: 0 0 4px;
}

.branch-pill {
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  background: var(--primary-light);
  color: var(--primary-on-light);
  white-space: nowrap;
}

.branch-glance {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 12px 0;
}

.glance-chip {
  padding: 10px 12px;
  background: var(--background-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.glance-chip strong {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 4px;
}

.glance-chip span { font-size: 14px; font-weight: 700; }
.glance-chip-ok { background: var(--bkg-green); border-color: var(--bkg-green-border); }
.branch-head .booking-muted a { color: var(--primary); text-decoration: underline; }

.branch-card .btn {
  width: 100%;
  margin-top: 8px;
  min-height: 48px;
}

.urgent-inline {
  margin-top: 12px;
  padding: 12px;
  background: var(--bkg-urgent);
  border: 1px solid #f3aaaa;
  border-radius: var(--radius);
}

.urgent-inline .urgent-btn { margin-top: 8px; }

details.branch-details {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

details.branch-details summary {
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  list-style: none;
}

details.branch-details summary::-webkit-details-marker { display: none; }
details.branch-details summary::after { content: ' ▾'; color: var(--text-muted); }
details.branch-details[open] summary::after { content: ' ▴'; }

.branch-meta { margin-top: 12px; font-size: 13px; }
.branch-meta div { margin-bottom: 6px; }

/* === Day grid === */
.day-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.day-card {
  padding: 14px;
  border-radius: var(--radius);
  border: 1px solid;
  text-align: left;
  cursor: pointer;
  min-height: 100px;
  display: grid;
  gap: 6px;
  background: var(--background);
  transition: 0.15s ease;
}

.day-card strong { font-size: 17px; line-height: 1.2; }
.day-card small { font-size: 13px; color: var(--text-muted); }

.day-card.free-day { background: var(--bkg-green); border-color: var(--bkg-green-border); }
.day-card.warn-day { background: var(--bkg-yellow); border-color: var(--bkg-yellow-border); }
.day-card.full-day { background: var(--bkg-red); border-color: var(--bkg-red-border); }
.day-card.closed-day {
  background: var(--bkg-gray);
  border-color: var(--bkg-gray-border);
  cursor: not-allowed;
  opacity: 0.85;
}

.day-card.active { outline: 2px solid var(--primary); outline-offset: 2px; }
.day-card:hover:not(.closed-day) { transform: translateY(-1px); }

@media (max-width: 520px) {
  .day-grid { grid-template-columns: repeat(2, 1fr); }
}

/* === Slots === */
.quick-bar {
  padding: 16px;
  background: var(--background-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
}

.quick-bar > div { margin-bottom: 8px; }
.quick-chips { display: flex; flex-wrap: wrap; gap: 10px; margin: 10px 0; }

.chip {
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--background);
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  transition: 0.15s ease;
}

.chip:hover { border-color: var(--primary); background: var(--primary-light); }

.slots-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.slots-group-header {
  grid-column: 1 / -1;
  font-size: 13px;
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-top: 8px;
}

.slots-group-header:first-child { margin-top: 0; }

.day-badge {
  font-size: 10px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--primary);
  color: var(--secondary);
  margin-left: 4px;
}

.day-today { outline: 2px solid var(--primary); outline-offset: 1px; }

.slot-card {
  padding: 14px;
  border-radius: var(--radius);
  border: 1px solid;
  display: grid;
  gap: 6px;
  min-height: 100px;
}

.slot-card.free {
  background: var(--bkg-green);
  border-color: var(--bkg-green-border);
  cursor: pointer;
}
.slot-card.free:hover { transform: translateY(-1px); }

.slot-card.busy {
  background: var(--bkg-red);
  border-color: var(--bkg-red-border);
}

.slot-card.locked {
  background: var(--bkg-gray);
  border-color: var(--bkg-gray-border);
}

.slot-time { font-size: 22px; font-weight: 900; }
.slot-employee { font-size: 14px; font-weight: 700; }
.slot-status {
  display: inline-flex;
  width: max-content;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  background: rgba(255,255,255,0.7);
}
.slot-tip { font-size: 12px; color: var(--text-muted); }

.status-message {
  padding: 12px 14px;
  border-radius: var(--radius);
  font-size: 14px;
  display: none;
}
.status-message.show { display: block; }
.status-success { background: var(--bkg-green); border: 1px solid var(--bkg-green-border); }

/* === Form === */
.form-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.form-grid label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-dark);
}

.form-grid input,
.form-grid select {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--background);
  font-size: 16px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-grid input:focus,
.form-grid select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(255, 215, 0, 0.2);
}

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

.booking-note {
  padding: 14px;
  background: var(--background-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 14px;
}

.booking-consent { margin: 16px 0; }
.booking-consent:has(.error) .booking-consent-label { color: #dc2626; }
.booking-consent-label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1.5;
}

.booking-consent-label input { flex-shrink: 0; margin-top: 3px; }
.booking-consent-label a { text-decoration: underline; }

/* === Summary === */
.summary-block {
  display: grid;
  gap: 20px;
  grid-template-columns: 1.2fr 1fr;
}

.qr-box {
  display: grid;
  place-items: center;
  padding: 16px;
  background: var(--background-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  min-height: 200px;
}

.qr-box img { max-width: 100%; height: auto; }

@media (max-width: 640px) {
  .summary-block { grid-template-columns: 1fr; }
}

/* === Actions === */
.booking-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

/* === Side card === */
.booking-side { position: sticky; top: 20px; }

.side-card {
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow-sm);
}

.side-card h3 { margin: 0 0 12px; font-size: 17px; }

.side-list { display: grid; gap: 12px; }

.side-item {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--background-alt);
}

.side-label {
  display: block;
  font-size: 11px;
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 4px;
}

.side-item span:last-child { font-size: 14px; font-weight: 700; }

/* === Footer info === */
.booking-footer-info {
  margin-top: 24px;
  padding: 20px;
  background: var(--background-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.booking-footer-info h2 { margin: 0 0 12px; font-size: 20px; }
.booking-footer-info p { margin: 0 0 8px; font-size: 14px; color: var(--text-muted); }

/* === Mobile sticky === */
.mobile-sticky {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 100;
  padding: 12px 16px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
  background: rgba(255,255,255,0.98);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 20px rgba(0,0,0,0.08);
}

.mobile-sticky.hidden { display: none !important; }

.mobile-sheet {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.mobile-sheet-title {
  display: block;
  font-size: 11px;
  font-weight: 800;
  color: var(--primary-on-light);
  text-transform: uppercase;
}

.mobile-sheet-main { font-size: 15px; font-weight: 800; }

.mobile-sheet .btn { min-height: 48px; padding: 12px 20px; }

@media (min-width: 521px) {
  .mobile-sticky { display: none !important; }
}

/* === Overlay / Modal === */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.5);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 200;
  backdrop-filter: blur(4px);
}

.overlay.open { display: flex; }

.modal-card {
  width: min(560px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  background: var(--background);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-lg);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
}

.modal-head h3 { margin: 0; font-size: 20px; }

.close-btn {
  width: 40px;
  height: 40px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--background-alt);
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  flex-shrink: 0;
}

.close-btn:hover { background: var(--border); }

.urgent-btn {
  background: linear-gradient(180deg, #ef5350 0%, #d32f2f 100%) !important;
  color: #fff !important;
}

/* === Toast === */
.toast-container {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 90%;
  width: 360px;
}

.toast {
  padding: 14px 18px;
  background: #1e293b;
  color: #fff;
  border-radius: var(--radius);
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  animation: toast-in 0.25s ease;
}

.toast.toast-error { background: #dc2626; }
.toast.toast-success { background: #16a34a; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.toast-close { background: none; border: none; color: inherit; cursor: pointer; padding: 4px; font-size: 18px; opacity: 0.8; }
.toast-close:hover { opacity: 1; }

/* === Week nav === */
.week-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.week-range { font-size: 14px; font-weight: 700; color: var(--text-dark); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--background-alt); color: var(--text-dark); }

/* === Slots empty state === */
.slots-empty-state {
  padding: 24px;
  text-align: center;
  background: var(--background-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 16px;
}

.slots-empty-state.hidden { display: none !important; }
.slots-empty-state p { margin: 0 0 16px; font-size: 16px; }

.status-error { background: var(--bkg-red); border: 1px solid var(--bkg-red-border); }

/* === Form groups === */
.form-group {
  margin-bottom: 20px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--background-alt);
}

.form-group legend {
  font-size: 13px;
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
  padding: 0 8px;
  margin-bottom: 12px;
}

.form-error-message {
  padding: 12px 14px;
  background: var(--bkg-red);
  border: 1px solid var(--bkg-red-border);
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 14px;
  display: none;
}

.form-error-message.show { display: block; }

.field-error {
  display: block;
  font-size: 12px;
  color: #dc2626;
  margin-top: 4px;
}

.field-hint {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* === Summary / Copy === */
.booking-id-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 12px 0;
  flex-wrap: wrap;
}

.booking-id-row code {
  font-size: 18px;
  font-weight: 900;
  font-family: ui-monospace, monospace;
  padding: 8px 12px;
  background: var(--background-alt);
  border-radius: var(--radius);
}

/* === Touch targets (min 44px) === */
@media (max-width: 720px) {
  .branch-card { min-height: 120px; padding: 20px; }
  .day-card { min-height: 88px; padding: 16px; }
  .slot-card.free { min-height: 56px; }
  .chip { min-height: 44px; padding: 12px 16px; }
}

/* === Loader === */
.booking-loader {
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.booking-loader.loading::after {
  content: "";
  width: 24px;
  height: 24px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: booking-spin 0.6s linear infinite;
}

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