/* ==========================================================================
   Tabelas de especificação (comparativos técnicos e ordenação JS)
   Usado exclusivamente em páginas com tabelas técnicas comparativas
   ========================================================================== */

.table-scroll {
  overflow-x: auto;
  margin: 1.4em 0 1.8em;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  -webkit-overflow-scrolling: touch;
}

.spec-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
  min-width: 640px; /* força scroll horizontal em telas pequenas em vez de espremer */
  background: var(--surface);
}

.spec-table caption {
  text-align: left;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: .95rem;
  color: var(--ink);
  padding: .8em 1em;
  background: var(--surface-soft);
  border-bottom: 1px solid var(--line);
}

.spec-table th,
.spec-table td {
  padding: .7em .9em;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.spec-table thead th {
  background: var(--surface-dark);
  color: var(--on-dark) !important;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  white-space: nowrap;
}

.spec-table tbody tr:nth-child(even) { background: var(--surface-soft); }
.spec-table tbody tr:hover { background: rgba(255, 153, 0, .08); }

.spec-table td.model-cell {
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
}

.spec-table td.num,
.spec-table th.num {
  font-family: var(--font-mono);
  color: var(--ink);
  white-space: nowrap;
}

.spec-table td.muted {
  color: var(--ink-soft);
  font-size: .85rem;
}

.spec-table tbody tr:last-child td { border-bottom: none; }

/* Lista de notas — explicações fora das células, bem espaçadas */
.table-notes {
  list-style: none;
  margin: -.6em 0 1.8em;
  padding: 0;
  font-size: .84rem;
  color: var(--ink-soft);
  border-left: 3px solid var(--line);
}
.table-notes li {
  padding: .5em 0 .5em 1em;
  margin-bottom: .35em;
  line-height: 1.55;
}
.table-notes li:last-child { margin-bottom: 0; }
.table-notes strong { color: var(--ink); font-family: var(--font-display); font-weight: 600; }

/* Cabeçalhos ordenáveis (JS liga isto em runtime) */
.spec-table th.sortable {
  cursor: pointer;
  user-select: none;
  position: relative;
  padding-right: 1.6em;
}
.spec-table th.sortable:hover,
.spec-table th.sortable:focus-visible { background: #2b2f37; }
.spec-table th.sortable::after {
  content: '⇅';
  position: absolute;
  right: .55em;
  top: 50%;
  transform: translateY(-50%);
  opacity: .45;
  font-size: .85em;
}
.spec-table th.sortable.sort-asc::after { content: '↑'; opacity: 1; color: var(--brand); }
.spec-table th.sortable.sort-desc::after { content: '↓'; opacity: 1; color: var(--brand); }
.spec-table th.sortable:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }

@media (max-width: 640px) {
  .spec-table { font-size: .84rem; }
  .spec-table th, .spec-table td { padding: .6em .7em; }

  /* Tabelas viram "cards" empilhados no celular — acaba com a barra de rolagem horizontal */
  .table-scroll:has(.responsive-cards) { overflow-x: visible; border: none; }
  .spec-table.responsive-cards { min-width: 0; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
  .spec-table.responsive-cards caption { border-radius: var(--radius) var(--radius) 0 0; }
  .spec-table.responsive-cards thead { display: none; }
  .spec-table.responsive-cards tbody,
  .spec-table.responsive-cards tr,
  .spec-table.responsive-cards td { display: block; width: 100%; }
  .spec-table.responsive-cards tr {
    padding: .7em .9em .5em;
    border-bottom: 6px solid var(--surface-soft);
  }
  .spec-table.responsive-cards tr:last-child { border-bottom: none; }
  .spec-table.responsive-cards td {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1em;
    text-align: right;
    padding: .45em 0;
    border-bottom: 1px dashed var(--line);
    white-space: normal;
  }
  .spec-table.responsive-cards td:last-child { border-bottom: none; }
  .spec-table.responsive-cards td::before {
    content: attr(data-label);
    text-align: left;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .03em;
    color: var(--ink-soft);
    flex-shrink: 0;
  }
  .spec-table.responsive-cards td.model-cell {
    display: block;
    text-align: left;
    font-size: 1.02rem;
    padding-bottom: .5em;
    border-bottom: 2px solid var(--brand);
    margin-bottom: .3em;
  }
  .spec-table.responsive-cards td.model-cell::before { content: none; }
}
