/* =====================================================
   SOFT DATA HUB - SHARED TRANSACTION PIN KEYPAD
   =====================================================

   The single keypad design used on every page and device.
   Markup is created by pin-keypad.js. Colours come from the
   variables below and follow the page theme automatically
   (data-theme="light" | "dark" is set by pin-keypad.js).

   - Phones:   compact bottom sheet (OPay style)
   - Tablets / desktop: the same sheet shown as a small
     centred card
   ===================================================== */

/* ---------- THEME TOKENS ---------- */

.pk-overlay {
  --pk-brand: #2878ff;
  --pk-brand-strong: #0845a5;
  --pk-brand-soft: rgba(40, 120, 255, 0.12);

  --pk-backdrop: rgba(8, 20, 45, 0.45);
  --pk-sheet: #ffffff;
  --pk-text: #0f1b33;
  --pk-muted: #6b778c;
  --pk-handle: #d7dde8;

  --pk-key: #f3f6fb;
  --pk-key-pressed: #e1e9f7;
  --pk-key-text: #0f1b33;

  --pk-box: #f7f9fc;
  --pk-box-border: #d9e1ee;
  --pk-dot: #0f1b33;

  --pk-error: #e53935;
  --pk-shadow: 0 -10px 40px rgba(8, 30, 80, 0.18);
}

.pk-overlay[data-theme="dark"] {
  --pk-brand: #4a8dff;
  --pk-brand-strong: #7aabff;
  --pk-brand-soft: rgba(74, 141, 255, 0.16);

  --pk-backdrop: rgba(0, 0, 0, 0.6);
  --pk-sheet: #111a2c;
  --pk-text: #eef3ff;
  --pk-muted: #93a1ba;
  --pk-handle: #2d3a55;

  --pk-key: #1b2640;
  --pk-key-pressed: #26345a;
  --pk-key-text: #eef3ff;

  --pk-box: #17213a;
  --pk-box-border: #2c3a5a;
  --pk-dot: #eef3ff;

  --pk-error: #ff6b6b;
  --pk-shadow: 0 -10px 40px rgba(0, 0, 0, 0.55);
}

/* ---------- RESET (protects against page styles) ---------- */

.pk-overlay,
.pk-overlay *,
.pk-overlay *::before,
.pk-overlay *::after {
  box-sizing: border-box;
}

.pk-overlay button {
  margin: 0;
  padding: 0;
  border: 0;
  width: auto;
  min-width: 0;
  max-width: none;
  height: auto;
  font: inherit;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  background: none;
  box-shadow: none;
  outline: none;
  transform: none;
  -webkit-appearance: none;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
}

/* ---------- OVERLAY ---------- */

.pk-overlay {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  background: var(--pk-backdrop);
  font-family: "Poppins", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  letter-spacing: normal;
  text-align: center;
  color: var(--pk-text);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.22s ease, visibility 0s linear 0.22s;
  -webkit-font-smoothing: antialiased;
}

.pk-overlay.show {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity 0.22s ease, visibility 0s;
}

html.pk-open,
html.pk-open body {
  overflow: hidden;
}

/* ---------- SHEET ---------- */

.pk-sheet {
  position: relative;
  width: 100%;
  max-width: 420px;
  max-height: 100%;
  overflow-y: auto;
  margin: 0;
  padding: 8px 18px calc(14px + env(safe-area-inset-bottom, 0px));
  background: var(--pk-sheet);
  color: var(--pk-text);
  border-radius: 22px 22px 0 0;
  box-shadow: var(--pk-shadow);
  text-align: center;
  transform: translateY(100%);
  transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
  outline: none;
}

.pk-overlay.show .pk-sheet {
  transform: translateY(0);
}

.pk-handle {
  display: block;
  width: 38px;
  height: 4px;
  margin: 0 auto 10px;
  border-radius: 4px;
  background: var(--pk-handle);
}

/* ---------- HEADER ---------- */

.pk-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 32px;
  padding: 0 36px;
}

.pk-lock {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--pk-brand-soft);
  color: var(--pk-brand);
  font-size: 12px;
  flex-shrink: 0;
}

.pk-overlay .pk-title {
  margin: 0;
  padding: 0;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--pk-text);
  letter-spacing: 0;
}

