body {
  background-color: #f4f7f9;
}

.product-item-generic {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 120px;
  margin: 4px;
  padding: 8px;
  border: 1px solid #eee;
  border-radius: 4px;
  text-decoration: none;
  color: #333;
  box-sizing: border-box;
  transition: box-shadow 0.2s ease;
}
.product-item-generic:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.product-item-generic .product-image {
  width: 100%;
  height: auto;
  object-fit: contain;
  margin-bottom: 6px;
}

.product-item-generic .product-name {
  font-size: 0.875rem;
  text-align: center;
  margin-bottom: 4px;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  width: 100%;
}

.product-item-generic .product-price {
  font-size: 1rem;
  font-weight: bold;
  color: blue;
  text-align: center;
}

.image-container {
  /* borda discreta: 1px sólido com cinza claríssimo */
  border: 1px solid rgba(0, 0, 0, 0.2);
  /* cantos levemente arredondados */
  border-radius: 0.375rem;
  /* um pouco de içamento interno para não grudar no conteúdo */
  padding: 0.75rem;
}

.filter-section {
  /* borda discreta: 1px sólido com cinza claríssimo */
  border: 1px solid rgba(0, 0, 0, 0.2);
  /* cantos levemente arredondados */
  border-radius: 0.375rem;
  /* um pouco de içamento interno para não grudar no conteúdo */
  padding: 0.75rem;
}

.component-container {
  background-color: #fff;
  padding: 2rem;
  border-radius: 0.75rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.component-header {
  text-align: center;
  margin-bottom: 1.5rem;
}

.component-header h1 {
  color: #333;
}

.image-container {
  max-width: 100%;
  overflow: auto;
  position: relative;
}

.zoom-controls {
  position: absolute;
  top: 0.5rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 0.25rem;
  z-index: 10;
}

.zoom-controls .btn {
  width: 2rem;
  height: 2rem;
  padding: 0;
  font-size: 1.25rem;
  line-height: 1;
  border-radius: 0.25rem;
}

@media (max-width: 576px) {
  .zoom-controls .btn {
    width: 2.5rem;
    height: 2.5rem;
    font-size: 1.5rem;
  }
}

.image-container img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 0 auto;
}

.table-container {
  max-width: 100%;
  min-height: 800px !important;
  overflow-y: auto;
  overflow-x: auto;
}

table.table > tbody > tr > td {
  padding: 4px;
  vertical-align: middle;
  font-size: 0.75em;
}

table.table > thead > tr > th {
  padding: 6px;
  vertical-align: middle;
  font-size: 0.8em;
}

table.table td {
  text-align: center;
}

table.table td.left-align {
  text-align: left;
}

.table-container thead th {
  position: sticky;
  top: 0;
  background-color: #fff;
  z-index: 2;
}

.no-wrap {
  white-space: nowrap;
}

.highlight {
  background-color: #acd8e6 !important;
  color: #000 !important;
}

table.table tbody tr.highlight,
table.table tbody tr.highlight td {
  opacity: 1 !important;
  background-color: #acd8e6 !important;
  color: #000 !important;
}

table.table tbody tr[data-item] {
  cursor: pointer;
}

/* Estilo para o formulário de detalhes inline */
.detail-form-container {
  display: none;
}

.detail-form {
  background: #f8f9fa;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 0.5rem;
  padding: 1rem;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.detail-form-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #dee2e6;
  padding-bottom: 0.5rem;
  margin-bottom: 1rem;
}

.detail-form-header h5 {
  margin: 0;
}

.btn-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
}

.detail-form-body label {
  font-weight: 600;
}

/* CSS global */
.product-list {
  background-color: white;
  display: flex;
  justify-content: center;
  flex-wrap: nowrap;
  /* nunca quebra linha */
  gap: 1rem;
  overflow-x: auto;
  /* se não couber, permite scroll */
  padding: 0.5rem 0;
  cursor: pointer;
}

