/* ════════════════════════════════════════════════════════════════
   Smart OTP v2 — Frontend Styles
   Design: clean, modern, premium — dark-indigo brand accent
   Font: DM Sans (loaded via Google Fonts in template if desired)
   ════════════════════════════════════════════════════════════════ */

/* ── Google Font import (optional — add to wp_head or theme) ── */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&display=swap');

/* ── Tokens ─────────────────────────────────────────────────── */
:root {
  --sotp-accent:        #4f46e5;      /* indigo-600        */
  --sotp-accent-hover:  #4338ca;      /* indigo-700        */
  --sotp-accent-light:  #eef2ff;      /* indigo-50         */
  --sotp-accent-ring:   rgba(79,70,229,.18);
  --sotp-success:       #16a34a;
  --sotp-success-bg:    #f0fdf4;
  --sotp-success-ring:  rgba(22,163,74,.18);
  --sotp-error:         #dc2626;
  --sotp-error-bg:      #fff1f2;
  --sotp-error-ring:    rgba(220,38,38,.18);
  --sotp-text:          #111827;
  --sotp-text-muted:    #6b7280;
  --sotp-text-light:    #9ca3af;
  --sotp-border:        #e5e7eb;
  --sotp-bg-card:       #ffffff;
  --sotp-bg-page:       #f8f9fc;
  --sotp-radius-sm:     8px;
  --sotp-radius:        14px;
  --sotp-radius-lg:     20px;
  --sotp-shadow:        0 4px 6px -1px rgba(0,0,0,.07), 0 2px 4px -1px rgba(0,0,0,.04);
  --sotp-shadow-lg:     0 20px 40px -8px rgba(0,0,0,.12), 0 8px 16px -4px rgba(0,0,0,.06);
  --sotp-font:          'DM Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --sotp-transition:    .18s cubic-bezier(.4,0,.2,1);
}

/* ── Page wrapper ────────────────────────────────────────────── */
.sotp-page-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 16px;
  background: var(--sotp-bg-page);
  background-image:
    radial-gradient(ellipse 60% 40% at 20% 10%, rgba(79,70,229,.06) 0%, transparent 70%),
    radial-gradient(ellipse 40% 50% at 80% 90%, rgba(79,70,229,.05) 0%, transparent 70%);
  font-family: var(--sotp-font);
}

/* ── Card ────────────────────────────────────────────────────── */
.sotp-card-outer {
  width: 100%;
  max-width: 400px;
  background: var(--sotp-bg-card);
  border-radius: var(--sotp-radius-lg);
  box-shadow: var(--sotp-shadow-lg);
  padding: 36px 32px 40px;
  box-sizing: border-box;
  position: relative;
  overflow: hidden;
}

/* subtle top-edge accent line */
.sotp-card-outer::before {
  content: '';
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  background: linear-gradient(90deg, var(--sotp-accent), #818cf8, var(--sotp-accent));
  background-size: 200% 100%;
  animation: sotp-shimmer 3s linear infinite;
}

@keyframes sotp-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Brand row ───────────────────────────────────────────────── */
.sotp-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
}

.sotp-brand-icon {
  width: 40px; height: 40px;
  background: var(--sotp-accent-light);
  color: var(--sotp-accent);
  border-radius: var(--sotp-radius-sm);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.sotp-brand-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--sotp-text);
  letter-spacing: -.2px;
}

/* ── Steps ───────────────────────────────────────────────────── */
.sotp-step {
  display: none;
  animation: sotp-fadein .24s ease;
}

.sotp-step--active { display: block; }

@keyframes sotp-fadein {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Typography ──────────────────────────────────────────────── */
.sotp-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--sotp-text);
  margin: 0 0 6px;
  letter-spacing: -.3px;
  line-height: 1.3;
}

.sotp-subtitle {
  font-size: 14px;
  color: var(--sotp-text-muted);
  margin: 0 0 24px;
  line-height: 1.6;
}

.sotp-hint {
  font-size: 12.5px;
  color: var(--sotp-text-light);
  margin: 6px 0 4px;
  line-height: 1.5;
}

