/* ============================================================
   QR / BARCODE SCAN PAGE
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

#qrPage {
  font-family: 'Plus Jakarta Sans', sans-serif;
  background: #f1f5f9;
  color: #0f172a;
  min-height: 100%;
  padding: 14px 10px 30px;
}

/* ── Header ── */
#qrPage .qr-header {
  max-width: 560px; margin: 0 auto 14px;
  background: #fff; border: 1px solid #e2e8f0; border-radius: 14px;
  padding: 14px 16px;
  display: flex; align-items: center; justify-content: space-between;
  box-shadow: 0 4px 16px rgba(0,0,0,.06);
}
#qrPage .qr-header-left { display: flex; align-items: center; gap: 12px; }
#qrPage .qr-icon {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, #6366f1, #818cf8);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
#qrPage .qr-icon svg { width: 18px; height: 18px; stroke: #fff; fill: none; stroke-width: 2.5; }
#qrPage .qr-title { font-size: 16px; font-weight: 800; letter-spacing: -.3px; }
#qrPage .qr-sub { font-size: 11.5px; color: #64748b; font-weight: 500; margin-top: 1px; }
#qrPage .qr-close-btn {
  width: 34px; height: 34px; border-radius: 9px;
  border: 1px solid #e2e8f0; background: #f8fafc;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 16px; color: #64748b;
  transition: all .15s ease;
}
#qrPage .qr-close-btn:hover { background: #fee2e2; border-color: #fecaca; color: #e11d48; }

/* ── Camera ── */
#qrPage .qr-camera-wrap {
  max-width: 560px; margin: 0 auto;
  position: relative;
  background: #0f172a;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 8px 28px rgba(0,0,0,.18);
  aspect-ratio: 3 / 4;
}
#qrPage #qr-reader {
  width: 100% !important; height: 100% !important;
}
#qrPage #qr-reader video {
  width: 100% !important; height: 100% !important;
  object-fit: cover !important;
}
/* Hide the library's own default border/UI chrome so our overlay is the only frame */
#qrPage #qr-reader__scan_region { border: none !important; }
#qrPage #qr-reader__dashboard { display: none !important; }

#qrPage .qr-frame {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}
#qrPage .qr-frame-box {
  width: 78%; max-width: 300px; aspect-ratio: 5 / 3;
  border-radius: 14px;
  box-shadow: 0 0 0 2000px rgba(15,23,42,.45);
  position: relative;
}
#qrPage .qr-frame-corner {
  position: absolute; width: 26px; height: 26px;
  border: 3px solid #4ade80;
}
#qrPage .qr-frame-corner.tl { top: -3px; left: -3px; border-right: none; border-bottom: none; border-top-left-radius: 10px; }
#qrPage .qr-frame-corner.tr { top: -3px; right: -3px; border-left: none; border-bottom: none; border-top-right-radius: 10px; }
#qrPage .qr-frame-corner.bl { bottom: -3px; left: -3px; border-right: none; border-top: none; border-bottom-left-radius: 10px; }
#qrPage .qr-frame-corner.br { bottom: -3px; right: -3px; border-left: none; border-top: none; border-bottom-right-radius: 10px; }

#qrPage .qr-scan-line {
  position: absolute; left: 6%; right: 6%; height: 2px;
  background: linear-gradient(90deg, transparent, #4ade80, transparent);
  box-shadow: 0 0 8px 1px rgba(74,222,128,.8);
  animation: qrScanMove 2.2s ease-in-out infinite;
}
@keyframes qrScanMove {
  0%   { top: 8%; }
  50%  { top: 92%; }
  100% { top: 8%; }
}

#qrPage .qr-hint {
  max-width: 560px; margin: 12px auto 0;
  text-align: center; font-size: 12.5px; color: #64748b; font-weight: 500;
}

