/* modal.css — Registration modal (phone → code → form → invoice → success) + OTP inputs + Footer.
   Shared by /business, /school and the cabinet (inputs, code cells). Look: a frosted card with a
   hairline border and an inset highlight (Authkit-style), flat accent, no gradients. Tokens: base.css. */

.modal-overlay {
  position: fixed; inset: 0; z-index: 10000;
  background: rgba(0,0,0,0.72); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s;
}
.modal-overlay.open { opacity: 1; pointer-events: auto; }
.modal-box {
  background: var(--surface, #0f1011);
  border: 1px solid var(--border-strong, #383b3f);
  box-shadow: 0 1px 0 rgba(255,255,255,0.06) inset, 0 24px 60px rgba(0,0,0,0.5);
  border-radius: var(--radius-lg, 16px); padding: 28px 24px 24px; width: 92%; max-width: 420px;
  position: relative; transform: translateY(12px);
  transition: transform 0.3s cubic-bezier(0.16,1,0.3,1);
  color: var(--text-2, #d0d6e0); font-family: var(--font-ui, inherit);
  max-height: 92dvh; overflow: auto; -webkit-overflow-scrolling: touch;
}
.modal-overlay.open .modal-box { transform: none; }
.modal-close {
  position: absolute; top: 8px; right: 8px; width: 44px; height: 44px;
  background: none; border: none; color: var(--muted, #8a8f98);
  font-size: 26px; cursor: pointer; line-height: 1; border-radius: var(--radius-sm, 6px);
  display: flex; align-items: center; justify-content: center;
}
.modal-close:hover { color: #fff; background: var(--surface-2, #161718); }
.modal-title {
  font-size: 20px; font-weight: 700; color: #fff; margin: 0 32px 14px 0; letter-spacing: -0.01em;
}
.modal-prompt-preview {
  display: none; padding: 10px 12px; border-radius: var(--radius-sm, 6px); margin-bottom: 14px;
  background: var(--surface-2, #161718); border: 1px solid var(--border, #23252a);
  font-size: 13px; color: var(--text-2, #d0d6e0); line-height: 1.5;
  max-height: 80px; overflow: hidden;
}

/* Stepper: 1 телефон · 2 код · 3 о бизнесе */
.modal-steps { display: flex; gap: 6px; list-style: none; margin: 0 0 18px; padding: 0; counter-reset: s; }
.modal-steps li { flex: 1; display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted, #8a8f98); }
.modal-steps li::before { content: ''; display: block; height: 3px; border-radius: 2px; background: var(--border, #23252a); }
.modal-steps li.done::before, .modal-steps li.now::before { background: var(--accent); }
.modal-steps li.now { color: #fff; }
.modal-steps li.done { color: var(--text-2, #d0d6e0); }

.modal-form { display: flex; flex-direction: column; gap: 10px; }
.modal-step { display: flex; flex-direction: column; gap: 10px; }
.modal-step[hidden] { display: none; }
.reg-field { display: block; }
.reg-label { display: block; font-size: 13px; color: var(--text-2, #d0d6e0); margin: 0 0 6px; }
.reg-label small { color: var(--muted, #8a8f98); }
.reg-input {
  width: 100%; min-height: 48px; padding: 12px 14px; border-radius: var(--radius-sm, 6px);
  background: var(--surface-2, #161718); border: 1px solid var(--border-strong, #383b3f);
  color: #fff; font-size: 16px; font-family: inherit;
  outline: none; transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none; appearance: none;
}
.reg-input::placeholder { color: var(--muted, #8a8f98); }
.reg-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent) inset;
}
select.reg-input { cursor: pointer; background-image: linear-gradient(45deg, transparent 50%, var(--muted, #8a8f98) 50%), linear-gradient(135deg, var(--muted, #8a8f98) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 36px; }
select.reg-input option { background: #161718; color: #fff; }

.modal-submit {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 48px; padding: 0 16px; border: 1px solid var(--accent); border-radius: var(--radius-sm, 6px);
  background: var(--accent); color: var(--on-accent, #052e1f); font-size: 15px; font-weight: 600; font-family: inherit;
  cursor: pointer; transition: filter 0.15s; text-decoration: none;
}
.modal-submit:hover { filter: brightness(1.05); }
.modal-submit:disabled { opacity: 0.55; cursor: default; filter: none; }

.modal-note {
  font-size: 13px; color: var(--muted, #8a8f98); text-align: left; line-height: 1.5;
  margin: 0;
}
.reg-result {
  font-size: 14px; font-weight: 600; text-align: center;
  min-height: 20px;
}
.reg-result:empty { min-height: 0; }
.reg-result.success { color: var(--accent-text, #6ee7b7); }
.reg-result.error { color: var(--danger-text, #fca5a5); }

/* OTP phone row */
.otp-phone-row {
  display: flex; align-items: center; gap: 0; min-height: 48px;
  background: var(--surface-2, #161718); border: 1px solid var(--border-strong, #383b3f);
  border-radius: var(--radius-sm, 6px); overflow: hidden; transition: border-color 0.15s, box-shadow 0.15s;
}
.otp-phone-row:focus-within { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.otp-prefix { padding: 0 0 0 14px; color: var(--text-2, #d0d6e0); font-size: 16px; font-weight: 600; flex-shrink: 0; }
.otp-phone-input {
  border: none !important; background: transparent !important;
  border-radius: 0 !important; padding-left: 6px !important;
  box-shadow: none !important; min-height: 46px;
}

/* OTP code digits: six cells of 44px fit a 360px screen with 20px gutters */
.otp-code-row { display: flex; align-items: center; justify-content: center; gap: 6px; }
.otp-digit {
  width: 44px; height: 48px; border-radius: var(--radius-sm, 6px); flex: none;
  background: var(--surface-2, #161718); border: 1px solid var(--border-strong, #383b3f);
  color: #fff; font-size: 22px; font-weight: 600;
  text-align: center; outline: none; font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s; caret-color: var(--accent);
  -webkit-appearance: none; appearance: none;
}
.otp-digit:focus { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.otp-dash { color: var(--muted, #8a8f98); font-size: 16px; }

/* Sent info and resend */
.otp-sent-info { text-align: center; font-size: 14px; color: var(--text-2, #d0d6e0); }
.otp-resend { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; }
.otp-resend-btn {
  background: none; border: none; color: var(--accent-text, #6ee7b7);
  font-size: 14px; cursor: pointer; font-family: inherit; min-height: 44px; padding: 0 8px;
}
.otp-resend-btn:disabled { color: var(--muted, #8a8f98); cursor: default; }
.otp-timer { font-size: 13px; color: var(--muted, #8a8f98); }

/* Payment step */
.pay-info { text-align: center; padding: 8px 0 4px; }
.pay-tariff { font-size: 13px; color: var(--muted, #8a8f98); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; margin-bottom: 8px; }
.pay-amount { font-size: 34px; font-weight: 700; color: #fff; letter-spacing: -0.02em; }
.pay-invoice { font-family: var(--font-mono, ui-monospace, monospace); font-size: 13px; letter-spacing: 0.04em; color: var(--muted, #8a8f98); margin: 6px 0 2px; }
.pay-note { font-size: 13px; color: var(--text-2, #d0d6e0); margin-top: 8px; line-height: 1.5; }
.pay-legal { font-size: 13px; color: var(--muted, #8a8f98); margin: 4px 0; line-height: 1.5; }
.pay-legal a, .consent-label a, .modal-note a { color: var(--accent-text, #6ee7b7); }
.kaspi-btn { background: var(--kaspi, #f14635) !important; border-color: var(--kaspi, #f14635) !important; color: #fff !important; }
.pay-status { text-align: center; font-size: 13px; color: var(--muted, #8a8f98); display: flex; align-items: center; justify-content: center; gap: 8px; }
.pay-status::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--warn, #f59e0b); animation: payPulse 1.6s ease-in-out infinite; }
@keyframes payPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
.pay-manual { text-align: center; font-size: 13px; color: var(--text-2, #d0d6e0); padding-top: 4px; line-height: 1.5; }
.pay-manual strong { color: #fff; }
.pay-manual:empty { display: none; }

/* Success */
.otp-success { text-align: center; padding: 12px 0 4px; }
.otp-success-icon {
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--accent-soft, rgba(16,185,129,0.14)); border: 1px solid var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; color: var(--accent-text, #6ee7b7); margin: 0 auto 14px;
}
.otp-success-text { font-size: 15px; color: var(--text-2, #d0d6e0); font-weight: 500; line-height: 1.55; }
#cabinetBtn { margin-top: 16px; }

/* Consent */
.consent-label { display: flex; align-items: flex-start; gap: 10px; margin: 4px 0 2px; font-size: 13px; color: var(--text-2, #d0d6e0); text-align: left; line-height: 1.5; cursor: pointer; }
.consent-label input { width: 18px; height: 18px; margin-top: 1px; flex-shrink: 0; accent-color: var(--accent); }

/* Bottom sheet on phones: the keyboard no longer hides the card */
@media (max-width: 600px) {
  .modal-overlay { align-items: flex-end; }
  .modal-box { width: 100%; max-width: none; border-radius: var(--radius-lg, 16px) var(--radius-lg, 16px) 0 0; padding: 24px 20px calc(20px + env(safe-area-inset-bottom)); transform: translateY(24px); border-bottom: 0; }
}
@media (max-width: 360px) {
  .otp-code-row { gap: 4px; }
  .otp-digit { width: 42px; }
}

/* Footer */
.footer { text-align: center; padding: 40px 20px 60px; background: #060310; color: #666; font-size: 13px; }
.footer a { color: var(--accent); text-decoration: none; }
.footer-ai { margin-top: 8px; font-size: 12px; color: var(--accent); font-weight: 600; }

/* --- Вход через Telegram (modal.js, api/qural/tg/*): second way on the phone step, then a waiting screen --- */
.modal-or { display: flex; align-items: center; gap: 10px; margin: 10px 0; color: var(--muted, #8a8f98); font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; }
.modal-or::before, .modal-or::after { content: ''; flex: 1; height: 1px; background: var(--border, #23252a); }
.modal-alt { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 48px; padding: 0 16px; border-radius: var(--radius-sm, 6px); border: 1px solid var(--border-strong, #383b3f); background: var(--surface-2, #161718); color: var(--text-1, #fff); font-size: 15px; font-weight: 600; font-family: inherit; cursor: pointer; text-decoration: none; transition: border-color 0.15s, filter 0.15s; }
.modal-alt:hover { border-color: var(--muted, #8a8f98); }
.modal-alt.tg, .modal-submit.tg { background: #2aabee; border-color: #2aabee; color: #fff; }
.modal-alt.tg::before, .modal-submit.tg::before, .cab-btn.tg::before { content: ''; width: 18px; height: 18px; flex: none; background: currentColor; -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9.4 15.7 9 21c.5 0 .8-.2 1-.5l2.5-2.4 5.2 3.8c1 .5 1.6.3 1.9-.9L23 4.3c.3-1.4-.5-2-1.5-1.6L1.6 10.4c-1.4.5-1.3 1.3-.2 1.6l5.1 1.6L18.3 6c.6-.4 1.1-.2.7.2z'/%3E%3C/svg%3E") center/contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9.4 15.7 9 21c.5 0 .8-.2 1-.5l2.5-2.4 5.2 3.8c1 .5 1.6.3 1.9-.9L23 4.3c.3-1.4-.5-2-1.5-1.6L1.6 10.4c-1.4.5-1.3 1.3-.2 1.6l5.1 1.6L18.3 6c.6-.4 1.1-.2.7.2z'/%3E%3C/svg%3E") center/contain no-repeat; }
.modal-link { background: none; border: 0; color: var(--accent-text, #6ee7b7); font: inherit; font-size: 13px; cursor: pointer; min-height: 44px; padding: 0 6px; width: 100%; }
.tg-wait { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; padding: 8px 0 4px; }
.tg-wait-text { margin: 0; color: var(--text-2, #d0d6e0); font-size: 15px; line-height: 1.5; }
.tg-spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--border-strong, #383b3f); border-top-color: #2aabee; animation: tgSpin 0.9s linear infinite; }
@keyframes tgSpin { to { transform: rotate(360deg); } }
