/* ============================================================
   NEODROP - Unified Authentication Styles (without back-to-main)
   Back button styles are now in back-button.css
   ============================================================ */

/* -------------------- CSS Variables -------------------- */
:root {
  --error-light: #ffebe6;
  --radius-large: 24px;
  --radius-medium: 16px;
  --radius-small: 8px;
  --shadow-sm: 0 4px 12px var(--tint-brand-08);
  --shadow-md: 0 8px 24px var(--tint-brand-15);
  --shadow-lg: 0 12px 36px var(--tint-brand-20);
  --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  --futuristic-font: 'Montserrat', 'Segoe UI', system-ui, sans-serif;
}

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

html {
  height: 100%;
  overflow-y: auto;
}

/* base.css задаёт html, body { height: 100% } — высоту ровно в экран.
   Карточка регистрации выше экрана телефона, и центрирование флексом
   выталкивало её верх за край, куда не прокрутить: страница не
   прокручивалась вовсе, а на iPhone SE пропадали заголовок и первое поле.
   Высота по содержимому и margin: auto у main центрируют форму, пока
   место есть, и не режут её, когда места нет. */
body {
  height: auto;
  min-height: 100%;
  background: linear-gradient(135deg, var(--bg-color) 0%, var(--primary-light) 100%);
  font-family: var(--futuristic-font);
  color: var(--text-color);
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 80px 20px 40px;
  position: relative;
}

body > main {
  margin-block: auto;
}

/* -------------------- Layout -------------------- */
.page-wrapper {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

.auth-container {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 0;
}

.auth-card {
  background: var(--surface);
  border-radius: var(--radius-large);
  box-shadow: var(--shadow-md);
  padding: 40px 32px;
  transition: var(--transition);
  animation: fadeInUp 0.5s ease-out forwards;
  width: 100%;
}
@media (hover: hover) {
  .auth-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
  }
}


/* -------------------- Headers -------------------- */
.auth-header {
  text-align: center;
  margin-bottom: 32px;
  position: relative;
}

.auth-header h1 {
  color: var(--primary-color);
  font-weight: 800;
  font-size: 32px;
  margin-bottom: 12px;
  letter-spacing: -0.5px;
}

.auth-header p {
  color: var(--text-light);
  font-size: 16px;
  max-width: 320px;
  margin: 0 auto;
}

.auth-header::after {
  content: '';
  position: absolute;
  bottom: -16px;
  left: 50%;
  transform: translateX(-50%);
  width: 80px;
  height: 4px;
  background: var(--primary-color);
  border-radius: 2px;
}

/* -------------------- Forms -------------------- */
.form-group {
  margin-bottom: 24px;
  position: relative;
}

.form-row {
  display: flex;
  gap: 16px;
  margin-bottom: 24px;
}

.form-row .form-group {
  flex: 1;
  margin-bottom: 0;
}

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

.auth-card input[type='text'],
.auth-card input[type='password'] {
  width: 100%;
  padding: 16px 20px;
  border: 2px solid var(--gray-medium);
  border-radius: var(--radius-medium);
  font-size: 16px;
  font-family: inherit;
  background-color: var(--gray-light);
  transition: var(--transition);
}

.auth-card input[type='text']:focus,
.auth-card input[type='password']:focus {
  outline: none;
  border-color: var(--primary-color);
  background-color: var(--surface);
  box-shadow: 0 0 0 4px var(--tint-brand-10);
}

/* Phone field */
.phone-field {
  position: relative;
}

/* -------------------- Checkbox (agreements) -------------------- */
.agreement-checkbox {
  margin: 20px 0 25px;
}

.checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1.4;
  color: var(--text-light);
  transition: var(--transition);
}

.checkbox-label:hover {
  color: var(--text-color);
}

