/* Pátio webapp — pátio de repasse à noite: asfalto escuro, sinalização azul
   Mercosul, faixa amarela de advertência. Tipografia Saira (BR, DNA rodoviário). */

:root {
  --bg-dark: #0b1120;
  --bg-card: rgba(23, 32, 51, 0.72);
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --accent: #8b5cf6;
  --hazard: #fbbf24;            /* amarelo sinalização — atenção/OCR */
  --text-main: #f4f7fb;
  --text-muted: #8fa0b8;
  --border: rgba(255, 255, 255, 0.09);
  --success: #10b981;
  --error: #f87171;
  --glass-bg: rgba(11, 17, 32, 0.65);
  --glass-border: rgba(255, 255, 255, 0.08);
  --font-body: 'Saira', system-ui, sans-serif;
  --font-display: 'Saira Condensed', 'Saira', sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; font-family: var(--font-body); }

body {
  background-color: var(--bg-dark);
  /* textura de asfalto: grade sutil + glows */
  background-image:
    linear-gradient(rgba(255,255,255,0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.025) 1px, transparent 1px);
  background-size: 44px 44px;
  color: var(--text-main);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

.bg-glow { position: fixed; border-radius: 50%; filter: blur(120px); z-index: -1; opacity: .5; animation: pulse 9s infinite alternate; }
.pattern-1 { top: -12%; left: -6%; width: 55vw; height: 55vw; background: radial-gradient(circle, rgba(59,130,246,.28) 0%, rgba(11,17,32,0) 70%); }
.pattern-2 { bottom: -12%; right: -6%; width: 42vw; height: 42vw; background: radial-gradient(circle, rgba(139,92,246,.22) 0%, rgba(11,17,32,0) 70%); animation-delay: -4s; }
@keyframes pulse { 0% { transform: scale(1); opacity: .38 } 100% { transform: scale(1.12); opacity: .58 } }

.app-container { display: flex; flex-direction: column; min-height: 100vh; }

/* ── Header ── */
.app-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 1rem 2rem;
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  background: var(--glass-bg);
  position: sticky; top: 0; z-index: 100;
}

.logo {
  display: flex; align-items: center; gap: .65rem;
  font-family: var(--font-display);
  font-size: 1.45rem; font-weight: 800; letter-spacing: 2.5px;
}
.logo i { color: var(--hazard); font-size: 1.7rem; }
.logo em { font-style: normal; font-weight: 600; color: var(--text-muted); letter-spacing: 1px; }

.header-status { display: flex; align-items: center; gap: .5rem; font-size: .82rem; color: var(--text-muted); letter-spacing: .5px; text-transform: uppercase; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--text-muted); }
.dot.on { background: var(--success); box-shadow: 0 0 8px rgba(16,185,129,.8); }
.dot.off { background: var(--error); box-shadow: 0 0 8px rgba(248,113,113,.8); }

/* ── Gate de acesso ── */
.gate-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(5, 8, 16, 0.88); backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center; padding: 1.5rem;
}
.gate-card {
  background: var(--bg-card); border: 1px solid var(--glass-border); border-radius: 20px;
  padding: 2.5rem 2rem; width: 100%; max-width: 380px; text-align: center;
  display: flex; flex-direction: column; gap: 1rem;
  box-shadow: 0 24px 60px rgba(0,0,0,.5);
  animation: slideUp .4s cubic-bezier(.16,1,.3,1);
}
.gate-icon { font-size: 2.6rem; color: var(--hazard); }
.gate-card h2 { font-family: var(--font-display); letter-spacing: 1px; font-weight: 700; }
.gate-card p { color: var(--text-muted); font-size: .95rem; }
.gate-card input {
  background: rgba(255,255,255,.05); border: 1px solid var(--border); border-radius: 12px;
  padding: .9rem 1rem; text-align: center; font-size: 1.2rem; letter-spacing: 4px;
}
.gate-card .btn-primary { justify-content: center; padding: .9rem; }

