/* ============================================================
   otp.css  –  Shared OTP UI  (imported by all portals)
   Design: Clean, trust-inspiring, telco aesthetic
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Sora:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;600&display=swap');

/* ── CSS Variables (portals can override these) ── */
:root {
  --otp-primary:      #0057FF;
  --otp-primary-dark: #003FBF;
  --otp-accent:       #00E5B0;
  --otp-bg:           #F0F4FF;
  --otp-card-bg:      #FFFFFF;
  --otp-text:         #0D1B3E;
  --otp-muted:        #6B7A99;
  --otp-border:       #D6E0FF;
  --otp-error:        #FF3B5C;
  --otp-success:      #00C48C;
  --otp-warn:         #FF8C00;
  --otp-radius:       16px;
  --otp-shadow:       0 8px 40px rgba(0,87,255,0.10);
}

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

body.otp-page {
  font-family: 'Sora', sans-serif;
  background: var(--otp-bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  position: relative;
  overflow: hidden;
}

/* ── Background decoration ── */
body.otp-page::before,
body.otp-page::after {
  content: '';
  position: fixed;
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
}
body.otp-page::before {
  width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(0,87,255,0.08) 0%, transparent 70%);
  top: -200px; right: -100px;
}
body.otp-page::after {
  width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(0,229,176,0.10) 0%, transparent 70%);
  bottom: -100px; left: -80px;
}

/* ── Portal Brand Header ── */
.otp-brand {
  text-align: center;
  margin-bottom: 28px;
  position: relative; z-index: 1;
  animation: fadeDown 0.5s ease both;
}
.otp-brand .portal-logo {
  max-height: 48px;
  margin-bottom: 8px;
}
.otp-brand .portal-name {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--otp-muted);
}

/* ── Card ── */
.otp-card {
  background: var(--otp-card-bg);
  border-radius: var(--otp-radius);
  box-shadow: var(--otp-shadow);
  border: 1px solid var(--otp-border);
  padding: 40px 36px;
  width: 100%;
  max-width: 420px;
  position: relative;
  z-index: 1;
  animation: fadeUp 0.5s ease 0.1s both;
}

/* Accent bar top */
.otp-card::before {
  content: '';
  position: absolute;
  top: 0; left: 24px; right: 24px;
  height: 3px;
  background: linear-gradient(90deg, var(--otp-primary), var(--otp-accent));
  border-radius: 0 0 4px 4px;
}

/* ── Card Header ── */
.otp-card-header {
  text-align: center;
  margin-bottom: 28px;
}
.otp-icon {
  width: 56px; height: 56px;
  background: linear-gradient(135deg, var(--otp-primary), var(--otp-accent));
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  box-shadow: 0 4px 16px rgba(0,87,255,0.25);
}
.otp-icon svg { width: 26px; height: 26px; fill: #fff; }

.otp-card-header h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--otp-text);
  margin-bottom: 6px;
}
.otp-card-header p {
  font-size: 14px;
  color: var(--otp-muted);
  line-height: 1.5;
}
.otp-card-header .otp-number-display {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  color: var(--otp-primary);
}

/* ── Form Elements ── */
.otp-field {
  margin-bottom: 18px;
}
.otp-field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--otp-muted);
  margin-bottom: 8px;
}

.otp-input-wrap {
  position: relative;
}
.otp-input-wrap .prefix {
  position: absolute;
  left: 14px; top: 50%;
  transform: translateY(-50%);
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  font-size: 15px;
  color: var(--otp-primary);
  pointer-events: none;
  border-right: 2px solid var(--otp-border);
  padding-right: 10px;
}

input[type="tel"],
input[type="text"],
input[type="number"] {
  width: 100%;
  height: 52px;
  border: 2px solid var(--otp-border);
  border-radius: 12px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 16px;
  font-weight: 600;
  color: var(--otp-text);
  background: #FAFBFF;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}
input[type="tel"] { padding: 0 14px 0 70px; letter-spacing: 0.05em; }
input[type="text"],
input[type="number"] { padding: 0 14px; text-align: center; letter-spacing: 0.3em; }

input:focus {
  border-color: var(--otp-primary);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(0,87,255,0.10);
}
input.has-error { border-color: var(--otp-error); }

/* ── OTP Boxes ── */
.otp-boxes {
  display: flex;
  gap: 10px;
  justify-content: center;
}
.otp-boxes input {
  width: 52px !important;
  height: 58px !important;
  padding: 0 !important;
  font-size: 22px !important;
  letter-spacing: 0 !important;
  text-align: center;
  border-radius: 12px;
}

/* ── Button ── */
.otp-btn {
  display: block;
  width: 100%;
  height: 52px;
  background: linear-gradient(135deg, var(--otp-primary), #1a75ff);
  color: #fff;
  font-family: 'Sora', sans-serif;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.04em;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
  box-shadow: 0 4px 18px rgba(0,87,255,0.30);
  margin-top: 6px;
  position: relative;
  overflow: hidden;
}
.otp-btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0);
  transition: background 0.2s;
}
.otp-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 24px rgba(0,87,255,0.38); }
.otp-btn:hover::after { background: rgba(255,255,255,0.07); }
.otp-btn:active { transform: translateY(0); }
.otp-btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

