/* ===== Variables ===== */
:root {
  --fondo: #f5f7fb;
  --superficie: #ffffff;
  --texto: #1a2233;
  --muted: #6b7489;
  --borde: #e3e7ef;
  --primario: #2f6bff;
  --primario-osc: #1f54d6;
  --acento: #00c48c;
  --peligro: #e5484d;
  --aviso: #d98a00;
  --radio: 14px;
  --sombra: 0 4px 18px rgba(20, 35, 80, 0.07);

  --amazon: #ff9900;
  --ml: #ffe600;
  --shein: #111111;
  --ali: #ff4747;
  --temu: #fb7701;

  --suave: #f1f4fa;
  --suave-hover: #e6ebf5;
  --sec-bg: #eef2ff;
  --sec-bg-hover: #e0e7ff;
  --hero-a: #dfe8ff;
  --hero-b: #d6fff1;
  --img-a: #eef2fb;
  --img-b: #f8f9fd;
  --estrella-vacia: #dfe3ec;
  color-scheme: light;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--fondo);
  color: var(--texto);
  line-height: 1.5;
}

a { color: inherit; text-decoration: none; }

.contenedor { width: min(1280px, 100% - 32px); margin-inline: auto; }
.muted { color: var(--muted); font-size: 0.875rem; }

