/* =========================================================
   PWA Inspeção Visual Hanna Hotéis — paleta plum + magenta
   ========================================================= */

:root {
  --plum: #5f0253;
  --plum-deep: #3d0136;
  --plum-light: #8b0a7a;
  --magenta: #e91e8c;
  --soft-magenta: #fce7f3;
  --cream: #fdf8fc;
  --ink: #1a0a18;
  --muted: #7a5c76;
  --line: #ede0eb;
  --white: #ffffff;
  --good: #0b6b3a;
  --bad: #b00020;
  --warn: #b76e00;
  --shadow: 0 4px 18px rgba(95, 2, 83, 0.15);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--cream);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}
body { display: flex; flex-direction: column; }

/* HEADER */
.app-header {
  background: linear-gradient(135deg, var(--plum) 0%, var(--plum-deep) 100%);
  color: var(--white);
  padding: 16px 20px;
  padding-top: calc(16px + env(safe-area-inset-top));
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow);
  z-index: 10;
}
.brand .eyebrow {
  display: block;
  color: var(--magenta);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin-bottom: 2px;
}
.brand h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.icon-btn {
  background: rgba(255,255,255,0.15);
  color: var(--white);
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
}
.icon-btn:active { background: rgba(255,255,255,0.3); }

/* SCREENS */
.screen {
  flex: 1;
  display: none;
  flex-direction: column;
  overflow: hidden;
  padding-bottom: env(safe-area-inset-bottom);
}
.screen.active { display: flex; }

.container {
  padding: 24px 20px;
  flex: 1;
  overflow-y: auto;
}
.container.center {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 40px 24px;
}
h2 {
  font-size: 24px;
  font-weight: 800;
  color: var(--plum);
  margin: 0 0 16px;
}
h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--plum);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 24px 0 12px;
}
p { color: var(--ink); line-height: 1.5; }
p.small { font-size: 14px; }
p.muted { color: var(--muted); }

/* BUTTONS */
.btn {
  display: block;
  width: 100%;
  padding: 16px 20px;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 700;
  border: none;
  cursor: pointer;
  margin-bottom: 12px;
  transition: transform 0.05s, opacity 0.15s;
  font-family: inherit;
}
.btn:active { transform: scale(0.98); }
.btn.primary {
  background: linear-gradient(135deg, var(--plum) 0%, var(--magenta) 100%);
  color: var(--white);
  box-shadow: var(--shadow);
}
.btn.secondary {
  background: var(--white);
  color: var(--plum);
  border: 2px solid var(--plum);
}
.btn.ghost {
  background: transparent;
  color: var(--muted);
  border: none;
}
.btn.big {
  padding: 20px 24px;
  font-size: 18px;
}
.btn:disabled { opacity: 0.5; pointer-events: none; }

/* INPUTS */
label {
  display: block;
  margin-bottom: 16px;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
select, input[type="text"] {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 16px;
  background: var(--white);
  color: var(--ink);
  margin-top: 6px;
  font-family: inherit;
}
select:focus, input:focus {
  outline: none;
  border-color: var(--magenta);
  box-shadow: 0 0 0 3px var(--soft-magenta);
}

/* SCAN SCREEN */
.scan-frame {
  flex: 1;
  position: relative;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}
#qr-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
#qr-reader {
  width: 100%;
  max-width: 480px;
}
.scan-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  pointer-events: none;
}
.reticle {
  width: 250px;
  height: 250px;
  border: 3px solid var(--magenta);
  border-radius: 24px;
  box-shadow: 0 0 0 9999px rgba(0,0,0,0.45);
  margin-bottom: 32px;
  position: relative;
}
.reticle::before, .reticle::after {
  content: "";
  position: absolute;
  width: 30px; height: 30px;
  border-color: var(--white);
  border-style: solid;
}
.reticle::before { top: -3px; left: -3px; border-width: 4px 0 0 4px; }
.reticle::after { bottom: -3px; right: -3px; border-width: 0 4px 4px 0; }
.hint {
  color: var(--white);
  font-weight: 600;
  text-shadow: 0 1px 4px rgba(0,0,0,0.6);
  background: rgba(0,0,0,0.5);
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 14px;
}
.bottom-actions {
  padding: 16px 20px 24px;
  background: var(--white);
}
.bottom-actions .btn { margin-bottom: 0; }