/* ── Phone input row ─────────────────────────────────────────── */
.sotp-input-group {
  display: flex;
  align-items: stretch;
  border: 1.5px solid var(--sotp-border);
  border-radius: var(--sotp-radius);
  overflow: hidden;
  transition: border-color var(--sotp-transition), box-shadow var(--sotp-transition);
  background: #fff;
}

.sotp-input-group:focus-within {
  border-color: var(--sotp-accent);
  box-shadow: 0 0 0 4px var(--sotp-accent-ring);
}

.sotp-input-group.is-valid {
  border-color: var(--sotp-success);
  box-shadow: 0 0 0 4px var(--sotp-success-ring);
}

.sotp-input-group.is-error {
  border-color: var(--sotp-error);
  box-shadow: 0 0 0 4px var(--sotp-error-ring);
}

.sotp-phone-prefix {
  display: flex; align-items: center;
  padding: 0 14px;
  font-size: 15px;
  font-weight: 600;
  color: var(--sotp-text-muted);
  background: #f9fafb;
  border-right: 1.5px solid var(--sotp-border);
  user-select: none;
  white-space: nowrap;
  letter-spacing: .2px;
}

.sotp-phone-input {
  flex: 1;
  border: none !important;
  outline: none !important;
  padding: 14px 14px !important;
  font-size: 16px !important;
  font-family: var(--sotp-font) !important;
  font-weight: 500 !important;
  color: var(--sotp-text) !important;
  background: transparent !important;
  letter-spacing: .5px;
  box-shadow: none !important;
  border-radius: 0 !important;
  width: 100% !important;
  box-sizing: border-box;
}

.sotp-phone-input::placeholder { color: var(--sotp-text-light); font-weight: 400; }

/* ── Validation messages ─────────────────────────────────────── */
.sotp-validation-msg {
  font-size: 13px;
  font-weight: 500;
  min-height: 20px;
  margin: 4px 0 8px;
  display: none;
  align-items: center;
  gap: 5px;
}

.sotp-validation-msg:not(:empty) { display: flex; }
.sotp-validation-msg--error  { color: var(--sotp-error); }
.sotp-validation-msg--success { color: var(--sotp-success); }

/* phone-step uses generic class; colour set by JS */
#sotp-phone-msg { }

/* ── Buttons ─────────────────────────────────────────────────── */
.sotp-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px 20px;
  border: none;
  border-radius: var(--sotp-radius);
  font-size: 15px;
  font-family: var(--sotp-font);
  font-weight: 600;
  cursor: pointer;
  transition: background var(--sotp-transition), transform var(--sotp-transition), box-shadow var(--sotp-transition);
  margin-top: 16px;
  box-sizing: border-box;
  position: relative;
  overflow: hidden;
  letter-spacing: .1px;
}

.sotp-btn--primary {
  background: var(--sotp-accent);
  color: #fff;
  box-shadow: 0 2px 8px rgba(79,70,229,.35);
}

.sotp-btn--primary:hover {
  background: var(--sotp-accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(79,70,229,.4);
}

.sotp-btn--primary:active { transform: translateY(0); }

.sotp-btn:disabled {
  opacity: .55;
  cursor: not-allowed;
  transform: none !important;
}

/* Loading spinner inside button */
.sotp-btn-spinner {
  display: none;
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: sotp-spin .7s linear infinite;
  flex-shrink: 0;
}

.sotp-btn.is-loading .sotp-btn-label  { opacity: .6; }
.sotp-btn.is-loading .sotp-btn-spinner { display: block; }

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

/* ── Back button (text link style) ──────────────────────────── */
.sotp-back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  color: var(--sotp-text-muted);
  font-size: 13px;
  font-family: var(--sotp-font);
  font-weight: 500;
  cursor: pointer;
  padding: 0;
  margin-bottom: 20px;
  transition: color var(--sotp-transition);
}
.sotp-back-link:hover { color: var(--sotp-text); }

/* ── OTP icon on step 2 ──────────────────────────────────────── */
.sotp-otp-icon {
  width: 64px; height: 64px;
  background: var(--sotp-accent-light);
  color: var(--sotp-accent);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 16px;
}

