/* ── Reset y base ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  margin: 0;
  background: #f5f7fb;
  color: #222;
}

/* ── Logo ───────────────────────────────────────────────────────── */
.logo {
  margin-bottom: 16px;
}

.logo-img {
  height: 80px;
  width: auto;
  max-width: 420px;
  display: block;
  margin: 0 auto;
}

@media (max-width: 500px) {
  .logo-img { height: 56px; }
}

/* ── Hero ───────────────────────────────────────────────────────── */
.hero {
  text-align: center;
  padding: 70px 20px 50px;
  background: linear-gradient(135deg, #eff6ff 0%, #f5f7fb 100%);
  border-bottom: 1px solid #e5eaf3;
}

.hero h1 {
  font-size: 32px;
  font-weight: 700;
  margin: 0 0 10px;
  color: #111;
}

.hero p{
  color:#ea580c;
  max-width: 560px;
  margin: 0 auto 30px;
  font-size: 16px;
  line-height: 1.5;
  }

/* ── Search box ─────────────────────────────────────────────────── */
.search-box {
  position: relative;
  display: inline-flex;
  gap: 8px;
  max-width: 560px;
  width: 100%;
  align-items: center;
}

.search-box input {
  flex: 1;
  padding: 10px 18px;
  height: 44px;
  border-radius: 10px;
  border: 1.5px solid #dde2ee;
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s;
}


.search-box input:focus {
  border-color: #2563eb;
}

.search-box button {
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  overflow: hidden;
  transition: transform 0.15s, opacity 0.15s;
  flex-shrink: 0;
}

.search-box button:hover {
  transform: scale(1.06);
  opacity: 0.9;
}

.btn-logo-img {
  height: 110x;
  width: 110px;
  display: block;
  object-fit: contain;
}

@media (max-width: 500px) {
  .btn-logo-img { height: 50px; width: 50px; }
}

/* ── Suggestions ────────────────────────────────────────────────── */
#suggestions {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 60px;
  background: white;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  z-index: 100;
  overflow: hidden;
}

#suggestions div {
  padding: 11px 16px;
  cursor: pointer;
  border-bottom: 1px solid #f0f0f0;
  font-size: 14px;
  text-align: left;
}

#suggestions div:last-child { border-bottom: none; }
#suggestions div:hover { background: #f0f5ff; }

/* ── Categorías ─────────────────────────────────────────────────── */
.categories {
  padding: 40px 20px;
  text-align: center;
}

.categories h2 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 20px;
  color: #333;
}

.grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  max-width: 560px;
  margin: auto;
}

@media (max-width: 500px) {
  .grid { grid-template-columns: repeat(2, 1fr); }
}

.card {
  background: white;
  padding: 18px 10px;
  border-radius: 12px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.06);
  font-size: 14px;
  font-weight: 500;
}

.cat-card {
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}

.cat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(37,99,235,0.12);
}

/* ── Filtros ────────────────────────────────────────────────────── */
.filters {
  max-width: 620px;
  margin: 0 auto 16px;
  padding: 18px 28px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  align-items: center;
}

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

.filter-group > label {
  font-size: 13px;
  font-weight: 600;
  color: #444;
}

.filter-group input[type="range"] {
  width: 200px;
  accent-color: #2563eb;
}

