@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --bg: #f9f9fb;
  --card-bg: #ffffff;
  --card-bg-soft: #f2f3f6;
  --text: #16181d;
  --muted: #6b7280;
  --border: #e6e7ec;

  --primary: #cf0a2c;
  --primary-dark: #93001f;
  --on-primary: #ffffff;
  --primary-tint: #fde8ea;
  --primary-tint-strong: #fbd2d7;

  --danger: #ba1a1a;
  --danger-tint: #fdecec;
  --success: #1a7f37;
  --success-tint: #e6f6ea;
  --warning: #935e00;
  --warning-tint: #fff4e5;
  --info: #0850c0;
  --info-tint: #e8f0fe;

  --radius: 0.75rem;
  --radius-sm: 0.5rem;
  --radius-pill: 999px;

  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

/* ---------- Cabeçalho ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.logo-mark {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  object-fit: cover;
  display: block;
  flex-shrink: 0;
}

.topbar .brand {
  font-weight: 700;
  font-size: 1.05rem;
  text-decoration: none;
  color: var(--primary);
  letter-spacing: -0.01em;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  width: 38px;
  height: 38px;
  padding: 0;
  margin-top: 0;
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: var(--primary);
  background: var(--primary-tint);
  flex-shrink: 0;
  cursor: pointer;
}

.icon-btn svg { flex-shrink: 0; }

.icon-btn.solid {
  background: var(--primary);
  color: #fff;
}

/* ---------- Layout ---------- */

.container {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 16px 100px;
}

.login-container {
  max-width: 380px;
  padding-top: 12vh;
  padding-bottom: 100px;
}

h1 { font-size: 1.5rem; font-weight: 700; margin: 0 0 4px; letter-spacing: -0.01em; }
h1:has(svg), h2:has(svg) { display: inline-flex; align-items: center; gap: 8px; }
h2 { font-size: 1.05rem; font-weight: 600; margin: 20px 0 10px; }

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.error { color: var(--danger); }
.success { color: var(--success); }

/* ---------- Hero (dashboard) ---------- */

.hero-card {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  border-radius: 1.25rem;
  padding: 22px;
  margin-bottom: 20px;
}

.hero-card h1 { color: #fff; }
.hero-card p { color: rgba(255,255,255,0.85); margin: 4px 0 16px; }

.hero-stats {
  display: flex;
  gap: 10px;
}

.stat-tile {
  flex: 1;
  background: rgba(255,255,255,0.16);
  border-radius: var(--radius);
  padding: 12px 14px;
}

.stat-tile .stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1.1; }
.stat-tile .stat-label { font-size: 0.75rem; color: rgba(255,255,255,0.85); margin-top: 2px; }

/* ---------- Cards ---------- */

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}

.upload-card {
  background: var(--card-bg-soft);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 24px 16px;
  text-align: center;
  margin-bottom: 20px;
}

.upload-card .upload-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--primary-tint);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px;
}

.upload-card label { cursor: pointer; }
.upload-card .upload-title,
.upload-card .muted {
  text-transform: none;
  letter-spacing: normal;
  font-weight: 400;
}
.upload-card .upload-title { font-weight: 700; font-size: 1.05rem; color: var(--text); }

.photos-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: -8px 0 16px;
}

.photo-chip {
  position: relative;
  width: 84px;
}

.photo-chip img {
  width: 84px;
  height: 84px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 2px solid var(--success);
  display: block;
}

.photo-chip span {
  display: block;
  text-align: center;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--success);
  margin-top: 3px;
}

.photo-chip-remove {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 22px;
  height: 22px;
  min-width: 0;
  padding: 0;
  margin: 0;
  border-radius: 50%;
  background: var(--danger);
  color: #fff;
  font-size: 0.9rem;
  line-height: 1;
  border: 2px solid #fff;
}
.photo-chip-remove:hover { background: var(--danger); opacity: 0.85; }

.spinner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.5);
  border-top-color: #fff;
  display: inline-block;
  animation: spin 0.7s linear infinite;
  vertical-align: -3px;
}

.card-photos {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

.card-photo-wrap {
  position: relative;
  flex: 1 1 240px;
  max-width: 320px;
}

.card-photo {
  width: 100%;
  max-width: 320px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  display: block;
}

.card-photo-label {
  position: absolute;
  left: 8px;
  bottom: 8px;
  background: rgba(0,0,0,0.6);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
}

/* ---------- Formulários ---------- */

label {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 14px;
}

.field-icon-wrap { position: relative; margin-top: 6px; }
.field-icon-wrap .field-icon {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
  display: flex;
}
.field-icon-wrap .field-toggle {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  padding: 4px;
  margin: 0;
  color: var(--muted);
  cursor: pointer;
  display: flex;
}
.field-icon-wrap .field-toggle:hover { background: none; }

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 16px;
}

@media (max-width: 520px) {
  .grid-2 { grid-template-columns: 1fr; }
}

input[type=text],
input[type=email],
input[type=password],
input[type=date],
input[type=file],
select,
textarea {
  width: 100%;
  margin-top: 6px;
  padding: 12px 14px;
  font-size: 0.95rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card-bg-soft);
  color: var(--text);
  font-family: inherit;
}

