/* Registration Modal */

.reg-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(12px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 10000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.reg-overlay.reg-overlay--visible {
  opacity: 1;
  pointer-events: auto;
}

.reg-modal {
  background: #fff;
  border-radius: 24px;
  width: 100%;
  max-width: 100%;
  position: relative;
  transform: translateY(40px);
  transition: transform 0.3s ease;
  max-height: 92vh;
  overflow: visible;
  margin: 16px;
}

.reg-modal-inner {
  overflow-y: auto;
  max-height: calc(92vh - 32px);
  padding: 24px 24px 8px 8px;
}

.reg-overlay.reg-overlay--visible .reg-modal {
  transform: translateY(0);
}

.reg-close {
  position: fixed;
  top: 16px;
  right: 16px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: #fff;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #90a1b9;
  transition: background 0.2s;
  z-index: 10001;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.reg-close:hover {
  background: #f5f5f5;
}

/* Step visibility */
.reg-step {
  display: flex;
  flex-direction: column;
  min-height: 489px;
}

.reg-step--hidden {
  display: none;
}

/* Header */
.reg-modal-header {
  margin-bottom: 32px;
}

.reg-title {
  font-size: 28px;
  font-weight: 700;
  color: #000;
  margin-bottom: 8px;
}

.reg-subtitle {
  font-size: 15px;
  color: #666;
  line-height: 1.5;
}

/* Input field */
.reg-field {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 0 24px 24px;
}

/* Step 2 space preview */
.reg-step2-avatar-float {
  position: absolute;
  top: -60px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  z-index: 1;
}

.reg-step2-avatar-float[hidden] {
  display: none;
}

.reg-step2-space-preview {
  height: 52px;
}

.reg-step2-avatar {
  position: relative;
  width: 116px;
  height: 116px;
  border-radius: 50%;
  background: #eef0f5;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: 0 0 0 4px #fff;
}

.reg-step2-initials {
  font-size: 24px;
  font-weight: 600;
  color: #7b8ab0;
  user-select: none;
}

.reg-step2-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.reg-step2-space-name {
  font-size: 32px;
  font-weight: 700;
  color: #000;
  margin: 0;
  text-align: center;
}

/* Avatar */
.reg-avatar-wrap {
  margin-bottom: 20px;
}

.reg-avatar-btn {
  position: relative;
  width: 116px;
  height: 116px;
  border-radius: 50%;
  border: none;
  background: #eef0f5;
  cursor: pointer;
  padding: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.reg-avatar-placeholder {
  font-size: 28px;
  font-weight: 600;
  color: #7b8ab0;
  user-select: none;
}

.reg-avatar-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.reg-avatar-overlay {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  opacity: 0;
  transition: opacity 0.2s;
}

.reg-avatar-btn:hover .reg-avatar-overlay {
  opacity: 1;
}

.reg-avatar-btn.reg-avatar-btn--loading .reg-avatar-overlay {
  opacity: 1;
}

.reg-avatar-btn.reg-avatar-btn--loading .reg-avatar-overlay svg {
  animation: reg-spin 0.7s linear infinite;
}

.reg-input {
  border: none;
  font-size: 32px;
  font-weight: 700;
  color: #000;
  outline: none;
  text-align: left;
  background: transparent;
  transition: border-color 0.2s;
  font-family: inherit;
}

.reg-input::placeholder {
  color: #c0c0c0;
}

.reg-input.reg-input--error {
  border-bottom-color: #ec003f;
}

.reg-field-hint {
  font-size: 13px;
  color: #ec003f;
  margin-top: 8px;
  min-height: 18px;
  text-align: center;
}

/* Footer */
.reg-modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 8px;
}

.reg-bot-hint {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.reg-bot-hint-icon {
  font-size: 28px;
  flex-shrink: 0;
  width: 36px;
  text-align: center;
}

.reg-bot-hint div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.reg-bot-hint strong {
  font-family: 'Roboto Flex', sans-serif;
  font-size: 24px;
  font-weight: 700;
  color: #020618;
  white-space: nowrap;
}

.reg-bot-hint span {
  font-family: 'Roboto Flex', sans-serif;
  font-size: 16px;
  font-weight: 500;
  color: #020618;
}

.reg-btn-next,
.reg-btn-done {
  flex-shrink: 0;
  font-size: 16px;
  padding: 14px 20px;
}

.reg-btn-next:disabled,
.reg-btn-done:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.reg-action-row--hidden {
  display: none;
}

/* Messenger cards */
.reg-messengers {
  display: flex;
  gap: 12px;
  margin-top: 110px;
  justify-content: center;
}

.reg-messenger-card {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border: 4px solid white;
  border-radius: 48px;
  padding: 48px 48px;
  background: none;
  text-decoration: none;
  color: inherit;
  transition:
    border-color 0.3s ease,
    box-shadow 0.3s ease,
    justify-content 0.3s ease;
  cursor: pointer;
  min-width: 378px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
}

.reg-messenger-card:hover {
  box-shadow: 0 4px 16px rgba(74, 144, 226, 0.12);
}

.reg-messenger-inner {
  display: flex;
  align-items: center;
  gap: 10px;
}

.reg-messenger-icon {
  width: 36px;
  height: 36px;
}

.reg-messenger-name {
  font-size: 24px;
  font-weight: 700;
  color: #28aee9;
}

#reg-max-link .reg-messenger-name {
  background: linear-gradient(135deg, #28aee9 0%, #a855f7 60%, #c084fc 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.reg-messenger-qr {
  width: 64px;
  height: 64px;
  flex-shrink: 0;
  overflow: hidden;
  transition: opacity 0.3s ease;
  border-radius: 8px;
  cursor: zoom-in;
}

.reg-messenger-qr[hidden] {
  display: block !important;
  width: 0;
  opacity: 0;
  pointer-events: none;
}

.reg-messenger-qr img,
.reg-messenger-qr canvas {
  width: 64px !important;
  height: 64px !important;
  display: block;
  transition: filter 0.2s ease;
  border-radius: 8px;
}

.reg-messenger-qr:hover img,
.reg-messenger-qr:hover canvas {
  filter: brightness(0.85) saturate(1.4);
}

/* QR popup */
.reg-qr-popup {
  position: fixed;
  inset: 0;
  z-index: 20000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(6px);
  cursor: zoom-out;
  animation: reg-qr-popup-in 0.2s ease;
}

.reg-qr-popup-box {
  background: #fff;
  border-radius: 20px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}

.reg-qr-popup-label {
  font-size: 15px;
  font-weight: 600;
  color: #333;
}

.reg-qr-popup-canvas {
  display: block;
  border-radius: 8px;
}

@keyframes reg-qr-popup-in {
  from { opacity: 0; transform: scale(0.9); }
  to   { opacity: 1; transform: scale(1); }
}

.reg-messenger-card--selected {
  border-color: #28aee9;
  box-shadow: 0 4px 16px rgba(40, 174, 233, 0.18);
  padding: 44px 48px;
  justify-content: space-between;
}

#reg-max-link.reg-messenger-card--selected {
  border: 4px solid transparent;
  background-image: linear-gradient(#fff, #fff), linear-gradient(43deg, #28aee9, #a855f7, #c084fc);
  background-origin: border-box;
  background-clip: padding-box, border-box;
  box-shadow: 0 4px 24px rgba(168, 85, 247, 0.2);
  padding: 44px 48px;
}

/* Sticky footer on step 2 */
.reg-modal-footer--sticky {
  position: sticky;
  bottom: 0;
  background: #fff;
  margin-top: auto;
}

/* Action row (back + done) */
.reg-action-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.reg-btn-back {
  background: #f0f1f3;
  border: none;
  font-size: 16px;
  font-weight: 500;
  color: #000;
  cursor: pointer;
  padding: 14px 20px;
  border-radius: 99px;
  font-family: inherit;
  transition: background 0.2s;
  white-space: nowrap;
}

.reg-btn-back:hover {
  background: #e4e5e8;
}

/* Step 3: done */
.reg-step-done {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 32px 0 48px;
  flex: 1;
}

.reg-done-icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: rgba(236, 0, 63, 0.1);
  color: #ec003f;
  font-size: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 24px;
}

/* Loading spinner on "Готово" button */
.reg-btn-done.reg-btn-done--loading {
  position: relative;
  color: transparent;
}

.reg-btn-done.reg-btn-done--loading::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: reg-spin 0.6s linear infinite;
}

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

/* Error state on step 2 */
.reg-error-msg {
  font-size: 13px;
  color: #ec003f;
  margin-top: 8px;
  text-align: center;
  min-height: 18px;
}

@media (max-width: 600px) {
  .reg-modal {
    padding: 24px 20px 0;
    border-radius: 20px 20px 0 0;
  }

  .reg-title {
    font-size: 22px;
  }

  .reg-input {
    font-size: 20px;
  }

  .reg-messengers {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }

  .reg-modal-footer {
    flex-wrap: wrap;
  }

  .reg-bot-hint strong {
    white-space: normal;
  }
}

@media (max-width: 400px) {
  .reg-messengers {
    grid-template-columns: 1fr;
  }
}
