/**
 * eKYC passport upload — styles for ekyc-passport-transfer.html
 */

/* ---- Tokens & base ---- */
:root {
  --bg: #0f172a;
  --card: #1e293b;
  --text: #f8fafc;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --accent-dim: #0284c7;
  --danger: #f87171;
  --ok: #4ade80;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: linear-gradient(160deg, var(--bg), #1e3a5f);
  color: var(--text);
  padding: 16px;
  padding-bottom: 32px;
}

h1 {
  font-size: 1.25rem;
  margin: 0 0 8px;
  font-weight: 700;
}

.page-header {
  max-width: 480px;
  margin: 0 auto 12px;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.78);
  border: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-logo {
  width: 96px;
  height: auto;
  display: block;
}

.header-meta {
  font-size: 0.95rem;
  line-height: 1.2;
  color: var(--muted);
}

.card {
  position: relative;
  background: var(--card);
  border-radius: 16px;
  padding: 20px;
  max-width: 480px;
  margin: 0 auto;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

/* ---- Preview / gallery trigger / still image ---- */
.preview-wrap {
  width: 100%;
  aspect-ratio: 4/3;
  background: #0f172a;
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  border: 1px dashed #475569;
  margin-bottom: 14px;
  position: relative;
}

.preview-still {
  flex: 1;
  min-height: 0;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.preview-wrap:has(.camera-video-slot:not(.hidden)) .preview-still {
  display: none;
}

.preview-still img#previewImg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

.preview-gallery-trigger {
  position: absolute;
  inset: 0;
  z-index: 2;
  margin: 0;
  padding: 16px;
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font: inherit;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}

.preview-gallery-trigger:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -4px;
  border-radius: 8px;
}

.preview-empty-ui {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  pointer-events: none;
}

.preview-still--has-image .preview-empty-ui {
  display: none;
}

.preview-plus {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
}

.preview-plus svg {
  display: block;
}

.preview-placeholder {
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
  padding: 0 12px;
  line-height: 1.4;
  max-width: 280px;
}

.row-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.row-btns-single .btn-cam-full {
  width: 100%;
  flex: none;
}

.row-btns-single .btn-cam-full.hidden {
  display: none;
}

.file-input-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---- Buttons (row + primary + camera bar) ---- */
button,
.file-btn {
  flex: 1;
  min-width: 100px;
  padding: 12px 16px;
  border: none;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  text-align: center;
}

.file-btn {
  background: #334155;
  color: var(--text);
  position: relative;
  overflow: hidden;
}

.file-btn input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

button.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-dim));
  color: #0f172a;
}

button.btn-cam {
  background: #475569;
  color: var(--text);
}

button.primary-full {
  width: 100%;
  margin-bottom: 12px;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Full-bleed hit target inside preview (overrides row button flex/min-width) */
button.preview-gallery-trigger {
  flex: none;
  min-width: 0;
  width: 100%;
  height: 100%;
  padding: 16px;
}

/* Live camera: same 4:3 frame as captured still (img uses absolute + cover) */
.camera-video-slot {
  flex: 1;
  min-height: 0;
  position: relative;
  background: #000;
  overflow: hidden;
}

.camera-video-slot.hidden {
  display: none;
}

.camera-video-slot video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

/* Capture / Close below preview so video + still share full inner frame */
.camera-bar-wrap {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 1200;
  margin-bottom: 0;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid #475569;
  background: rgba(30, 41, 59, 0.96);
  backdrop-filter: blur(4px);
}

.camera-bar-wrap.hidden {
  display: none;
}

.camera-bar {
  display: flex;
  gap: 10px;
  padding: 12px;
  background: transparent;
  justify-content: center;
}

.camera-bar button {
  flex: 1;
  max-width: none;
}

#shutterBtn {
  padding-top: 20px;
  padding-bottom: 20px;
  font-size: 1.02rem;
}

body.camera-active {
  padding-bottom: calc(120px + env(safe-area-inset-bottom));
}

/* ---- Passport API result + Next ---- */
.pp-result-panel.hidden {
  display: none;
}

.pp-result-panel {
  margin-top: 16px;
  padding: 14px;
  border-radius: 12px;
  background: #0f172a;
  border: 1px solid #334155;
}

.pp-result-title {
  font-size: 0.9rem;
  font-weight: 700;
  margin: 0 0 12px;
  color: var(--text);
}

.pp-result-dl {
  display: grid;
  grid-template-columns: minmax(88px, 34%) 1fr;
  gap: 8px 12px;
  margin: 0 0 14px;
  font-size: 0.8rem;
}

.pp-result-dl dt {
  margin: 0;
  color: var(--muted);
  font-weight: 600;
}

.pp-result-dl dd {
  margin: 0;
  word-break: break-word;
  color: var(--text);
}

.pp-result-success {
  margin: 0 0 14px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(74, 222, 128, 0.12);
  border: 1px solid rgba(74, 222, 128, 0.35);
  color: var(--ok);
  font-size: 0.9rem;
  font-weight: 700;
  text-align: center;
}

.pp-result-success.hidden {
  display: none;
}

.pp-result-fail {
  margin: 0 0 14px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(248, 113, 113, 0.12);
  border: 1px solid rgba(248, 113, 113, 0.35);
  color: var(--danger);
  font-size: 0.9rem;
  font-weight: 700;
  text-align: center;
}

.pp-result-fail.hidden {
  display: none;
}

.pp-result-panel .primary-full {
  margin-bottom: 0;
}

.pp-result-panel .primary-full.hidden {
  display: none;
}

/* ---- Submit loading overlay ---- */
#submitLoadingOverlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: rgba(15, 23, 42, 0.72);
  backdrop-filter: blur(4px);
}

#submitLoadingOverlay.show {
  display: flex;
}

.submit-loading-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(56, 189, 248, 0.25);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: submitLoadingSpin 0.75s linear infinite;
}

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

.submit-loading-bar {
  width: min(280px, 80vw);
  height: 4px;
  background: #334155;
  border-radius: 999px;
  overflow: hidden;
}

.submit-loading-bar::after {
  content: "";
  display: block;
  height: 100%;
  width: 35%;
  background: linear-gradient(90deg, var(--accent), var(--accent-dim));
  border-radius: 999px;
  animation: submitLoadingBar 1.1s ease-in-out infinite;
}

@keyframes submitLoadingBar {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(400%);
  }
}

.submit-loading-text {
  font-size: 0.9rem;
  color: var(--muted);
  font-weight: 600;
}