/* ── Manual waybill entry ── */
#qrPage .qr-manual-entry {
  max-width: 560px; margin: 18px auto 0;
}
#qrPage .qr-manual-divider {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 12px;
  color: #94a3b8; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em;
}
#qrPage .qr-manual-divider::before,
#qrPage .qr-manual-divider::after {
  content: ""; flex: 1; height: 1px; background: #e2e8f0;
}
#qrPage .qr-manual-row {
  display: flex; gap: 8px;
}
#qrPage .qr-manual-row input {
  flex: 1; min-width: 0; height: 46px;
  border: 1px solid #e2e8f0; border-radius: 11px;
  padding: 0 14px; font-family: inherit; font-size: 13.5px;
  color: #0f172a; background: #fff;
  box-sizing: border-box;
}
#qrPage .qr-manual-row input:focus {
  outline: none; border-color: #6366f1; box-shadow: 0 0 0 3px rgba(99,102,241,.12);
}
#qrPage .qr-manual-row input::placeholder { color: #94a3b8; }
#qrPage .qr-manual-btn {
  height: 46px; padding: 0 20px; border: none; border-radius: 11px;
  background: #6366f1; color: #fff;
  font-family: inherit; font-size: 13.5px; font-weight: 700;
  cursor: pointer; transition: background .15s ease; flex-shrink: 0;
}
#qrPage .qr-manual-btn:hover { background: #4f46e5; }

/* ── Camera error ── */
#qrPage .qr-cam-error {
  max-width: 560px; margin: 0 auto;
  background: #fff; border: 1px solid #fecaca; border-radius: 16px;
  padding: 32px 20px; text-align: center;
}
#qrPage .qr-cam-error .qr-err-icon { font-size: 34px; margin-bottom: 10px; }
#qrPage .qr-cam-error h3 { font-size: 15px; font-weight: 700; color: #0f172a; margin-bottom: 6px; }
#qrPage .qr-cam-error p { font-size: 12.5px; color: #64748b; margin-bottom: 16px; line-height: 1.5; }

/* ── Loading ── */
#qrPage .qr-loading {
  max-width: 560px; margin: 60px auto; text-align: center;
}
#qrPage .qr-spinner {
  width: 42px; height: 42px; margin: 0 auto 16px;
  border: 4px solid #e0e7ff; border-top-color: #6366f1;
  border-radius: 50%; animation: qrSpin .8s linear infinite;
}
@keyframes qrSpin { to { transform: rotate(360deg); } }
#qrPage .qr-loading p { font-size: 13px; color: #64748b; font-weight: 600; }

/* ── Result card ── */
#qrPage .qr-result-card {
  max-width: 560px; margin: 0 auto;
  background: #fff; border: 1px solid #e2e8f0; border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(0,0,0,.04);
}
#qrPage .qr-result-top {
  padding: 16px 18px; border-bottom: 1px solid #f1f5f9;
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
}
#qrPage .ref-badge-lg {
  display: inline-block; padding: 5px 12px;
  background: #eef2ff; border: 1px solid #e0e7ff;
  border-radius: 8px; font-size: 14px; font-weight: 800; color: #6366f1;
}
#qrPage .qr-section { padding: 14px 18px; border-bottom: 1px solid #f8fafc; }
#qrPage .qr-section:last-child { border-bottom: none; }
#qrPage .qr-section-title {
  font-size: 10px; font-weight: 700; color: #94a3b8;
  text-transform: uppercase; letter-spacing: .07em; margin-bottom: 9px;
}
#qrPage .qr-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
#qrPage .qr-field { background: #f8fafc; border-radius: 9px; padding: 9px 11px; }
#qrPage .qr-field.full { grid-column: 1 / -1; }
#qrPage .qr-field-label { font-size: 10px; color: #94a3b8; font-weight: 600; margin-bottom: 3px; }
#qrPage .qr-field-value { font-size: 13px; font-weight: 600; color: #0f172a; word-break: break-word; }
#qrPage .qr-field-value.green { color: #16a34a; }
#qrPage .qr-field-value a { color: #6366f1; text-decoration: none; }

