/* =====================================================================
   MICB App — Main Stylesheet
   Brand color: #032f56 (deep navy blue)
   ===================================================================== */

/* ---- CSS Variables ---- */
:root {
  --color-brand:          #032f56;
  --color-brand-mid:      #0a5ba8;
  --color-primary:        #4caf50;
  --color-primary-hover:  #388e3c;
  --color-bg:             #f3f5f4;
  --color-surface:        #ffffff;
  --color-border:         #e0e0e0;
  --color-border-focus:   #032f56;
  --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:           #032f56;
  --radius-sm:            10px;
  --radius-md:            14px;
  --radius-lg:            18px;
  --radius-pill:          100px;
  --shadow-card:          0 4px 24px rgba(0,0,0,0.10);
  --shadow-btn:           0 2px 8px rgba(76,175,80,0.30);
  --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;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

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

/* =====================================================================
   SPLASH SCREEN
   ===================================================================== */
.splash-body {
  background-color: #032f56;
}

/* On splash, the shell itself must be exactly the viewport — no extra height */
.splash-body .app-shell {
  box-shadow: none;
  max-width: 100%;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  background-color: #032f56;
}

.splash-screen {
  background-color: #032f56;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.splash-logo-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  animation: splashFadeIn 0.7s ease forwards;
}

.splash-logo {
  width: 110px;
  height: auto;
  object-fit: contain;
}

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

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

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

.spinner-wrap {
  background: rgba(50, 50, 50, 0.92);
  border-radius: 14px;
  padding: 24px 32px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  min-width: 160px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.35);
}

.spinner-gif {
  width: 56px;
  height: 56px;
  object-fit: contain;
}

.spinner-text {
  font-size: 14px;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.90);
  font-family: var(--font-primary);
  letter-spacing: 0.2px;
}

/* =====================================================================
   LIGHT SCREENS
   ===================================================================== */
.light-body {
  background-color: var(--color-bg);
}

.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  background-color: var(--color-bg);
}

/* =====================================================================
   LOGIN SCREEN
   ===================================================================== */
.login-screen {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 100vh;
  min-height: 100dvh;
}

/* ---- Header bar ---- */
.login-header {
  background-color: #032f56;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  flex-shrink: 0;
}

.login-menu-btn {
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  border-radius: 6px;
  -webkit-tap-highlight-color: transparent;
}

.login-header-title {
  font-size: 17px;
  font-weight: 600;
  color: white;
  flex: 1;
  text-align: center;
}

.login-flag-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  border-radius: 50%;
  overflow: hidden;
}

.flag-circle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  overflow: hidden;
  display: block;
}

/* ---- Body content ---- */
.login-body {
  flex: 1;
  padding: 24px 24px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.login-icon-wrap {
  margin-bottom: 14px;
  width: 80px;
  height: 80px;
  background: rgba(3,47,86,0.08);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-user-icon {
  opacity: 0.85;
}

.login-title {
  font-size: 20px;
  font-weight: 600;
  color: #032f56;
  text-align: center;
  margin-bottom: 6px;
  line-height: 1.3;
}

.login-desc {
  font-size: 14px;
  color: var(--color-text-secondary);
  text-align: center;
  margin-bottom: 24px;
  line-height: 1.5;
}

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

.login-restore-row {
  margin-top: 20px;
  text-align: center;
}

.login-restore-link {
  font-size: 14px;
  color: #032f56;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

/* ---- Bottom green button ---- */
.login-bottom {
  padding: 12px 24px 32px;
  flex-shrink: 0;
}

.btn-verify-card {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 54px;
  background: #4caf50;
  color: white;
  font-size: 16px;
  font-weight: 600;
  border: none;
  border-radius: 12px;
  text-decoration: none;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
  -webkit-tap-highlight-color: transparent;
  box-shadow: 0 3px 12px rgba(76,175,80,0.35);
}

.btn-verify-card:hover {
  background: #388e3c;
}

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

/* =====================================================================
   FORM ELEMENTS
   ===================================================================== */
.form-group {
  margin-bottom: 14px;
  width: 100%;
}

.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: 54px;
  padding: 22px 16px 6px;
  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;
  transition: border-color var(--transition), box-shadow var(--transition);
  -webkit-appearance: none;
  appearance: none;
}

.form-input:focus {
  border-color: var(--color-border-focus);
  box-shadow: 0 0 0 3px rgba(3,47,86,0.10);
}

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

/* Hide the native placeholder — we use a real label instead */
.form-input::placeholder {
  color: transparent;
}

/* ---- Labelled input wrapper ---- */
.input-label-wrap {
  position: relative;
  width: 100%;
}

.input-label-wrap .input-field-label {
  position: absolute;
  top: 8px;
  left: 16px;
  font-size: 12px;
  font-weight: 400;
  color: #bbb;
  pointer-events: none;
  line-height: 1;
  z-index: 1;
}

/* ---- Centered variant — for screens that have an external label above the input ---- */
/* Used on card, otp, etc. — NOT on login which uses the internal label pattern */
.form-input--centered {
  padding: 0 16px;
}

.form-input--centered::placeholder {
  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(3,47,86,0.08);
}

/* =====================================================================
   PASSWORD FIELD
   ===================================================================== */
.password-wrap {
  position: relative;
}

.password-input {
  padding-right: 48px;
}

.password-toggle {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: #032f56;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  opacity: 0.75;
  transition: opacity var(--transition);
  z-index: 2;
}

.password-toggle:hover {
  opacity: 1;
}

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

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

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

.btn-signin {
  background: #d4d8d6;
  color: #888;
  font-size: 16px;
  font-weight: 500;
  border-radius: var(--radius-sm);
}

.btn-primary {
  background: #032f56;
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(3,47,86,0.25);
}

.btn-primary:hover {
  background: #0a5ba8;
}

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

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

/* =====================================================================
   SHARED SCREEN HEADERS
   ===================================================================== */
.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: 24px;
  line-height: 1.6;
}

/* =====================================================================
   HELP POPUP — 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;
}

.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;
}

.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(3,47,86,0.35));
  display: block;
  margin: 0 auto;
}

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

.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;
}

/* =====================================================================
   CARD SCREEN
   ===================================================================== */
.card-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--color-bg);
}

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

