/* ============================================================
   VL Agronegócios — Página Tabelas de Pesquisa
   Paleta: variáveis do :root em treinamentos/base.css
   ============================================================ */

/* ---------- Hero customizada para a página ---------- */
.hero-pesquisa {
  min-height: 60vh;
  background:
    linear-gradient(180deg, rgba(26, 60, 42, 0.55) 0%, rgba(26, 60, 42, 0.82) 100%),
    url('/assets/imgs/foto-servico-treinamento.jpg') center/cover no-repeat;
  padding: 120px 24px 80px;
}

.hero-pesquisa .hero-inner {
  max-width: 880px;
}

/* ---------- Section page-head (reutilizável) ---------- */
.section-pesquisa {
  padding: 90px 0;
  background: var(--cream-50);
}

.section-pesquisa.section-ia {
  background: var(--cream-100);
}

.section-pesquisa .page-head {
  max-width: 900px;
  margin: 0 auto 48px;
  text-align: center;
}

.section-pesquisa .page-head .kicker {
  display: inline-block;
  padding: 6px 14px;
  border-radius: var(--r-pill);
  background: var(--green-100);
  color: var(--green-800);
  font-weight: 600;
  font-size: .78rem;
  letter-spacing: .02em;
  margin-bottom: 14px;
}

.section-pesquisa .page-head h2 {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: clamp(1.7rem, 2.4vw, 2.3rem);
  color: var(--green-900);
  hyphens: none;
  margin-bottom: 16px;
  line-height: 1.15;
}

.section-pesquisa .page-head p {
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--text-soft);
  line-height: 1.75;
  text-align: justify;
  text-justify: inter-word;
}

/* ---------- Wrapper das tabelas ---------- */
.tabela-wrapper {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--r-lg);
  background: var(--white);
  box-shadow: var(--shadow-md);
  position: relative;
}

.tabela-wrapper::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 36px;
  pointer-events: none;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, .75) 100%);
  border-radius: 0 var(--r-lg) var(--r-lg) 0;
}

/* ---------- Base das tabelas ---------- */
.tabela-pesquisa {
  width: 100%;
  min-width: 900px;
  border-collapse: separate;
  border-spacing: 0;
  font-family: var(--font-body);
  color: var(--text);
  font-size: .95rem;
  line-height: 1.6;
}

.tabela-pesquisa thead th {
  background: var(--green-700);
  color: #ffffff;
  font-family: var(--font-head);
  font-weight: 600;
  padding: 14px 16px;
  text-align: left;
  font-size: .9rem;
  letter-spacing: .01em;
  position: sticky;
  top: 0;
  z-index: 2;
  hyphens: none;
}

.tabela-pesquisa thead th:first-child {
  border-top-left-radius: var(--r-md);
}

.tabela-pesquisa thead th:last-child {
  border-top-right-radius: var(--r-md);
}

.tabela-pesquisa tbody th[scope="row"] {
  text-align: left;
  font-weight: 700;
  color: var(--green-800);
  font-family: var(--font-head);
  padding: 14px 16px;
  background: var(--green-50);
  border-top: 1px solid var(--border);
  white-space: nowrap;
}

.tabela-pesquisa tbody td {
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  vertical-align: top;
  text-align: left;
}

.tabela-pesquisa tbody td p {
  text-align: justify;
  text-justify: inter-word;
}

/* Linhas agrupadas (grupo de princípios) */
.tabela-principios .grupo-row td {
  padding: 0;
  border: none;
  padding: 3px;
}

.tabela-principios .grupo-nome {
  display: block !important;
  background: var(--gold);
  color: #ffffff;
  padding: 10px 16px;
  font-family: var(--font-head);
  font-weight: 700;
  margin: 18px 0 0 !important;
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1rem;
}

.tabela-principios tbody tr:not(.grupo-row):hover td,
.tabela-principios tbody tr:not(.grupo-row):hover th[scope="row"] {
  background: var(--green-50);
  transition: background var(--t);
}

.tabela-pesquisa tbody tr:nth-child(even) td,
.tabela-pesquisa tbody tr:nth-child(even) th[scope="row"] {
  padding: 3px;
}

.tabela-pesquisa tbody tr:nth-child(even):hover td,
.tabela-pesquisa tbody tr:nth-child(even):hover th[scope="row"] {
  background: var(--green-50);
}

/* Última linha arredondada */
.tabela-pesquisa tbody tr:last-child td:first-child,
.tabela-pesquisa tbody tr:last-child th[scope="row"] {
  border-bottom-left-radius: var(--r-md);
}

.tabela-pesquisa tbody tr:last-child td:last-child {
  border-bottom-right-radius: var(--r-md);
}

/* ---------- Grid de 4 tabelas de IA ---------- */
.tabelas-ia-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.tabela-ia-card {
  background: var(--white);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform var(--t), box-shadow var(--t);
}

.tabela-ia-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.tabela-ia-head {
  background: linear-gradient(135deg, var(--green-700) 0%, var(--green-800) 100%);
  color: #fff;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.tabela-ia-head i {
  color: var(--gold);
  font-size: 1.2rem;
  flex-shrink: 0;
}

.tabela-ia-head h3 {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 1rem;
  line-height: 1.35;
  hyphens: none;
  margin: 0;
  color: #ffffff;
}

.tabela-ia-card .tabela-wrapper {
  box-shadow: none;
  border-radius: 0;
}

.tabela-ia {
  min-width: 820px;
  font-size: .88rem;
}

.tabela-ia thead th {
  padding: 10px 14px;
  background: var(--green-600);
  border-radius: 0 !important;
  font-size: .82rem;
}

.tabela-ia tbody th[scope="row"] {
  padding: 12px 14px;
  font-size: .86rem;
}