.product-item {
  flex: 0 0 auto;
  width: 180px;
  text-decoration: none;
  color: inherit;
  border: 1px solid #ddd;
  border-radius: 0.25rem;
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: box-shadow 0.2s ease;
  position: relative;
}

.product-item.exact-match {
  border-color: #16a34a;
  box-shadow: 2px rgba(22, 163, 74, 0.18);
}

.product-item:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.product-image {
  width: 95px;
  height: 95px;
  object-fit: cover;
  margin-bottom: 0.5rem;
}

.product-name {
  font-size: 0.875rem;
  text-align: center;
  margin-bottom: 0.25rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.product-price {
  font-weight: bold;
  font-size: 0.9rem;
  color: #007bff;
}

.source-badge {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  font-size: 0.65rem;
  padding: 0.25em 0.4em;
  opacity: 0.8;
}

.product-list-title {
  display: inline-block;
  /* ajusta ao tamanho do texto */
  background-color: #ffe600;
  /* azul vivo */
  color: #000000;
  /* texto branco */
  padding: 0.4rem 0.8rem;
  /* espaço interno confortável */
  border-radius: 0.25rem;
  /* cantos arredondados */
  font-size: 1.3rem;
  /* leve aumento de tamanho */
  font-weight: 600;
  /* semi-bold */
  margin-bottom: 0.75rem;
  /* separação maior da lista */
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  /* sombra sutil */
}

.disclaimer {
  margin-top: 0.5rem;
  font-size: 0.75rem;
  /* texto menor */
  font-style: italic;
  /* opcional, para suavizar */
  color: #666;
  line-height: 1.4;
}

#detail-item-container {
  width: 100%;
  max-width: 350px;
  margin: 0 auto;
  overflow: hidden;
}

#detail-item-container .adsbygoogle {
  display: block !important;
  width: 100% !important;
  height: auto !important;
}

/* Painel flutuante */
#floating-availability-container {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 700px;
  /* largura máxima */
  background-color: #fff;
  /* branco puro para contraste */
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  border-radius: 0.5rem;
  border: 1px solid rgba(0, 0, 0, 0.15);
  padding: 0.5rem;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

#floating-availability-close {
  position: absolute;
  top: 0.25rem;
  right: 0.5rem;
  background: transparent;
  border: none;
  font-size: 1.75rem;
  /* aumentado de 1.2rem para 1.75rem */
  line-height: 1;
  cursor: pointer;
  color: #333;
}

/* Loading visível até o inner ser preenchido */
#floating-availability-container .availability-loading {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0.75rem 1.25rem;
  border: 1px solid #ddd;
  border-radius: 0.375rem;
  color: #333;
  font-weight: 500;
  font-size: 0.95rem;
}

#floating-availability-container .availability-inner {
  display: none;
  flex-direction: column;
  gap: 0.5rem;
}

/* Quando tiver conteúdo, esconde o loading e mostra o inner */
#floating-availability-container.has-availability .availability-loading {
  display: none;
}

#floating-availability-container.has-availability .availability-inner {
  display: flex;
}

/* Título e lista */
#floating-availability-container .product-list-title {
  background-color: #ffe600;
  color: #000;
  padding: 0.25rem 0.5rem;
  /* padding menor */
  font-size: 1rem;
  /* fonte menor */
  font-weight: 600;
  border-radius: 0.25rem;
  align-self: center;
}

#floating-availability-container .product-list {
  display: flex;
  flex-wrap: nowrap;
  /* mantém em uma linha */
  gap: 0.75rem;
  padding: 0 1rem;
  /* buffer interno p/ não cortar cards */
  box-sizing: border-box;
  overflow-x: auto;
  /* scroll horizontal sempre ativo se extrapolar */
  scroll-padding: 0 1rem;
  /* buffer ao rolar */
  /* retire width: max-content e margin:0 auto se existir */
}

#floating-availability-container .product-item {
  flex: 0 0 auto;
  width: 160px;
}

