/* ============================================================
   Spotties Car - CSS Principal (Mobile-First)
   ============================================================ */

:root {
  --primary:      #111827;
  --accent:       #16a34a;
  --accent-light: #22c55e;
  --bg:           #f9fafb;
  --surface:      #ffffff;
  --border:       #e5e7eb;
  --text:         #111827;
  --text-muted:   #6b7280;
  --danger:       #ef4444;
  --warning:      #f59e0b;
  --radius:       12px;
  --shadow:       0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:    0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
  --nav-height:   64px;
  --topbar-height:56px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding-bottom: calc(var(--nav-height) + 8px);
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button { cursor: pointer; border: none; background: none; font: inherit; }
input, textarea, select { font: inherit; }

/* ---- Topbar ---- */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--topbar-height);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px;
  box-shadow: var(--shadow);
}
.topbar-logo { font-size: 1.25rem; font-weight: 800; letter-spacing: -.5px; }
.topbar-logo span { color: var(--accent); }
.topbar-actions { display: flex; gap: 8px; }
.topbar-btn {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); transition: background .15s;
}
.topbar-btn:hover { background: var(--bg); color: var(--text); }

/* ---- Bottom Nav ---- */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  height: var(--nav-height);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex; align-items: center;
  box-shadow: 0 -1px 3px rgba(0,0,0,.07);
}
.nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 3px; padding: 8px 4px;
  color: var(--text-muted); font-size: .65rem; font-weight: 500;
  transition: color .15s;
}
.nav-item.active { color: var(--accent); }
.nav-item svg { width: 22px; height: 22px; }
.nav-item-publish {
  flex: 1; display: flex; align-items: center; justify-content: center;
}
.nav-publish-btn {
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 12px rgba(22,163,74,.4);
  transition: transform .15s, box-shadow .15s;
}
.nav-publish-btn:hover { transform: scale(1.05); box-shadow: 0 6px 16px rgba(22,163,74,.5); }

/* ---- Page container ---- */
.page {
  display: none;
  padding-top: calc(var(--topbar-height) + 8px);
  min-height: 100vh;
}
.page.active { display: block; }
.container { max-width: 480px; margin: 0 auto; padding: 0 12px; }

/* ---- Cards ---- */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 12px;
}

/* ---- Post Card ---- */
.post-card { }
.post-header {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px 8px;
}
.avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--border); overflow: hidden; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .9rem; color: var(--text-muted);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.post-user-info { flex: 1; min-width: 0; }
.post-username { font-weight: 700; font-size: .9rem; }
.post-meta { font-size: .75rem; color: var(--text-muted); }
.post-image-wrap { position: relative; background: #000; aspect-ratio: 4/3; overflow: hidden; cursor: pointer; }

/* Coração de duplo clique */
.dbl-heart {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%) scale(0);
  font-size: 5rem; pointer-events: none; opacity: 0;
  z-index: 10; filter: drop-shadow(0 2px 8px rgba(0,0,0,.4));
}
.dbl-heart.animate { animation: heartPop .8s ease forwards; }
@keyframes heartPop {
  0%   { transform: translate(-50%,-50%) scale(0);   opacity: 1; }
  40%  { transform: translate(-50%,-50%) scale(1.3); opacity: 1; }
  70%  { transform: translate(-50%,-50%) scale(1.1); opacity: 1; }
  100% { transform: translate(-50%,-50%) scale(1.4); opacity: 0; }
}
.post-image-wrap img { width: 100%; height: 100%; object-fit: cover; }
.post-image-placeholder {
  width: 100%; height: 100%; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 8px;
  background: linear-gradient(135deg, #1f2937, #374151);
  color: #9ca3af; font-size: .85rem;
}
.rarity-badge {
  position: absolute; top: 10px; right: 10px;
  padding: 3px 10px; border-radius: 20px;
  font-size: .7rem; font-weight: 700; color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,.3);
}
.points-badge {
  position: absolute; bottom: 10px; right: 10px;
  background: rgba(0,0,0,.6); color: #fff;
  padding: 3px 8px; border-radius: 20px;
  font-size: .75rem; font-weight: 700;
}
.post-actions {
  display: flex; align-items: center; gap: 4px;
  padding: 8px 10px 4px;
}
.action-btn {
  display: flex; align-items: center; gap: 5px;
  padding: 6px 10px; border-radius: 8px;
  font-size: .82rem; font-weight: 500; color: var(--text-muted);
  transition: background .15s, color .15s;
}
.action-btn:hover { background: var(--bg); color: var(--text); }
.action-btn.liked { color: var(--danger); }
.action-btn svg { width: 18px; height: 18px; }
.post-caption { padding: 4px 14px 12px; font-size: .88rem; line-height: 1.5; }
.post-caption strong { font-weight: 700; }
.post-car-info {
  margin: 0 14px 12px;
  background: var(--bg); border-radius: 8px;
  padding: 8px 12px;
  display: flex; align-items: center; gap: 8px;
}
.post-car-info svg { width: 16px; height: 16px; color: var(--text-muted); flex-shrink: 0; }
.car-name { font-size: .82rem; font-weight: 600; }
.car-year { font-size: .75rem; color: var(--text-muted); }