.checkboxes {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.checkboxes label {
  font-size: 13px;
  color: #333;
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
}

.checkboxes input[type="checkbox"] {
  accent-color: #2563eb;
  width: 15px;
  height: 15px;
  cursor: pointer;
}

/* ── Resumen de mejores precios ─────────────────────────────────── */
.summary {
  max-width: 620px;
  margin: 0 auto 16px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

@media (max-width: 500px) {
  .summary { grid-template-columns: 1fr; }
}

.summary-card {
  background: white;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.06);
  text-align: center;
  border-top: 3px solid #e5eaf3;
}

.summary-card.is-new    { border-top-color: #2563eb; }
.summary-card.is-refurb { border-top-color: #7c3aed; }
.summary-card.is-used   { border-top-color: #059669; }

.summary-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #888;
  margin-bottom: 6px;
}

.summary-price {
  font-size: 22px;
  font-weight: 800;
  color: #111;
}

.summary-saving {
  font-size: 12px;
  color: #059669;
  font-weight: 600;
  margin-top: 4px;
}

/* ── Resultados ─────────────────────────────────────────────────── */
.results {
  padding: 10px 20px 60px;
  text-align: center;
}

.results > h2 {
  font-size: 18px;
  font-weight: 600;
  color: #333;
  margin-bottom: 10px;
}

/* ── Bloque por condición ───────────────────────────────────────── */
.block {
  background: white;
  margin: 16px auto;
  max-width: 620px;
  padding: 22px 24px;
  border-radius: 14px;
  box-shadow: 0 2px 14px rgba(0,0,0,0.07);
  text-align: left;
}

.block h3 {
  margin: 0 0 14px;
  font-size: 17px;
  font-weight: 700;
  color: #2563eb;
  border-bottom: 2px solid #eff2ff;
  padding-bottom: 10px;
}

/* ── Card de producto ───────────────────────────────────────────── */
.product-card {
  padding: 12px 0;
  border-bottom: 1px solid #f0f2f7;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.product-card:last-child { border-bottom: none; }

/* Fila 1: nombre + badge */
.product-info {
  width: 100%;
}

.product-name {
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
  display: block;
}

.product-source {
  font-size: 12px;
  color: #888;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: none;
}

/* Fila 2: tienda + precio + botones */
.product-card-row2 {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
}

.product-source-row2 {
  font-size: 12px;
  color: #888;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.product-price {
  font-size: 15px;
  font-weight: 800;
  color: #111;
  white-space: nowrap;
  flex-shrink: 0;
}

.price-alert {
  width: 100%;
  margin-top: 0;
  min-height: 0;
}

/* Badge mejor precio */
.badge-best {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  background: #dcfce7;
  color: #166534;
  border-radius: 4px;
  padding: 2px 5px;
  margin-left: 4px;
  vertical-align: middle;
  white-space: nowrap;
}

@media (min-width: 501px) {
  .product-card {
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
  }
  .product-info { flex: 1; min-width: 0; }
  .product-source { display: block; }
  .product-source-row2 { display: none; }
  .product-card-row2 {
    width: auto;
    flex: none;
    gap: 8px;
  }
  .product-price { font-size: 19px; }
  .price-alert { width: 100%; }
}

@media (max-width: 500px) {
  .btn-offer { padding: 6px 10px; font-size: 12px; }
  .btn-history { padding: 5px 7px; font-size: 13px; }
  .btn-alert { padding: 5px 7px; font-size: 13px; }
  .block { padding: 14px 12px; }
}

.btn-offer {
  display: inline-block;
  padding: 8px 14px;
  background: #2563eb;
  color: white;
  border-radius: 8px;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  transition: background 0.2s;
}

.btn-offer:hover { background: #1d4ed8; }

/* Badge "Mejor precio" */
.badge-best {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  background: #dcfce7;
  color: #166534;
  border-radius: 4px;
  padding: 2px 6px;
  margin-left: 6px;
  vertical-align: middle;
}

/* ── Footer ─────────────────────────────────────────────────────── */
footer {
  margin-top: 40px;
  text-align: center;
  color: #999;
  padding: 24px 20px;
  border-top: 1px solid #e9ecf3;
  font-size: 13px;
}

.footer-sub {
  font-size: 11px;
  color: #bbb;
  margin-top: 4px;
}

/* ── Botón histórico ─────────────────────────────────────────────── */
.btn-history {
  background: none;
  border: 1.5px solid #e0e7ff;
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 16px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  line-height: 1;
}

.btn-history:hover {
  background: #eff6ff;
  border-color: #2563eb;
}

/* ── Modal histórico ─────────────────────────────────────────────── */
.history-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.history-box {
  background: white;
  border-radius: 16px;
  padding: 28px;
  width: 100%;
  max-width: 600px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
}

.history-title {
  font-size: 18px;
  font-weight: 700;
  color: #111;
}

.history-subtitle {
  font-size: 13px;
  color: #888;
  margin-top: 3px;
}

.history-close {
  background: none;
  border: none;
  font-size: 18px;
  color: #aaa;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.history-close:hover { color: #333; }

/* Stats row */
.history-stats {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.stat {
  flex: 1;
  min-width: 100px;
  background: #f8f9fc;
  border-radius: 10px;
  padding: 10px 14px;
  text-align: center;
}

.stat-label {
  display: block;
  font-size: 11px;
  color: #999;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 4px;
}

.stat-value {
  display: block;
  font-size: 16px;
  font-weight: 700;
  color: #111;
}

.stat-min { color: #059669; }
.stat-max { color: #dc2626; }

/* Gráfica */
.history-chart-wrap {
  position: relative;
  height: 220px;
}

/* ── Selector de fechas ──────────────────────────────────────────── */
.history-daterange {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  padding: 12px 16px;
  background: #f8f9fc;
  border-radius: 10px;
}

.daterange-group {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.daterange-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: #999;
}

.date-input {
  border: 1.5px solid #e0e7ff;
  border-radius: 7px;
  padding: 6px 10px;
  font-size: 13px;
  color: #222;
  background: white;
  cursor: pointer;
  outline: none;
}

.date-input:focus {
  border-color: #2563eb;
}

.daterange-sep {
  color: #ccc;
  font-size: 16px;
  padding-top: 14px;
}

.daterange-shortcuts {
  display: flex;
  gap: 6px;
  margin-left: auto;
  padding-top: 14px;
}

.shortcut-btn {
  border: 1.5px solid #e0e7ff;
  border-radius: 6px;
  background: white;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 600;
  color: #555;
  cursor: pointer;
  transition: all 0.15s;
}

.shortcut-btn:hover {
  border-color: #2563eb;
  color: #2563eb;
}

.shortcut-btn.active {
  background: #2563eb;
  border-color: #2563eb;
  color: white;
}

/* ── Alertas de precio ───────────────────────────────────────────── */
.price-alert {
  margin-top: 4px;
  min-height: 16px;
}

.alert-fake {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  color: #92400e;
  background: #fef3c7;
  border: 1px solid #fcd34d;
  border-radius: 4px;
  padding: 2px 7px;
}

.alert-good {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  color: #166534;
  background: #dcfce7;
  border: 1px solid #86efac;
  border-radius: 4px;
  padding: 2px 7px;
}

/* ── Botón alerta ────────────────────────────────────────────────── */
.btn-alert {
  background: none;
  border: 1.5px solid #e0e7ff;
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 16px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  line-height: 1;
}

.btn-alert:hover {
  background: #fef3c7;
  border-color: #f59e0b;
}

/* ── Formulario de alerta inline ─────────────────────────────────── */
.alert-form {
  grid-column: 1 / -1;
  width: 100%;
  margin-top: 10px;
}

.alert-form-inner {
  background: #f8f9fc;
  border: 1.5px solid #e0e7ff;
  border-radius: 10px;
  padding: 16px;
}

.alert-form-title {
  font-size: 14px;
  font-weight: 700;
  color: #333;
  margin-bottom: 12px;
}

.alert-form-row {
  margin-bottom: 10px;
}

.alert-input {
  width: 100%;
  padding: 8px 12px;
  border: 1.5px solid #dde2ee;
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  background: white;
  transition: border-color 0.2s;
}

.alert-input:focus {
  border-color: #2563eb;
}

.alert-price-label {
  font-size: 12px;
  color: #666;
  display: block;
  margin-bottom: 6px;
}

.alert-price-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.alert-price-input {
  width: 120px !important;
}

.alert-euro {
  font-size: 16px;
  font-weight: 700;
  color: #333;
}

.alert-checkbox-label {
  font-size: 12px;
  color: #555;
  display: flex;
  align-items: flex-start;
  gap: 6px;
  cursor: pointer;
  line-height: 1.4;
}

.alert-checkbox-label input {
  margin-top: 2px;
  accent-color: #2563eb;
  flex-shrink: 0;
}

.alert-form-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.btn-alert-cancel {
  flex: 1;
  padding: 8px;
  border: 1.5px solid #dde2ee;
  border-radius: 8px;
  background: white;
  font-size: 13px;
  color: #666;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-alert-cancel:hover {
  background: #f0f0f0;
}

.btn-alert-save {
  flex: 2;
  padding: 8px;
  border: none;
  border-radius: 8px;
  background: #2563eb;
  color: white;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-alert-save:hover {
  background: #1d4ed8;
}

.btn-alert-save:disabled {
  background: #93c5fd;
  cursor: not-allowed;
}

.alert-form-msg {
  font-size: 12px;
  margin-top: 8px;
  min-height: 16px;
}

.alert-msg-ok {
  color: #166534;
  font-weight: 600;
}

.alert-msg-error {
  color: #dc2626;
  font-weight: 600;
}

/* El formulario ocupa toda la fila de la card */
.alert-form {
  grid-column: 1 / -1;
  grid-row: 3;
}

/* Texto botón oferta según pantalla */
.btn-offer-short { display: none; }
.btn-offer-full  { display: inline; }

@media (max-width: 500px) {
  .btn-offer-short { display: inline; }
  .btn-offer-full  { display: none; }
}
