/* ─────────────────────────────────────────────────────────────────────────
   style.css — Mobile Line Termination Form
   Clean, trustworthy government-service aesthetic
───────────────────────────────────────────────────────────────────────── */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --primary: #1a56db;
  --primary-dk: #1340aa;
  --danger: #c0392b;
  --danger-lt: #fdf2f1;
  --success: #1a7f4b;
  --success-lt: #f0faf4;
  --warning-lt: #fffbeb;
  --grey-50: #f9fafb;
  --grey-100: #f3f4f6;
  --grey-300: #d1d5db;
  --grey-500: #6b7280;
  --grey-700: #374151;
  --grey-900: #111827;
  --radius: 10px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--grey-100);
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 24px 16px 48px;
  color: var(--grey-900);
  line-height: 1.5;
}

/* ── Layout ────────────────────────────────────────────────────────────── */
.container {
  width: 100%;
  max-width: 480px;
}

.card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 36px 32px;
}

/* ── Header ────────────────────────────────────────────────────────────── */
.header {
  text-align: center;
  margin-bottom: 28px;
}

.logo {
  font-size: 40px;
  margin-bottom: 12px;
  display: block;
}

h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--grey-900);
  margin-bottom: 6px;
}

.subtitle {
  color: var(--grey-500);
  font-size: 14px;
}

/* ── Progress bar ──────────────────────────────────────────────────────── */
.progress {
  display: flex;
  gap: 4px;
  margin-bottom: 28px;
}

.progress-step {
  flex: 1;
  text-align: center;
  font-size: 11px;
  font-weight: 500;
  padding: 6px 4px;
  border-radius: 4px;
  background: var(--grey-100);
  color: var(--grey-500);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.progress-step.done {
  background: #e8f5e9;
  color: var(--success);
}

.progress-step.active {
  background: var(--primary);
  color: #fff;
}

/* ── Inline mobile number & secondary subtitle ────────────────────────── */
/* .mobile-number  — emphasises the number inline within subtitle text     */
/* .subtitle-sub   — secondary line below the main subtitle                */
.mobile-number {
  font-weight: 700;
  color: var(--grey-900);
  white-space: nowrap;
  letter-spacing: 0.5px;
}

.subtitle-sub {
  display: block;
  margin-top: 4px;
  font-size: 13px;
  color: var(--grey-500);
}

/* ── Alerts ────────────────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  margin-bottom: 20px;
}

.alert-error {
  background: var(--danger-lt);
  border-left: 4px solid var(--danger);
  color: var(--danger);
}

.alert-warning {
  background: #fffbeb;
  border-left: 4px solid #f59e0b;
  color: #78350f;
}

.alert-info {
  background: #eff6ff;
  border-left: 3px solid #93c5fd;
  color: #1e3a5f;
  margin-bottom: 24px;
}

.alert-info ul {
  font-weight: 400;
}

.alert-support {
  font-size: 12px;
  margin-top: 8px;
  opacity: 0.85;
}

/* ── Warning banner ────────────────────────────────────────────────────── */
.warning-banner {
  background: #fefce8;
  border-left: 3px solid #fde68a;
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 13px;
  color: #713f12;
  margin-bottom: 16px;
}

.warning-banner.danger {
  background: var(--danger-lt);
  border-color: var(--danger);
  color: var(--danger);
}

/* ── Form ──────────────────────────────────────────────────────────────── */
.form-group {
  margin-bottom: 20px;
}

label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--grey-700);
  margin-bottom: 6px;
}

input[type="tel"],
input[type="text"] {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--grey-300);
  border-radius: var(--radius);
  font-size: 16px;
  color: var(--grey-900);
  transition: border-color 0.15s;
  background: #fff;
}

input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26, 86, 219, 0.12);
}

input::placeholder {
  color: var(--grey-300);
}

small {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  color: var(--grey-500);
}

.attempts {
  color: var(--danger);
  font-weight: 600;
}

/* ── Input with prefix (+65) ───────────────────────────────────────────── */
.input-prefix-wrapper {
  display: flex;
  align-items: stretch;
}

.input-prefix {
  padding: 11px 12px;
  background: var(--grey-50);
  border: 1.5px solid var(--grey-300);
  border-right: none;
  border-radius: var(--radius) 0 0 var(--radius);
  font-size: 15px;
  color: var(--grey-500);
  white-space: nowrap;
}

.input-prefix-wrapper input {
  border-radius: 0 var(--radius) var(--radius) 0;
  flex: 1;
}

/* ── Re-entry field validation states ─────────────────────────────────── */
.input-prefix-wrapper.is-match .input-prefix,
.input-prefix-wrapper.is-match input {
  border-color: var(--success);
}