/* ── Hero ── */
.main-content { flex: 1; display: flex; flex-direction: column; align-items: center; padding: 2.5rem 1.25rem 5rem; max-width: 860px; width: 100%; margin: 0 auto; }
.hero { text-align: center; margin-bottom: 2rem; }
.hero h1 {
  font-family: var(--font-display);
  font-size: clamp(2.3rem, 6vw, 3.4rem); font-weight: 800;
  letter-spacing: 1px; text-transform: uppercase; line-height: 1.05;
  background: linear-gradient(to right, #fff 30%, #7d9cc9);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.hero p { color: var(--text-muted); font-size: 1.05rem; max-width: 520px; margin: .75rem auto 0; }

/* ── Chaveador de módulos (venda × entrada) ── */
.mode-switch {
  display: flex; gap: .25rem; margin-bottom: 1.75rem;
  background: var(--bg-card); border: 1px solid var(--glass-border);
  border-radius: 14px; padding: .35rem; backdrop-filter: blur(16px);
}
.mode-btn {
  display: flex; align-items: center; gap: .5rem;
  background: transparent; border: none; color: var(--text-muted);
  padding: .6rem 1.1rem; border-radius: 10px; cursor: pointer;
  font-family: var(--font-display); font-size: .92rem; font-weight: 600;
  letter-spacing: .8px; text-transform: uppercase; transition: all .25s ease;
}
.mode-btn i { font-size: 1.15rem; }
.mode-btn.active { background: linear-gradient(135deg, var(--primary), var(--accent)); color: #fff; box-shadow: 0 4px 14px rgba(59,130,246,.45); }

/* ── Stepper ── */
.stepper {
  display: flex; width: 100%; max-width: 640px; margin-bottom: 2rem;
  background: var(--bg-card); border: 1px solid var(--glass-border); border-radius: 16px;
  padding: .4rem; gap: .25rem; backdrop-filter: blur(16px);
  position: sticky; top: 76px; z-index: 90;
  box-shadow: 0 8px 32px rgba(0,0,0,.25);
}
.step {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: .5rem;
  background: transparent; border: none; color: var(--text-muted);
  padding: .7rem .25rem; border-radius: 12px; cursor: pointer;
  font-family: var(--font-display); font-size: .95rem; font-weight: 600; letter-spacing: .8px;
  text-transform: uppercase; transition: all .25s ease;
}
.step .step-num {
  width: 24px; height: 24px; border-radius: 50%; font-size: .85rem;
  display: flex; align-items: center; justify-content: center;
  border: 1.5px solid currentColor; flex-shrink: 0;
}
.step.active { background: linear-gradient(135deg, var(--primary), var(--accent)); color: #fff; box-shadow: 0 4px 14px rgba(59,130,246,.45); }
.step.done { color: var(--success); }
.step.done .step-num { border-color: var(--success); background: rgba(16,185,129,.15); }

/* ── Painéis ── */
.panel { width: 100%; animation: slideUp .45s cubic-bezier(.16,1,.3,1); display: flex; flex-direction: column; gap: 1.25rem; }

/* Captura de foto */
.capture-row { display: flex; align-items: stretch; gap: 1rem; width: 100%; }
.capture-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .35rem;
  border: 2px dashed rgba(251,191,36,.5); border-radius: 18px;
  background:
    linear-gradient(rgba(251,191,36,.06), rgba(251,191,36,.02));
  padding: 1.6rem 1rem; cursor: pointer; text-align: center;
  transition: all .25s ease;
}
.capture-btn:hover { border-color: var(--hazard); background: rgba(251,191,36,.1); transform: translateY(-2px); }
.capture-btn i { font-size: 2.2rem; color: var(--hazard); }
.capture-btn strong { font-family: var(--font-display); letter-spacing: 1px; text-transform: uppercase; font-size: 1.05rem; }
.capture-btn small { color: var(--text-muted); font-size: .82rem; }
.capture-or { display: flex; align-items: center; color: var(--text-muted); font-size: .85rem; text-transform: uppercase; letter-spacing: 1px; }

/* Variante azul — captura de comprovante de residência (endereço) */
.capture-btn.cool {
  border-color: rgba(59,130,246,.5);
  background: linear-gradient(rgba(59,130,246,.06), rgba(59,130,246,.02));
}
.capture-btn.cool:hover { border-color: var(--primary); background: rgba(59,130,246,.1); }
.capture-btn.cool i { color: var(--primary); }

/* Anúncio pro WhatsApp */
.anuncio-com-foto { display: flex; gap: 1rem; align-items: flex-start; flex-wrap: wrap; }
#anuncio-foto {
  width: 200px; max-width: 100%; border-radius: 12px;
  border: 2px solid var(--hazard); object-fit: cover;
}
.anuncio-com-foto textarea { flex: 1; min-width: 240px; }
.anuncio-passos {
  color: var(--text-muted); font-size: .88rem; line-height: 1.7;
  margin: .5rem 0 0; padding-left: 1.3rem;
}
.anuncio-passos li::marker { color: var(--primary); font-weight: 700; }
#anuncio-texto {
  width: 100%; background: rgba(255,255,255,.05); border: 1px solid var(--border);
  border-radius: 12px; padding: 1rem 1.1rem; color: var(--text-main);
  font-family: var(--font-body); font-size: .95rem; line-height: 1.55; resize: vertical;
}

/* Estrela da foto do anúncio */
.btn-midia-destacar.ativo { background: rgba(251,191,36,.9) !important; color: #10151f !important; }

/* Estoque de veículos (módulo Entrada) */
#estoque-lista { display: flex; flex-direction: column; gap: .6rem; }
.estoque-item {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  background: rgba(255,255,255,.03); border: 1px solid var(--border);
  border-radius: 12px; padding: .8rem 1rem;
  cursor: pointer; transition: border-color .2s ease, background .2s ease;
}
.estoque-item:hover { border-color: var(--primary); background: rgba(59,130,246,.07); }
.estoque-item-info { flex: 1; }
.estoque-item-info { display: flex; flex-direction: column; }
.estoque-item-info small { color: var(--text-muted); }
.form-grid input[readonly] { opacity: .65; cursor: not-allowed; }

/* Mídia do veículo (fotos/vídeo no Drive) */
.midia-desc { color: var(--text-muted); font-size: .88rem; margin: -0.6rem 0 1rem; }
#midia-card .capture-row { margin-bottom: .75rem; }

.midia-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: .75rem; margin-top: .5rem;
}
.midia-thumb {
  position: relative; border-radius: 12px; overflow: hidden;
  border: 1px solid var(--border); background: rgba(255,255,255,.03);
}
.midia-thumb a { display: block; aspect-ratio: 4 / 3; }
.midia-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.midia-thumb-fallback {
  width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); font-size: 2.4rem;
}
.midia-play {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 2.6rem; background: rgba(0,0,0,.35); pointer-events: none;
}
.midia-thumb-actions {
  position: absolute; top: .4rem; right: .4rem; display: flex; gap: .3rem;
}
.midia-thumb-actions button {
  width: 30px; height: 30px; display: flex; align-items: center; justify-content: center;
  border: none; border-radius: 8px; cursor: pointer;
  background: rgba(5,8,16,.72); color: #fff; font-size: .95rem;
  backdrop-filter: blur(6px); transition: background .2s ease;
}
.midia-thumb-actions button:hover { background: rgba(59,130,246,.85); }