.tabela-ia tbody td {
  padding: 12px 14px;
  font-size: .86rem;
}

.tabela-ia tbody tr:last-child td,
.tabela-ia tbody tr:last-child th[scope="row"] {
  border-radius: 0 !important;
}

/* ============================================================
   RESPONSIVIDADE
   ============================================================ */

/* ---------- Tablet (768–1023px) ---------- */
@media (max-width: 1023px) {
  .section-pesquisa {
    padding: 72px 0;
  }

  .tabelas-ia-grid {
    grid-template-columns: 1fr;
    gap: 20px;
  }
}

/* ---------- Mobile (< 768px) ---------- */
@media (max-width: 767px) {
  .hero-pesquisa {
    min-height: auto;
    padding: 110px 20px 60px;
  }

  .section-pesquisa {
    padding: 56px 0;
  }

  .section-pesquisa .page-head {
    margin-bottom: 32px;
    padding: 0 8px;
  }

  .section-pesquisa .page-head h2 {
    font-size: 1.55rem;
  }

  .tabela-ia-head {
    padding: 14px 16px;
  }

  .tabela-ia-head h3 {
    font-size: .95rem;
  }
}

/* ---------- Mobile pequeno (< 640px): Tabelas empilhadas em cards ---------- */
@media (max-width: 640px) {
  /* Conjunto A — Princípios (grande) */
  .tabela-principios,
  .tabela-principios thead,
  .tabela-principios tbody,
  .tabela-principios tr,
  .tabela-principios td,
  .tabela-principios th[scope="row"] {
    display: block;
    width: 100%;
    min-width: auto !important;
  }

  .tabela-principios thead {
    display: none;
  }

  .tabela-principios tbody tr.grupo-row {
    display: block;
    margin: 20px 12px 0;
  }

  .tabela-principios .grupo-nome {
    margin: 0 !important;
  }

  .tabela-principios tbody tr:not(.grupo-row) {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    margin: 12px;
    padding: 4px 0;
    box-shadow: var(--shadow-sm);
  }

  .tabela-principios tbody tr:not(.grupo-row):hover {
    background: var(--white);
  }

  .tabela-principios tbody th[scope="row"],
  .tabela-principios tbody td {
    width: 100% !important;
    display: block;
    padding: 10px 14px;
    background: var(--white) !important;
    border: none;
    border-bottom: 1px dashed var(--cream-300);
    text-align: left !important;
    font-size: .92rem;
    line-height: 1.6;
  }

  .tabela-principios tbody tr:not(.grupo-row) td:last-child,
  .tabela-principios tbody tr:not(.grupo-row) th[scope="row"]:last-child {
    border-bottom: none;
  }

  .tabela-principios tbody th[scope="row"]::before,
  .tabela-principios tbody td::before {
    display: block;
    font-weight: 700;
    color: var(--green-800);
    font-family: var(--font-head);
    font-size: .78rem;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: .04em;
  }

  .tabela-principios tbody th[scope="row"] {
    color: var(--green-800);
    background: var(--green-50) !important;
  }

  .tabela-principios tbody th[scope="row"]::before {
    content: "Princípio";
  }

  .tabela-principios tbody td:nth-of-type(1)::before { content: "Características"; }
  .tabela-principios tbody td:nth-of-type(2)::before { content: "Exemplos"; }
  .tabela-principios tbody td:nth-of-type(3)::before { content: "Fontes"; }
  .tabela-principios tbody td:nth-of-type(4)::before { content: "Principais Resultados"; }

  /* Wrapper sem scroll horizontal agora que está empilhado */
  .tabela-wrapper:has(.tabela-principios) {
    overflow: visible;
  }
  .tabela-wrapper:has(.tabela-principios)::after {
    display: none;
  }

  /* Tabelas de IA (4 cards do conjunto B) */
  .tabela-ia,
  .tabela-ia thead,
  .tabela-ia tbody,
  .tabela-ia tr,
  .tabela-ia td,
  .tabela-ia th[scope="row"] {
    display: block;
    width: 100%;
    min-width: auto !important;
  }

  .tabela-ia thead {
    display: none;
  }

  .tabela-ia tbody tr {
    padding: 4px 0;
    border-bottom: 1px solid var(--border);
  }

  .tabela-ia tbody tr:last-child {
    border-bottom: none;
  }

  .tabela-ia tbody th[scope="row"],
  .tabela-ia tbody td {
    display: block;
    width: 100% !important;
    padding: 10px 16px;
    background: var(--white) !important;
    border: none;
    border-bottom: 1px dashed var(--cream-300);
    text-align: left !important;
  }

  .tabela-ia tbody tr td:last-child,
  .tabela-ia tbody tr th[scope="row"]:last-child {
    border-bottom: none;
  }

  .tabela-ia tbody th[scope="row"] {
    background: var(--green-50) !important;
  }

  .tabela-ia tbody th[scope="row"]::before,
  .tabela-ia tbody td::before {
    display: block;
    font-weight: 700;
    color: var(--green-800);
    font-family: var(--font-head);
    font-size: .75rem;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: .04em;
  }

  .tabela-ia tbody th[scope="row"]::before { content: "Main"; }
  .tabela-ia tbody td:nth-of-type(1)::before { content: "Características"; }
  .tabela-ia tbody td:nth-of-type(2)::before { content: "Exemplos"; }
  .tabela-ia tbody td:nth-of-type(3)::before { content: "Fontes"; }
  .tabela-ia tbody td:nth-of-type(4)::before { content: "Principais Resultados"; }

  .tabela-ia-card .tabela-wrapper {
    overflow: visible;
  }
  .tabela-ia-card .tabela-wrapper::after {
    display: none;
  }
}
