/* PWA — bare functional styles. Designer phase will replace this.
 *
 * All rules are scoped under .pwa-shell (set on the body of the PWA layout)
 * because Propshaft serves every file under app/assets/stylesheets/ on every
 * page, so unscoped rules would bleed into the rest of the app.
 */

.pwa-shell, .pwa-shell * { box-sizing: border-box; }

.pwa-shell {
  margin: 0;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  color: #f3f4f6;
  background: #1f2937;
  min-height: 100vh;
}

#pwa-root {
  max-width: 540px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

#pwa-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.75rem;
  background: #111827;
  border-bottom: 1px solid #374151;
  position: sticky;
  top: 0;
  z-index: 5;
}

.pwa-status { display: flex; gap: 0.4rem; flex-shrink: 0; }

.pwa-pill {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.8rem;
  background: #16a34a;
  color: #fff;
}
.pwa-pill[data-state="offline"] { background: #dc2626; }
.pwa-pill--quiet { background: #4b5563; }
.pwa-pill--warn  { background: #f59e0b; cursor: pointer; }
.pwa-pill[hidden] { display: none; }

.pwa-user {
  font-size: 0.85rem;
  color: #9ca3af;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.pwa-shell main { flex: 1; padding: clamp(0.6rem, 3vw, 1rem); }

.pwa-screen { display: block; }
.pwa-screen[hidden] { display: none; }

.pwa-screen-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}
.pwa-screen-head h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0;
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.pwa-msg { color: #d1d5db; }

.pwa-btn {
  appearance: none;
  border: 0;
  background: #374151;
  color: #f3f4f6;
  padding: 0.75rem 1.1rem;
  border-radius: 0.5rem;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.pwa-btn:active { transform: translateY(1px); }
.pwa-btn--primary { background: #2563eb; }
.pwa-btn--ghost { background: transparent; color: #9ca3af; padding: 0.7rem 0.9rem; }
.pwa-btn--remove {
  display: block;
  width: 100%;
  margin-bottom: 1rem;
  background: transparent;
  border: 1px solid #7f1d1d;
  color: #f87171;
}

#pwa-scanner-container {
  position: relative;
  background: #000;
  border-radius: 0.75rem;
  overflow: hidden;
  aspect-ratio: 1 / 1;
  margin-bottom: 1rem;
}
#pwa-scanner { width: 100%; height: 100%; }
#pwa-scanner video { width: 100% !important; height: 100% !important; object-fit: cover; }

#pwa-scanner-resume {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: rgba(17, 24, 39, 0.92);
  color: #f3f4f6;
  border: 0;
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
#pwa-scanner-resume[hidden] { display: none; }
.pwa-scanner-resume-icon {
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 999px;
  background: #2563eb;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  padding-left: 0.25rem;
}
.pwa-scanner-resume-text {
  font-size: 1.05rem;
  font-weight: 600;
}

.pwa-or {
  text-align: center;
  color: #6b7280;
  margin: 0.6rem 0;
  font-size: 0.85rem;
}

.pwa-manual {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.pwa-manual label {
  font-size: 0.85rem;
  color: #9ca3af;
}
.pwa-manual input {
  padding: 0.75rem;
  border-radius: 0.5rem;
  border: 1px solid #374151;
  background: #111827;
  color: #f3f4f6;
  font-size: 1.1rem;
}

.pwa-hint {
  margin-top: 0.5rem;
  color: #fca5a5;
  font-size: 0.9rem;
}

/* Amber-stripe callout shared between the heat-prompt screen and the
 * picker's "currently at" banner. Per-class rules below add layout. */
.pwa-heat-prompt,
.pwa-current-banner {
  background: #111827;
  border: 1px solid #374151;
  border-left: 4px solid #f59e0b;
  border-radius: 0.5rem;
  padding: 0.7rem 0.9rem;
}

.pwa-heat-prompt {
  color: #f3f4f6;
  font-size: 0.95rem;
  line-height: 1.35;
  margin: 0 0 1rem;
}

.pwa-meta {
  color: #9ca3af;
  font-size: 0.9rem;
  margin: 0.25rem 0 0.75rem;
}

.pwa-current-banner {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  margin-bottom: 1rem;
}
.pwa-current-banner[data-state="empty"] { border-left-color: #6b7280; }
.pwa-current-banner[data-state="done"] {
  background: #064e3b;
  border-color: #065f46;
  border-left-color: #34d399;
}
.pwa-current-banner[data-state="done"] .pwa-current-label,
.pwa-current-banner[data-state="done"] .pwa-current-time { color: #a7f3d0; }
.pwa-current-banner[data-state="done"] .pwa-current-value { color: #ffffff; }
.pwa-current-label {
  font-size: 0.8rem;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.pwa-current-value {
  font-size: 1.25rem;
  font-weight: 600;
  color: #f3f4f6;
  line-height: 1.2;
}
.pwa-current-time {
  font-size: 0.8rem;
  color: #9ca3af;
}

/* Temporary QC-walk affordance: three sticker-color pills for hot/customer/
 * inventory. Fully colored at rest so the foreman/QC can match the WO's
 * paper sticker by sight; current selection pops with a white outline. */
.pwa-priority { margin-bottom: 1rem; }
.pwa-priority .pwa-pick-section { margin: 0 0 0.4rem; }
.pwa-priority-pills {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.5rem;
}
.pwa-priority-pill {
  min-height: 3rem;
  padding: 0.6rem 0.5rem;
  border-radius: 0.5rem;
  border: 0;
  color: #ffffff;
  font: inherit;
  font-weight: 600;
  font-size: 1rem;
  text-align: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  opacity: 0.55;
}
.pwa-priority-pill[data-current="true"] {
  opacity: 1;
  outline: 2px solid #f3f4f6;
  outline-offset: 2px;
}
.pwa-priority-pill:active { filter: brightness(0.85); }
.pwa-priority-pill--hot       { background: #db2777; }
.pwa-priority-pill--customer  { background: #ea580c; }
.pwa-priority-pill--inventory { background: #16a34a; }

.pwa-pick-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.pwa-pick-section {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #9ca3af;
  margin: 0.4rem 0 0.4rem;
}

.pwa-pick-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.pwa-pick-tile {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 4.5rem;
  padding: 0.75rem 0.85rem;
  border-radius: 0.5rem;
  background: #374151;
  border: 0;
  color: #f3f4f6;
  font: inherit;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.pwa-pick-tile:active { background: #4b5563; }
.pwa-pick-tile[data-current="true"] { outline: 2px solid #60a5fa; }
.pwa-pick-tile--done[data-current="true"] {
  outline: 2px solid #34d399;
  background: #064e3b;
}
.pwa-pick-tile--done[data-current="true"]:active { background: #065f46; }
.pwa-pick-tile-label {
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.2;
  overflow-wrap: anywhere;
}
.pwa-pick-tile-meta {
  font-size: 0.85rem;
  color: #9ca3af;
  margin-top: 0.4rem;
}
.pwa-pick-tile--category .pwa-pick-tile-meta { color: #93c5fd; }

.pwa-pick-item {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 1rem;
  border-radius: 0.5rem;
  background: #374151;
  border: 0;
  color: #f3f4f6;
  font: inherit;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.pwa-pick-item:active { background: #4b5563; }
.pwa-pick-item[data-current="true"] {
  outline: 2px solid #60a5fa;
}
.pwa-pick-label { font-size: 1.2rem; font-weight: 600; overflow-wrap: anywhere; }
.pwa-pick-sub { font-size: 0.85rem; color: #9ca3af; }

.pwa-confirm-card {
  background: #064e3b;
  padding: 1.5rem;
  border-radius: 0.75rem;
  margin-bottom: 1rem;
}
.pwa-confirm-line { margin: 0.25rem 0; font-size: 1.1rem; }
.pwa-confirm-time { font-size: 0.85rem; color: #a7f3d0; }

.pwa-footer {
  text-align: center;
  padding: 0.5rem 0.75rem 0.75rem;
  font-size: 0.8rem;
  color: #6b7280;
  border-top: 1px solid #1f2937;
}

.pwa-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 100;
}
.pwa-modal[hidden] { display: none; }
.pwa-modal-card {
  background: #1f2937;
  border: 1px solid #374151;
  border-radius: 0.75rem;
  padding: 1.25rem;
  max-width: 360px;
  width: 100%;
}
.pwa-modal-title {
  margin: 0 0 0.6rem;
  font-size: 1.2rem;
  font-weight: 700;
  color: #f3f4f6;
}
.pwa-modal-body {
  margin: 0 0 1rem;
  color: #d1d5db;
  line-height: 1.4;
}
.pwa-modal-body strong { color: #f3f4f6; }
.pwa-modal-actions {
  display: flex;
  gap: 0.5rem;
}
.pwa-modal-actions .pwa-btn { flex: 1; }

.pwa-rejected-list {
  max-height: 60vh;
  overflow-y: auto;
  margin: 0 0 1rem;
}
.pwa-rejected-item {
  padding: 0.5rem 0;
  border-bottom: 1px solid #374151;
  color: #d1d5db;
}
.pwa-rejected-item:last-child { border-bottom: 0; }
.pwa-rejected-head   { color: #f3f4f6; margin-bottom: 0.2rem; }
.pwa-rejected-reason { font-size: 0.9rem; }
.pwa-rejected-time   { font-size: 0.75rem; color: #9ca3af; margin-top: 0.2rem; }
