/* ─── Reset e base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:           #0f1117;
  --bg-card:      #1a1d27;
  --bg-card-hover:#1f2335;
  --border:       #2a2d3e;
  --text:         #e2e8f0;
  --text-muted:   #8892a4;
  --text-faint:   #4a5568;

  --green:        #22c55e;
  --green-bg:     #052e16;
  --yellow:       #eab308;
  --yellow-bg:    #1c1a05;
  --gray:         #6b7280;
  --gray-bg:      #1a1d27;
  --blue:         #60a5fa;
  --blue-bg:      #0c1a2e;

  --radius:       12px;
  --radius-sm:    6px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─── Layout ───────────────────────────────────────────────────────────────── */
.container { max-width: 1200px; margin: 0 auto; padding: 0 20px; }

/* ─── Header ───────────────────────────────────────────────────────────────── */
.header {
  border-bottom: 1px solid var(--border);
  padding: 20px 0;
  margin-bottom: 32px;
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}
.header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
}
.last-update {
  font-size: 0.8rem;
  color: var(--text-muted);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 12px;
}

/* ─── Stats ────────────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
}
.stat-value {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 6px;
}
.stat-label { font-size: 0.8rem; color: var(--text-muted); }
.stat-card.green .stat-value { color: var(--green); }
.stat-card.yellow .stat-value { color: var(--yellow); }
.stat-card.blue .stat-value { color: var(--blue); }
.stat-card.gray .stat-value { color: var(--gray); }

/* ─── Filtros ──────────────────────────────────────────────────────────────── */
.filters {
  margin-bottom: 28px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.filter-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  min-width: 80px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.filter-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 100px;
  padding: 5px 14px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.15s;
}
.filter-btn:hover { border-color: var(--blue); color: var(--text); }
.filter-btn.active {
  background: var(--blue-bg);
  border-color: var(--blue);
  color: var(--blue);
  font-weight: 600;
}

/* ─── Grid de ads ──────────────────────────────────────────────────────────── */
.ads-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.ads-header h2 { font-size: 1rem; color: var(--text-muted); font-weight: 500; }
.ads-count { font-size: 0.8rem; color: var(--text-faint); }

#ads-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 20px;
}

/* ─── Card de anúncio ──────────────────────────────────────────────────────── */
.ad-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color 0.15s, transform 0.15s;
}
.ad-card:hover {
  border-color: #3a3d4e;
  transform: translateY(-2px);
}
.ad-card.badge-champion { border-left: 3px solid var(--green); }
.ad-card.badge-watching { border-left: 3px solid var(--yellow); }
.ad-card.badge-new      { border-left: 3px solid var(--gray); }

.ad-thumb {
  width: 100%;
  aspect-ratio: 16/9;
  overflow: hidden;
  background: #0d0f18;
}
.ad-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: opacity 0.2s;
}
.ad-thumb img:hover { opacity: 0.9; }

.thumb-iframe-wrap {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
}
.thumb-iframe-wrap iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
  pointer-events: none;
}
.thumb-overlay {
  position: absolute;
  bottom: 6px;
  right: 6px;
  background: rgba(0,0,0,0.6);
  color: #fff;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  text-decoration: none;
  opacity: 0;
  transition: opacity 0.2s;
}
.ad-card:hover .thumb-overlay { opacity: 1; }
.thumb-overlay:hover {
  background: rgba(96,165,250,0.8);
  text-decoration: none;
}

.thumb-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-faint);
  font-size: 0.8rem;
}

.ad-content {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}

.ad-header { display: flex; flex-direction: column; gap: 4px; }
.ad-badges { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

.badge-score {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 100px;
}
.badge-score.badge-champion { background: var(--green-bg); color: var(--green); border: 1px solid var(--green); }
.badge-score.badge-watching { background: var(--yellow-bg); color: var(--yellow); border: 1px solid var(--yellow); }
.badge-score.badge-new      { background: var(--gray-bg); color: var(--gray); border: 1px solid #374151; }

.badge-tag { font-size: 0.65rem; font-weight: 700; padding: 2px 8px; border-radius: 100px; text-transform: uppercase; letter-spacing: 0.05em; }
.badge-is-new { background: var(--blue-bg); color: var(--blue); border: 1px solid var(--blue); }

.ad-meta { font-size: 0.75rem; color: var(--text-muted); }

.ad-copy {
  font-size: 0.875rem;
  color: var(--text);
  line-height: 1.5;
}

.ad-footer { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 6px; }
.ad-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.tag {
  font-size: 0.7rem;
  background: #1e2130;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 2px 8px;
  border-radius: 4px;
}

.suggestion-block {
  background: #0c1f0c;
  border: 1px solid #1a4a1a;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.hook-label { font-size: 0.75rem; font-weight: 600; color: var(--green); }
.suggestion-text { font-size: 0.8rem; color: #a7f3a7; line-height: 1.4; }

.btn-detail {
  display: block;
  text-align: center;
  background: #1e2130;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  padding: 8px;
  font-size: 0.8rem;
  margin-top: auto;
  transition: all 0.15s;
}
.btn-detail:hover {
  background: var(--blue-bg);
  border-color: var(--blue);
  color: var(--blue);
  text-decoration: none;
}

/* ─── Empty state ──────────────────────────────────────────────────────────── */
#empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
  display: none;
}
#empty-state p { margin-top: 8px; font-size: 0.875rem; }

/* ─── Loading / Error ──────────────────────────────────────────────────────── */
#loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px;
  color: var(--text-muted);
  font-size: 0.875rem;
  gap: 10px;
}
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

#error-banner {
  display: none;
  background: #2a0a0a;
  border: 1px solid #7f1d1d;
  color: #fca5a5;
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 20px;
  font-size: 0.875rem;
}

/* ─── Detail page ──────────────────────────────────────────────────────────── */
.detail-back { display: inline-flex; align-items: center; gap: 6px; color: var(--text-muted); font-size: 0.875rem; margin-bottom: 20px; }
.detail-back:hover { color: var(--text); text-decoration: none; }

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
  align-items: start;
}
@media (max-width: 768px) {
  .detail-grid { grid-template-columns: 1fr; }
  #ads-grid { grid-template-columns: 1fr; }
}

.detail-preview img {
  width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.snapshot-container {
  width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  background: #0d0f18;
}
.snapshot-container iframe {
  width: 100%;
  height: 500px;
  border: none;
  display: block;
}
.snapshot-fallback {
  display: block;
  padding: 10px 16px;
  font-size: 0.8rem;
  color: var(--blue);
  border-top: 1px solid var(--border);
  text-align: center;
}

.detail-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}
.detail-section h3 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); margin-bottom: 12px; }
.detail-copy { font-size: 0.9rem; line-height: 1.6; color: var(--text); white-space: pre-wrap; }

.score-breakdown { display: flex; flex-direction: column; gap: 10px; }
.score-row { display: flex; justify-content: space-between; align-items: center; }
.score-row-label { font-size: 0.85rem; color: var(--text-muted); }
.score-row-pts { font-size: 0.85rem; font-weight: 700; color: var(--text); }
.score-total { border-top: 1px solid var(--border); padding-top: 10px; font-size: 1rem; font-weight: 700; }

.timeline { display: flex; flex-direction: column; gap: 6px; }
.timeline-item { display: flex; gap: 10px; align-items: center; font-size: 0.8rem; }
.timeline-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--blue); flex-shrink: 0; }
.timeline-label { color: var(--text-muted); }
.timeline-value { color: var(--text); }