/* Placa digitada */
.plate-form { display: flex; flex-direction: column; justify-content: center; gap: .75rem; min-width: 220px; }
.plate-input-wrap {
  display: flex; align-items: stretch; overflow: hidden;
  background: #fff; border-radius: 10px; border: 2px solid #1b2334;
  box-shadow: 0 4px 14px rgba(0,0,0,.35);
}
.plate-band {
  background: #003399; color: #fff; display: flex; align-items: center;
  padding: 0 .6rem; font-size: .75rem; font-weight: 700; letter-spacing: 1px;
}
.plate-input-wrap input {
  border: none; outline: none; background: transparent; width: 100%;
  color: #10151f; font-family: var(--font-display); font-weight: 800;
  font-size: 1.7rem; letter-spacing: 5px; text-transform: uppercase;
  padding: .45rem .75rem; text-align: center;
}
.plate-input-wrap input::placeholder { color: #b7bfcc; }

/* Cards e formulários */
.card {
  background: var(--bg-card); border: 1px solid var(--glass-border); border-radius: 20px;
  padding: 1.75rem; box-shadow: 0 20px 40px rgba(0,0,0,.3); backdrop-filter: blur(20px);
}
.card-title {
  display: flex; align-items: center; gap: .6rem;
  font-family: var(--font-display); font-size: 1.15rem; font-weight: 700;
  letter-spacing: 1px; text-transform: uppercase; margin-bottom: 1.25rem;
}
.card-title i { color: var(--primary); font-size: 1.35rem; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 1rem; }
.form-grid label {
  display: flex; flex-direction: column; gap: .35rem;
  font-size: .78rem; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .8px; font-weight: 500;
}
.form-grid label small { text-transform: none; letter-spacing: 0; }
.form-grid input, .form-grid select {
  background: rgba(255,255,255,.05); border: 1px solid var(--border); border-radius: 10px;
  color: var(--text-main); font-size: 1rem; padding: .7rem .8rem; outline: none;
  transition: border-color .2s, box-shadow .2s; width: 100%;
}
.form-grid input:focus, .form-grid select:focus { border-color: rgba(96,165,250,.6); box-shadow: 0 0 0 3px rgba(59,130,246,.15); }
.form-grid select { appearance: none; }
.form-grid select option { background: #172033; }
.form-grid .span-2 { grid-column: span 2; }
.form-grid input.upper { text-transform: uppercase; }
.check-label { flex-direction: row !important; align-items: center; justify-content: space-between; gap: .75rem !important; }
.check-label input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--hazard); flex-shrink: 0; }

