/* ==========================================================================
 * UX1.2a — QR handover safety (preview dialog + manual code input)
 * Isolated from style.css monolith. Light/dark via existing tokens.
 * ========================================================================== */

.handover-import-modal.modal-overlay {
  z-index: 10050;
}

.handover-import-dialog {
  text-align: left;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  max-width: min(92vw, 420px);
  width: 100%;
  gap: 0.75rem;
  padding: 1.1rem 1rem 1rem;
  box-sizing: border-box;
}

.handover-import-dialog h2 {
  margin: 0.15rem 0 0;
  font-size: 1.12rem;
  font-weight: 700;
  color: var(--color-text-main);
  line-height: 1.3;
}

.handover-import-target {
  margin: 0;
  font-size: 0.92rem;
  color: var(--color-text-main);
  line-height: 1.4;
}

.handover-import-target strong {
  font-weight: 700;
}

.handover-import-preview {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.35rem;
  font-size: 0.88rem;
  color: var(--color-text-muted);
  line-height: 1.4;
}

.handover-import-warning {
  margin: 0;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  border: 1px solid color-mix(in srgb, var(--rose, #c45) 35%, var(--color-border));
  background: color-mix(in srgb, var(--rose, #c45) 10%, var(--color-surface, #fff));
  color: var(--color-text-main);
  font-size: 0.86rem;
  line-height: 1.45;
}

.handover-import-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 0.25rem;
}

.handover-import-actions button {
  flex: 1 1 120px;
  min-width: 120px;
  min-height: 44px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
}

.handover-import-cancel {
  border: 1px solid var(--color-border);
  background: transparent;
  color: var(--color-text-main);
}

.handover-import-confirm {
  border: none;
  background: var(--teal);
  color: var(--sm-surface);
}

.handover-import-confirm:disabled,
.handover-import-cancel:disabled,
#handover-import-close:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.handover-manual-panel {
  display: none;
  margin-top: 0.75rem;
  padding: 0.75rem;
  border-radius: 12px;
  border: 1px solid var(--color-border);
  background: color-mix(in srgb, var(--sm-surface, #fff) 88%, var(--sm-bg, #e9efed));
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
}

.handover-manual-panel.is-open {
  display: grid;
  gap: 0.55rem;
}

.handover-manual-panel label {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--color-text-main);
}

.handover-manual-panel textarea {
  width: 100%;
  min-height: 96px;
  max-height: 180px;
  box-sizing: border-box;
  resize: vertical;
  border-radius: 10px;
  border: 1px solid var(--color-border);
  padding: 0.65rem 0.7rem;
  font-size: 0.86rem;
  line-height: 1.4;
  color: var(--color-text-main);
  background: var(--color-surface, #fff);
  overflow-wrap: anywhere;
}

.handover-manual-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.handover-manual-actions button {
  flex: 1 1 120px;
  min-height: 44px;
  min-width: 120px;
  border-radius: 12px;
  font-weight: 700;
  cursor: pointer;
}

.handover-manual-submit {
  border: none;
  background: var(--teal);
  color: var(--sm-surface);
}

.handover-manual-cancel {
  border: 1px solid var(--color-border);
  background: transparent;
  color: var(--color-text-main);
}

@media (max-width: 360px) {
  .handover-import-dialog {
    max-width: 96vw;
    padding: 0.95rem 0.8rem 0.85rem;
  }

  .handover-import-actions button,
  .handover-manual-actions button {
    flex-basis: 100%;
  }
}

body.dark-theme .handover-manual-panel {
  background: color-mix(in srgb, var(--sm-surface) 80%, #000);
}

body.dark-theme .handover-import-warning {
  background: color-mix(in srgb, var(--rose, #c45) 16%, var(--sm-surface));
}

/* ==========================================================================
 * UX1.2b — Answer-first QR transfer workspace (segmented send/receive)
 * ========================================================================== */

.handover-transfer-workspace {
  display: grid;
  gap: 0.85rem;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  margin: 0 0 1rem;
}

.handover-mode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem;
  width: 100%;
  padding: 0.3rem;
  box-sizing: border-box;
  border-radius: 14px;
  border: 1px solid var(--color-border);
  background: color-mix(in srgb, var(--sm-surface, #fff) 82%, var(--sm-bg, #e9efed));
}

.handover-mode-tab {
  min-height: 44px;
  min-width: 0;
  margin: 0;
  padding: 0.55rem 0.65rem;
  border: none;
  border-radius: 11px;
  background: transparent;
  color: var(--color-text-muted, #5b6b66);
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
  touch-action: manipulation;
}

.handover-mode-tab[aria-selected="true"] {
  background: var(--teal, #2a9d8f);
  color: var(--sm-surface, #fff);
}

.handover-mode-tab:focus-visible {
  outline: 2px solid var(--teal, #2a9d8f);
  outline-offset: 2px;
}

.handover-mode-panel {
  display: grid;
  gap: 0.65rem;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  min-width: 0;
}

.handover-mode-panel[hidden] {
  display: none !important;
}

.handover-panel-title {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 700;
  color: var(--color-text-main);
  line-height: 1.3;
}

.handover-panel-copy {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.45;
  color: var(--color-text-muted, #5b6b66);
}

.handover-transfer-workspace .action-btn,
.handover-transfer-workspace .handover-data-action,
.handover-transfer-workspace .handover-raw-share,
.handover-transfer-workspace .handover-scan-action,
.handover-transfer-workspace .handover-manual-action {
  min-height: 44px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.handover-transfer-workspace .handover-qr-container,
.handover-transfer-workspace #qr-container {
  display: none;
  width: 100%;
  max-width: 100%;
  margin: 0;
  padding: 0.6rem;
  box-sizing: border-box;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

.handover-transfer-workspace #qr-container canvas,
.handover-transfer-workspace .handover-qr-container canvas {
  display: block;
  width: min(100%, 280px) !important;
  height: auto !important;
  max-width: 100%;
  margin: 0 auto;
  box-sizing: border-box;
}

.handover-transfer-workspace .handover-warning,
.handover-transfer-workspace #qr-dense-warning {
  display: none;
  margin: 0;
  font-size: 0.86rem;
  line-height: 1.4;
  color: var(--color-text-main);
}

.handover-transfer-workspace .handover-raw-share {
  display: none;
}

/* ── UX1.2c.1 — scanner scan surface ──────────────────────────────────────
 * `.scanner-wrapper` (style.css) carries a 2px accent border and no height of
 * its own, and the only rule that used to hide it —
 * `.handover-data-details .scanner-wrapper` — targets an ancestor the receive
 * DOM no longer has. Left unhidden and unsized it renders as a 4px purple
 * line, before and during scanning, while the camera stream runs unseen.
 * Idle is hidden here; scanning gets a real, deterministic box.
 */
.handover-transfer-workspace .scanner-wrapper {
  display: none;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}

.handover-transfer-workspace .scanner-wrapper.scanning {
  display: block;
  position: relative;
  aspect-ratio: 1 / 1;
  min-height: 220px;
  max-height: 70vh;
}

/* The library injects its <video> — and a <canvas> while decoding — into the
 * container, which has no styling of its own. Without an explicit size they
 * collapse to nothing inside an already-collapsed wrapper. */
.handover-transfer-workspace .scanner-wrapper.scanning #scanner-container {
  display: block;
  width: 100%;
  height: 100%;
}

.handover-transfer-workspace
  .scanner-wrapper.scanning
  #scanner-container video,
.handover-transfer-workspace
  .scanner-wrapper.scanning
  #scanner-container canvas {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.handover-transfer-workspace .handover-success-msg {
  display: none;
  margin: 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--teal, #2a9d8f);
}

body.dark-theme .handover-mode-tabs {
  background: color-mix(in srgb, var(--sm-surface) 78%, #000);
  border-color: color-mix(in srgb, var(--color-border) 80%, #000);
}

body.dark-theme .handover-mode-tab {
  color: color-mix(in srgb, var(--color-text-main) 75%, transparent);
}

body.dark-theme .handover-mode-tab[aria-selected="true"] {
  background: var(--teal, #2a9d8f);
  color: #fff;
}

@media (max-width: 360px) {
  .handover-mode-tab {
    font-size: 0.9rem;
    padding: 0.5rem 0.4rem;
  }

  .handover-transfer-workspace #qr-container canvas,
  .handover-transfer-workspace .handover-qr-container canvas {
    width: min(100%, 240px) !important;
  }
}

/* ==========================================================================
 * UX1.2c — QR discoverability entries (home / hospital / tools)
 * ========================================================================== */

.home-utility-row {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.qr-discovery-entry {
  box-sizing: border-box;
  display: grid;
  gap: 0.12rem;
  align-content: center;
  width: 100%;
  min-height: 44px;
  margin: 0;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--teal, #2a9d8f);
  border-radius: 8px;
  background: var(--teal-bg, color-mix(in srgb, var(--teal, #2a9d8f) 12%, var(--sm-surface, #fff)));
  color: var(--sm-ink, var(--color-text-main));
  text-align: left;
  cursor: pointer;
  box-shadow: inset 3px 0 0 var(--teal, #2a9d8f);
  -webkit-tap-highlight-color: transparent;
}

.qr-discovery-entry--home {
  /* Locked: width:auto (not 100%) so margins are not added outside a
     100% box. Buttons still shrink-wrap under width:auto, so min/max
     width fill the content box minus the 1rem side margins. */
  width: auto;
  min-width: calc(100% - 2rem);
  max-width: calc(100% - 2rem);
  min-height: 56px;
  max-height: 64px;
  margin: 0 1rem 0.75rem;
  padding: 0.5rem 0.75rem;
}

.pillar-menu .qr-discovery-entry {
  grid-column: 1 / -1;
  min-height: 52px;
  padding: 0.55rem 0.78rem;
}

.qr-discovery-entry__title,
.qr-discovery-entry__sub {
  min-width: 0;
  margin: 0;
  hyphens: none;
  overflow-wrap: normal;
  word-break: normal;
  line-height: 1.25;
}

.qr-discovery-entry__title {
  color: var(--sm-ink, var(--color-text-main));
  font-size: 0.92rem;
  font-weight: 800;
}

.qr-discovery-entry__sub {
  color: var(--sm-muted, var(--color-text-muted));
  font-size: 0.74rem;
  font-weight: 500;
  line-height: 1.3;
}

.qr-discovery-entry:focus {
  outline: none;
}

.qr-discovery-entry:focus-visible {
  outline: 2px solid var(--teal, #2a9d8f);
  outline-offset: 2px;
}

.qr-discovery-entry:hover {
  background: color-mix(
    in srgb,
    var(--teal, #2a9d8f) 18%,
    var(--sm-surface, #fff)
  );
}

body.dark-theme .qr-discovery-entry {
  background: color-mix(in srgb, var(--teal, #2a9d8f) 22%, var(--sm-surface, #1a1a1a));
  border-color: var(--teal, #2a9d8f);
  color: var(--sm-ink, var(--color-text-main));
}

body.dark-theme .qr-discovery-entry__title {
  color: var(--sm-ink, var(--color-text-main));
}

body.dark-theme .qr-discovery-entry__sub {
  color: var(--sm-muted, var(--color-text-muted));
}

@media (max-width: 360px) {
  .qr-discovery-entry--home {
    margin-inline: 0.5rem;
    min-width: calc(100% - 1rem);
    max-width: calc(100% - 1rem);
  }

  .qr-discovery-entry__title {
    font-size: 0.86rem;
  }

  .qr-discovery-entry__sub {
    font-size: 0.7rem;
  }
}
