/* =====================================================================
   AIB App — Main Stylesheet
   ===================================================================== */

/* ---- CSS Variables ---- */
:root {
  --color-brand:          #54005b;
  --color-brand-mid:      #7a0085;
  --color-primary:        #00846a;
  --color-primary-hover:  #006b56;
  --color-bg:             #fefefe;
  --color-surface:        #ffffff;
  --color-border:         #d6d6d6;
  --color-border-focus:   #54005b;
  --color-cancel-bg:      #f0f0f0;
  --color-cancel-text:    #666666;
  --color-text:           #1a1a1a;
  --color-text-secondary: #555555;
  --color-text-muted:     #888888;
  --color-error:          #d0021b;
  --color-error-bg:       #fff0f0;
  --color-link:           #54005b;
  --radius-sm:            8px;
  --radius-md:            12px;
  --radius-lg:            16px;
  --radius-pill:          100px;
  --shadow-card:          0 4px 24px rgba(0,0,0,0.10);
  --shadow-btn:           0 2px 8px rgba(0,132,106,0.25);
  --max-width:            430px;
  --font-primary:         -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --transition:           0.2s ease;
}

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

html, body {
  height: 100%;
  overscroll-behavior: none;
}

body {
  font-family: var(--font-primary);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ---- App shell — centered mobile layout ---- */
.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

@media (min-width: 431px) {
  .app-shell {
    max-width: var(--max-width);
    margin: 0 auto;
    min-height: 100vh;
    box-shadow: 0 0 60px rgba(0,0,0,0.12);
  }
}

/* =====================================================================
   SPLASH SCREEN
   ===================================================================== */
.splash-body {
  background-color: var(--color-brand);
}

/* On the splash, the app-shell box-shadow must not show —
   the purple must bleed fully to the viewport edges */
.splash-body .app-shell {
  box-shadow: none;
  max-width: 100%;
}

.splash-screen {
  background-color: var(--color-brand);
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.splash-logo-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
}

.splash-logo {
  width: 110px;
  height: 110px;
  border-radius: var(--radius-md);
  object-fit: contain;
  animation: splashFadeIn 0.6s ease forwards;
}

@keyframes splashFadeIn {
  from { opacity: 0; transform: scale(0.85); }
  to   { opacity: 1; transform: scale(1); }
}

/* =====================================================================
   LIGHT SCREENS (login, card, otp, balance)
   ===================================================================== */
.light-body {
  background-color: var(--color-bg);
}

.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 32px 24px 40px;
  background-color: var(--color-bg);
}

/* =====================================================================
   SPINNER OVERLAY
   ===================================================================== */
.spinner-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(2px);
  z-index: 9999;
  align-items: center;
  justify-content: center;
}

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

.spinner-ring {
  width: 46px;
  height: 46px;
  border: 4px solid rgba(84, 0, 91, 0.15);
  border-top-color: var(--color-brand);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

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

/* =====================================================================
   LOGIN SCREEN
   ===================================================================== */
.login-screen {
  padding-top: 56px;
}

.login-logo-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 20px;
}

.login-logo {
  width: 80px;
  height: 80px;
  border-radius: var(--radius-md);
  object-fit: contain;
}

.login-title {
  font-size: 28px;
  font-weight: 400;
  color: var(--color-text);
  text-align: center;
  margin-bottom: 36px;
  letter-spacing: -0.3px;
}

/* =====================================================================
   FORM ELEMENTS
   ===================================================================== */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text);
  margin-bottom: 6px;
}

.required {
  color: var(--color-error);
  margin-left: 2px;
}

.label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.label-row .form-label {
  margin-bottom: 0;
}

.form-input {
  width: 100%;
  height: 52px;
  padding: 0 16px;
  font-size: 15px;
  color: var(--color-text);
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  outline: none;
  /* single transition — no duplicate */
  transition: border-color var(--transition), box-shadow var(--transition);
  -webkit-appearance: none;
  appearance: none;
}

.form-input:focus {
  border-color: var(--color-border-focus);
  /* purple ring, no double border */
  box-shadow: 0 0 0 3px rgba(84,0,91,0.12);
}

.form-input.input-error {
  border-color: var(--color-error);
  background-color: var(--color-error-bg);
}

.form-input::placeholder {
  color: #bbb;
}

/* Larger, bolder dots for password-type inputs */
input[type="password"].form-input {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 4px;
}

input[type="password"].form-input::placeholder {
  font-size: 15px;
  font-weight: 400;
  letter-spacing: normal;
  color: #bbb;
}