#floating-availability-container .disclaimer {
  font-size: 0.75rem;
  text-align: center;
}

/* Responsividade */
@media (max-width: 576px) {
  #floating-availability-container {
    bottom: 0.5rem;
    left: 0.5rem;
    right: 0.5rem;
    padding: 0.5rem;
  }

  #floating-availability-container .product-item {
    width: 120px;
  }
}

/* Pontinhos mais visíveis */
#floating-availability-container .availability-loading .dot {
  color: #007bff;
  /* azul para chamar atenção */
  animation: blink 1s infinite;
  margin: 0 2px;
}

/* Esconde o botão fechar até que os anúncios sejam carregados */
#floating-availability-container:not(.has-availability)
  #floating-availability-close {
  display: none;
}

@keyframes blink {
  0%,
  20% {
    opacity: 0;
  }

  50% {
    opacity: 1;
  }

  100% {
    opacity: 0;
  }
}

@media (max-width: 576px) {
  /* Ajusta o painel para caber na tela */
  #floating-availability-container {
    left: 0.5rem !important;
    right: 0.5rem !important;
    bottom: 0.5rem !important;
    width: auto;
    max-width: calc(100% - 1rem);
    transform: none;
    /* retira o translateX(-50%) */
    padding: 0.5rem;
  }

  #floating-availability-container .product-list {
    gap: 0.5rem;
  }

  #floating-availability-container .product-list .product-item {
    flex: 0 0 calc((100% - 0.5rem) / 2);
    width: calc((100% - 0.5rem) / 2);
  }

  /* Itens menores para caber mais fácil */
  #floating-availability-container .product-item {
    width: 100px;
    /* ou até 90px, se preferir */
  }

  /* Fecha mais visível no canto */
  #floating-availability-close {
    top: 0.25rem !important;
    right: 0.25rem !important;
    font-size: 1.5rem;
  }

  /* Remove sombra exagerada e borda muito larga */
  #floating-availability-container {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(0, 0, 0, 0.1);
  }

  /* Scroll mais “tátil” */
  #floating-availability-container .product-list {
    gap: 0.5rem;
    padding-bottom: 0.25rem;
    -webkit-overflow-scrolling: touch;
  }
}

.badge-compativel-outline {
  position: relative;
  padding: 2px 6px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #28a745;
  border: 1px solid #28a745;
  border-radius: 4px;
  background-color: #fff;
  animation: badgePulse 1s infinite ease-in-out;
}

@keyframes badgePulse {
  0% {
    box-shadow: 0 0 0 0 rgba(40, 167, 69, 0.4);
  }
  70% {
    box-shadow: 0 0 0 8px rgba(40, 167, 69, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(40, 167, 69, 0);
  }
}

/* Efeito de brilho passando por cima */
.badge-compativel-outline::after {
  content: "";
  position: absolute;
  top: 0;
  left: -50%;
  width: 50%;
  height: 100%;
  background: linear-gradient(
    120deg,
    transparent,
    rgba(255, 255, 255, 0.6),
    transparent
  );
  transform: skewX(-20deg);
  animation: badgeShine 1s infinite;
}

@keyframes badgeShine {
  0% {
    left: -50%;
  }
  100% {
    left: 150%;
  }
}

.badge-compativel-outline:hover {
  background-color: rgba(40, 167, 69, 0.1);
}

.badge-verificar-outline {
  padding: 2px 6px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #a77428;
  border: 1px solid #a77428;
  border-radius: 4px;
}
.badge-verificar-outline:hover {
  background-color: rgba(167, 116, 40, 0.1);
}

/* 1) Transição suave para mudança de cor de fundo (já feito via JS) */
#loading-container {
  transition: background-color 0.5s ease;
}

/* 2) Animação de “pulse” + leve “bounce” no texto */
#loading-text {
  display: inline-block; /* necessário para transformar */
  animation: pulseBounce 1s infinite; /* duração: 1.5s, repete para sempre */
}