.checkbox-label input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.checkmark {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  background: var(--surface);
  border: 2px solid var(--gray-medium);
  border-radius: var(--radius-small);
  transition: var(--transition);
  position: relative;
  margin-top: 2px;
}
@media (hover: hover) {
  .checkbox-label:hover .checkmark {
    border-color: var(--primary-color);
    transform: scale(1.05);
  }
}


.checkbox-label input[type="checkbox"]:checked + .checkmark {
  background-color: var(--primary-color);
  border-color: var(--primary-color);
  box-shadow: 0 4px 12px var(--tint-brand-30);
}

.checkbox-label input[type="checkbox"]:checked + .checkmark::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 45%;
  width: 5px;
  height: 10px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: translate(-50%, -50%) rotate(45deg);
  animation: checkmarkAppear 0.3s ease-out;
}

.checkbox-text {
  flex: 1;
}

.checkbox-text a {
  color: var(--primary-color);
  text-decoration: none;
  font-weight: 600;
}

.checkbox-text a:hover {
  color: var(--primary-dark);
  text-decoration: underline;
}

@keyframes checkmarkAppear {
  0% {
    transform: translate(-50%, -50%) rotate(45deg) scale(0);
    opacity: 0;
  }
  100% {
    transform: translate(-50%, -50%) rotate(45deg) scale(1);
    opacity: 1;
  }
}

/* -------------------- Error Messages -------------------- */
.errorlist {
  list-style: none;
  margin-top: 8px;
}

.errorlist li {
  color: var(--danger-text);
  font-size: 14px;
  padding: 10px 16px;
  background: var(--error-light);
  border-radius: var(--radius-medium);
  position: relative;
  padding-left: 42px;
  border: 1px solid rgba(255, 61, 0, 0.15);
  animation: errorAppear 0.4s ease-out;
}

.errorlist li::before {
  content: '!';
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  background: var(--error-color);
  color: var(--text-on-brand);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 14px;
}

.field-with-error input {
  border-color: var(--error-color) !important;
  background-color: var(--error-light) !important;
}

@keyframes errorAppear {
  0% {
    opacity: 0;
    transform: translateY(10px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

/* -------------------- Buttons -------------------- */
.auth-button {
  width: 100%;
  padding: 16px;
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
  color: var(--text-on-brand);
  border: none;
  border-radius: var(--radius-medium);
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
  margin-top: 8px;
}
@media (hover: hover) {
  .auth-button:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
  }
}


.auth-button:active {
  transform: translateY(1px);
}

/* Copy button (for confirmation pages) */
.copy-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 14px 20px;
  background: var(--surface);
  border: 2px solid var(--primary-color);
  border-radius: var(--radius-medium);
  color: var(--primary-color);
  font-weight: 700;
  font-size: 16px;
  cursor: pointer;
  transition: var(--transition);
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}
@media (hover: hover) {
  .copy-btn:hover {
    background: var(--primary-light);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
  }
}


/* Telegram button (compact) */
.telegram-btn.compact {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px;
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
  color: var(--text-on-brand);
  border: none;
  border-radius: var(--radius-medium);
  font-weight: 700;
  font-size: 1rem;
  text-decoration: none;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
  margin-top: 15px;
}
@media (hover: hover) {
  .telegram-btn.compact:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
  }
}


/* -------------------- Links -------------------- */
.auth-footer {
  text-align: center;
  margin-top: 28px;
  color: var(--text-light);
  font-size: 15px;
}

.auth-link {
  color: var(--primary-color);
  font-weight: 600;
  text-decoration: none;
  position: relative;
  transition: var(--transition);
  display: inline-block;
  padding: 0 4px;
}

.auth-link::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--primary-color);
  transition: var(--transition);
}

.auth-link:hover {
  color: var(--primary-dark);
}

.auth-link:hover::after {
  width: 100%;
}

.forgot-password {
  text-align: right;
  margin-top: 12px;
}

.auth-forgot-link {
  color: var(--text-light);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transition: var(--transition);
  display: inline-block;
  position: relative;
  padding: 4px 0 2px;
}

.auth-forgot-link:hover {
  color: var(--primary-color);
}

