@import url("https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600&display=swap");

:root {
  color-scheme: dark;
  --bg: #0b0f14;
  --surface: #111826;
  --surface-2: #151e30;
  --border: rgba(255, 255, 255, 0.08);
  --text: #f4f6fb;
  --muted: #a7b0c3;
  --accent: #50d2ff;
  --accent-2: #9bff85;
  --danger: #ff7a7a;
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
}

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

body {
  margin: 0;
  background: radial-gradient(1200px 900px at 10% 10%, #1c2740 0%, transparent 70%),
    radial-gradient(1200px 900px at 90% 0%, #132035 0%, transparent 60%), var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.bg-glow {
  position: fixed;
  inset: 0;
  background: radial-gradient(600px 600px at 50% 30%, rgba(80, 210, 255, 0.15), transparent 70%);
  pointer-events: none;
  z-index: -1;
}

header.hero {
  padding: 48px 5vw 32px;
  display: grid;
  gap: 32px;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  align-items: center;
}

.hero__content h1 {
  font-size: clamp(2rem, 4vw, 3.2rem);
  margin: 0 0 12px;
}

.subtitle {
  margin: 0;
  color: var(--muted);
  max-width: 48ch;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 0.7rem;
  color: var(--accent);
  margin-bottom: 12px;
}

.meta {
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  color: var(--muted);
  font-size: 0.9rem;
}

.dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--accent-2);
  align-self: center;
}

.hero__panel {
  background: linear-gradient(145deg, rgba(17, 24, 38, 0.85), rgba(21, 30, 48, 0.95));
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 24px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 16px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25);
}

.kpi {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.kpi__label {
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.kpi__value {
  font-size: 1.3rem;
  font-weight: 600;
}

main {
  padding: 0 5vw 64px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 24px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card__header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.card__header h2 {
  margin: 0 0 8px;
  font-size: 1.3rem;
}

.card__header p {
  margin: 0;
  color: var(--muted);
}

.insights {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.insight {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
}

.insight h3 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.insight p {
  margin: 0;
  color: var(--muted);
}

.segmented {
  display: inline-flex;
  background: var(--surface-2);
  border-radius: 999px;
  padding: 4px;
  border: 1px solid var(--border);
}

.segmented__button {
  background: none;
  border: none;
  color: var(--muted);
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.9rem;
}

.segmented__button.is-active {
  background: linear-gradient(135deg, rgba(80, 210, 255, 0.2), rgba(155, 255, 133, 0.15));
  color: var(--text);
}

.chart {
  background: var(--surface-2);
  border-radius: 16px;
  padding: 12px;
  border: 1px solid var(--border);
}

.bar-list {
  display: none;
  flex-direction: column;
  gap: 12px;
}

.bar-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
}

.bar-item__label {
  font-size: 0.9rem;
  color: var(--text);
}

.bar-item__value {
  font-weight: 600;
  color: var(--accent);
  font-size: 0.95rem;
  text-align: right;
}

.bar-track {
  margin-top: 8px;
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 220ms ease;
}

.chart-tooltip {
  position: fixed;
  z-index: 20;
  background: rgba(12, 16, 24, 0.95);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 1rem;
  color: var(--text);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  opacity: 0;
  transition: opacity 120ms ease;
  min-width: 180px;
}

.chart-tooltip__title {
  font-weight: 600;
  margin-bottom: 6px;
}

.chart-tooltip__metric {
  color: var(--accent);
  font-weight: 600;
}

@media (max-width: 720px) {
  #daily-chart {
    height: 200px;
  }
}

canvas {
  width: 100%;
  height: auto;
}

#daily-chart {
  height: 260px;
}

.select-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--muted);
}

select,
input[type="search"] {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 0.95rem;
  min-width: 180px;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.toggle {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 0.85rem;
}

.table-wrap {
  max-height: 360px;
  overflow: auto;
  border-radius: 16px;
  border: 1px solid var(--border);
}

.keywords-list {
  display: none;
  flex-direction: column;
  gap: 12px;
}

.keyword-card {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.02);
  display: grid;
  gap: 10px;
}

.keyword-card__title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.keyword-card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.keyword-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 12px;
  font-size: 0.85rem;
  color: var(--muted);
}

.keyword-metrics strong {
  color: var(--text);
  font-weight: 600;
  display: block;
  margin-top: 2px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

thead {
  background: rgba(255, 255, 255, 0.04);
  position: sticky;
  top: 0;
  z-index: 1;
}

th,
td {
  padding: 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  cursor: pointer;
  color: var(--muted);
  font-weight: 500;
}

tbody tr:hover {
  background: rgba(80, 210, 255, 0.06);
}

.status-pill {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  border: 1px solid var(--border);
  display: inline-block;
}

.status-pill.qualificado {
  color: var(--accent-2);
  border-color: rgba(155, 255, 133, 0.4);
}

.status-pill.nao-qualificado {
  color: var(--danger);
  border-color: rgba(255, 122, 122, 0.4);
}

footer {
  padding: 0 5vw 40px;
  color: var(--muted);
  font-size: 0.85rem;
}

@media (max-width: 720px) {
  html,
  body {
    overflow-x: hidden;
  }

  body {
    overflow-x: hidden;
  }

  .hero__panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .card__header {
    flex-direction: column;
    align-items: flex-start;
  }

  #daily-chart {
    height: 220px;
  }

  #bar-chart {
    display: none;
  }

  .bar-list {
    display: flex;
  }

  .card {
    overflow: visible;
  }

  .table-wrap {
    overflow-x: auto;
    touch-action: pan-x pan-y;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
  }

  #keywords-table {
    display: none;
  }

  .keywords-list {
    display: flex;
  }

  #keywords-table,
  #campaigns-table,
  #adgroups-table {
    table-layout: auto;
    width: max-content;
    min-width: 100%;
  }

  #keywords-table th,
  #keywords-table td,
  #campaigns-table th,
  #campaigns-table td,
  #adgroups-table th,
  #adgroups-table td {
    word-break: normal;
    white-space: nowrap;
  }

  #keywords-table td:first-child,
  #keywords-table th:first-child {
    white-space: normal;
    min-width: 160px;
  }

  #campaigns-table td:first-child,
  #campaigns-table th:first-child,
  #adgroups-table td:first-child,
  #adgroups-table th:first-child {
    white-space: normal;
    min-width: 200px;
  }
}