/* ── Phone display (step 2) ──────────────────────────────────── */
.sotp-phone-display {
  color: var(--sotp-text);
  font-weight: 700;
}

/* ── OTP digit boxes ─────────────────────────────────────────── */
.sotp-otp-inputs {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin: 24px 0 6px;
  flex-wrap: wrap;
}

.sotp-otp-digit {
  width: 54px !important;
  height: 60px !important;
  font-size: 26px !important;
  font-weight: 700 !important;
  text-align: center !important;
  border: 1.5px solid var(--sotp-border) !important;
  border-radius: var(--sotp-radius-sm) !important;
  background: #fafbfc !important;
  color: var(--sotp-text) !important;
  font-family: var(--sotp-font) !important;
  box-sizing: border-box !important;
  transition: border-color var(--sotp-transition), box-shadow var(--sotp-transition), background var(--sotp-transition) !important;
  outline: none !important;
  caret-color: var(--sotp-accent);
  /* Prevent theme overrides */
  padding: 0 !important;
  margin: 0 !important;
  line-height: 1 !important;
  box-shadow: none !important;
}

.sotp-otp-digit:focus {
  border-color: var(--sotp-accent) !important;
  box-shadow: 0 0 0 4px var(--sotp-accent-ring) !important;
  background: #fff !important;
}

.sotp-otp-digit.is-filled {
  background: var(--sotp-accent-light) !important;
  border-color: var(--sotp-accent) !important;
  color: var(--sotp-accent) !important;
}

.sotp-otp-digit.is-error {
  border-color: var(--sotp-error) !important;
  box-shadow: 0 0 0 3px var(--sotp-error-ring) !important;
  animation: sotp-shake .3s ease;
}

@keyframes sotp-shake {
  0%, 100% { transform: translateX(0); }
  25%       { transform: translateX(-4px); }
  75%       { transform: translateX(4px); }
}

/* ── Resend block ────────────────────────────────────────────── */
.sotp-resend {
  text-align: center;
  margin-top: 20px;
  font-size: 13.5px;
  color: var(--sotp-text-muted);
}

.sotp-resend a {
  color: var(--sotp-accent);
  font-weight: 600;
  text-decoration: none;
  transition: color var(--sotp-transition);
}
.sotp-resend a:hover { color: var(--sotp-accent-hover); text-decoration: underline; }

/* ── Step 3: success ─────────────────────────────────────────── */
.sotp-success-icon {
  width: 80px; height: 80px;
  background: var(--sotp-success-bg);
  color: var(--sotp-success);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 20px;
  animation: sotp-pop .4s cubic-bezier(.34,1.56,.64,1);
}

@keyframes sotp-pop {
  from { transform: scale(.6); opacity: 0; }
  to   { transform: scale(1);  opacity: 1; }
}

.sotp-redirect-bar {
  height: 4px;
  background: var(--sotp-border);
  border-radius: 99px;
  margin-top: 24px;
  overflow: hidden;
}

.sotp-redirect-bar-fill {
  height: 100%;
  background: var(--sotp-success);
  border-radius: 99px;
  width: 0%;
  animation: sotp-progress 2s ease-in-out forwards;
}

@keyframes sotp-progress {
  to { width: 100%; }
}

/* ── Mobile responsive ───────────────────────────────────────── */
@media (max-width: 480px) {
  .sotp-card-outer { padding: 28px 20px 32px; }
  .sotp-title { font-size: 19px; }
  .sotp-otp-digit {
    width: 46px !important;
    height: 52px !important;
    font-size: 22px !important;
  }
  .sotp-otp-inputs { gap: 8px; }
}

@media (max-width: 360px) {
  .sotp-otp-digit {
    width: 38px !important;
    height: 46px !important;
    font-size: 19px !important;
  }
  .sotp-otp-inputs { gap: 6px; }
}

/* ── Autofill override (prevent browser yellow) ──────────────── */
.sotp-phone-input:-webkit-autofill,
.sotp-phone-input:-webkit-autofill:hover,
.sotp-phone-input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 1000px #fff inset !important;
  -webkit-text-fill-color: var(--sotp-text) !important;
}