.auth-forgot-link::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 1px;
  background: currentColor;
  transition: var(--transition);
}

.auth-forgot-link:hover::after {
  width: 100%;
}

/* -------------------- Password Strength -------------------- */
.password-strength-container {
  margin-top: 8px;
}

.password-strength {
  height: 6px;
  background: var(--gray-medium);
  border-radius: 3px;
  overflow: hidden;
  position: relative;
  margin-top: 12px;
}

.strength-meter {
  height: 100%;
  width: 0;
  transition: width 0.4s ease, background-color 0.4s ease;
  position: absolute;
  top: 0;
  left: 0;
}

.strength-label {
  font-size: 13px;
  font-weight: 600;
  margin-top: 5px;
  text-align: right;
}

.strength-weak { color: var(--danger-text); }
.strength-medium { color: var(--warning-text); }
.strength-strong { color: var(--success-text); }

/* -------------------- Confirmation Pages -------------------- */
.confirm-container {
  max-width: 500px;
  width: 100%;
  margin: 0 auto;
  padding: 40px;
  background: var(--surface);
  border-radius: var(--radius-large);
  box-shadow: var(--shadow-md);
  text-align: center;
  animation: fadeInUp 0.6s ease-out forwards;
}

.code-box {
  font-size: 1.8rem;
  background: var(--gray-light);
  padding: 20px;
  border-radius: var(--radius-medium);
  letter-spacing: 2px;
  font-weight: 600;
  color: var(--text-color);
  margin: 20px 0;
  border: 2px dashed var(--primary-light);
  word-break: break-all;
}

.instruction {
  text-align: left;
  background: var(--primary-light);
  padding: 20px;
  border-radius: var(--radius-medium);
  margin: 20px 0;
  border-left: 4px solid var(--primary-color);
}

.instruction ol {
  margin: 10px 0;
  padding-left: 20px;
}

.instruction li {
  margin: 10px 0;
  color: var(--text-color);
}

.instruction code {
  background: var(--surface);
  padding: 2px 6px;
  border-radius: var(--radius-small);
  color: var(--primary-dark);
  font-weight: 600;
}

#status {
  margin-top: 20px;
  color: var(--text-light);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 16px;
}

.loader-small {
  border: 3px solid var(--gray-light);
  border-top: 3px solid var(--primary-color);
  border-radius: 50%;
  width: 30px;
  height: 30px;
  animation: spin 1s linear infinite;
  margin: 20px auto;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.countdown {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--primary-color);
  margin-top: 10px;
}

/* Compact confirm (Telegram) */
.confirm-code-box {
  background: var(--gray-light);
  border: 2px dashed var(--primary-light);
  border-radius: var(--radius-medium);
  padding: 16px 20px;
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: 2px;
  text-align: center;
  color: var(--text-color);
  margin-bottom: 20px;
  word-break: break-all;
}

.instruction-card {
  border: 1px solid var(--gray-light);
  border-radius: var(--radius-medium);
  margin-bottom: 20px;
  overflow: hidden;
}

.instruction-toggle {
  width: 100%;
  padding: 14px 20px;
  background: var(--gray-light);
  border: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  color: var(--text-color);
  cursor: pointer;
  transition: background 0.2s;
  font-size: 16px;
}

.instruction-toggle:hover {
  background: var(--gray-medium);
}

.instruction-toggle.active svg {
  transform: rotate(180deg);
}

.instruction-toggle svg {
  transition: transform 0.3s;
}

.instruction-content {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition: max-height 0.4s ease, opacity 0.3s ease;
  background: var(--surface);
  padding: 0 20px;
}

.instruction-content.expanded {
  max-height: 500px;
  opacity: 1;
  padding: 20px;
}

.instruction-content ol {
  margin: 0;
  padding-left: 20px;
}

.instruction-content li {
  margin: 8px 0;
  color: var(--text-color);
  font-size: 15px;
}