/* Veículo — placa Mercosul */
.vehicle-hero { display: flex; gap: 1.75rem; align-items: center; }
.plate-display {
  background: #fff; border-radius: 8px; overflow: hidden;
  box-shadow: 0 4px 15px rgba(0,0,0,.35); border: 2px solid #1b2334;
  width: 158px; text-align: center; flex-shrink: 0;
}
.plate-header { background: #003399; color: #fff; font-size: .68rem; font-weight: 700; padding: 4px 0; letter-spacing: 2px; }
.plate-number { color: #10151f; font-size: 1.9rem; font-weight: 800; font-family: var(--font-display); padding: .4rem; letter-spacing: 4px; }
.vehicle-title h3 { font-family: var(--font-display); font-size: 1.45rem; letter-spacing: .5px; margin-bottom: .3rem; }
.vehicle-title p { color: var(--text-muted); margin-bottom: .5rem; }

.badge { padding: .22rem .7rem; border-radius: 20px; font-size: .78rem; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }
.badge.success { background: rgba(16,185,129,.18); color: #34d399; border: 1px solid rgba(16,185,129,.3); }
.badge.warn { background: rgba(251,191,36,.15); color: var(--hazard); border: 1px solid rgba(251,191,36,.3); }

.divider { height: 1px; background: var(--border); margin: 1.5rem 0; }

/* Botões */
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--accent)); color: #fff; border: none;
  padding: .85rem 1.6rem; border-radius: 12px; font-size: 1rem; font-weight: 600;
  font-family: var(--font-display); letter-spacing: 1px; text-transform: uppercase;
  cursor: pointer; display: flex; align-items: center; gap: .5rem;
  transition: all .25s ease; box-shadow: 0 4px 15px rgba(59,130,246,.4);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(59,130,246,.6); }