.pk-overlay .pk-close {
  position: absolute;
  top: 50%;
  right: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  margin-top: -16px;
  border-radius: 50%;
  background: var(--pk-key);
  color: var(--pk-muted);
  font-size: 15px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.pk-overlay .pk-close:active {
  background: var(--pk-key-pressed);
  color: var(--pk-text);
}

.pk-overlay .pk-close:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ---------- MESSAGE ---------- */

.pk-overlay .pk-message {
  margin: 8px auto 14px;
  padding: 0;
  max-width: 320px;
  min-height: 18px;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.45;
  color: var(--pk-muted);
}

.pk-overlay .pk-message.error {
  color: var(--pk-error);
  font-weight: 500;
}

/* ---------- PIN BOXES ---------- */

.pk-boxes {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin: 0 0 8px;
}

.pk-box {
  position: relative;
  width: 46px;
  height: 46px;
  border-radius: 12px;
  border: 1.5px solid var(--pk-box-border);
  background: var(--pk-box);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.pk-box::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 10px;
  height: 10px;
  margin: -5px 0 0 -5px;
  border-radius: 50%;
  background: var(--pk-dot);
  transform: scale(0);
  transition: transform 0.15s ease;
}

.pk-box.active {
  border-color: var(--pk-brand);
  box-shadow: 0 0 0 3px var(--pk-brand-soft);
}

.pk-box.filled {
  border-color: var(--pk-brand);
}

.pk-box.filled::after {
  transform: scale(1);
}

/* ---------- FORGOT PIN ---------- */

.pk-overlay .pk-forgot {
  display: inline-block;
  margin: 2px 0 12px;
  padding: 4px 8px;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--pk-brand);
  text-decoration: none;
}

.pk-overlay.busy .pk-forgot {
  opacity: 0.4;
  pointer-events: none;
}

/* ---------- KEYPAD ---------- */

.pk-pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  max-width: 320px;
  margin: 0 auto;
}

.pk-overlay .pk-key {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 48px;
  border-radius: 12px;
  background: var(--pk-key);
  color: var(--pk-key-text);
  font-size: 21px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  transition: background 0.12s ease, transform 0.08s ease;
}

.pk-overlay .pk-key:active {
  background: var(--pk-key-pressed);
  transform: scale(0.96);
}

.pk-overlay .pk-key:focus-visible,
.pk-overlay .pk-close:focus-visible {
  box-shadow: 0 0 0 2px var(--pk-brand);
}

.pk-overlay .pk-key-action {
  background: transparent;
  color: var(--pk-brand);
  font-size: 19px;
}

.pk-overlay .pk-key-blank {
  background: transparent;
  cursor: default;
  pointer-events: none;
}

.pk-overlay .pk-key:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

/* ---------- FOOTER ---------- */

.pk-secure {
  margin-top: 12px;
  font-size: 11px;
  line-height: 1.4;
  color: var(--pk-muted);
  letter-spacing: 0.2px;
}

.pk-secure i {
  margin-right: 4px;
  color: var(--pk-brand);
}

/* ---------- PROCESSING ---------- */

.pk-overlay.busy .pk-boxes .pk-box {
  animation: pk-pulse 1s ease-in-out infinite;
}

.pk-overlay.busy .pk-boxes .pk-box:nth-child(2) { animation-delay: 0.12s; }
.pk-overlay.busy .pk-boxes .pk-box:nth-child(3) { animation-delay: 0.24s; }
.pk-overlay.busy .pk-boxes .pk-box:nth-child(4) { animation-delay: 0.36s; }

@keyframes pk-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(0.9); }
}

/* ---------- WRONG PIN ---------- */

.pk-sheet.pk-shake .pk-boxes {
  animation: pk-shake 0.4s ease;
}

@keyframes pk-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

/* =====================================================
   RESPONSIVE - same design, adapted to the screen
   ===================================================== */

/* Very small phones */
@media (max-width: 340px) {
  .pk-sheet { padding-left: 12px; padding-right: 12px; }
  .pk-boxes { gap: 10px; }
  .pk-box { width: 42px; height: 42px; }
  .pk-overlay .pk-key { height: 44px; font-size: 19px; }
}

/* Short screens (landscape phones, small devices) */
@media (max-height: 600px) {
  .pk-handle { margin-bottom: 6px; }
  .pk-overlay .pk-message { margin: 4px auto 8px; }
  .pk-box { width: 40px; height: 40px; }
  .pk-overlay .pk-forgot { margin-bottom: 6px; }
  .pk-pad { gap: 6px; }
  .pk-overlay .pk-key { height: 40px; font-size: 18px; }
  .pk-secure { display: none; }
}

/* Tablets and desktop: compact centred card */
@media (min-width: 600px) and (min-height: 601px) {
  .pk-overlay {
    align-items: center;
    padding: 24px;
  }

  .pk-sheet {
    max-width: 360px;
    padding: 18px 22px 18px;
    border-radius: 20px;
    transform: translateY(16px) scale(0.98);
    opacity: 0;
    transition: transform 0.24s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.2s ease;
  }

  .pk-overlay.show .pk-sheet {
    transform: none;
    opacity: 1;
  }

  .pk-handle { display: none; }

  .pk-overlay .pk-key:hover:not(:disabled) {
    background: var(--pk-key-pressed);
  }

  .pk-overlay .pk-key-action:hover:not(:disabled) {
    background: var(--pk-brand-soft);
  }
}

@media (prefers-reduced-motion: reduce) {
  .pk-overlay,
  .pk-sheet,
  .pk-box,
  .pk-box::after,
  .pk-overlay .pk-key {
    transition: none !important;
    animation: none !important;
  }
}
