/* Hộp đăng nhập bằng QR ở /login (public/zenpn/qr-login.js). Trạng thái nằm ở
 * .zc-qr-card[data-state]: loading, waiting, scanned, done, expired, declined, error.
 * Mọi phần hiện/ẩn đều chuyển bằng transition hai chiều nên vào và ra đối xứng. */

.zc-qr-overlay {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  overflow-y: auto;
  padding: 16px;
  background: rgba(8, 12, 20, .55);
  opacity: 0;
  visibility: hidden;
  transition: opacity .2s ease, visibility 0s linear .2s;
}
.zc-qr-overlay[data-open] { opacity: 1; visibility: visible; transition: opacity .2s ease, visibility 0s; }

.zc-qr-card {
  width: 100%;
  max-width: 360px;
  margin: auto;
  padding: 22px 20px 18px;
  color: var(--zc-text);
  text-align: center;
  background: var(--zc-card);
  border: 1px solid var(--zc-line);
  border-radius: 14px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .35);
  transform: translateY(12px) scale(.98);
  transition: transform .25s cubic-bezier(.2, .8, .2, 1);
}
.zc-qr-overlay[data-open] .zc-qr-card { transform: none; }

.zc-qr-title { margin: 0 0 14px; color: var(--zc-heading); font-size: 18px; font-weight: 700; overflow-wrap: anywhere; }

.zc-qr-frame {
  position: relative;
  display: grid;
  width: min(200px, 100%);
  aspect-ratio: 1;
  margin: 0 auto;
  overflow: hidden;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 0 0 1px var(--zc-line);
}
.zc-qr-frame > * { position: relative; grid-area: 1 / 1; min-width: 0; min-height: 0; }
.zc-qr-cover { z-index: 1; }

.zc-qr-image {
  display: block;
  width: 100%;
  height: 100%;
  opacity: 1;
  transition: opacity .25s ease, filter .25s ease;
}
.zc-qr-image:not([src]) { visibility: hidden; }
.zc-qr-card[data-state="loading"] .zc-qr-image { opacity: 0; }
.zc-qr-card:is([data-state="expired"], [data-state="declined"], [data-state="error"]) .zc-qr-image { filter: blur(3px); opacity: .5; }

.zc-qr-skeleton {
  margin: 14px;
  border-radius: 8px;
  background: linear-gradient(90deg, rgba(15, 23, 42, .06) 25%, rgba(15, 23, 42, .13) 37%, rgba(15, 23, 42, .06) 63%);
  background-size: 400% 100%;
  opacity: 0;
  transition: opacity .2s ease;
  animation: zc-qr-shimmer 1.4s ease infinite;
}
.zc-qr-card[data-state="loading"] .zc-qr-skeleton { opacity: 1; }

.zc-qr-cover {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 12px;
  color: #0f172a;
  background: rgba(255, 255, 255, .84);
  opacity: 0;
  visibility: hidden;
  transition: opacity .25s ease, visibility 0s linear .25s;
}
.zc-qr-card:is([data-state="scanned"], [data-state="done"], [data-state="expired"], [data-state="declined"], [data-state="error"]) .zc-qr-cover {
  opacity: 1;
  visibility: visible;
  transition: opacity .25s ease, visibility 0s;
}

