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

:root {
  --primary: #3B5BDB;
  --primary-hover: #2f4cc7;
  --primary-active: #2540b0;
  --bg: #b0b7e8;
  --card-bg: #ffffff;
  --text-title: #1a1d2e;
  --text-body: #52576e;
  --text-light: #8c91a8;
  --border: #dde1f0;
  --border-focus: #3B5BDB;
  --input-bg: #f8f9ff;
  --input-active-bg: #ffffff;
  --error: #e03535;
  --success: #2a9d5c;
  --shadow-card: 0 24px 64px rgba(59,91,219,0.10), 0 2px 12px rgba(59,91,219,0.06);
  --shadow-input: 0 2px 8px rgba(59,91,219,0.08);
  --radius-card: 22px;
  --radius-input: 13px;
  --radius-btn: 13px;
  --transition: 0.18s cubic-bezier(0.4,0,0.2,1);
}

html, body {
  height: 100%;
  font-family: 'DM Sans', sans-serif;
}

/* ===== Background ===== */
.page-bg {
  min-height: 100vh;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  background-image: radial-gradient(ellipse 70% 60% at 60% 40%, #c5cbf2 0%, transparent 70%),
                    radial-gradient(ellipse 50% 40% at 20% 80%, #a0aadd 0%, transparent 60%);
  padding: 20px;
}

/* ===== Card ===== */
.card {
  background: var(--card-bg);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  width: 100%;
  max-width: 540px;
  overflow: hidden;
  position: relative;
  animation: cardIn 0.48s cubic-bezier(0.22,1,0.36,1) both;
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(32px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.card-inner {
  padding: 56px 48px 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  position: relative;
}

/* ===== Icon ===== */
.icon-wrap {
  margin-bottom: 24px;
  animation: fadeDown 0.4s 0.1s both;
}

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

/* ===== Title ===== */
.title {
  font-family: 'DM Serif Display', serif;
  font-size: clamp(1.6rem, 4vw, 2rem);
  font-weight: 400;
  color: var(--text-title);
  letter-spacing: -0.5px;
  margin-bottom: 10px;
  animation: fadeDown 0.4s 0.15s both;
}

.subtitle {
  font-size: clamp(0.875rem, 2.2vw, 0.975rem);
  color: var(--text-body);
  margin-bottom: 36px;
  text-align: center;
  line-height: 1.5;
  animation: fadeDown 0.4s 0.2s both;
}

/* ===== OTP Inputs ===== */
.otp-wrapper {
  display: flex;
  gap: clamp(8px, 2vw, 14px);
  justify-content: center;
  margin-bottom: 10px;
  animation: fadeDown 0.4s 0.25s both;
  width: 100%;
}

.otp-input {
  width: clamp(44px, 11vw, 70px);
  height: clamp(54px, 12vw, 76px);
  border: 1.8px solid var(--border);
  border-radius: var(--radius-input);
  background: var(--input-bg);
  text-align: center;
  font-family: 'DM Sans', sans-serif;
  font-size: clamp(1.25rem, 3.5vw, 1.65rem);
  font-weight: 600;
  color: var(--text-title);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition), transform var(--transition);
  caret-color: var(--primary);
  -webkit-appearance: none;
  appearance: none;
}

.otp-input:focus {
  border-color: var(--border-focus);
  background: var(--input-active-bg);
  box-shadow: 0 0 0 3.5px rgba(59,91,219,0.13), var(--shadow-input);
  transform: translateY(-2px) scale(1.035);
}

.otp-input.filled {
  border-color: #a0abf5;
  background: #f0f2ff;
}

.otp-input.error-shake {
  border-color: var(--error);
  box-shadow: 0 0 0 3px rgba(224,53,53,0.12);
  animation: shake 0.38s cubic-bezier(0.36,0.07,0.19,0.97) both;
}

@keyframes shake {
  10%, 90%  { transform: translateX(-3px); }
  20%, 80%  { transform: translateX(5px); }
  30%, 50%, 70% { transform: translateX(-6px); }
  40%, 60%  { transform: translateX(6px); }
  100%      { transform: translateX(0); }
}

/* ===== Error ===== */
.error-msg {
  color: var(--error);
  font-size: 0.82rem;
  font-weight: 500;
  margin-bottom: 0;
  margin-top: 4px;
  min-height: 20px;
  opacity: 0;
  transition: opacity 0.2s;
  text-align: center;
}

.error-msg.show {
  opacity: 1;
}

/* ===== Button ===== */
.verify-btn {
  margin-top: 28px;
  width: 100%;
  max-width: 220px;
  height: 52px;
  background: var(--primary);
  color: #fff;
  font-family: 'DM Sans', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-btn);
  cursor: pointer;
  letter-spacing: 0.3px;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
  box-shadow: 0 4px 18px rgba(59,91,219,0.22);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  position: relative;
  overflow: hidden;
  animation: fadeDown 0.4s 0.3s both;
}

.verify-btn:hover {
  background: var(--primary-hover);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(59,91,219,0.28);
}

.verify-btn:active {
  background: var(--primary-active);
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(59,91,219,0.18);
}

.verify-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none;
}

.btn-spinner {
  display: none;
  width: 18px;
  height: 18px;
  border: 2.5px solid rgba(255,255,255,0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

.verify-btn.loading .btn-text { display: none; }
.verify-btn.loading .btn-spinner { display: block; }

/* ===== Resend ===== */
.resend-text {
  margin-top: 24px;
  font-size: 0.9rem;
  color: var(--text-light);
  text-align: center;
  animation: fadeDown 0.4s 0.35s both;
}

.resend-link {
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
  transition: color var(--transition), text-decoration var(--transition);
}

.resend-link:hover {
  color: var(--primary-hover);
  text-decoration: underline;
}

.resend-link.disabled {
  color: var(--text-light);
  pointer-events: none;
  font-weight: 400;
}

.resend-timer {
  font-size: 0.82rem;
  color: var(--text-light);
  margin-top: 6px;
  min-height: 18px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* ===== Success Overlay ===== */
.success-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-card);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
  backdrop-filter: blur(4px);
}

.success-overlay.show {
  opacity: 1;
  pointer-events: all;
}

.success-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  animation: successPop 0.42s cubic-bezier(0.22,1,0.36,1) both;
}

@keyframes successPop {
  from { opacity: 0; transform: scale(0.7); }
  to   { opacity: 1; transform: scale(1); }
}

.success-icon {
  animation: bounceIn 0.5s 0.05s cubic-bezier(0.22,1,0.36,1) both;
}

@keyframes bounceIn {
  from { transform: scale(0.5); opacity: 0; }
  60%  { transform: scale(1.15); }
  to   { transform: scale(1); opacity: 1; }
}

.success-msg {
  font-family: 'DM Serif Display', serif;
  font-size: 1.4rem;
  color: var(--text-title);
  letter-spacing: -0.3px;
}

/* ===== Responsive ===== */

/* Tablet */
@media (max-width: 600px) {
  .card-inner {
    padding: 40px 28px 36px;
  }
}

/* Mobile */
@media (max-width: 420px) {
  .card-inner {
    padding: 32px 16px 28px;
  }

  .otp-wrapper {
    gap: 7px;
  }

  .otp-input {
    border-radius: 10px;
    font-size: 1.2rem;
  }

  .verify-btn {
    max-width: 100%;
  }

  .title {
    font-size: 1.45rem;
  }

  .subtitle {
    font-size: 0.85rem;
  }
}

/* Very small phones */
@media (max-width: 340px) {
  .otp-input {
    width: 40px;
    height: 48px;
    font-size: 1.1rem;
  }

  .otp-wrapper {
    gap: 5px;
  }
}