.btn-primary:active { transform: translateY(1px); }
.btn-secondary {
  background: rgba(255,255,255,.05); color: var(--text-main); border: 1px solid var(--border);
  padding: .85rem 1.4rem; border-radius: 12px; font-size: .95rem; font-weight: 500;
  cursor: pointer; display: flex; align-items: center; gap: .5rem; transition: all .2s;
}
.btn-secondary:hover { background: rgba(255,255,255,.1); }
.panel-actions { display: flex; justify-content: space-between; gap: 1rem; }
.panel-actions .btn-primary:only-child { margin-left: auto; }
.btn-gerar { background: linear-gradient(135deg, #d97706, var(--hazard)); box-shadow: 0 4px 15px rgba(251,191,36,.35); color: #1b1200; }
.btn-gerar:hover { box-shadow: 0 6px 22px rgba(251,191,36,.5); }

/* Avisos e estados */
.hidden { display: none !important; }
.notice {
  display: flex; align-items: flex-start; gap: .6rem;
  background: rgba(251,191,36,.08); border: 1px solid rgba(251,191,36,.3);
  color: #fde68a; border-radius: 12px; padding: .85rem 1rem; font-size: .92rem;
  animation: slideDown .3s ease;
}
.notice i { font-size: 1.15rem; margin-top: .1rem; }
.error-message { color: var(--error); font-size: .92rem; display: flex; align-items: center; gap: .5rem; animation: slideDown .3s ease; }
.state-container { display: flex; flex-direction: column; align-items: center; gap: 1rem; color: var(--text-muted); padding: 1rem 0; animation: fadeIn .3s ease; }
.spinner { width: 38px; height: 38px; border: 3px solid rgba(59,130,246,.3); border-radius: 50%; border-top-color: var(--primary); animation: spin 1s ease-in-out infinite; }

/* Resumo e documentos */
.resumo-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1.1rem; }
.detail-item { display: flex; flex-direction: column; gap: .2rem; }
.detail-item .label { color: var(--text-muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .8px; }
.detail-item .value { font-size: 1.02rem; font-weight: 500; }

.result-header { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.result-header .card-title { margin-bottom: 0; }
.doc-list { list-style: none; display: flex; flex-direction: column; gap: .6rem; }
.doc-item {
  display: flex; align-items: center; gap: .9rem;
  background: rgba(255,255,255,.04); border: 1px solid var(--border); border-radius: 12px;
  padding: .75rem 1rem; animation: slideUp .4s cubic-bezier(.16,1,.3,1) both;
}
.doc-item > i { font-size: 1.6rem; color: var(--error); }
.doc-info { flex: 1; display: flex; flex-direction: column; }
.doc-info small { color: var(--text-muted); }
.doc-item .btn-secondary { padding: .5rem .8rem; }

/* Animações */
@keyframes spin { to { transform: rotate(360deg) } }
@keyframes slideDown { from { opacity: 0; transform: translateY(-10px) } to { opacity: 1; transform: translateY(0) } }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px) } to { opacity: 1; transform: translateY(0) } }
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }

/* Responsivo */
@media (max-width: 700px) {
  .app-header { padding: .85rem 1.1rem; }
  .stepper { top: 64px; }
  .step .step-label { display: none; }
  .step.active .step-label { display: inline; }
  .capture-row { flex-direction: column; }
  .capture-or { justify-content: center; }
  .plate-form { min-width: 0; }
  .plate-form .btn-primary { justify-content: center; }
  .vehicle-hero { flex-direction: column; text-align: center; }
  .form-grid { grid-template-columns: 1fr 1fr; }
  .form-grid .span-2 { grid-column: span 2; }
  .panel-actions { flex-direction: row; }
  .result-header .btn-secondary { width: 100%; justify-content: center; }
}

/* ── Autorização de visitante (UC1) ── */
#panel-autorizacao .card + .card { margin-top: 1.25rem; }
#input-busca-morador {
  width: 100%; background: rgba(255,255,255,.04); border: 1px solid var(--border);
  border-radius: 12px; padding: .95rem 1.1rem; color: var(--text-main); font-size: 1rem;
  margin-bottom: .9rem;
}
#input-busca-morador:focus { outline: none; border-color: rgba(96,165,250,.6); box-shadow: 0 0 0 3px rgba(59,130,246,.15); }

.lista-resultados { display: flex; flex-direction: column; gap: .6rem; }
.resultado-item {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  background: rgba(255,255,255,.03); border: 1px solid var(--border);
  border-radius: 12px; padding: 1rem 1.1rem;
  cursor: pointer; transition: border-color .2s ease, background .2s ease;
}
.resultado-item:active, .resultado-item:hover { border-color: var(--primary); background: rgba(59,130,246,.07); }
.resultado-item-info { display: flex; flex-direction: column; gap: .15rem; }
.resultado-item-info small { color: var(--text-muted); }
.resultado-vazio { color: var(--text-muted); font-size: .92rem; padding: .5rem .2rem; }

.morador-chip {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  background: rgba(59,130,246,.1); border: 1px solid rgba(59,130,246,.3);
  border-radius: 12px; padding: .9rem 1.1rem; margin-bottom: 1.25rem;
}
.morador-chip strong { display: block; font-size: 1.05rem; }
.morador-chip small { color: var(--text-muted); }

/* Mobile-first: alvos de toque grandes, sem depender de hover */
@media (max-width: 640px) {
  .mode-btn { flex: 1; justify-content: center; padding: .8rem .5rem; font-size: .82rem; }
  .resultado-item, #input-busca-morador, .form-grid input, .btn-primary, .btn-secondary { min-height: 48px; }
}