/* CONFIRM CARD */
.confirm-card {
  background: linear-gradient(135deg, var(--plum) 0%, var(--plum-deep) 100%);
  color: var(--white);
  padding: 28px 24px;
  border-radius: 16px;
  text-align: center;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}
.confirm-eyebrow {
  color: var(--magenta);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin-bottom: 8px;
}
.confirm-card h2 { color: var(--white); font-size: 22px; margin: 0 0 8px; }
.confirm-uh { font-size: 36px; font-weight: 800; letter-spacing: -0.02em; }
.prep-list { margin-bottom: 24px; }
.prep-list ol { padding-left: 22px; }
.prep-list li { margin-bottom: 10px; line-height: 1.5; }

/* RECORD SCREEN */
.record-frame {
  flex: 1;
  position: relative;
  background: #000;
}
#record-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.record-overlay {
  position: absolute;
  top: 0; left: 0; right: 0;
  padding: 16px 20px;
  padding-top: calc(16px + env(safe-area-inset-top));
  pointer-events: none;
  background: linear-gradient(to bottom, rgba(0,0,0,0.6), transparent);
}
.rec-indicator {
  display: inline-flex;
  align-items: center;
  background: rgba(0,0,0,0.65);
  color: var(--white);
  padding: 6px 14px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.08em;
}
.rec-dot {
  width: 10px; height: 10px;
  background: var(--bad);
  border-radius: 50%;
  margin-right: 8px;
  animation: blink 1s infinite;
}
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }
#rec-timer { margin-left: 12px; font-variant-numeric: tabular-nums; }
.rec-step {
  margin-top: 16px;
  background: rgba(0,0,0,0.65);
  color: var(--white);
  padding: 12px 16px;
  border-radius: 12px;
  border-left: 4px solid var(--magenta);
  display: inline-block;
}
.rec-step-num {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.16em;
  color: var(--magenta);
  margin-bottom: 4px;
}
.rec-step-text { font-size: 17px; font-weight: 700; }
.rec-info {
  position: absolute;
  bottom: 100px;
  left: 20px; right: 20px;
  background: rgba(0,0,0,0.65);
  color: var(--white);
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 13px;
  text-align: center;
}
.btn-stop {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bad);
  color: var(--white);
  border: 4px solid var(--white);
  width: 76px;
  height: 76px;
  border-radius: 50%;
  font-weight: 800;
  font-size: 14px;
  letter-spacing: 0.06em;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  cursor: pointer;
}
.btn-stop:active { transform: translateX(-50%) scale(0.95); }

/* REVIEW */
#review-video {
  width: 100%;
  border-radius: 12px;
  margin: 16px 0;
  background: #000;
}
.review-actions { display: flex; gap: 12px; }
.review-actions .btn { flex: 1; }

/* SPINNER */
.spinner {
  width: 64px;
  height: 64px;
  border: 5px solid var(--line);
  border-top-color: var(--magenta);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
  margin-bottom: 24px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
  margin: 16px 0;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--plum), var(--magenta));
  width: 0%;
  transition: width 0.3s;
}

/* DONE / ERROR ICONS */
.check-circle, .error-circle {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  font-weight: 800;
  color: var(--white);
  margin-bottom: 24px;
}
.check-circle { background: var(--good); }
.error-circle { background: var(--bad); }
.done-meta {
  background: var(--soft-magenta);
  padding: 16px 20px;
  border-radius: 12px;
  margin: 16px 0 24px;
  width: 100%;
  text-align: left;
}
.done-meta div { margin-bottom: 6px; font-size: 14px; }

/* MODAL */
.modal {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.6);
  z-index: 100;
  align-items: flex-end;
  justify-content: center;
}
.modal.active { display: flex; }
.modal-content {
  background: var(--white);
  width: 100%;
  max-height: 85%;
  overflow-y: auto;
  border-radius: 20px 20px 0 0;
  padding: 24px 20px;
  position: relative;
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
}
.modal-close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: none;
  border: none;
  font-size: 28px;
  color: var(--muted);
  cursor: pointer;
}
.modal-content ol { padding-left: 22px; }
.modal-content li { margin-bottom: 10px; }
