/*
 * Telegram Mini App styling.
 *
 * We use Telegram's theme CSS variables (--tg-theme-*) where available so the
 * app automatically matches the user's Telegram light/dark theme. Sensible
 * fallbacks are provided for when the app is opened outside Telegram.
 */

:root {
  /* Fallbacks; overridden by Telegram theme params injected in app.js. */
  --bg: var(--tg-theme-bg-color, #ffffff);
  --secondary-bg: var(--tg-theme-secondary-bg-color, #f1f1f4);
  --text: var(--tg-theme-text-color, #1c1c1e);
  --hint: var(--tg-theme-hint-color, #8e8e93);
  --link: var(--tg-theme-link-color, #2481cc);
  --button: var(--tg-theme-button-color, #2481cc);
  --button-text: var(--tg-theme-button-text-color, #ffffff);

  --radius: 14px;
  --success: #2ecc71;
  --error: #e74c3c;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: 420px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 32px) 20px
    calc(env(safe-area-inset-bottom) + 24px);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ---- Header ---- */
.header {
  text-align: center;
  margin-bottom: 28px;
}

.logo {
  color: var(--button);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--secondary-bg);
  margin-bottom: 16px;
}

.title {
  font-size: 22px;
  font-weight: 600;
  margin: 0 0 6px;
}

.subtitle {
  font-size: 15px;
  color: var(--hint);
  margin: 0;
  line-height: 1.4;
}

/* ---- Card ---- */
.card {
  background: var(--secondary-bg);
  border-radius: var(--radius);
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

/* ---- OTP inputs ---- */
.otp {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.otp-input {
  width: 100%;
  aspect-ratio: 1 / 1;
  text-align: center;
  font-size: 24px;
  font-weight: 600;
  color: var(--text);
  background: var(--bg);
  border: 2px solid transparent;
  border-radius: 12px;
  outline: none;
  transition: border-color 0.15s ease, transform 0.1s ease;
}

.otp-input:focus {
  border-color: var(--button);
}

.otp-input.filled {
  border-color: var(--button);
}

/* ---- Button ---- */
.btn {
  position: relative;
  width: 100%;
  border: none;
  border-radius: 12px;
  padding: 15px;
  font-size: 16px;
  font-weight: 600;
  color: var(--button-text);
  background: var(--button);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.15s ease, transform 0.05s ease;
}

.btn:active {
  transform: scale(0.99);
}

.btn:disabled {
  opacity: 0.6;
  cursor: default;
}

/* ---- Loading spinner ---- */
.spinner {
  position: absolute;
  width: 20px;
  height: 20px;
  border: 2.5px solid rgba(255, 255, 255, 0.4);
  border-top-color: var(--button-text);
  border-radius: 50%;
  display: none;
  animation: spin 0.7s linear infinite;
}

.btn.loading .btn-label {
  visibility: hidden;
}

.btn.loading .spinner {
  display: block;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---- Toast notifications ---- */
.toast {
  margin-top: auto;
  text-align: center;
  font-size: 15px;
  font-weight: 500;
  padding: 0 8px;
  min-height: 24px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.success {
  color: var(--success);
}

.toast.error {
  color: var(--error);
}

/* ---- Success checkmark animation ---- */
.success-anim {
  display: flex;
  justify-content: center;
  margin-top: 24px;
}

.success-anim svg {
  width: 64px;
  height: 64px;
  color: var(--success);
}

.success-anim .check-circle {
  stroke-dasharray: 76;
  stroke-dashoffset: 76;
  animation: draw 0.5s ease forwards;
}

.success-anim .check-mark {
  stroke-dasharray: 18;
  stroke-dashoffset: 18;
  animation: draw 0.3s ease 0.45s forwards;
}

@keyframes draw {
  to {
    stroke-dashoffset: 0;
  }
}