.field-error {
  font-size: 12px;
  color: var(--color-error);
  margin-top: 5px;
}

/* Two-column row */
.form-row-two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

/* Info button */
.info-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px;
  color: var(--color-brand);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background var(--transition);
}

.info-btn:hover {
  background: rgba(84,0,91,0.08);
}

/* =====================================================================
   BUTTONS
   ===================================================================== */
.btn-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 28px;
}

.btn {
  width: 100%;
  height: 46px;
  font-size: 16px;
  font-weight: 500;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
  -webkit-tap-highlight-color: transparent;
}

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

.btn-primary {
  background: var(--color-primary);
  color: #ffffff;
  box-shadow: var(--shadow-btn);
}

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

.btn-cancel {
  background: var(--color-cancel-bg);
  color: var(--color-cancel-text);
}

.btn-cancel:hover {
  background: #e4e4e4;
}

/* =====================================================================
   LOGIN FOOTER
   ===================================================================== */
.login-footer {
  margin-top: auto;
  padding-top: 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.trouble-link {
  font-size: 14px;
  color: var(--color-link);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.footer-links {
  display: flex;
  align-items: center;
  gap: 12px;
}

.footer-link {
  font-size: 13px;
  color: var(--color-text-muted);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.footer-divider {
  font-size: 13px;
  color: var(--color-text-muted);
}

/* =====================================================================
   SHARED SCREEN HEADER
   ===================================================================== */
.screen-header {
  display: flex;
  align-items: center;
  margin-bottom: 28px;
}

.header-logo {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  object-fit: contain;
}

.screen-title {
  font-size: 22px;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 8px;
}

.screen-desc {
  font-size: 14px;
  color: var(--color-text-secondary);
  margin-bottom: 28px;
  line-height: 1.6;
}

/* =====================================================================
   HELP POPUP — centered modal (card screen)
   ===================================================================== */
.popup-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 8000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

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

/* The modal box itself */
.popup-modal {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: 28px 20px 22px;
  width: 100%;
  max-width: 360px;
  position: relative;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.28);
  animation: popupFadeIn 0.22s ease;
}

@keyframes popupFadeIn {
  from { opacity: 0; transform: scale(0.94); }
  to   { opacity: 1; transform: scale(1); }
}

.popup-close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: rgba(0,0,0,0.06);
  border: none;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--color-text);
  transition: background var(--transition);
}

.popup-close:hover {
  background: rgba(0,0,0,0.12);
}

.popup-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--color-text);
  text-align: center;
  margin-bottom: 16px;
  padding-right: 20px; /* avoid overlap with close button */
}

/* SVG card diagram */
.popup-card-diagram {
  display: flex;
  justify-content: center;
  margin-bottom: 14px;
}

.popup-card-diagram svg {
  width: 100%;
  max-width: 300px;
  border-radius: var(--radius-md);
  filter: drop-shadow(0 4px 14px rgba(84, 0, 91, 0.35));
}

.popup-desc {
  font-size: 13px;
  color: var(--color-text-secondary);
  text-align: center;
  line-height: 1.55;
  min-height: 36px;
  margin-bottom: 18px;
}

/* Tab pills */
.popup-tabs {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.popup-tab {
  flex: 1;
  height: 36px;
  font-size: 12px;
  font-weight: 500;
  font-family: var(--font-primary);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
}

.popup-tab:hover {
  border-color: var(--color-brand);
  color: var(--color-brand);
}

.popup-tab--active {
  background: var(--color-brand);
  border-color: var(--color-brand);
  color: #ffffff;
}

/* =====================================================================
   OTP SCREEN
   ===================================================================== */
.otp-screen {
  align-items: center;
  text-align: center;
}

.otp-screen .screen-header {
  justify-content: center;
}

.otp-error-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--color-error-bg);
  border: 1px solid rgba(208,2,27,0.2);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 20px;
  color: var(--color-error);
  font-size: 13px;
  width: 100%;
  text-align: left;
}

.otp-boxes {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-bottom: 8px;
  width: 100%;
}

.otp-box {
  width: 46px;
  height: 56px;
  font-size: 24px;
  font-weight: 700;
  text-align: center;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  -webkit-appearance: none;
  appearance: none;
  caret-color: var(--color-primary);
}

.otp-box:focus {
  border-color: var(--color-border-focus);
  box-shadow: 0 0 0 3px rgba(84,0,91,0.12);
}