/* ---- Badge ---- */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 20px;
  font-size: .7rem; font-weight: 700; color: #fff;
}
.badge-green  { background: var(--accent); }
.badge-gray   { background: var(--text-muted); }
.badge-yellow { background: var(--warning); }
.badge-red    { background: var(--danger); }
.badge-purple { background: #8b5cf6; }
.badge-pink   { background: #ec4899; }

/* ---- Ranking ---- */
.ranking-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  transition: background .15s;
}
.ranking-item:last-child { border-bottom: none; }
.ranking-item:hover { background: var(--bg); }
.rank-pos {
  width: 32px; text-align: center;
  font-weight: 800; font-size: 1rem; color: var(--text-muted);
  flex-shrink: 0;
}
.rank-pos.gold   { color: #f59e0b; }
.rank-pos.silver { color: #9ca3af; }
.rank-pos.bronze { color: #b45309; }
.rank-info { flex: 1; min-width: 0; }
.rank-name { font-weight: 700; font-size: .9rem; }
.rank-sub  { font-size: .75rem; color: var(--text-muted); }
.rank-points { font-weight: 800; font-size: .95rem; color: var(--accent); }

/* ---- Profile ---- */
.profile-header {
  background: var(--surface);
  padding: 20px 16px 16px;
  text-align: center;
  border-bottom: 1px solid var(--border);
}
.profile-avatar {
  width: 80px; height: 80px; border-radius: 50%;
  margin: 0 auto 12px;
  background: var(--border); overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem; font-weight: 800; color: var(--text-muted);
}
.profile-name { font-size: 1.2rem; font-weight: 800; }
.profile-username { font-size: .85rem; color: var(--text-muted); margin-bottom: 6px; }
.profile-bio { font-size: .85rem; color: var(--text-muted); margin-bottom: 14px; line-height: 1.5; }
.profile-stats { display: flex; justify-content: center; gap: 24px; margin-bottom: 14px; }
.stat-item { text-align: center; }
.stat-value { font-size: 1.1rem; font-weight: 800; }
.stat-label { font-size: .7rem; color: var(--text-muted); }
.profile-actions { display: flex; gap: 8px; justify-content: center; }
.btn {
  padding: 8px 20px; border-radius: 8px;
  font-size: .85rem; font-weight: 600;
  transition: all .15s;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #15803d; }
.btn-outline {
  background: transparent; color: var(--text);
  border: 1.5px solid var(--border);
}
.btn-outline:hover { background: var(--bg); }
.btn-danger { background: var(--danger); color: #fff; }

/* ---- Level Progress ---- */
.level-card {
  background: var(--surface); border-radius: var(--radius);
  padding: 16px; margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.level-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.level-title { font-size: 1rem; font-weight: 700; }
.level-badge { font-size: .8rem; font-weight: 600; padding: 3px 10px; border-radius: 20px; background: var(--accent); color: #fff; }
.progress-bar { height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; margin-bottom: 6px; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-light)); border-radius: 4px; transition: width .5s ease; }
.progress-labels { display: flex; justify-content: space-between; font-size: .72rem; color: var(--text-muted); }

/* ---- Achievements ---- */
.achievements-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 12px; }
.achievement-item {
  background: var(--bg); border-radius: 10px; padding: 12px 8px;
  text-align: center; border: 1.5px solid var(--border);
  transition: border-color .15s;
}
.achievement-item.unlocked { border-color: var(--accent); background: #f0fdf4; }
.achievement-icon { font-size: 1.6rem; margin-bottom: 4px; }
.achievement-name { font-size: .7rem; font-weight: 700; line-height: 1.3; }
.achievement-desc { font-size: .62rem; color: var(--text-muted); margin-top: 2px; }

/* ---- Post grid ---- */
.posts-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; }
.grid-post { aspect-ratio: 1; background: var(--border); overflow: hidden; position: relative; cursor: pointer; }
.grid-post img { width: 100%; height: 100%; object-fit: cover; transition: transform .2s; }
.grid-post:hover img { transform: scale(1.05); }
.grid-post-overlay {
  position: absolute; inset: 0; background: rgba(0,0,0,.4);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity .2s;
  color: #fff; font-size: .75rem; font-weight: 700; gap: 6px;
}
.grid-post:hover .grid-post-overlay { opacity: 1; }

/* ---- Forms ---- */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: 6px; }
.form-input {
  width: 100%; padding: 10px 14px;
  border: 1.5px solid var(--border); border-radius: 8px;
  font-size: .9rem; transition: border-color .15s;
  background: var(--surface);
}
.form-input:focus { outline: none; border-color: var(--accent); }
.form-textarea { resize: vertical; min-height: 80px; }
.form-select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }

/* ---- Auth pages ---- */
.auth-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 20px; background: var(--bg);
}
.auth-card { width: 100%; max-width: 380px; }
.auth-logo { text-align: center; margin-bottom: 28px; }
.auth-logo h1 { font-size: 2rem; font-weight: 900; }
.auth-logo h1 span { color: var(--accent); }
.auth-logo p { color: var(--text-muted); font-size: .9rem; margin-top: 4px; }
.auth-form { background: var(--surface); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow-md); }
.auth-title { font-size: 1.2rem; font-weight: 800; margin-bottom: 20px; }
.auth-footer { text-align: center; margin-top: 16px; font-size: .85rem; color: var(--text-muted); }
.auth-footer a { color: var(--accent); font-weight: 600; }

/* ---- Upload area ---- */
.upload-area {
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 32px 16px; text-align: center; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.upload-area:hover, .upload-area.dragover { border-color: var(--accent); background: #f0fdf4; }
.upload-area svg { width: 40px; height: 40px; color: var(--text-muted); margin: 0 auto 8px; }
.upload-preview { position: relative; border-radius: var(--radius); overflow: hidden; }
.upload-preview img { width: 100%; aspect-ratio: 4/3; object-fit: cover; }
.upload-remove {
  position: absolute; top: 8px; right: 8px;
  background: rgba(0,0,0,.6); color: #fff;
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}

/* ---- Toast notifications ---- */
#toast-container { position: fixed; top: 70px; right: 12px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--text); color: #fff;
  padding: 10px 16px; border-radius: 8px;
  font-size: .85rem; font-weight: 500;
  box-shadow: var(--shadow-md);
  animation: slideIn .3s ease;
  max-width: 280px;
}
.toast.success { background: var(--accent); }
.toast.error   { background: var(--danger); }
@keyframes slideIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }

/* ---- Loading ---- */
.spinner {
  width: 24px; height: 24px; border: 3px solid var(--border);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin .7s linear infinite; margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-overlay {
  display: flex; align-items: center; justify-content: center;
  padding: 40px; color: var(--text-muted); flex-direction: column; gap: 12px;
}

/* ---- Tabs ---- */
.tabs { display: flex; border-bottom: 1px solid var(--border); background: var(--surface); }
.tab-btn {
  flex: 1; padding: 12px 8px; font-size: .85rem; font-weight: 600;
  color: var(--text-muted); border-bottom: 2px solid transparent;
  transition: color .15s, border-color .15s;
}
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ---- Search ---- */
.search-bar {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg); border: 1.5px solid var(--border);
  border-radius: 10px; padding: 8px 12px; margin: 12px;
}
.search-bar svg { width: 18px; height: 18px; color: var(--text-muted); flex-shrink: 0; }
.search-bar input { flex: 1; border: none; background: none; font-size: .9rem; }
.search-bar input:focus { outline: none; }

/* ---- Comments modal ---- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,.5); display: flex; align-items: flex-end;
}
.modal-sheet {
  background: var(--surface); border-radius: 16px 16px 0 0;
  width: 100%; max-height: 80vh; display: flex; flex-direction: column;
  animation: slideUp .3s ease;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
}
.modal-title { font-weight: 700; }
.modal-close { color: var(--text-muted); }
.modal-body { flex: 1; overflow-y: auto; padding: 12px 16px; }
.modal-footer { padding: 12px 16px; border-top: 1px solid var(--border); display: flex; gap: 8px; }
.comment-item { display: flex; gap: 10px; margin-bottom: 14px; }
.comment-body { flex: 1; }
.comment-user { font-weight: 700; font-size: .85rem; }
.comment-text { font-size: .85rem; margin-top: 2px; }
.comment-time { font-size: .72rem; color: var(--text-muted); margin-top: 2px; }

/* ---- Rarity colors ---- */
.rarity-Comum    { background: #9ca3af; }
.rarity-Normal   { background: #3b82f6; }
.rarity-Especial { background: #8b5cf6; }
.rarity-Raro     { background: #f59e0b; }
.rarity-Lendario { background: #ef4444; }
.rarity-Mitico   { background: #ec4899; }

/* ---- Utilities ---- */
.text-center { text-align: center; }
.text-muted  { color: var(--text-muted); }
.mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-8  { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.p-12  { padding: 12px; }
.p-16  { padding: 16px; }
.flex  { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-8 { gap: 8px; }
.font-bold { font-weight: 700; }
.hidden { display: none !important; }
.w-full { width: 100%; }

/* ---- Responsive (tablet+) ---- */
@media (min-width: 600px) {
  .container { padding: 0 20px; }
  .achievements-grid { grid-template-columns: repeat(4, 1fr); }
}

/* ---- Explore Grid ---- */
#explore-posts {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px;
  padding: 8px;
}
.explore-item {
  aspect-ratio: 1;
  background: var(--border);
  overflow: hidden;
  position: relative;
  cursor: pointer;
  border-radius: 6px;
}
.explore-item img {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform .2s;
}
.explore-item:hover img { transform: scale(1.05); }
.explore-overlay {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: linear-gradient(transparent, rgba(0,0,0,.7));
  padding: 20px 8px 8px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

/* ---- Location link in post ---- */
.post-location {
  display: flex; align-items: center; gap: 4px;
  font-size: .78rem; color: var(--text-muted);
  padding: 0 12px 8px;
}
.post-location svg { width: 13px; height: 13px; flex-shrink: 0; }
.location-link {
  background: none; border: none; padding: 0;
  color: var(--accent); font-size: .78rem;
  cursor: pointer; text-align: left;
  text-decoration: underline;
}
/* ---- Repost ----*/
.action-btn.reposted {
  color: #10b981;
}
.action-btn.reposted svg {
  stroke: #10b981;
}
/* ---- Botão Seguir no Feed ---- */
.feed-follow-btn {
  margin-left: auto;
  padding: 1px 7px;
  border-radius: 20px;
  font-size: .62rem;
  font-weight: 700;
  border: 1.5px solid transparent;
  cursor: pointer;
  background: #10b981;
  color: #fff;
  white-space: nowrap;
  transition: background .2s, color .2s, border-color .2s;
}
.feed-follow-btn.following {
  background: #ffffff;
  color: #111827;
  border-color: #d1d5db;
}
/* ---- Menu de Configurações ---- */
.settings-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 12px;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: .95rem;
  font-weight: 500;
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  transition: background .15s;
}
.settings-item:hover, .settings-item:active {
  background: var(--surface2);
}
.settings-item-danger {
  color: #ef4444;
}
/* ---- Modal de Níveis ---- */
.level-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface2 );
}
.level-row-icon {
  font-size: 1.5rem;
  width: 36px;
  text-align: center;
}
.level-row-name {
  font-weight: 700;
  font-size: .95rem;
}
.level-row-pts {
  font-size: .78rem;
  color: var(--text-muted);
  margin-top: 2px;
}
/* ---- Modal de Seguidores ---- */
.follower-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  cursor: pointer;
  transition: background .15s;
}
.follower-item:hover, .follower-item:active {
  background: var(--surface2);
}
/* ---- Botão de opções no grid do perfil ---- */
.grid-post-options {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(0,0,0,.55);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
}
/* ---- Chat ---- */
.chat-bubble {
  max-width: 75%;
  padding: 8px 12px;
  border-radius: 18px;
  font-size: 1.2rem;
  line-height: 1.4;
  word-break: break-word;
}
.chat-bubble.mine {
  background: #10b981;
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}
.chat-bubble.theirs {
  background: var(--surface2);
  color: var(--text);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}
.emoji-btn {
  background: var(--surface2);
  border: none;
  border-radius: 10px;
  font-size: 1.3rem;
  padding: 6px 10px;
  cursor: pointer;
  transition: transform .1s;
}
.emoji-btn:active {
  transform: scale(.9);
}
