/* ══════════════════════════════════════════
   VARIÁVEIS & RESET
══════════════════════════════════════════ */
:root {
  --brand:      #6c63ff;
  --brand-rgb:  108, 99, 255;
  --bg:         #07071a;
  --surface:    #0f0f28;
  --surface2:   #16163a;
  --border:     rgba(255,255,255,0.08);
  --text:       #f0f0ff;
  --text2:      #9898cc;
  --text3:      #55558a;
  --success:    #43e97b;
  --warn:       #f7971e;
  --danger:     #ff6b6b;
  --wa:         #25d366;
  --r:          16px;
  --r-sm:       10px;
  --r-pill:     100px;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

/* ══════════════════════════════════════════
   TELAS
══════════════════════════════════════════ */
.screen {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
}

.screen.active { display: flex; }

/* ══════════════════════════════════════════
   TELA CONFIG
══════════════════════════════════════════ */
#screen-config {
  background: var(--bg);
}

.config-scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 0;
  padding-bottom: env(safe-area-inset-bottom, 24px);
}

.config-scroll::-webkit-scrollbar { display: none; }

/* Header */
.config-header {
  padding: 56px 20px 20px;
  text-align: center;
  background: linear-gradient(180deg, rgba(var(--brand-rgb), 0.12) 0%, transparent 100%);
  border-bottom: 1px solid var(--border);
}

.brand-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: rgba(var(--brand-rgb), 0.12);
  border: 1px solid rgba(var(--brand-rgb), 0.25);
  border-radius: var(--r-pill);
  padding: 5px 14px;
  margin-bottom: 8px;
}

.badge-icon { color: var(--brand); font-size: 13px; }
.badge-text { font-size: 13px; font-weight: 600; letter-spacing: 0.2px; }

.config-subtitle {
  font-size: 13px;
  color: var(--text2);
}

/* ── Preview 2D do cartão ── */
.preview-wrapper {
  padding: 24px 20px 12px;
  display: flex;
  justify-content: center;
}

.card-2d {
  position: relative;
  width: 100%;
  max-width: 360px;
  background: linear-gradient(140deg, var(--surface2) 0%, var(--surface) 100%);
  border: 1px solid rgba(var(--brand-rgb), 0.2);
  border-radius: var(--r);
  padding: 18px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,0.55), 0 0 0 1px rgba(255,255,255,0.04);
  transition: border-color 0.3s;
}

.card-glow {
  position: absolute;
  top: -50%;
  left: -20%;
  width: 140%;
  height: 150%;
  background: radial-gradient(ellipse at 25% 25%, rgba(var(--brand-rgb), 0.25) 0%, transparent 60%);
  pointer-events: none;
  transition: background 0.4s;
}

.card-top-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 12px;
}

/* Avatar */
.avatar-container {
  position: relative;
  flex-shrink: 0;
  width: 68px;
  height: 68px;
}

.avatar-ring {
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  background: conic-gradient(from 0deg, var(--brand), #ff6584 50%, var(--brand));
  animation: spin 4s linear infinite;
  transition: background 0.4s;
}

@keyframes spin { to { transform: rotate(360deg); } }

.avatar-img {
  position: absolute;
  inset: 3px;
  width: calc(100% - 6px);
  height: calc(100% - 6px);
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--surface);
  z-index: 1;
  background: var(--surface2);
}

/* Marca no cartão */
.card-brand-info { flex: 1; min-width: 0; }

.card-logo {
  height: 20px;
  max-width: 80px;
  object-fit: contain;
  margin-bottom: 4px;
  display: block;
}