.field-icon-wrap input { padding-left: 46px; }

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-tint);
  background: #fff;
}

input[type=checkbox] { width: auto; margin-top: 0; display: inline-block; accent-color: var(--primary); }

textarea { resize: vertical; }

/* ---------- Botões ---------- */

button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 12px 22px;
  border-radius: var(--radius-pill);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  margin-top: 4px;
  font-family: inherit;
}

button:hover, .btn:hover { background: var(--primary-dark); }

.btn-block { width: 100%; }

.btn-secondary {
  background: var(--primary-tint);
  color: var(--primary);
}
.btn-secondary:hover { background: var(--primary-tint-strong); }

.btn-neutral {
  background: var(--card-bg-soft);
  color: var(--text);
}
.btn-neutral:hover { background: var(--border); }

.btn-danger {
  background: #fff;
  color: var(--danger);
  border: 1px solid var(--danger);
}
.btn-danger:hover { background: var(--danger-tint); }

button:disabled, .btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: var(--primary);
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

/* ---------- Listas / avatares / badges ---------- */

.list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-left: 4px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  text-decoration: none;
  color: var(--text);
}

.list-item.accent-primary { border-left-color: var(--primary); }
.list-item.accent-warning { border-left-color: #d69a00; }
.list-item.accent-success { border-left-color: var(--success); }

.list-item-body { flex: 1; min-width: 0; }
.list-item-title { font-weight: 700; }
.list-item-subtitle { color: var(--muted); font-size: 0.85rem; margin-top: 2px; }

.avatar-circle {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  color: #fff;
  flex-shrink: 0;
  background: var(--primary);
}

.badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 5px 11px;
  border-radius: var(--radius-pill);
  background: var(--card-bg-soft);
  color: var(--muted);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.badge-draft { background: var(--warning-tint); color: var(--warning); }
.badge-sent { background: var(--success-tint); color: var(--success); }
.badge-error { background: var(--danger-tint); color: var(--danger); }
.badge-verified { background: var(--info-tint); color: var(--info); }

.badge-processing {
  background: var(--info-tint);
  color: var(--info);
}

.badge-processing::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 2px solid var(--info);
  border-top-color: transparent;
  animation: spin 0.7s linear infinite;
}

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

.list-item.is-processing { opacity: 0.85; }

.ai-badge {
  background: var(--primary-tint);
  color: var(--primary);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
}

/* ---------- Secções de definições ---------- */

.section-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}

.section-card h2 {
  margin-top: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--primary);
}

/* ---------- Aviso de duplicado / erro ---------- */

.duplicate-warning, .banner-warning {
  border-color: var(--danger);
  background: var(--danger-tint);
}

.generated-password {
  display: inline-block;
  font-size: 1.2rem;
  font-weight: 700;
  padding: 8px 14px;
  background: var(--card-bg-soft);
  border-radius: var(--radius-sm);
  letter-spacing: 0.5px;
  user-select: all;
}

/* ---------- Navegação inferior (mobile-first) ---------- */

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--card-bg);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  z-index: 20;
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  text-decoration: none;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 600;
  padding: 4px 10px;
  flex: 1;
}

.bottom-nav-item.active { color: var(--primary); }

.fab {
  position: fixed;
  right: 20px;
  bottom: calc(76px + env(safe-area-inset-bottom));
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 16px rgba(207, 10, 44, 0.35);
  z-index: 15;
  text-decoration: none;
}
.fab:hover { background: var(--primary-dark); }

@media (min-width: 720px) {
  .container { padding-bottom: 40px; }
  .bottom-nav { display: none; }
  .fab { bottom: 24px; }
}

/* ---------- Verificado ---------- */

.verified-check {
  color: var(--success);
  display: inline-flex;
  vertical-align: -2px;
  margin-left: 4px;
}

/* ---------- Modal ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 17, 21, 0.55);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
  padding: 0;
}

.modal-box {
  background: var(--card-bg);
  width: 100%;
  max-width: 520px;
  max-height: 88vh;
  overflow-y: auto;
  border-radius: 1.25rem 1.25rem 0 0;
  padding: 20px;
}

@media (min-width: 640px) {
  .modal-overlay { align-items: center; }
  .modal-box { border-radius: var(--radius); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.bulk-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card-bg-soft);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 8px;
}

.bulk-item input[type=checkbox] {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.bulk-item .bulk-item-body { flex: 1; min-width: 0; }
.bulk-item .bulk-item-title { font-weight: 700; font-size: 0.92rem; }
.bulk-item .bulk-item-subtitle { color: var(--muted); font-size: 0.8rem; }

.bulk-result-icon { flex-shrink: 0; }
.bulk-result-icon.ok { color: var(--success); }
.bulk-result-icon.fail { color: var(--danger); }

.progress-track {
  background: var(--card-bg-soft);
  border-radius: var(--radius-pill);
  height: 10px;
  overflow: hidden;
  margin-bottom: 8px;
}

.progress-fill {
  background: var(--primary);
  height: 100%;
  width: 0%;
  transition: width 0.2s ease;
}