/* 3) Keyframes combinando leve expansão (“pulse”) e movimento vertical (“bounce”) */
@keyframes pulseBounce {
  0%,
  100% {
    transform: scale(0.9) translateY(0);
    opacity: 1;
  }
  50% {
    transform: scale(1.1) translateY(-5px);
    opacity: 0.9;
  }
}

/* 4) Opcional: adicione uma borda luminosa para destacar ainda mais */
#loading-container {
  border-radius: 0.25rem;
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.4);
}

/* Highlight minimalista para peças substitutas */
.substitute-container {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.substitute-item {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  border: 1px solid #007bff;
  background: #f0f8ff;
  border-radius: 0.25rem;
  font-weight: bold;
  font-size: 0.9rem;
}
@media (max-width: 576px) {
  .substitute-item {
    font-size: 0.8rem;
    padding: 0.2rem 0.4rem;
  }
}

/* Aparar paddings e bordas no desktop também (mais limpo) */
.table-parts td,
.table-parts th {
  padding: 0.5rem 0.75rem;
}

/* Chip do PartNumber */
.pn-chip {
  display: inline-block;
  padding: 6px 10px;
  border: 1px solid #007bff;
  background: #f0f8ff;
  border-radius: 6px;
  font-weight: 700;
}

/* Micro-rotulo de substitutos */
.subs-badge {
  margin-top: 4px;
  font-size: 0.85em;
  color: #6c757d;
}

/* ===== MOBILE LAYOUT CLEAN ===== */
@media (max-width: 576px) {
  /* some o thead; cada <tr> vira cartão */
  .table-parts thead {
    display: none;
  }

  .table-parts {
    border-collapse: separate;
    border-spacing: 0 12px; /* respiro entre cartões */
  }

  .table-parts tbody tr {
    display: grid;
    grid-template-columns: 56px 1fr; /* Nº fixo + conteúdo flex */
    grid-template-areas:
      "item desc"
      "year part"
      "subs subs"
      "cta  cta";
    padding: 14px;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    background: #fff;
    align-items: center;
  }

  .table-parts tbody tr td {
    border: 0 !important;
    padding: 0 !important;
    background: transparent !important;
    text-align: left; /* padrão mobile */
  }

  /* mapeamento das áreas */
  .table-parts .cell-item {
    grid-area: item;
    text-align: center;
  }
  .table-parts .cell-desc {
    grid-area: desc;
  }
  .table-parts .cell-year {
    grid-area: year;
  }
  .table-parts .cell-part {
    grid-area: part;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
  }
  .table-parts .cell-detail {
    display: none !important;
  } /* oculta coluna desktop */

  /* badges de item e ano (destaque limpo) */
  .table-parts .cell-item {
    display: inline-block;
    min-width: 36px;
    padding: 4px 8px;
    border-radius: 999px; /* pill */
    font-weight: 700;
    background: #eef2ff;
    border: 1px solid #3b82f6;
    color: #1e3a8a;
  }
  .table-parts .cell-year {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px; /* pill */
    font-weight: 600;
    background: #ecfdf5;
    border: 1px solid #10b981;
    color: #065f46;
    width: fit-content;
  }

  /* descrição com 2 linhas, mais legível */
  .table-parts .cell-desc {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.25;
    font-size: 1em;
  }

  /* part number (chip) */
  .pn-chip {
    display: inline-flex;
    align-items: center;
    height: 34px;
    padding: 0 12px;
    border: 1px solid #007bff;
    background: #f0f8ff;
    border-radius: 8px;
    font-weight: 700;
  }

  /* linha de substitutos: ocupa a largura toda centralizada */
  .subs-row {
    grid-area: subs;
    display: flex;
    justify-content: center;
  }
  .subs-badge {
    font-size: 0.85rem;
    color: #6b7280;
  }

  /* CTA ocupa a linha inteira e centraliza */
  .btn-mobile-cta {
    grid-area: cta;
    justify-self: center;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    font-weight: 700;
    border-radius: 10px;
    white-space: nowrap;
  }

  /* tirar hover/seleção pesada no mobile (mantém a lógica JS) */
  .table-parts tbody tr:hover,
  .table-parts tbody tr.selected {
    background: transparent !important;
    outline: 2px solid rgba(59, 130, 246, 0.35); /* borda sutil */
    outline-offset: -2px;
  }
}

/* Botão CTA mais compacto no mobile */
.btn-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 14px; /* menor que 12px 20px */
  font-size: 0.9rem; /* reduz fonte */
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  border: none;
  border-radius: 8px; /* cantos menos “almofadados” */
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.3);
  text-decoration: none;
  transition: all 0.25s ease;
  max-width: 200px; /* evita “full width” gigante */
}