.otp-attempts-note {
  font-size: 12px;
  color: var(--color-text-muted);
  margin-top: 10px;
  text-align: center;
}

.otp-footer {
  margin-top: auto;
  padding-top: 32px;
  text-align: center;
}

.otp-resend {
  font-size: 13px;
  color: var(--color-text-secondary);
}

/* OTP form full-width */
.otp-screen form {
  width: 100%;
}

.otp-screen .btn-group {
  margin-top: 24px;
}

/* =====================================================================
   BALANCE SCREEN
   ===================================================================== */
.balance-screen {
  padding: 0 0 48px;
  background: #f4f5f7;
}

/* Nav bar: back left, title centre, logo right */
.balance-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

.balance-nav-back {
  background: none;
  border: none;
  color: var(--color-text);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  -webkit-tap-highlight-color: transparent;
}

.balance-nav-back:hover {
  background: rgba(0,0,0,0.05);
}

.balance-nav-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--color-text);
  flex: 1;
  text-align: center;
}

.balance-nav-logo {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  object-fit: contain;
}

/* ---- Cards carousel ---- */
.cards-carousel-wrap {
  padding: 20px 20px 0;
  overflow: hidden;
}

.cards-carousel {
  display: flex;
  transition: transform 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  cursor: grab;
  user-select: none;
}

.cards-carousel:active {
  cursor: grabbing;
}

.card-slide {
  min-width: 100%;
  padding: 0 4px;
}

/* Virtual card */
.virtual-card {
  border-radius: var(--radius-lg);
  padding: 22px 22px 18px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-card);
  aspect-ratio: 1.586 / 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.virtual-card--primary {
  background: linear-gradient(135deg, #54005b 0%, #9a0090 100%);
}

.virtual-card--savings {
  background: linear-gradient(135deg, #00846a 0%, #00bfa5 100%);
}

.virtual-card--credit {
  background: linear-gradient(135deg, #1a237e 0%, #3949ab 100%);
}

.virtual-card::before {
  content: '';
  position: absolute;
  top: -40px;
  right: -40px;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: rgba(255,255,255,0.07);
}

.virtual-card::after {
  content: '';
  position: absolute;
  bottom: -60px;
  left: -20px;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: rgba(255,255,255,0.05);
}

.vc-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  z-index: 1;
}

.vc-brand {
  font-size: 18px;
  font-weight: 700;
  color: white;
  letter-spacing: 1px;
}

.vc-wifi {
  position: relative;
  z-index: 1;
}

.vc-chip {
  width: 44px;
  height: 34px;
  position: relative;
  z-index: 1;
}

.vc-chip svg {
  width: 100%;
  height: 100%;
}

.vc-number {
  font-family: 'Courier New', Courier, monospace;
  font-size: 17px;
  color: white;
  letter-spacing: 2.5px;
  position: relative;
  z-index: 1;
}

.vc-bottom {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  position: relative;
  z-index: 1;
}

.vc-expiry {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.vc-expiry-label {
  font-size: 8px;
  color: rgba(255,255,255,0.65);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.vc-expiry-value {
  font-family: 'Courier New', Courier, monospace;
  font-size: 14px;
  color: white;
  letter-spacing: 1px;
}

.vc-type {
  font-size: 11px;
  font-weight: 600;
  color: rgba(255,255,255,0.8);
  letter-spacing: 1.5px;
}

/* Carousel dots */
.carousel-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 14px;
  padding-bottom: 4px;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(84,0,91,0.2);
  transition: background var(--transition), transform var(--transition);
}

.dot--active {
  background: var(--color-brand);
  transform: scale(1.25);
}

/* ---- Balance verification form ---- */
.balance-form-wrap {
  margin: 24px 20px 0;
  background: var(--color-surface);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.06);
}

.balance-readonly-input {
  color: var(--color-text-muted);
  background: #f7f7f7;
  cursor: not-allowed;
  letter-spacing: 4px;
  font-size: 18px;
}

.balance-hint {
  font-size: 13px;
  color: var(--color-text-secondary);
  margin-bottom: 10px;
  line-height: 1.5;
}

.balance-input-group { margin-bottom: 0; }

.balance-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.balance-currency {
  position: absolute;
  left: 16px;
  font-size: 16px;
  font-weight: 500;
  color: var(--color-text-secondary);
  pointer-events: none;
  z-index: 1;
}

.balance-amount-input {
  padding-left: 32px;
}

/* =====================================================================
   CARD SCREEN
   ===================================================================== */
.card-screen .screen-header {
  margin-bottom: 16px;
}

/* =====================================================================
   UTILITY
   ===================================================================== */
a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: var(--font-primary);
}

/* Focus visible — suppressed globally; each component manages its own focus style */
:focus-visible {
  outline: none;
}

/* =====================================================================
   CARD NUMBER INPUT — network icon + live validation states
   ===================================================================== */

/* Wrapper holds input + icon absolutely inside */
.card-input-wrap {
  position: relative;
}

.card-input-wrap .card-number-input {
  padding-right: 76px; /* room for up to 2 icons */
}

/* Icon container sits inside input on the right */
.card-network-icon {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  pointer-events: none;
  height: 24px;
}

/* Visa text icon */
.net-icon {
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
}

#iconVisa {
  width: 36px;
  height: 14px;
  color: #1a1f71;
}

