/* ==========================================================================
   Design tokens
   Conceito: a corrida termina, a jornada até um novo endereço começa.
   O formulário público é desenhado como uma passagem/bilhete — o elo físico
   entre o banco do carro e a próxima casa do passageiro.
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,500;9..144,600;9..144,700&family=Inter:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500&display=swap');

:root {
  --ink: #161A2C;
  --ink-soft: #2A3147;
  --paper: #EEF0F4;
  --surface: #FFFFFF;
  --brass: #B8863B;
  --brass-light: #D9AE6B;
  --slate: #5B6472;
  --slate-light: #8891A0;
  --success: #3F7C63;
  --success-bg: #E5F0EA;
  --warning: #B8863B;
  --warning-bg: #F6EDDC;
  --danger: #A94A3F;
  --danger-bg: #F5E5E2;
  --border: #DCDFE6;

  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'Inter', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 22px;

  --shadow-card: 0 1px 2px rgba(22, 26, 44, 0.04), 0 8px 24px rgba(22, 26, 44, 0.08);
  --shadow-lift: 0 12px 32px rgba(22, 26, 44, 0.14);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

h1, h2, h3 {
  font-family: var(--font-display);
  margin: 0;
  letter-spacing: -0.01em;
}

button, input, select, textarea { font-family: inherit; font-size: inherit; }

:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 22px;
  border-radius: var(--radius-sm);
  border: none;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.btn-primary {
  background: var(--ink);
  color: #fff;
}
.btn-primary:hover { background: var(--ink-soft); box-shadow: var(--shadow-lift); }

.btn-brass {
  background: var(--brass);
  color: #fff;
}
.btn-brass:hover { background: #a5762f; }

.btn-ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--border);
}
.btn-ghost:hover { border-color: var(--ink); }

.btn-sm { padding: 8px 14px; font-size: 13px; border-radius: 6px; }
.btn-block { width: 100%; }

/* ==========================================================================
   Pagina publica: o "bilhete" de indicacao
   ========================================================================== */

.ticket-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px 16px;
  background:
    radial-gradient(circle at 15% 0%, rgba(184, 134, 59, 0.12), transparent 45%),
    var(--paper);
}

.ticket {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  animation: ticket-in 0.5s cubic-bezier(.2,.8,.2,1);
}

@keyframes ticket-in {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

.ticket-header {
  background: var(--ink);
  color: #fff;
  padding: 26px 28px 22px;
  position: relative;
}

.ticket-eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--brass-light);
  margin-bottom: 10px;
}

.ticket-header h1 {
  font-size: 26px;
  line-height: 1.15;
  font-weight: 600;
}

.ticket-header p {
  margin: 10px 0 0;
  color: #C7CBD8;
  font-size: 14px;
  line-height: 1.5;
}

.ticket-stamp {
  position: absolute;
  top: 22px;
  right: 24px;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: 1.5px dashed var(--brass-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--brass-light);
  text-align: center;
  line-height: 1.2;
  transform: rotate(8deg);
}

.ticket-perforation {
  position: relative;
  height: 0;
  border-top: 2px dashed var(--border);
  margin: 0 0;
}
.ticket-perforation::before,
.ticket-perforation::after {
  content: '';
  position: absolute;
  top: -11px;
  width: 22px;
  height: 22px;
  background: var(--paper);
  border-radius: 50%;
}
.ticket-perforation::before { left: -11px; }
.ticket-perforation::after { right: -11px; }

.ticket-body {
  padding: 26px 28px 30px;
}

.field {
  margin-bottom: 18px;
}

.field label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--slate);
  margin-bottom: 7px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.field input,
.field select {
  width: 100%;
  padding: 13px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  transition: border-color 0.15s ease;
}

.field input:focus,
.field select:focus {
  border-color: var(--brass);
}

.ticket-footer-note {
  margin-top: 16px;
  font-size: 12.5px;
  color: var(--slate-light);
  text-align: center;
  line-height: 1.5;
}

.alert {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  margin-bottom: 18px;
}
.alert-error { background: var(--danger-bg); color: var(--danger); }
.alert-success { background: var(--success-bg); color: var(--success); }

