/* ===== Reset & Base ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  overflow-x: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
}

body {
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  background: #1a1a1a;
  max-width: 430px;
  margin: 0 auto;
  width: 100%;
}

.screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  min-height: 100%;
  display: none;
  flex-direction: column;
  transition: opacity 0.3s ease;
}

.screen.active {
  display: flex;
}

/* Splash */
#splash {
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

.splash-gradient {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, #a8b5e8 0%, #8b9ad6 30%, #6b7bc9 60%, #5647e3 100%);
}

.splash-logo {
  position: relative;
  z-index: 1;
  width: 180px;
  height: auto;
  max-width: 70vw;
}

/* Language */
#language {
  background: #5647e3;
  justify-content: center;
  align-items: center;
  padding: 2rem 1.5rem;
}

.lang-bg {
  position: absolute;
  inset: 0;
  background: #5647e3;
}

.lang-logo {
  position: relative;
  z-index: 1;
  width: 140px;
  height: auto;
  margin-bottom: 2rem;
}

.lang-title {
  position: relative;
  z-index: 1;
  color: #fff;
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  text-align: center;
}

.lang-subtitle {
  position: relative;
  z-index: 1;
  color: rgba(255,255,255,0.85);
  font-size: 0.95rem;
  margin-bottom: 2rem;
  text-align: center;
}

.lang-toggle {
  position: relative;
  z-index: 1;
  display: flex;
  background: #fff;
  border-radius: 12px;
  padding: 4px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.1);
}

.lang-option {
  flex: 1;
  padding: 12px 16px;
  border: none;
  background: transparent;
  color: #555;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  border-radius: 10px;
}

.lang-option.active {
  background: #8b7ce8;
  color: #fff;
}

.lang-footer {
  position: absolute;
  bottom: 2rem;
  left: 0;
  right: 0;
  text-align: center;
  color: rgba(255,255,255,0.7);
  font-size: 0.8rem;
}

.lang-footer p { margin: 0.2rem 0; }

/* Profile (email + NIC) */
#profile {
  background: #5647e3;
  padding: 0;
}

.forgot-icon,
.card-icon {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 2rem 0;
  min-height: 160px;
}

.padlock-emoji,
.card-emoji {
  font-size: 110px;
  line-height: 1;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.2));
}

.forgot-card,
.card-panel {
  flex: 1;
  background: #fff;
  border-radius: 28px 28px 0 0;
  padding: 2rem 1.5rem 3rem;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.1);
}

.forgot-title,
.card-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: #1a1a1a;
  margin-bottom: 0.5rem;
}

.forgot-instruction,
.card-instruction {
  font-size: 0.9rem;
  color: #666;
  margin-bottom: 1.5rem;
  line-height: 1.4;
}

.forgot-form .form-group,
.card-form .form-group {
  margin-bottom: 1.25rem;
}

.forgot-form label,
.card-form label {
  display: block;
  font-size: 0.9rem;
  font-weight: 500;
  color: #212121;
  margin-bottom: 0.5rem;
}

.forgot-form .form-input,
.card-form .form-input {
  width: 100%;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 0.95rem;
}

/* Login */
#login {
  background: #282828;
  padding: 0;
}

.login-header {
  flex: 0 0 auto;
  width: 100%;
  max-height: 50vh;
  overflow: hidden;
}

.login-header-img {
  width: 100%;
  height: auto;
  display: block;
  object-fit: cover;
  object-position: center top;
}

.login-card {
  flex: 1;
  background: #fff;
  border-radius: 28px 28px 0 0;
  margin-top: -24px;
  padding: 2rem 1.5rem 3rem;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.08);
  position: relative;
  z-index: 3;
}

.login-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: #212121;
  margin-bottom: 1.5rem;
}

.login-form .form-group { margin-bottom: 1.25rem; }

.login-form label {
  display: block;
  font-size: 0.9rem;
  font-weight: 500;
  color: #212121;
  margin-bottom: 0.5rem;
}

.input-row {
  display: flex;
  gap: 8px;
}