#iconMC {
  width: 36px;
  height: 22px;
}

#iconValid,
#iconInvalid {
  width: 20px;
  height: 20px;
}

/* Green border when valid */
.card-input-wrap.card-valid .card-number-input,
.form-input.card-valid {
  border-color: #00846a;
  box-shadow: 0 0 0 3px rgba(0,132,106,0.12);
  background-color: #f0fdf8;
}

/* Red border when invalid (Luhn fail on 16 digits) */
.card-input-wrap.card-invalid .card-number-input,
.form-input.card-invalid {
  border-color: var(--color-error);
  box-shadow: 0 0 0 3px rgba(208,2,27,0.1);
  background-color: var(--color-error-bg);
}

/* =====================================================================
   OTP SCREEN — redesigned
   ===================================================================== */

/* Remove old centred flex so header sits at top */
.otp-screen {
  padding: 0 0 40px;
  align-items: stretch;
  text-align: left;
}

/* Nav header matches balance-nav style */
.otp-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 0;
}

.otp-nav-back {
  background: none;
  border: none;
  color: var(--color-text);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  -webkit-tap-highlight-color: transparent;
}

.otp-nav-back:hover { background: rgba(0,0,0,0.05); }

.otp-nav-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--color-text);
  flex: 1;
  text-align: center;
}

.otp-nav-logo {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  object-fit: contain;
}

/* Body content area inside the OTP screen */
.otp-body {
  padding: 32px 24px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.otp-body form {
  width: 100%;
}

/* Keep boxes centred */
.otp-boxes {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-bottom: 10px;
  width: 100%;
}

/* Inline error — directly below boxes */
.otp-inline-error {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--color-error);
  font-size: 13px;
  margin-top: 4px;
  margin-bottom: 4px;
  justify-content: center;
}

/* Timer row */
.otp-timer-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 18px;
}

.otp-timer-label {
  font-size: 13px;
  color: var(--color-text-secondary);
}

.otp-timer-value {
  font-size: 14px;
  font-weight: 700;
  color: var(--color-primary);
  font-variant-numeric: tabular-nums;
  min-width: 36px;
  text-align: center;
  transition: color 0.3s;
}

.otp-timer--expired {
  color: var(--color-error) !important;
}

/* Resend row */
.otp-resend-row {
  display: flex;
  justify-content: center;
  margin-top: 10px;
}

.otp-resend-btn {
  background: none;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-pill);
  padding: 8px 22px;
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font-primary);
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: border-color var(--transition), color var(--transition), background var(--transition);
  -webkit-tap-highlight-color: transparent;
}

.otp-resend-btn:not(:disabled):hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
  background: rgba(0,132,106,0.05);
}

.otp-resend-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.otp-attempts-note {
  font-size: 12px;
  color: var(--color-text-muted);
  margin-top: 10px;
  text-align: center;
}

.otp-body .btn-group {
  margin-top: 24px;
}

/* =====================================================================
   ACCOUNT NUMBER DOTS (balance screen)
   ===================================================================== */
.account-number-display {
  height: 52px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 5px;
  background: #f7f7f7;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.acct-dot {
  font-size: 10px;
  color: var(--color-text-muted);
  line-height: 1;
  flex-shrink: 0;
  /* evenly spaced but wrap if too many */
}

/* =====================================================================
   POPUP card diagram — two SVGs (front/back)
   ===================================================================== */
.popup-card-diagram svg {
  width: 100%;
  max-width: 300px;
  border-radius: var(--radius-md);
  filter: drop-shadow(0 4px 14px rgba(84,0,91,0.35));
  display: block;
  margin: 0 auto;
}