/* ===== Botones ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; border: none; cursor: pointer; font: inherit; font-weight: 600;
  padding: 10px 18px; border-radius: 10px; transition: background .15s, transform .1s;
}
.btn:active { transform: scale(.98); }
.btn--primario { background: var(--primario); color: #fff; }
.btn--primario:hover { background: var(--primario-osc); }
.btn--secundario { background: var(--sec-bg); color: var(--primario); }
.btn--secundario:hover { background: var(--sec-bg-hover); }
.btn--ghost { border: 1px solid var(--borde); background: transparent; }
.btn--bloque { width: 100%; }

/* ===== Topbar ===== */
.topbar { background: var(--superficie); border-bottom: 1px solid var(--borde); position: sticky; top: 0; z-index: 10; }
.topbar__inner { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.logo { font-size: 1.35rem; font-weight: 800; display: flex; align-items: center; }
.logo__icono { color: var(--primario); margin-right: 6px; }
.logo__x { color: var(--acento); }
.logo__mx { color: var(--muted); font-size: .8em; font-weight: 600; margin-left: 1px; }
.menu { display: flex; align-items: center; gap: 22px; font-weight: 500; color: var(--muted); }
.menu a:hover { color: var(--texto); }

/* ===== Hero ===== */
.hero {
  background: radial-gradient(1200px 400px at 20% -20%, var(--hero-a) 0%, transparent 60%),
              radial-gradient(800px 300px at 90% 0%, var(--hero-b) 0%, transparent 60%);
  padding: 48px 0 24px;
  text-align: center;
}
.hero h1 { font-size: clamp(1.8rem, 4vw, 2.8rem); line-height: 1.15; letter-spacing: -0.02em; }
.resaltado { color: var(--primario); }
.hero__sub { color: var(--muted); max-width: 620px; margin: 14px auto 28px; font-size: 1.05rem; }

.buscador {
  display: flex; align-items: center; gap: 8px;
  background: var(--superficie); border: 1px solid var(--borde);
  border-radius: 16px; padding: 8px; max-width: 780px; margin: 0 auto;
  box-shadow: var(--sombra);
}
.buscador__icono { padding-left: 10px; }
.buscador input[type="text"] {
  flex: 1; border: none; outline: none; font: inherit; font-size: 1rem; padding: 10px 6px; min-width: 0;
}
.buscador__foto {
  display: flex; align-items: center; gap: 6px; cursor: pointer;
  padding: 10px 14px; border-radius: 10px; background: var(--suave); font-weight: 500; white-space: nowrap;
}
.buscador__foto:hover { background: var(--suave-hover); }

.sugerencias { margin-top: 16px; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; font-size: .875rem; color: var(--muted); }
.sugerencias a { background: var(--superficie); border: 1px solid var(--borde); padding: 4px 12px; border-radius: 999px; color: var(--texto); }
.sugerencias a:hover { border-color: var(--primario); }

/* ===== Layout principal ===== */
.layout {
  display: grid;
  grid-template-columns: 280px 1fr 320px;
  gap: 24px;
  padding: 16px 0 48px;
  align-items: start;
}

/* ===== Filtros ===== */
.filtros {
  background: var(--superficie); border: 1px solid var(--borde); border-radius: var(--radio);
  padding: 24px; box-shadow: var(--sombra);
}
.filtros h3 { font-size: .9rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 24px 0 10px; padding-top: 20px; border-top: 1px solid var(--borde); }
.filtros h3:first-child { margin-top: 0; padding-top: 0; border-top: none; }
.chip-check { display: flex; align-items: center; gap: 10px; padding: 8px 10px; margin: 0 -10px; border-radius: 8px; font-size: 1.05rem; cursor: pointer; }
.chip-check:hover { background: var(--suave); }
.chip-check input { accent-color: var(--primario); width: 18px; height: 18px; }
.punto { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.punto.amazon { background: var(--amazon); }
.punto.ml { background: var(--ml); border: 1px solid #d4c000; }
.punto.shein { background: var(--shein); }
.punto.ali { background: var(--ali); }
.punto.temu { background: var(--temu); }
.rango { display: flex; align-items: center; gap: 8px; }
.rango input { width: 100%; padding: 11px 12px; font-size: 1rem; border: 1px solid var(--borde); border-radius: 8px; font: inherit; }

/* ===== Resultados ===== */
.resultados__cabecera { display: flex; justify-content: space-between; align-items: end; gap: 12px; margin-bottom: 16px; }
.resultados__cabecera h2 { font-size: 1.25rem; }
.orden { padding: 8px 12px; border: 1px solid var(--borde); border-radius: 10px; font: inherit; background: var(--superficie); }

.tarjetas { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }

.tarjeta {
  position: relative; display: flex; flex-direction: column; gap: 12px;
  background: var(--superficie); border: 1px solid var(--borde); border-radius: var(--radio);
  padding: 14px; transition: box-shadow .2s, transform .2s;
}
.tarjeta:hover { box-shadow: var(--sombra); transform: translateY(-2px); }
.tarjeta--destacada { border: 2px solid var(--acento); box-shadow: 0 6px 24px rgba(0, 196, 140, .15); }
.tarjeta--agotado { opacity: .6; }

.insignia {
  position: absolute; top: -11px; left: 14px;
  background: var(--acento); color: #fff; font-size: .75rem; font-weight: 700;
  padding: 3px 10px; border-radius: 999px;
}
.tarjeta__img {
  height: 120px; border-radius: 10px; background: linear-gradient(135deg, var(--img-a), var(--img-b));
  display: grid; place-items: center; font-size: 3rem;
}
.tarjeta__info { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.tarjeta h4 { font-size: .95rem; font-weight: 600; line-height: 1.3; }

.tienda { align-self: start; font-size: .72rem; font-weight: 700; padding: 2px 8px; border-radius: 6px; }
.tienda--amazon { background: #fff3e0; color: #b36b00; }
.tienda--ml { background: #fff9c2; color: #6b5f00; }
.tienda--shein { background: #ececec; color: #111; }
.tienda--ali { background: #ffe5e5; color: #c62828; }
.tienda--temu { background: #ffeedd; color: #c25500; }

.precio { font-size: 1.6rem; font-weight: 800; letter-spacing: -0.02em; }
.precio small { font-size: .8rem; font-weight: 500; color: var(--muted); }

.datos { list-style: none; font-size: .85rem; color: var(--muted); display: grid; gap: 2px; }
.datos .ok { color: var(--acento); font-weight: 600; }
.datos .no { color: var(--peligro); font-weight: 600; }
.datos .lento { color: var(--aviso); }
.datos strong { color: var(--texto); }

/* ===== Asistente IA ===== */
.asistente {
  background: var(--superficie); border: 1px solid var(--borde); border-radius: var(--radio);
  display: flex; flex-direction: column; position: sticky; top: 84px; overflow: hidden;
  box-shadow: var(--sombra);
}
.asistente__cabecera {
  display: flex; align-items: center; gap: 10px; padding: 14px 16px;
  background: linear-gradient(135deg, var(--primario), #7a5cff); color: #fff;
}
.asistente__cabecera .muted { color: rgba(255,255,255,.8); font-size: .8rem; }
.asistente__avatar {
  width: 36px; height: 36px; border-radius: 50%; background: rgba(255,255,255,.2);
  display: grid; place-items: center; font-size: 1.1rem;
}

.chat { padding: 16px; display: flex; flex-direction: column; gap: 12px; min-height: 280px; font-size: .9rem; }
.msg { padding: 10px 14px; border-radius: 14px; max-width: 90%; }
.msg--usuario { align-self: end; background: var(--primario); color: #fff; border-bottom-right-radius: 4px; }
.msg--ia { align-self: start; background: var(--suave); border-bottom-left-radius: 4px; }
.msg ul { margin: 8px 0 8px 18px; }
.adjunto {
  background: rgba(255,255,255,.18); border-radius: 8px; padding: 6px 10px;
  margin-bottom: 6px; font-size: .8rem;
}

.chat__entrada { display: flex; gap: 6px; padding: 10px; border-top: 1px solid var(--borde); }
.chat__entrada input[type="text"] {
  flex: 1; border: 1px solid var(--borde); border-radius: 10px; padding: 8px 12px; font: inherit; min-width: 0;
}
.chat__adjuntar { display: grid; place-items: center; width: 38px; border-radius: 10px; background: var(--suave); cursor: pointer; }
.chat__entrada .btn { padding: 8px 14px; }

/* ===== Pie ===== */
.pie { border-top: 1px solid var(--borde); padding: 20px 0; text-align: center; color: var(--muted); font-size: .85rem; }

/* ===== Responsive ===== */
@media (max-width: 1100px) {
  .layout { grid-template-columns: 240px 1fr; }
  .asistente { grid-column: 1 / -1; position: static; }
}
@media (max-width: 720px) {
  .menu a:not(.btn) { display: none; }
  .layout { grid-template-columns: 1fr; }
  .columna-izq { position: static; }
  .buscador { flex-wrap: wrap; }
  .buscador input[type="text"] { flex-basis: calc(100% - 40px); }
  .buscador__foto, .buscador .btn { flex: 1; }
  .buscador__foto span { display: inline; }
  .resultados__cabecera { flex-direction: column; align-items: start; }
}

/* ===== Calificaciones ===== */
.calificacion { display: flex; align-items: center; gap: 2px 5px; font-size: .8rem; flex-wrap: wrap; }
.calificacion .resenas { white-space: nowrap; }
.calificacion strong { color: var(--texto); }
.resenas { color: var(--muted); }
.estrellas {
  --valor: 0%;
  position: relative; display: inline-block; font-size: .9rem; line-height: 1; letter-spacing: 0;
}
.estrellas::before { content: "★★★★★"; color: var(--estrella-vacia); }
.estrellas::after {
  content: "★★★★★"; color: #ffb400;
  position: absolute; left: 0; top: 0; width: var(--valor); overflow: hidden; white-space: nowrap;
}

/* ===== Columna izquierda + historial ===== */
.columna-izq { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 84px; }

.historial {
  background: var(--superficie); border: 1px solid var(--borde); border-radius: var(--radio);
  padding: 18px 24px;
}
.historial__cabecera { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.historial h3 { font-size: .85rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.historial__borrar { font-size: .8rem; color: var(--muted); }
.historial__borrar:hover { color: var(--peligro); }
.historial__lista { list-style: none; }
.historial__lista a {
  display: flex; align-items: center; gap: 8px; padding: 7px 8px; margin: 0 -8px;
  border-radius: 8px; font-size: .9rem;
}
.historial__lista a:hover { background: var(--suave); }
.historial__icono { font-size: .85rem; opacity: .7; }
.historial__texto { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.historial__hora { font-size: .75rem; color: var(--muted); }
.historial__ver { display: block; margin-top: 8px; font-size: .85rem; font-weight: 600; color: var(--primario); }

/* ===== Modo oscuro ===== */
:root[data-theme="dark"] {
  --fondo: #1c2230;
  --superficie: #262d3d;
  --texto: #eceff5;
  --muted: #a0a8bc;
  --borde: #3a4357;
  --primario: #4d82ff;
  --primario-osc: #6b97ff;
  --acento: #1fd39e;
  --peligro: #ff6b6f;
  --aviso: #f0a92e;
  --sombra: 0 4px 18px rgba(0, 0, 0, 0.25);
  --suave: #303849;
  --suave-hover: #394257;
  --sec-bg: #2c3a60;
  --sec-bg-hover: #354672;
  --hero-a: #26365f;
  --hero-b: #1f4442;
  --img-a: #2e3647;
  --img-b: #343d50;
  --estrella-vacia: #4b5569;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
  --fondo: #1c2230;
  --superficie: #262d3d;
  --texto: #eceff5;
  --muted: #a0a8bc;
  --borde: #3a4357;
  --primario: #4d82ff;
  --primario-osc: #6b97ff;
  --acento: #1fd39e;
  --peligro: #ff6b6f;
  --aviso: #f0a92e;
  --sombra: 0 4px 18px rgba(0, 0, 0, 0.25);
  --suave: #303849;
  --suave-hover: #394257;
  --sec-bg: #2c3a60;
  --sec-bg-hover: #354672;
  --hero-a: #26365f;
  --hero-b: #1f4442;
  --img-a: #2e3647;
  --img-b: #343d50;
  --estrella-vacia: #4b5569;
  color-scheme: dark;
  }
}
input, select { background: var(--superficie); color: var(--texto); }
.buscador input[type="text"] { background: transparent; }

/* Etiquetas de tienda en oscuro */
:root[data-theme="dark"] .tienda--amazon { background: #4a3618; color: #ffb547; }
:root[data-theme="dark"] .tienda--ml { background: #4a4418; color: #ffe94d; }
:root[data-theme="dark"] .tienda--shein { background: #3a4152; color: #e6e9f0; }
:root[data-theme="dark"] .tienda--ali { background: #4d2427; color: #ff7b7b; }
:root[data-theme="dark"] .tienda--temu { background: #4b301a; color: #ff9a4a; }
:root[data-theme="dark"] .punto.shein { background: #e6e9f0; }
:root[data-theme="dark"] .tarjeta--destacada { box-shadow: 0 6px 24px rgba(31, 211, 158, .12); }

/* Interruptor de tema (sol / luna) */
.interruptor-tema {
  position: relative; display: flex; align-items: center; justify-content: space-between;
  width: 64px; height: 32px; padding: 0 8px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--borde); background: var(--suave); font-size: .85rem;
  transition: background .25s;
}
.interruptor-tema__icono { position: relative; z-index: 1; line-height: 1; }
.interruptor-tema__perilla {
  position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%;
  background: var(--superficie); box-shadow: 0 1px 4px rgba(0,0,0,.25);
  transition: transform .25s ease;
}
:root[data-theme="dark"] .interruptor-tema { background: #34415e; }
:root[data-theme="dark"] .interruptor-tema__perilla { transform: translateX(32px); background: #4d82ff; }

/* ===== Precio en tienda y desglose ===== */
.precio-tienda { font-size: .78rem; color: var(--muted); margin-bottom: -6px; }
.precio-desglose { font-size: .75rem; color: var(--muted); line-height: 1.35; }
.precio-desglose .final { color: var(--acento); font-weight: 600; }