.input-prefix-wrapper.is-match {
  box-shadow: 0 0 0 3px rgba(26, 127, 75, 0.12);
  border-radius: var(--radius);
}

.input-prefix-wrapper.is-mismatch .input-prefix,
.input-prefix-wrapper.is-mismatch input {
  border-color: var(--danger);
}

.input-prefix-wrapper.is-mismatch {
  box-shadow: 0 0 0 3px rgba(192, 57, 43, 0.10);
  border-radius: var(--radius);
}

.validation-msg {
  font-size: 13px;
  margin-top: 7px;
  min-height: 18px;
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--grey-500);
}

.validation-msg.is-match {
  color: var(--success);
  font-weight: 500;
}

.validation-msg.is-mismatch {
  color: var(--danger);
}

/* ── OTP input ─────────────────────────────────────────────────────────── */
.otp-input {
  font-size: 28px !important;
  letter-spacing: 12px;
  text-align: center;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* ── Buttons ───────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 20px;
  border: none;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, transform 0.1s;
}

.btn:active {
  transform: scale(0.98);
}

.btn-full {
  width: 100%;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-dk);
}

.btn-secondary {
  background: var(--grey-100);
  color: var(--grey-700);
  border: 1.5px solid var(--grey-300);
}

.btn-secondary:hover {
  background: var(--grey-300);
}

.btn-singpass {
  background: #d42027;
  color: #fff;
  font-size: 15px;
}

.btn-singpass:hover {
  background: #b71c1c;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover:not(:disabled) {
  background: #a93226;
}

.btn-danger:disabled {
  background: var(--grey-300);
  cursor: not-allowed;
  transform: none;
}

/* ── Loading states ─────────────────────────────────────────────────────── */
/* Inline spinner shown inside a button while waiting for a server response */
.btn-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
  flex-shrink: 0;
}

/* Secondary-style buttons use a dark spinner */
.btn-secondary .btn-spinner,
.btn-secondary[disabled] .btn-spinner {
  border-color: rgba(55, 65, 81, 0.3);
  border-top-color: var(--grey-700);
}

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

/* Full-page overlay for navigations that leave the page (e.g. Singpass redirect) */
.page-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(255, 255, 255, 0.90);
  backdrop-filter: blur(3px);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.page-overlay.active {
  display: flex;
}

.page-overlay-spinner {
  width: 40px;
  height: 40px;
  border-width: 4px;
  border-color: rgba(26, 86, 219, 0.25);
  border-top-color: var(--primary);
  animation: spin 0.8s linear infinite;
}

.page-overlay-text {
  font-size: 15px;
  font-weight: 600;
  color: var(--grey-700);
}

/* ── Info / Summary boxes ──────────────────────────────────────────────── */
.info-box {
  background: var(--grey-50);
  border-radius: var(--radius);
  padding: 16px;
  font-size: 14px;
  color: var(--grey-700);
  margin-bottom: 24px;
}

.info-box ul,
.info-box ol {
  margin-top: 8px;
  padding-left: 20px;
}

.info-box li {
  margin-bottom: 4px;
}

.success-box {
  background: var(--success-lt);
  border: 1px solid #a7f3d0;
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 20px;
}

.summary-card {
  border: 1.5px solid var(--grey-300);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 20px;
}

.summary-card h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--grey-700);
  margin-bottom: 12px;
}

.summary-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.summary-table td {
  padding: 6px 0;
  vertical-align: top;
}

.summary-table td:first-child {
  color: var(--grey-500);
  width: 130px;
  font-size: 13px;
}

.danger-text {
  color: var(--danger);
}

/* ── Checkbox ──────────────────────────────────────────────────────────── */
.checkbox-group {
  margin-bottom: 20px;
}

.checkbox-label {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 14px;
  color: var(--grey-700);
  cursor: pointer;
  font-weight: normal;
}

.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin-top: 1px;
  flex-shrink: 0;
  accent-color: var(--danger);
  cursor: pointer;
}

/* ── Brand logo (ZYM) ──────────────────────────────────────────────────── */
.brand-logo-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
}

.brand-logo-img {
  width: 40%;
  height: auto;
  display: block;
}

/* ── Myinfo button ─────────────────────────────────────────────────────── */
.myinfo-btn-link {
  display: block;
  width: 100%;
  text-align: center;
  text-decoration: none;
}

.myinfo-btn-img {
  /* Scale to fill card width while respecting aspect ratio (318:48) */
  width: 100%;
  max-width: 318px;
  height: auto;
  display: block;
  margin: 0 auto;
  border-radius: 8px;
  transition: opacity 0.15s, transform 0.1s;
}