.country-code {
  flex: 0 0 110px;
  padding: 12px 28px 12px 14px;
  border: 1px solid #e0e0e0;
  border-radius: 10px;
  font-size: 0.9rem;
  background: #f0f0f0;
  color: #333;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M2 5l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

.form-input {
  flex: 1;
  padding: 12px 14px;
  border: 1px solid #e0e0e0;
  border-radius: 10px;
  font-size: 16px;
  background: #f0f0f0;
}

.form-input-password {
  width: 100%;
}

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

.form-actions {
  display: flex;
  align-items: center;
  gap: 2.5rem;
  margin: 1.5rem 0 1rem;
}

.btn-login {
  min-width: 140px;
  padding: 16px 36px;
  background: linear-gradient(90deg, #5647e3 0%, #6b5ce7 50%, #7d6ef0 100%);
  border: none;
  border-radius: 28px;
  color: #fff;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(86, 71, 227, 0.4);
}

.link-forgot,
.link-register {
  color: #4285F4;
  text-decoration: none;
  font-weight: 500;
}

.link-forgot { margin-left: auto; white-space: nowrap; }

.register-prompt {
  font-size: 0.9rem;
  color: #212121;
}

/* OTP */
#otp {
  background: #5647e3;
  padding: 0;
}

.otp-header {
  display: flex;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  z-index: 2;
}

.btn-back, .btn-change {
  padding: 8px 18px;
  background: rgba(255,255,255,0.3);
  border: none;
  border-radius: 10px;
  color: #fff;
  font-size: 0.9rem;
  cursor: pointer;
}

.otp-illustration {
  padding: 0.5rem 1rem 1rem;
  max-height: 38vh;
  display: flex;
  justify-content: center;
}

.otp-illustration img {
  max-width: 100%;
  max-height: 38vh;
  object-fit: contain;
}

.otp-card {
  flex: 1;
  background: #fff;
  border-radius: 28px 28px 0 0;
  padding: 2.5rem 1.5rem 3.5rem;
  box-shadow: 0 -4px 24px rgba(0,0,0,0.1);
}

.otp-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: #1a1a1a;
  margin-bottom: 0.75rem;
}

.otp-instruction {
  font-size: 0.9rem;
  color: #555;
  margin-bottom: 1.75rem;
  line-height: 1.5;
}

.otp-inputs {
  display: flex;
  gap: 14px;
  justify-content: center;
  margin-bottom: 1.25rem;
}

.otp-input {
  width: 54px;
  height: 54px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 1.5rem;
  font-weight: 600;
  text-align: center;
  color: #1a1a1a;
}

.otp-input:focus {
  outline: none;
  border-color: #5647e3;
}

.otp-resend {
  font-size: 0.9rem;
  color: #555;
  margin-bottom: 1.5rem;
}

.btn-verify,
.btn-submit {
  width: 100%;
  padding: 16px 24px;
  background: linear-gradient(90deg, #5647e3 0%, #6b5ce7 50%, #7d6ef0 100%);
  border: none;
  border-radius: 12px;
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(86, 71, 227, 0.35);
}

.btn-verify { margin-bottom: 1.5rem; }

.otp-sent {
  font-size: 0.85rem;
  color: #666;
}

.phone-masked {
  color: #4285F4;
  font-weight: 700;
}

/* Card */
#card {
  background: #5647e3;
  padding: 0;
}

.card-row {
  display: flex;
  gap: 12px;
}

.card-field-expiry { flex: 1.65; min-width: 0; }
.card-field-cvv { flex: 1; min-width: 0; }

.card-pin-wrap { position: relative; }

.card-pin-wrap .form-input { padding-right: 44px; }

.btn-eye {
  position: absolute;
  right: 10px;
  bottom: 12px;
  border: none;
  background: transparent;
  color: #666;
  cursor: pointer;
  padding: 6px;
}

.btn-eye svg { width: 20px; height: 20px; }

/* Form errors & states */
.form-error {
  color: #e53935;
  font-size: 0.78rem;
  margin-top: 6px;
  line-height: 1.4;
}

.form-group.input-error .form-input,
.form-group.input-error .country-code {
  border-color: #e53935;
}

.btn-login:disabled,
.btn-verify:disabled,
.btn-submit:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

/* Toast */
.user-toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 16px) + 20px);
  transform: translateX(-50%) translateY(120%);
  z-index: 100;
  min-width: min(320px, calc(100vw - 32px));
  padding: 14px 18px;
  border-radius: 12px;
  background: #5647e3;
  color: #fff;
  font-size: 0.9rem;
  font-weight: 600;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  transition: transform 0.35s ease;
}

.user-toast.show { transform: translateX(-50%) translateY(0); }
.user-toast.error { background: #e53935; }

@media (min-width: 600px) {
  body { background: #2a2a2a; }
  .screen {
    max-width: 430px;
    left: 50%;
    transform: translateX(-50%);
    box-shadow: 0 0 48px rgba(0, 0, 0, 0.35);
  }
}