.card-company {
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-slogan {
  font-size: 11px;
  color: var(--text2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.card-separator {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--brand), transparent);
  opacity: 0.35;
  margin: 10px 0;
  transition: background 0.3s;
}

/* Pessoa */
.person-name {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 2px;
}

.person-role {
  font-size: 12px;
  color: var(--brand);
  font-weight: 500;
  margin-bottom: 8px;
  transition: color 0.3s;
}

.person-contacts { display: flex; flex-direction: column; gap: 3px; }

.contact-line {
  font-size: 11px;
  color: var(--text2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Formulário ── */
.form {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 8px 20px 4px;
}

.fieldset {
  border: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px 0 20px;
  border-bottom: 1px solid var(--border);
}

.fieldset:last-child { border-bottom: none; }

.legend {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.4px;
  color: var(--text3);
  margin-bottom: 8px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text2);
}

.input {
  width: 100%;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text);
  font-size: 15px;
  padding: 13px 14px;
  outline: none;
  transition: border-color 0.2s, background 0.2s;
  -webkit-appearance: none;
  appearance: none;
}

.input:focus {
  border-color: var(--brand);
  background: rgba(var(--brand-rgb), 0.07);
}

/* Upload */
.upload-box {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255,255,255,0.03);
  border: 1px dashed rgba(var(--brand-rgb), 0.35);
  border-radius: var(--r-sm);
  padding: 14px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.upload-box:active {
  background: rgba(var(--brand-rgb), 0.08);
  border-color: var(--brand);
}

.upload-emoji { font-size: 20px; flex-shrink: 0; }
.upload-label { font-size: 13px; color: var(--text2); }

.file-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

/* Cor */
.color-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.color-native {
  width: 48px;
  height: 48px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: transparent;
  cursor: pointer;
  padding: 3px;
  -webkit-appearance: none;
  appearance: none;
  flex-shrink: 0;
}

.color-native::-webkit-color-swatch-wrapper { padding: 0; }
.color-native::-webkit-color-swatch { border-radius: 6px; border: none; }

.color-swatch {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--brand);
  box-shadow: 0 0 10px rgba(var(--brand-rgb), 0.5);
  flex-shrink: 0;
  transition: background 0.2s, box-shadow 0.2s;
}

.color-hex {
  font-size: 13px;
  color: var(--text2);
  font-family: 'Courier New', monospace;
}

.color-presets {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.preset {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s;
  -webkit-appearance: none;
}

.preset:active { transform: scale(0.88); }

.preset.on {
  border-color: #fff;
  transform: scale(1.12);
}

/* CTA */
.cta-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 24px 20px 36px;
}

.cta-hint { font-size: 12px; color: var(--text3); text-align: center; }

/* ══════════════════════════════════════════
   BOTÕES GLOBAIS
══════════════════════════════════════════ */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: linear-gradient(135deg, var(--brand) 0%, #9b59b6 100%);
  border: none;
  border-radius: var(--r-pill);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  padding: 16px 28px;
  cursor: pointer;
  width: 100%;
  max-width: 360px;
  letter-spacing: 0.2px;
  box-shadow: 0 8px 28px rgba(var(--brand-rgb), 0.4);
  transition: transform 0.13s, box-shadow 0.13s, opacity 0.2s;
  position: relative;
  overflow: hidden;
}

.btn-primary::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.14) 0%, transparent 55%);
  border-radius: inherit;
  pointer-events: none;
}

.btn-primary:active { transform: scale(0.96); box-shadow: 0 3px 12px rgba(var(--brand-rgb), 0.25); }

.btn-primary:disabled {
  opacity: 0.32;
  box-shadow: none;
  pointer-events: none;
}

.btn-outline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 360px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  color: var(--text2);
  font-size: 14px;
  padding: 14px 24px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.btn-outline:active { border-color: var(--brand); color: var(--brand); }

.btn-icon { font-size: 20px; animation: pulse 2.2s ease-in-out infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.55} }

/* ══════════════════════════════════════════
   TELA DE ERRO
══════════════════════════════════════════ */
#screen-error {
  background: var(--bg);
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
}

.error-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: 100%;
  max-width: 360px;
  text-align: center;
}

.error-icon {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: rgba(255,107,107,0.12);
  border: 1px solid rgba(255,107,107,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 34px;
  animation: shake 0.5s ease 0.2s both;
}

@keyframes shake {
  0%,100%{transform:translateX(0)}
  20%{transform:translateX(-5px)}
  40%{transform:translateX(5px)}
  60%{transform:translateX(-3px)}
  80%{transform:translateX(3px)}
}

.error-title { font-size: 21px; font-weight: 700; color: var(--danger); }
.error-desc  { font-size: 14px; color: var(--text2); line-height: 1.5; }

.error-steps {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 18px 20px;
  width: 100%;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 8px;
  list-style: decimal;
  padding-left: 36px;
}

.error-steps li { font-size: 13px; color: var(--text); line-height: 1.4; }

/* ══════════════════════════════════════════
   TELA AR
══════════════════════════════════════════ */
#screen-ar { background: #000; }

#ar-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* HUD */
.hud {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  z-index: 10;
  pointer-events: none;
}

.hud * { pointer-events: all; }

/* Topo */
.hud-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 50px 14px 14px;
  background: linear-gradient(180deg, rgba(0,0,0,0.72) 0%, transparent 100%);
}