.instruction-content code {
  background: var(--gray-light);
  padding: 2px 6px;
  border-radius: var(--radius-small);
  color: var(--primary-dark);
  font-size: 0.9em;
}

.help-text.compact {
  font-size: 0.8rem;
  margin-top: 8px;
  color: var(--text-light);
  line-height: 1.5;
}

.copy-notification {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--primary-color);
  color: var(--text-on-brand);
  padding: 10px 20px;
  border-radius: var(--radius-medium);
  font-weight: 600;
  box-shadow: var(--shadow-md);
  transition: transform 0.3s ease, opacity 0.3s ease;
  z-index: var(--z-toast);
  opacity: 0;
  font-size: 0.9rem;
}

.copy-notification.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* -------------------- Responsive -------------------- */
@media (max-width: 768px) {
  body {
    padding: 70px 16px 30px;
  }
  .auth-card {
    padding: 32px 24px;
  }
  .auth-header h1 {
    font-size: 28px;
  }
  .form-row {
    flex-direction: column;
    gap: 16px;
  }
  .confirm-container {
    padding: 32px 24px;
  }
  .confirm-code-box {
    font-size: 1.4rem;
    padding: 14px 16px;
  }
  .copy-btn {
    padding: 12px 16px;
    font-size: 15px;
  }
  .instruction-toggle {
    padding: 12px 16px;
    font-size: 15px;
  }
}

@media (max-width: 480px) {
  body {
    padding: 60px 12px 20px;
  }
  .auth-card {
    padding: 28px 20px;
    border-radius: var(--radius-large);
  }
  .auth-header h1 {
    font-size: 26px;
  }
  .auth-header::after {
    bottom: -12px;
    width: 60px;
  }
  .auth-card input[type='text'],
  .auth-card input[type='password'] {
    padding: 14px 18px;
    font-size: 15px;
  }
  .auth-button {
    padding: 14px;
    font-size: 16px;
  }
  .confirm-container {
    padding: 24px 16px;
  }
  .code-box {
    font-size: 1.4rem;
    padding: 12px;
  }
  .confirm-code-box {
    font-size: 1.2rem;
    padding: 12px;
  }
  .copy-btn {
    padding: 10px 14px;
    font-size: 14px;
  }
  .instruction-toggle {
    padding: 10px 14px;
    font-size: 14px;
  }
  .instruction-content.expanded {
    padding: 16px;
  }
  .telegram-btn.compact {
    padding: 10px;
    font-size: 0.95rem;
  }
  .loader-small {
    width: 24px;
    height: 24px;
    border-width: 2px;
  }
  .countdown {
    font-size: 1rem;
  }
  .copy-notification {
    bottom: 20px;
    padding: 8px 16px;
    font-size: 0.85rem;
  }
  .agreement-checkbox {
    margin: 16px 0 20px;
  }
  .checkbox-label {
    font-size: 12px;
    gap: 8px;
  }
  .checkmark {
    width: 18px;
    height: 18px;
  }
}

@media (max-width: 360px) {
  body {
    padding: 50px 8px 16px;
  }
  .auth-card {
    padding: 20px 16px;
  }
  .auth-header h1 {
    font-size: 24px;
  }
  .auth-card input[type='text'],
  .auth-card input[type='password'] {
    padding: 12px 16px;
    font-size: 14px;
  }
  .auth-button {
    padding: 12px;
    font-size: 15px;
  }
  .confirm-container {
    padding: 20px 12px;
  }
  .code-box {
    font-size: 1.2rem;
    padding: 8px;
  }
  .instruction-toggle {
    padding: 8px 10px;
    font-size: 0.8rem;
  }
  .instruction-content li {
    font-size: 0.75rem;
  }
  .telegram-btn.compact {
    padding: 8px;
    font-size: 0.85rem;
  }
}

/* -------------------- Animation -------------------- */
@keyframes fadeInUp {
  0% {
    opacity: 0;
    transform: translateY(20px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}