.thanks-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
}
.thanks-card {
  max-width: 420px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 40px 32px;
}
.thanks-card h1 { font-size: 24px; margin-bottom: 12px; }
.thanks-card p { color: var(--slate); line-height: 1.6; }

/* ==========================================================================
   Login admin
   ========================================================================== */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ink);
  padding: 20px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 34px 30px;
  box-shadow: var(--shadow-lift);
}
.login-card .ticket-eyebrow { color: var(--brass); }
.login-card h1 { font-size: 22px; margin-bottom: 6px; }
.login-card p.sub { color: var(--slate); font-size: 14px; margin: 0 0 22px; }

/* ==========================================================================
   Admin shell
   ========================================================================== */

.admin-shell {
  display: grid;
  grid-template-columns: 232px 1fr;
  min-height: 100vh;
}

.admin-sidebar {
  background: var(--ink);
  color: #fff;
  padding: 26px 20px;
  display: flex;
  flex-direction: column;
}

.admin-brand {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 600;
  margin-bottom: 4px;
}
.admin-brand-sub {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--brass-light);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 30px;
}

.admin-nav { display: flex; flex-direction: column; gap: 4px; }
.admin-nav a {
  display: block;
  padding: 10px 12px;
  border-radius: 8px;
  color: #C7CBD8;
  text-decoration: none;
  font-size: 14.5px;
  font-weight: 500;
}
.admin-nav a:hover { background: rgba(255,255,255,0.06); color: #fff; }
.admin-nav a.active { background: var(--brass); color: #fff; }

.admin-sidebar form { margin-top: auto; }
.admin-sidebar .btn-ghost {
  color: #C7CBD8;
  border-color: rgba(255,255,255,0.18);
}
.admin-sidebar .btn-ghost:hover { border-color: #fff; color: #fff; }

.admin-content {
  padding: 34px 40px;
  max-width: 1100px;
}

.admin-content h2 {
  font-size: 24px;
  margin-bottom: 4px;
}
.admin-content .page-sub {
  color: var(--slate);
  font-size: 14.5px;
  margin: 0 0 28px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 32px;
}
.stat-card {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 20px 22px;
  box-shadow: var(--shadow-card);
}
.stat-card .num {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 600;
}
.stat-card .label {
  font-size: 12.5px;
  color: var(--slate);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 4px;
}

.card {
  background: var(--surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: 24px 26px;
  margin-bottom: 24px;
}
.card h3 { font-size: 17px; margin-bottom: 16px; }

.form-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: flex-end;
}
.form-row .field { flex: 1; min-width: 160px; margin-bottom: 0; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
th, td {
  text-align: left;
  padding: 12px 10px;
  border-bottom: 1px solid var(--border);
}
th {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--slate);
  font-weight: 600;
}
tr:last-child td { border-bottom: none; }

.code-pill {
  font-family: var(--font-mono);
  background: var(--paper);
  padding: 3px 9px;
  border-radius: 6px;
  font-size: 12.5px;
}

.status-pill {
  display: inline-block;
  padding: 4px 11px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 600;
}
.status-novo { background: var(--warning-bg); color: var(--warning); }
.status-contatado { background: #E4E9F5; color: #3A538C; }
.status-negociando { background: #EFE6F5; color: #6E3F8C; }
.status-fechado { background: var(--success-bg); color: var(--success); }
.status-perdido { background: var(--danger-bg); color: var(--danger); }

.status-select {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 12.5px;
  background: var(--surface);
}

.qr-cell img {
  width: 56px;
  height: 56px;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.link-copy {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--slate);
}

.badge-off {
  opacity: 0.5;
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--slate);
}

@media (max-width: 860px) {
  .admin-shell { grid-template-columns: 1fr; }
  .admin-sidebar { flex-direction: row; align-items: center; padding: 16px 18px; }
  .admin-brand, .admin-brand-sub { display: none; }
  .admin-nav { flex-direction: row; gap: 4px; }
  .admin-sidebar form { margin-top: 0; margin-left: auto; }
  .admin-content { padding: 22px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}
