/* Comparador CSS — dark theme matching site design system */

.search-input:focus {
  outline: none;
  border-color: #D4FF3D;
  box-shadow: 0 0 0 3px rgba(212,255,61,0.1);
}

.autocomplete-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: rgba(23,24,27,0.95);
  border: 1px solid rgba(212,255,61,0.2);
  border-top: none;
  border-radius: 0 0 8px 8px;
  max-height: 300px;
  overflow-y: auto;
  z-index: 10;
  display: none;
  box-shadow: 0 8px 16px rgba(0,0,0,0.4);
  backdrop-filter: blur(12px);
}

.autocomplete-dropdown.visible {
  display: block;
}

.autocomplete-item {
  padding: 12px 16px;
  cursor: pointer;
  border-bottom: 1px solid rgba(242,243,240,0.08);
  transition: background 0.15s;
  color: #F2F3F0;
  font-size: 14px;
}

.autocomplete-item:hover {
  background: rgba(212,255,61,0.1);
  color: #D4FF3D;
}

.autocomplete-item.selected {
  background: rgba(212,255,61,0.2);
  color: #D4FF3D;
  font-weight: 600;
}

/* Table styling */
#comparison-table {
  background: rgba(11,11,12,0.7);
}

#comparison-table thead {
  background: rgba(23,24,27,0.8);
  border-bottom: 1px solid rgba(242,243,240,0.1);
}

#comparison-table th {
  padding: 16px;
  text-align: left;
  font-weight: 600;
  color: #D4FF3D;
  font-size: 14px;
  white-space: nowrap;
  letter-spacing: 0.02em;
}

#comparison-table td {
  padding: 16px;
  border-bottom: 1px solid rgba(242,243,240,0.08);
  vertical-align: top;
  color: #F2F3F0;
}

#comparison-table tr:last-child td {
  border-bottom: none;
}

.label-col,
.label-col-data {
  position: sticky;
  left: 0;
  background: rgba(11,11,12,0.9);
  min-width: 180px;
  font-weight: 600;
  border-right: 1px solid rgba(242,243,240,0.1);
  z-index: 5;
}

.label-col {
  color: #D4FF3D;
  font-size: 13px;
  letter-spacing: 0.02em;
}

.label-col-data {
  color: #F2F3F0;
  font-size: 14px;
}

/* >=600px: columnas de ancho fijo y parejo (table-layout: fixed) para que la
   tabla NUNCA genere scroll horizontal al comparar 3-4 motos: el ancho se
   reparte entre las columnas en vez de crecer con el contenido. Cubre desktop,
   tablets e iPad vertical (768). En celular angosto (<600) se mantiene el
   scroll, ahí es inevitable con tantas columnas y así quedan legibles. */
@media (min-width: 600px) {
  #comparison-table { table-layout: fixed; width: 100%; }
  .label-col, .label-col-data { width: 150px; min-width: 0; }
  #comparison-table td { overflow-wrap: anywhere; }
  /* imagen fluida: se adapta al ancho de la columna (tope 140px) para que
     nunca fuerce a la columna a ser más ancha -> sin desborde */
  .product-image { width: 100%; height: auto; aspect-ratio: 1 / 1; max-width: 140px; }
}
/* tablets angostas (600–768): columna de etiquetas y padding más chicos
   (si no, el min-width:140 del bloque móvil deja un pequeño desborde) */
@media (min-width: 600px) and (max-width: 768px) {
  .label-col, .label-col-data { width: 110px !important; min-width: 0 !important; }
  #comparison-table th, #comparison-table td { padding: 10px !important; }
}

/* Product header in table */
.product-header {
  text-align: center;
  padding: 20px 16px !important;
}

.product-image {
  width: 140px;
  max-width: 100%;
  height: 140px;
  margin: 0 auto 12px;
  background: rgba(23,24,27,0.8);
  border-radius: 8px;
  object-fit: contain;
  box-sizing: border-box;
  padding: 8px;
  display: block;
  border: 1px solid rgba(212,255,61,0.15);
}

.product-name {
  font-weight: 700;
  color: #F2F3F0;
  font-size: 16px;
  margin-top: 8px;
  /* nombre recortado a 2 líneas (evita que ensanche la columna) */
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}

/* botón "Buy on Amazon" del header: a bloque, para apilarse sobre "llego al trabajo" */
.product-header .tile-buy {
  display: block;
  width: 100%;
  box-sizing: border-box;
  text-align: center;
  margin: 8px 0 0;
}

/* el header de producto vive en un <th> (white-space:nowrap por defecto). Con
   ID para ganarle a `#comparison-table th`: forzamos wrap en TODO su contenido
   (nombre, botones) para que nada se desborde de la columna y no aparezca
   scroll horizontal al comparar 3-4 motos. */
#comparison-table .product-header,
#comparison-table .product-header * {
  white-space: normal;
  overflow-wrap: anywhere;
}

.product-brand {
  color: #6E727A;
  font-size: 13px;
  margin-top: 4px;
}