.hud-circle-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255,255,255,0.12);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.15);
  color: #fff;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s;
  flex-shrink: 0;
}

.hud-circle-btn:active { background: rgba(255,255,255,0.25); }

.hud-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--r-pill);
  padding: 6px 13px;
  font-size: 12px;
  color: #fff;
  max-width: 52%;
  white-space: nowrap;
  overflow: hidden;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text3);
  flex-shrink: 0;
  transition: background 0.3s;
}

.status-dot.searching { background: var(--warn); animation: blink 0.9s infinite; }
.status-dot.found     { background: var(--success); }
.status-dot.placed    { background: var(--brand); }

@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0.25} }

/* Quality bars */
.quality-widget {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.quality-label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: rgba(255,255,255,0.45);
}

.q-bars {
  display: flex;
  align-items: flex-end;
  gap: 3px;
}

.qb {
  display: block;
  width: 5px;
  border-radius: 2px;
  background: rgba(255,255,255,0.18);
  transition: background 0.25s;
}

.qb:nth-child(1) { height: 7px; }
.qb:nth-child(2) { height: 10px; }
.qb:nth-child(3) { height: 13px; }
.qb:nth-child(4) { height: 16px; }
.qb:nth-child(5) { height: 19px; }

.qb.lit { background: var(--success); }
.qb:nth-child(1).lit,
.qb:nth-child(2).lit { background: var(--warn); }

/* Centro */
.hud-mid {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  pointer-events: none;
}

.reticle-wrap {
  position: relative;
  width: 90px;
  height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.reticle {
  position: absolute;
  border-radius: 50%;
  border: 2px solid rgba(var(--brand-rgb), 0.6);
}

.r1 {
  width: 90px;
  height: 90px;
  animation: r-pulse 2s ease-in-out infinite;
}

.r2 {
  width: 115px;
  height: 115px;
  border-color: rgba(var(--brand-rgb), 0.2);
  animation: r-pulse 2s ease-in-out 0.4s infinite;
}

/* Cantos do retículo */
.r1::before, .r1::after {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  border-color: var(--brand);
  border-style: solid;
}

.r1::before {
  top: -2px; left: -2px;
  border-width: 3px 0 0 3px;
  border-radius: 2px 0 0 0;
}

.r1::after {
  bottom: -2px; right: -2px;
  border-width: 0 3px 3px 0;
  border-radius: 0 0 2px 0;
}

@keyframes r-pulse {
  0%,100% { transform: scale(1);    opacity: 0.9; }
  50%      { transform: scale(1.07); opacity: 0.5; }
}

.scan-tip {
  font-size: 13px;
  color: rgba(255,255,255,0.85);
  text-align: center;
  line-height: 1.5;
  text-shadow: 0 1px 6px rgba(0,0,0,0.9);
  background: rgba(0,0,0,0.42);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--r-pill);
  padding: 9px 16px;
}

/* Rodapé HUD */
.hud-bottom {
  padding: 12px 14px calc(28px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(0deg, rgba(0,0,0,0.75) 0%, transparent 100%);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.phase { display: flex; flex-direction: column; gap: 10px; }
.phase.hidden { display: none; }
.hidden { display: none !important; }

.btn-place { font-size: 15px; max-width: 100%; }

/* Slider */
.slider-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(0,0,0,0.52);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--r-pill);
  padding: 10px 16px;
}

.slider-label { font-size: 18px; color: rgba(255,255,255,0.55); flex-shrink: 0; }

.slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 2px;
  background: rgba(255,255,255,0.2);
  outline: none;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--brand);
  box-shadow: 0 0 10px rgba(var(--brand-rgb), 0.6);
  cursor: pointer;
}

.adjust-btns {
  display: flex;
  gap: 10px;
}

.hud-action {
  flex: 1;
  border-radius: var(--r-pill);
  width: auto;
  height: 46px;
  font-size: 18px;
}

/* WhatsApp */
.btn-wa {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  background: linear-gradient(135deg, var(--wa) 0%, #1da851 100%);
  border: none;
  border-radius: var(--r-pill);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  padding: 16px 24px;
  cursor: pointer;
  box-shadow: 0 6px 22px rgba(37,211,102,0.4);
  transition: transform 0.13s, box-shadow 0.13s;
}

.btn-wa:active { transform: scale(0.96); box-shadow: 0 3px 10px rgba(37,211,102,0.25); }

/* ══════════════════════════════════════════
   ACESSIBILIDADE
══════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}