.zc-qr-icons { display: grid; width: 44px; height: 44px; }
.zc-qr-icon {
  grid-area: 1 / 1;
  width: 44px;
  height: 44px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0;
  transform: scale(.6);
  transition: opacity .2s ease, transform .3s cubic-bezier(.2, .8, .2, 1.2);
}
.zc-qr-icon-phone { color: #245ac6; }
.zc-qr-icon-done { color: #16a34a; }
.zc-qr-card[data-state="scanned"] .zc-qr-icon-phone,
.zc-qr-card[data-state="done"] .zc-qr-icon-done,
.zc-qr-card:is([data-state="expired"], [data-state="declined"], [data-state="error"]) .zc-qr-icon-renew { opacity: 1; transform: none; }

.zc-qr-renew,
.zc-qr-close {
  min-width: 96px;
  min-height: 36px;
  padding: 8px 14px;
  font: inherit;
  font-size: 13px;
  border-radius: 8px;
  cursor: pointer;
}
.zc-qr-renew {
  color: #fff;
  font-weight: 600;
  background: #245ac6;
  border: 1px solid transparent;
  opacity: 0;
  visibility: hidden;
  transform: translateY(4px);
  transition: opacity .2s ease, transform .2s ease, visibility 0s linear .2s, filter .2s;
}
.zc-qr-card:is([data-state="expired"], [data-state="declined"], [data-state="error"]) .zc-qr-renew {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition: opacity .2s ease, transform .2s ease, visibility 0s, filter .2s;
}
.zc-qr-renew:hover { filter: brightness(1.08); }
.zc-qr-renew:active { transform: scale(.97); }
.zc-qr-close {
  color: var(--zc-text);
  background: var(--zc-raised);
  border: 1px solid var(--zc-line);
  transition: background .2s;
}
.zc-qr-close:hover { background: var(--zc-hover, rgba(255, 255, 255, .06)); }
.zc-qr-renew:focus-visible,
.zc-qr-close:focus-visible { outline: 2px solid var(--zc-blue); outline-offset: 2px; }

.zc-qr-timer { width: min(200px, 100%); margin: 10px auto 0; transition: opacity .2s ease; }
.zc-qr-card:not([data-state="waiting"]):not([data-state="scanned"]) .zc-qr-timer { opacity: 0; }
.zc-qr-track { display: block; height: 3px; overflow: hidden; background: var(--zc-line); border-radius: 3px; }
.zc-qr-bar { display: block; height: 100%; background: var(--zc-blue); transform-origin: left center; transition: transform 1s linear; }
.zc-qr-bar:dir(rtl) { transform-origin: right center; }
.zc-qr-countdown { min-height: 18px; margin: 6px 0 0; color: var(--zc-muted); font-size: 12px; line-height: 18px; font-variant-numeric: tabular-nums; }

.zc-qr-status-wrap { display: grid; margin-top: 12px; }
.zc-qr-status {
  grid-area: 1 / 1;
  min-height: 1.5em;
  margin: 0;
  color: var(--zc-heading);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.5;
  overflow-wrap: anywhere;
  transition: color .2s ease;
}
.zc-qr-status[data-enter] { animation: zc-qr-in .22s ease both; }
.zc-qr-status-ghost { pointer-events: none; animation: zc-qr-out .22s ease both; }
.zc-qr-card[data-state="done"] .zc-qr-status { color: #16a34a; }
.zc-qr-card:is([data-state="expired"], [data-state="declined"], [data-state="error"]) .zc-qr-status:not(.zc-qr-status-ghost) { color: #e5484d; }

.zc-qr-email-wrap {
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
  transition: grid-template-rows .25s ease, opacity .2s ease;
}
.zc-qr-card:is([data-state="scanned"], [data-state="done"]) .zc-qr-email-wrap { grid-template-rows: 1fr; opacity: 1; }
.zc-qr-email {
  min-height: 0;
  margin: 0;
  overflow: hidden;
  padding-top: 4px;
  color: var(--zc-muted);
  font-size: 13px;
  overflow-wrap: anywhere;
  unicode-bidi: plaintext;
}
.zc-qr-email:empty { padding-top: 0; }

.zc-qr-steps {
  display: grid;
  gap: 8px;
  margin: 16px 0 0;
  padding: 0;
  text-align: start;
  list-style: none;
  counter-reset: zc-qr;
}
.zc-qr-steps li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  color: var(--zc-text);
  font-size: 13px;
  line-height: 1.45;
  overflow-wrap: anywhere;
  counter-increment: zc-qr;
}
.zc-qr-steps li::before {
  content: counter(zc-qr);
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  color: var(--zc-blue);
  font-size: 11px;
  font-weight: 700;
  background: color-mix(in srgb, var(--zc-blue) 14%, transparent);
  border-radius: 50%;
}

.zc-qr-warn { margin: 12px 0 0; color: var(--zc-muted); font-size: 12px; line-height: 1.5; opacity: .85; }
.zc-qr-actions { display: flex; justify-content: center; margin-top: 16px; }

@keyframes zc-qr-shimmer { from { background-position: 100% 50%; } to { background-position: 0 50%; } }
@keyframes zc-qr-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes zc-qr-out { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateY(-4px); } }

@media (prefers-reduced-motion: reduce) {
  .zc-qr-overlay, .zc-qr-card, .zc-qr-image, .zc-qr-skeleton, .zc-qr-cover, .zc-qr-icon, .zc-qr-renew,
  .zc-qr-timer, .zc-qr-bar, .zc-qr-status, .zc-qr-email-wrap { transition: none !important; animation: none !important; }
  .zc-qr-status-ghost { display: none; }
}