.product-badge {
  display: inline-block;
  background: rgba(212,255,61,0.2);
  color: #D4FF3D;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  margin-top: 10px;
  border: 1px solid rgba(212,255,61,0.3);
}

/* Highlights for max/min values */
.highlight-max {
  background: rgba(212,255,61,0.2);
  color: #D4FF3D;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid rgba(212,255,61,0.3);
}

.highlight-min {
  background: rgba(212,255,61,0.1);
  color: #D4FF3D;
  padding: 4px 8px;
  border-radius: 4px;
}

.empty-cell {
  color: #6E727A;
  font-style: italic;
}

/* Radar chart container */
#radar-chart {
  max-width: 100%;
  max-height: 100%;
}

/* Responsive design */
@media (max-width: 768px) {
  .product-image {
    width: 100px;
    height: 100px;
  }

  .product-name {
    font-size: 14px;
  }

  #comparison-table th,
  #comparison-table td {
    padding: 12px;
    font-size: 13px;
  }

  .label-col,
  .label-col-data {
    min-width: 140px;
  }
}

@media (max-width: 576px) {
  .product-image {
    width: 80px;
    height: 80px;
  }

  .product-name {
    font-size: 13px;
  }

  .product-brand {
    font-size: 12px;
  }

  #comparison-table {
    font-size: 12px;
  }

  #comparison-table th,
  #comparison-table td {
    padding: 10px;
  }

  .label-col,
  .label-col-data {
    min-width: 100px;
  }
}

/* ====== MÓVIL (<600px): swipe horizontal con la columna "Spec" fija ======
   Con 3-4 motos no entran en la pantalla, así que en vez de apretarlas
   (ilegibles) se le da a cada columna un ancho cómodo y la tabla se DESLIZA;
   la columna de specs queda congelada a la izquierda. Los botones salen del
   encabezado a la lista de acciones de abajo (#compare-actions). */
.eb-mob-actions { display: none; }        /* en desktop, oculto */
.eb-swipe-hint { display: none; }