.otp-btn.secondary {
  background: transparent;
  color: var(--otp-primary);
  box-shadow: none;
  border: 2px solid var(--otp-border);
  height: 44px;
  font-size: 14px;
}
.otp-btn.secondary:hover { border-color: var(--otp-primary); background: rgba(0,87,255,0.04); transform: none; box-shadow: none; }

/* ── Alerts ── */
.otp-alert {
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 13.5px;
  font-weight: 500;
  margin-bottom: 18px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  line-height: 1.45;
}
.otp-alert .alert-icon { flex-shrink: 0; margin-top: 1px; }
.otp-alert svg { width: 18px; height: 18px; }

.otp-alert.error   { background: #FFF0F3; color: #C0002A; border: 1px solid #FFB3C1; }
.otp-alert.success { background: #EDFAF5; color: #007A57; border: 1px solid #9BE5CC; }
.otp-alert.info    { background: #EEF4FF; color: #003FBF; border: 1px solid #C2D4FF; }
.otp-alert.warning { background: #FFF7ED; color: #A05000; border: 1px solid #FFCC80; }

/* ── Timer ── */
.otp-timer {
  text-align: center;
  font-size: 13px;
  color: var(--otp-muted);
  margin-top: 14px;
}
.otp-timer .countdown {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  color: var(--otp-primary);
}
.otp-timer .countdown.expired { color: var(--otp-error); }

/* ── Divider ── */
.otp-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  color: var(--otp-muted);
  font-size: 12px;
  font-weight: 500;
}
.otp-divider::before,
.otp-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--otp-border);
}

/* ── Success Screen ── */
.otp-success-screen {
  text-align: center;
}
.otp-success-screen .success-badge {
  width: 72px; height: 72px;
  background: linear-gradient(135deg, var(--otp-success), #00a37a);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
  box-shadow: 0 6px 24px rgba(0,196,140,0.30);
  animation: popIn 0.4s cubic-bezier(0.175,0.885,0.32,1.275) both;
}
.otp-success-screen .success-badge svg { width: 34px; height: 34px; stroke: #fff; fill: none; stroke-width: 2.5; }
.otp-success-screen h2 { font-size: 20px; font-weight: 700; color: var(--otp-text); margin-bottom: 8px; }
.otp-success-screen p  { font-size: 14px; color: var(--otp-muted); line-height: 1.6; }

.status-badge {
  display: inline-block;
  margin-top: 16px;
  padding: 6px 16px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.status-badge.new     { background: #EEF4FF; color: var(--otp-primary); }
.status-badge.already { background: #FFF7ED; color: var(--otp-warn); }

/* ── Footer Note ── */
.otp-footer-note {
  text-align: center;
  font-size: 12px;
  color: var(--otp-muted);
  margin-top: 20px;
  line-height: 1.5;
}

/* ── Powered by ── */
.otp-powered {
  text-align: center;
  font-size: 11px;
  color: #B0BAD0;
  margin-top: 28px;
  position: relative; z-index: 1;
  animation: fadeUp 0.5s ease 0.3s both;
}

/* ── Loading Screen ── */
.otp-loading-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(240, 244, 255, 0.95);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
}

.otp-loading-overlay.show {
  opacity: 1;
  visibility: visible;
}

.otp-loading-content {
  text-align: center;
  background: var(--otp-card-bg);
  border-radius: var(--otp-radius);
  padding: 32px;
  box-shadow: var(--otp-shadow);
  border: 1px solid var(--otp-border);
  max-width: 280px;
  width: 90%;
}

.otp-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--otp-border);
  border-top: 4px solid var(--otp-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 16px;
}

.otp-loading-text {
  font-size: 16px;
  font-weight: 500;
  color: var(--otp-text);
  margin-bottom: 8px;
}

.otp-loading-subtext {
  font-size: 14px;
  color: var(--otp-muted);
}

.otp-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  pointer-events: none;
}

/* ── Animations ── */
@keyframes fadeUp   { from { opacity:0; transform:translateY(16px); } to { opacity:1; transform:none; } }
@keyframes fadeDown { from { opacity:0; transform:translateY(-16px); } to { opacity:1; transform:none; } }
@keyframes popIn    { from { opacity:0; transform:scale(0.5); } to { opacity:1; transform:scale(1); } }
@keyframes spin     { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* ── Responsive ── */
@media (max-width: 480px) {
  .otp-card { padding: 28px 20px; }
  .otp-boxes input { width: 44px !important; height: 50px !important; font-size: 18px !important; }
}