.myinfo-btn-link:hover .myinfo-btn-img {
  opacity: 0.88;
}

.myinfo-btn-link:active .myinfo-btn-img {
  transform: scale(0.98);
}

/* ── Singpass logo (legacy fallback) ───────────────────────────────────── */
.singpass-logo {
  height: 20px;
}

/* ── Steps preview ─────────────────────────────────────────────────────── */
.steps-preview {
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--grey-100);
}

.steps-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--grey-500);
  margin-bottom: 8px;
}

.steps-list {
  padding-left: 18px;
  font-size: 13px;
  color: var(--grey-700);
}

.steps-list li {
  margin-bottom: 4px;
}

/* ── Divider ───────────────────────────────────────────────────────────── */
.divider {
  border: none;
  border-top: 1px solid var(--grey-100);
  margin: 20px 0;
}

/* ── Countdown ─────────────────────────────────────────────────────────── */
.countdown-text {
  text-align: center;
  font-size: 12px;
  color: var(--grey-500);
  margin-top: 16px;
}

/* ── Error modal overlay ───────────────────────────────────────────────────
   Built as a plain div (not <dialog>) — native <dialog> has positioning
   bugs on Android Chrome that make it render as a block element at the top
   of the page rather than a centred modal. The div approach is universally
   reliable across all mobile and desktop browsers.
────────────────────────────────────────────────────────────────────────── */
.error-modal-overlay {
  /* Full-viewport fixed overlay — identical visual result to dialog::backdrop */
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(17, 24, 39, 0.60);
  backdrop-filter: blur(2px);
  /* Flexbox centring is the most reliable cross-browser centering method */
  display: flex;
  align-items: center;
  justify-content: center;
  /* Padding ensures card never touches screen edge on narrow phones */
  padding: 16px;
  /* Box-sizing so padding is included in size calculation */
  box-sizing: border-box;
}

.error-modal-card {
  /* Fluid width: fills available space minus the 16px padding each side,
     capped at 448px on large screens */
  width: 100%;
  max-width: 448px;
  /* Scroll internally if content is taller than viewport (zoomed or tiny screen) */
  max-height: calc(100vh - 32px);
  max-height: calc(100svh - 32px);
  overflow-y: auto;
  background: #ffffff;
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
  /* em padding: scales when user changes OS font size or zooms */
  padding: 1.75em 1.5em 1.5em;
  /* Flex column so children stack and stretch correctly */
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.75em;
  box-sizing: border-box;
}

/* Icon wrapper */
.error-dialog-icon-wrap {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  background: var(--danger);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.error-dialog-icon-wrap svg {
  width: 24px;
  height: 24px;
  fill: #ffffff;
  flex-shrink: 0;
}

.error-dialog-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--grey-900);
  line-height: 1.3;
}

/* Mobile number pill */
.error-dialog-mobile {
  font-size: 1rem;
  font-weight: 600;
  color: var(--grey-700);
  background: var(--grey-100);
  border: 1.5px solid var(--grey-300);
  padding: 0.25em 0.875em;
  border-radius: 100px;
  display: inline-block;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.error-dialog-body {
  font-size: 0.9375rem;
  color: var(--grey-700);
  line-height: 1.65;
  word-break: break-word;
  overflow-wrap: break-word;
}

.error-dialog-support {
  font-size: 0.8125rem;
  color: var(--grey-500);
  line-height: 1.5;
}

.error-dialog-actions {
  display: flex;
  flex-direction: column;
  gap: 0.625em;
  width: 100%;
  margin-top: 0.375em;
}

/* WCAG 2.5.5: minimum 44×44 px touch target */
.error-dialog-actions .btn {
  min-height: 44px;
}

/* Tighten card padding on very small phones (< 360px) */
@media (max-width: 360px) {
  .error-modal-card {
    padding: 1.25em 1em 1em;
  }
}

/* ── Badge ─────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.badge-pending {
  background: #fef9c3;
  color: #854d0e;
}

/* ── Code ──────────────────────────────────────────────────────────────── */
code {
  font-family: "SF Mono", "Fira Code", monospace;
  font-size: 12px;
  background: var(--grey-100);
  padding: 2px 6px;
  border-radius: 4px;
  word-break: break-all;
}

/* ── Mobile responsive ─────────────────────────────────────────────────── */
@media (max-width: 480px) {
  body {
    padding: 12px 8px 32px;
  }

  .card {
    padding: 24px 20px;
  }

  .progress-step {
    font-size: 10px;
    padding: 5px 2px;
  }
}

/* ── Footer copyright ──────────────────────────────────────────────────── */
.footer-copyright {
  text-align: center;
  margin-top: 16px;
  font-size: 12px;
  color: var(--text-muted);
}