.btn-cta:hover {
  background: linear-gradient(135deg, #1d4ed8, #1e40af);
  box-shadow: 0 4px 10px rgba(29, 78, 216, 0.4);
  transform: translateY(-1px);
}

.btn-cta i {
  font-size: 1rem; /* ícone menor */
}

.cell-year,
.cell-item {
  font-size: 0.9rem !important;
}

/* Remove hover em telas menores que 768px (mobile / sm) */
@media (max-width: 767.98px) {
  .table-hover > tbody > tr:hover > * {
    --bs-table-bg-state: transparent; /* reseta a cor de fundo */
    background-color: transparent !important; /* remove highlight */
  }
}

@media (max-width: 576px) {
  .table-parts tbody tr {
    grid-template-columns: minmax(56px, auto) 1fr;
  }
}

@media (min-width: 580px) {
  .table-container {
    padding-bottom: 200px;
  }
}

@media (max-width: 576px) {
  #details-container {
    padding-top: 15px !important;
    padding-left: 5px !important;
    padding-right: 5px !important;
  }
}

/* Fix Highlight na barra de scroll */
.product-list {
  overflow-x: auto;
  overflow-y: hidden;
}

.product-item {
  position: relative;
  overflow: hidden;
  contain: paint;
}

/* barra compacta, SEM quebrar linha */
.offer-inline {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(90deg, #2563eb 0%, #22c55e 100%);
  color: #fff;
  border-radius: 12px;
  padding: 6px 8px;
  white-space: nowrap; /* <- chave p/ não quebrar */
  flex-wrap: nowrap; /* <- impede wrap */
  max-width: 100%;
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.25);
}
.offer-text {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 700;
}
.offer-text .price {
  font-size: 0.95rem;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.12);
}
.offer-text .dot {
  opacity: 0.8;
}
.offer-cta {
  flex: 0 0 auto;
  background: #fff;
  color: #0b5ed7;
  font-weight: 800;
  font-size: 0.9rem;
  padding: 4px 10px;
  border-radius: 10px;
  text-decoration: none;
  box-shadow: 0 2px 0 rgba(11, 94, 215, 0.22);
}

/* tira o sublinhado do link inteiro */
.offer-inline {
  text-decoration: none !important;
}

/* também tira de spans internos */
.offer-inline .price,
.offer-inline .count {
  text-decoration: none !important;
}

.offer-inline {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 10px;
  margin-top: 8px;
  background: linear-gradient(90deg, #2563eb 0%, #22c55e 100%);
  color: #fff;
  border-radius: 12px;
  text-decoration: none;
  white-space: nowrap;
  flex-wrap: nowrap;
  max-width: 100%;
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.25);
}

/* reflexo sempre ativo */
.offer-inline::before {
  content: "";
  position: absolute;
  top: 0;
  left: -75%;
  width: 50%;
  height: 100%;
  background: linear-gradient(
    120deg,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.6) 50%,
    rgba(255, 255, 255, 0) 100%
  );
  transform: skewX(-20deg);
  animation: shine 2.5s ease-in-out infinite;
}

@keyframes shine {
  from {
    left: -75%;
  }
  to {
    left: 125%;
  }
}