@media (max-width: 599px) {
  /* columnas legibles -> la tabla se desborda y se desliza */
  #comparison-table th:not(.label-col),
  #comparison-table td:not(.label-col):not(.label-col-data) { min-width: 150px; }
  .label-col, .label-col-data { min-width: 104px; background: #0f1012; }  /* opaca: la columna fija */
  /* los botones se mudan a la sección de acciones de abajo.
     Se usa el ID #comparison-table para ganar en especificidad a
     commute.css (.product-header .pd-commute{display:block}), que se
     carga después y, a igual especificidad, ganaría por orden de fuente. */
  #comparison-table .product-header .tile-buy,
  #comparison-table .product-header .pd-commute { display: none; }

  .eb-swipe-hint { display: block; text-align: center; margin-top: 14px;
                   font-size: 12px; color: #6E727A; letter-spacing: 0.03em; }

  .eb-mob-actions { display: grid; gap: 10px; margin-top: 18px; }
  .ca-row { display: grid; grid-template-columns: 48px 1fr; align-items: center;
            column-gap: 12px; row-gap: 10px; padding: 12px;
            background: rgba(23,24,27,0.6); border: 1px solid rgba(242,243,240,0.08);
            border-radius: 12px; }
  .ca-thumb { width: 48px; height: 48px; border-radius: 8px; object-fit: contain;
              background: rgba(11,11,12,0.7); padding: 4px; box-sizing: border-box;
              border: 1px solid rgba(212,255,61,0.15); }
  .ca-name { font-size: 14px; font-weight: 600; color: #F2F3F0;
             line-height: 1.35; overflow-wrap: anywhere; }
  .ca-btns { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .ca-buy, .ca-btns .pd-commute {
    display: flex; align-items: center; justify-content: center; min-height: 44px;
    padding: 10px 12px; border-radius: 10px; font-size: 13px; font-weight: 600;
    text-align: center; text-decoration: none; box-sizing: border-box; margin: 0; width: 100%;
  }
  .ca-buy { background: #FF9900; color: #0B0B0C; }
}

/* Input group relative positioning for remove button */
.input-group {
  position: relative;
}

.btn-remove {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: #6E727A;
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  transition: color .35s ease;
}

.btn-remove:hover {
  color: #D4FF3D;
}

/* Button hover states */
#btn-add-model:hover {
  background: rgba(212,255,61,0.25);
  border-color: rgba(212,255,61,0.5);
}

#btn-add-model:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* =========================================================================
   Selección por categoría + grilla de miniaturas + barra de comparar
   ========================================================================= */

/* --- chips de categoría --- */
.cat-chips { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 28px; }
.cat-chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 16px; border-radius: 999px; cursor: pointer;
  background: rgba(11,11,12,0.6); color: #F2F3F0;
  border: 1px solid rgba(242,243,240,0.18);
  font-family: inherit; font-size: 14px; font-weight: 500;
  transition: border-color .25s ease, background .25s ease, color .25s ease;
}
.cat-chip:hover { border-color: #D4FF3D; }
.cat-chip.active { background: #D4FF3D; color: #0B0B0C; border-color: #D4FF3D; font-weight: 600; }
.cat-chip .cat-count { font-size: 12px; opacity: 0.55; }
.cat-chip.active .cat-count { opacity: 0.7; }

/* --- grilla de miniaturas --- */
.product-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px;
}
.grid-msg { grid-column: 1 / -1; padding: 40px; text-align: center; color: #6E727A; font-size: 15px; }

.product-tile {
  position: relative; display: flex; flex-direction: column; gap: 6px;
  padding: 12px; border-radius: 12px; cursor: pointer; text-align: left;
  background: rgba(11,11,12,0.7); border: 1px solid rgba(242,243,240,0.1);
  font-family: inherit; color: #F2F3F0;
  transition: border-color .2s ease, transform .2s ease, background .2s ease;
}
@media (hover: hover) { .product-tile:hover { border-color: rgba(212,255,61,0.5); transform: translateY(-3px); } }
.product-tile.selected { border-color: #D4FF3D; background: rgba(212,255,61,0.08); }
.product-tile .tile-img {
  display: block; width: 100%; aspect-ratio: 1; border-radius: 8px; overflow: hidden;
  background: #0B0B0C;
}
.product-tile .tile-img img { width: 100%; height: 100%; object-fit: contain; box-sizing: border-box; padding: 8px; display: block; }
.tile-brand { font-size: 11px; color: #6E727A; letter-spacing: 0.02em; text-transform: uppercase; }
.tile-name { font-size: 13px; font-weight: 600; line-height: 1.3; color: #F2F3F0; }
.tile-rating { font-size: 12px; color: #D4FF3D; }
.tile-check {
  position: absolute; top: 8px; right: 8px; z-index: 2;
  width: 24px; height: 24px; border-radius: 999px;
  display: flex; align-items: center; justify-content: center;
  background: #D4FF3D; color: #0B0B0C; font-size: 14px; font-weight: 700;
  transform: scale(0); transition: transform .18s ease;
}
.product-tile.selected .tile-check { transform: scale(1); }
/* tile usado como enlace (catálogo de models.html) */
a.product-tile { text-decoration: none; }
.tile-media { display: flex; flex-direction: column; gap: 6px; text-decoration: none; color: inherit; }
.product-tile .tile-buy { display: block; text-align: center; margin-top: 6px; }
.tile-details { display: block; text-align: center; margin-top: 2px; padding: 9px 14px;
                background: #333333; color: #F2F3F0; border-radius: 8px; text-decoration: none;
                font-weight: 600; font-size: 13px; transition: background .2s ease; }
.tile-details:hover { background: #444444; }

/* --- barra de comparar (sticky, aparece al seleccionar) --- */
.compare-bar {
  position: fixed; left: 50%; bottom: 20px; transform: translate(-50%, 160%);
  z-index: 60; width: calc(100% - 32px); max-width: 640px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 14px 12px 24px; border-radius: 999px;
  background: rgba(23,24,27,0.9); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border: 1px solid rgba(212,255,61,0.25); box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  transition: transform .35s cubic-bezier(.2,.8,.2,1), border-color .3s ease;
}
.compare-bar.visible { transform: translate(-50%, 0); }
.compare-bar.warn { border-color: #FF9900; }
#compare-count { font-size: 14px; color: #F2F3F0; font-weight: 500; white-space: nowrap; }
.compare-actions { display: flex; align-items: center; gap: 8px; }
.btn-clear {
  background: transparent; border: 1px solid rgba(242,243,240,0.18); color: #6E727A;
  padding: 10px 16px; border-radius: 999px; font-family: inherit; font-size: 13px; cursor: pointer;
  transition: color .25s ease, border-color .25s ease;
}
.btn-clear:hover { color: #F2F3F0; border-color: #F2F3F0; }
.btn-compare {
  background: #D4FF3D; color: #0B0B0C; border: none;
  padding: 11px 22px; border-radius: 999px; font-family: inherit; font-size: 14px; font-weight: 600;
  cursor: pointer; white-space: nowrap; transition: background .25s ease, opacity .25s ease;
}
.btn-compare:hover:not(:disabled) { background: #e4ff6b; }
.btn-compare:disabled { opacity: 0.45; cursor: not-allowed; }

/* --- botón "Buy on Amazon" en el header de la tabla --- */
.tile-buy {
  display: inline-block; margin-top: 10px; padding: 9px 14px;
  background: #FF9900; color: #0B0B0C; border-radius: 8px; text-decoration: none;
  font-weight: 600; font-size: 13px; transition: opacity .2s ease;
}
.tile-buy:hover { opacity: 0.88; }

@media (max-width: 640px) {
  .compare-bar { bottom: 12px; padding: 10px 12px 10px 18px; }
  #compare-count { font-size: 13px; }
  .btn-clear { padding: 9px 12px; }
  .btn-compare { padding: 10px 16px; font-size: 13px; }
  .product-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
}

/* En móvil y tablet ocultamos las filas Pros/Contras de la tabla (solo ocultar,
   no eliminar): siguen visibles en desktop (>=1025px). */
@media (max-width: 1024px) {
  #comparison-table tr.eb-hide-mobile { display: none; }
}