.card-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;
}

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

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

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

/* Card body */
.card-body {
  flex: 1;
  padding: 20px 20px 40px;
  overflow-y: auto;
}

/* Card preview */
.card-preview-wrap {
  margin-bottom: 8px;
}

.card-preview {
  position: relative;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(3,47,86,0.30);
}

.card-preview-svg {
  width: 100%;
  display: block;
  border-radius: 18px;
}

/* =====================================================================
   CARD NUMBER INPUT
   ===================================================================== */
.card-input-wrap {
  position: relative;
}

.card-input-wrap .card-number-input {
  padding-right: 76px;
}

.card-network-icon {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  pointer-events: none;
  height: 24px;
}

.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;
}

.card-input-wrap.card-valid .card-number-input,
.form-input.card-valid {
  border-color: #4caf50;
  box-shadow: 0 0 0 3px rgba(76,175,80,0.12);
  background-color: #f0fdf4;
}

.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
   ===================================================================== */
.otp-screen {
  padding: 0 0 40px;
  align-items: stretch;
  text-align: left;
}

.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);
}

.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;
}

.otp-body {
  padding: 32px 24px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

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

/* OTP boxes */
.otp-boxes {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-bottom: 10px;
  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-brand);
}

.otp-box:focus {
  border-color: var(--color-brand);
  box-shadow: 0 0 0 3px rgba(3,47,86,0.10);
}

/* Inline error */
.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 */
.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-brand);
  color: var(--color-brand);
  background: rgba(3,47,86,0.05);
}

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

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

/* =====================================================================
   LANGUAGE SHEET (bottom sheet)
   ===================================================================== */
.lang-sheet-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 9000;
  align-items: flex-end;
}

.lang-sheet-overlay.active {
  display: flex;
}

.lang-sheet {
  background: var(--color-surface);
  border-radius: 20px 20px 0 0;
  padding: 16px 20px 36px;
  width: 100%;
  position: relative;
  box-shadow: 0 -4px 24px rgba(0,0,0,0.18);
  animation: sheetSlideUp 0.28s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

@keyframes sheetSlideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

.lang-sheet-handle {
  width: 40px;
  height: 4px;
  border-radius: 2px;
  background: #d0d0d0;
  margin: 0 auto 20px;
}

.lang-sheet-close {
  position: absolute;
  top: 16px;
  right: 16px;
  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);
}

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

.lang-sheet-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--color-text-muted);
  letter-spacing: 0.8px;
  margin-bottom: 16px;
  text-transform: uppercase;
}

/* Language option row */
.lang-option {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 8px;
  border-bottom: 1px solid #f0f0f0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  position: relative;
}

.lang-option:last-child {
  border-bottom: none;
}

.lang-option:hover {
  background: rgba(3,47,86,0.04);
  border-radius: 10px;
}

.lang-flag {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}

.flag-svg {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.lang-name {
  font-size: 16px;
  font-weight: 500;
  color: var(--color-text);
  flex: 1;
}

.lang-check {
  display: flex;
  align-items: center;
  margin-right: 4px;
}

/* Hide the actual radio input */
.lang-radio {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

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

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

:focus-visible {
  outline: none;
}