/* Status pill (reuse the same visual language as the scan-out page) */
#qrPage .pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 11px; border-radius: 20px; font-size: 12px; font-weight: 700;
}
#qrPage .pill.pending   { background: #fefce8; color: #ca8a04; }
#qrPage .pill.delivered { background: #f0fdf4; color: #16a34a; }
#qrPage .pill.returned  { background: #fff1f2; color: #e11d48; }
#qrPage .pill.exchange  { background: #eef2ff; color: #4f46e5; }
#qrPage .pill-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* Timeline */
#qrPage .qr-timeline { display: flex; flex-direction: column; }
#qrPage .qr-tl-item {
  position: relative; padding: 0 0 16px 22px;
  border-left: 2px solid #e2e8f0;
}
#qrPage .qr-tl-item:last-child { border-left-color: transparent; padding-bottom: 0; }
#qrPage .qr-tl-dot {
  position: absolute; left: -6px; top: 1px;
  width: 10px; height: 10px; border-radius: 50%;
  background: #6366f1; border: 2px solid #fff; box-shadow: 0 0 0 2px #6366f1;
}
#qrPage .qr-tl-item:first-child .qr-tl-dot { background: #16a34a; box-shadow: 0 0 0 2px #16a34a; }
#qrPage .qr-tl-status { font-size: 13px; font-weight: 700; color: #0f172a; }
#qrPage .qr-tl-meta { font-size: 11px; color: #94a3b8; margin-top: 2px; }
#qrPage .qr-tl-remark { font-size: 11.5px; color: #64748b; margin-top: 3px; font-style: italic; }

/* ── Actions ── */
#qrPage .qr-actions {
  max-width: 560px; margin: 14px auto 0;
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
}
#qrPage .qr-btn {
  width: 100%; height: 46px; border-radius: 11px; border: none;
  font-family: inherit; font-size: 13.5px; font-weight: 700;
  cursor: pointer; transition: all .15s ease;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  box-sizing: border-box;
}
#qrPage .qr-btn-rescan { background: #6366f1; color: #fff; }
#qrPage .qr-btn-rescan:hover { background: #4f46e5; box-shadow: 0 3px 12px rgba(99,102,241,.3); }
#qrPage .qr-btn-close { background: #f1f5f9; color: #475569; border: 1px solid #e2e8f0; }
#qrPage .qr-btn-close:hover { background: #e2e8f0; }
#qrPage .qr-btn-deliver { background: #16a34a; color: #fff; }
#qrPage .qr-btn-deliver:hover { background: #15803d; box-shadow: 0 3px 12px rgba(22,163,74,.3); }
#qrPage .qr-btn-update { background: #eef2ff; color: #4f46e5; border: 1px solid #e0e7ff; }
#qrPage .qr-btn-update:hover { background: #e0e7ff; }

/* Ownership banner - shown instead of Deliver/Update when the scanned order isn't the rider's own */
#qrPage .qr-not-mine {
  max-width: 560px; margin: 14px auto 0;
  background: #fffbeb; border: 1px solid #fde68a; color: #92400e;
  border-radius: 12px; padding: 12px 14px;
  font-size: 12.5px; font-weight: 600; line-height: 1.5; text-align: center;
}

/* Error card (order not found etc.) */
#qrPage .qr-error-card {
  max-width: 560px; margin: 0 auto;
  background: #fff; border: 1px solid #fecaca; border-radius: 16px;
  padding: 30px 20px; text-align: center;
}
#qrPage .qr-error-card .qr-err-icon { font-size: 36px; margin-bottom: 10px; }
#qrPage .qr-error-card h3 { font-size: 15px; font-weight: 700; color: #0f172a; margin-bottom: 6px; }
#qrPage .qr-error-card .qr-scanned-code {
  display: inline-block; margin-bottom: 6px;
  background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 8px;
  padding: 4px 10px; font-size: 12px; font-weight: 700; color: #475569;
}
#qrPage .qr-error-card p { font-size: 12.5px; color: #64748b; margin-bottom: 4px; line-height: 1.5; }

@media (max-width: 480px) {
  #qrPage .qr-grid { grid-template-columns: 1fr; }
}
