:root {
  --red: #d81e05;
  --red-dark: #a81604;
  --ink: #1a1a1a;
  --ink-soft: #555;
  --line: #e6e6e6;
  --bg: #f5f6f8;
  --white: #fff;
  --green: #25d366;
  --green-dark: #1da851;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0, 0, 0, .06), 0 6px 24px rgba(0, 0, 0, .05);
  --max: 1180px;
}

* { box-sizing: border-box; }

html, body { margin: 0; overflow-x: hidden; }

body {
  font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.45;
}

a { color: inherit; }

/* ---------- Topbar ---------- */
.topbar {
  background: var(--white);
  border-bottom: 3px solid var(--red);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar__inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 18px;
}
.brand__logo { height: 46px; display: block; }
.topbar__title { display: flex; flex-direction: column; line-height: 1.2; }
.topbar__kicker {
  font-weight: 800;
  font-size: 18px;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.topbar__sub { color: var(--ink-soft); font-size: 13px; }
.topbar__store {
  margin-left: auto;
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  color: var(--red);
  white-space: nowrap;
}

/* ---------- Layout ---------- */
.layout {
  max-width: var(--max);
  margin: 0 auto;
  padding: 24px 20px 48px;
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 24px;
  align-items: start;
}
.main { display: flex; flex-direction: column; gap: 24px; min-width: 0; }

/* ---------- Cards ---------- */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}
.card__head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.card__head h2 { font-size: 18px; margin: 0; }
.step {
  display: grid;
  place-items: center;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--red);
  color: var(--white);
  font-weight: 700;
  font-size: 15px;
  flex: none;
}

/* ---------- Form ---------- */
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field--wide { grid-column: 1 / -1; }
.field label { font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.req { color: var(--red); }
.opt { color: var(--ink-soft); font-weight: 400; font-size: 12px; }
.field input, .field textarea, .select, .search {
  font: inherit;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field textarea:focus, .select:focus, .search:focus {
  outline: none;
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(216, 30, 5, .12);
}
.field input.invalid { border-color: var(--red); background: #fff6f5; }
.error { color: var(--red); font-size: 12px; min-height: 0; }
textarea { resize: vertical; }

/* ---------- Toolbar (search + filter) ---------- */
.toolbar { display: flex; gap: 12px; margin-bottom: 16px; }
.search { flex: 1; }
.select { min-width: 200px; }

/* ---------- Products ---------- */
.products {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.loading { color: var(--ink-soft); padding: 20px 0; grid-column: 1 / -1; }
.product {
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.product__media {
  aspect-ratio: 1;
  background: #fafafa;
  border-radius: 8px;
  display: grid;
  place-items: center;
  overflow: hidden;
}
.product__media img { width: 100%; height: 100%; object-fit: contain; }
.product__name { font-weight: 600; font-size: 13.5px; line-height: 1.35; }
.product__sku { font-size: 11px; color: var(--ink-soft); }
.product__foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.product__price { font-weight: 800; font-size: 16px; }
.product__price small { display: block; font-weight: 500; font-size: 10px; color: var(--ink-soft); }
.add {
  border: none;
  background: var(--red);
  color: #fff;
  font: inherit;
  font-weight: 600;
  font-size: 13px;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s;
  white-space: nowrap;
}
.add:hover { background: var(--red-dark); }
.add.added { background: var(--ink); }
.no-results { grid-column: 1 / -1; color: var(--ink-soft); padding: 16px 0; }

/* ---------- Summary ---------- */
.summary { position: sticky; top: 92px; }
.summary__card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.summary__title { font-size: 17px; margin: 0 0 14px; }
.cart { display: flex; flex-direction: column; gap: 10px; max-height: 42vh; overflow-y: auto; }
.cart__empty { color: var(--ink-soft); font-size: 13.5px; margin: 4px 0; }
.line { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; padding-bottom: 10px; border-bottom: 1px dashed var(--line); }
.line__name { font-size: 13px; font-weight: 600; }
.line__sku { font-size: 11px; color: var(--ink-soft); }
.line__sub { font-weight: 700; font-size: 14px; text-align: right; align-self: center; }
.line__ctrl { display: flex; align-items: center; gap: 8px; }
.qty { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.qty button { border: none; background: #f3f3f3; width: 26px; height: 28px; font-size: 16px; cursor: pointer; color: var(--ink); }
.qty button:hover { background: #e9e9e9; }
.qty input { width: 38px; height: 28px; border: none; text-align: center; font: inherit; font-size: 13px; }
.qty input::-webkit-outer-spin-button, .qty input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.line__unit { font-size: 11px; color: var(--ink-soft); }
.remove { border: none; background: none; color: var(--ink-soft); cursor: pointer; font-size: 16px; line-height: 1; padding: 2px 4px; }
.remove:hover { color: var(--red); }

.totals { margin-top: 16px; border-top: 2px solid var(--ink); padding-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.totals__row { display: flex; justify-content: space-between; font-size: 14px; color: var(--ink-soft); }
.totals__row span:last-child { color: var(--ink); font-weight: 600; }
.totals__row--grand { font-size: 18px; margin-top: 4px; }
.totals__row--grand span { color: var(--ink) !important; font-weight: 800 !important; }
.totals__row--grand span:last-child { color: var(--red) !important; }

.shipping { margin-top: 14px; padding: 11px 12px; border-radius: 9px; font-size: 13px; display: flex; gap: 8px; align-items: flex-start; }
.shipping--ok { background: #ecfbf1; color: #136c36; border: 1px solid #bfe9cd; }
.shipping--warn { background: #fff7ec; color: #8a5a00; border: 1px solid #ffe2b0; }
.shipping b { font-weight: 700; }

.actions { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }
.btn {
  font: inherit;
  font-weight: 700;
  font-size: 15px;
  padding: 13px 16px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  transition: background .15s, opacity .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn--primary { background: var(--red); color: #fff; }
.btn--primary:not(:disabled):hover { background: var(--red-dark); }
.btn--ghost { background: #f0f0f0; color: var(--ink); }
.btn--ghost:not(:disabled):hover { background: #e6e6e6; }
.hint { font-size: 12px; color: var(--ink-soft); margin: 10px 2px 0; text-align: center; }

/* Spinner para botones en estado de carga (acciones lentas) */
.spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  vertical-align: -2px;
  margin-right: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Footer ---------- */
.foot { text-align: center; color: var(--ink-soft); font-size: 12.5px; padding: 0 20px 30px; }
.foot a { color: var(--red); text-decoration: none; }
.foot__version { opacity: 0.6; font-variant-numeric: tabular-nums; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 14px;
  box-shadow: var(--shadow);
  z-index: 50;
  animation: rise .2s ease;
}
@keyframes rise { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .summary { position: static; }
  .grid { grid-template-columns: 1fr; }
  .topbar__sub { display: none; }
  /* Compactar la barra superior para que no se salga del marco en móvil */
  .topbar__inner { gap: 10px; padding: 10px 14px; }
  .brand__logo { height: 36px; }
  .topbar__title { min-width: 0; }
  .topbar__kicker { font-size: 15px; }
  .topbar__store {
    font-size: 12px;
    padding: 7px 10px;
    border: 1px solid var(--red);
    border-radius: 8px;
    line-height: 1;
  }
  /* Apila el buscador y el selector de categorías en vertical */
  .toolbar { flex-direction: column; }
  .select { min-width: 0; width: 100%; }
}

/* ---------- Wizard por pasos (solo móvil) ---------- */
/* Por defecto (escritorio) el wizard no aparece: se ve todo en dos columnas. */
.wizard-steps,
.wizard-nav { display: none; }

@media (max-width: 900px) {
  /* Mostrar un solo paso a la vez */
  .step-pane { display: none; }
  .step-pane.is-active { display: block; }

  /* Indicador de pasos (1 Datos · 2 Productos · 3 Resumen) */
  .wizard-steps {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 12px 14px;
    gap: 6px;
    background: var(--white);
    border-bottom: 1px solid var(--line);
  }
  .wizard-steps__item {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--ink-soft);
  }
  .wizard-steps__num {
    display: grid;
    place-items: center;
    width: 22px; height: 22px;
    border-radius: 50%;
    background: #e9e9e9;
    color: var(--ink-soft);
    font-size: 12px;
    flex: none;
  }
  .wizard-steps__item.is-current { color: var(--red); }
  .wizard-steps__item.is-current .wizard-steps__num { background: var(--red); color: #fff; }
  .wizard-steps__item.is-done { color: var(--ink); }
  .wizard-steps__item.is-done .wizard-steps__num { background: var(--ink); color: #fff; }

  /* Barra de navegación fija inferior (no se mueve con el scroll) */
  .wizard-nav {
    display: flex;
    align-items: center;
    gap: 10px;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
    background: var(--white);
    border-top: 1px solid var(--line);
    box-shadow: 0 -4px 16px rgba(0, 0, 0, .08);
    z-index: 40;
  }
  .wz-meta {
    flex: 1;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    color: var(--ink-soft);
  }
  .wz-btn {
    font: inherit;
    font-weight: 700;
    font-size: 15px;
    padding: 12px 20px;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    transition: background .15s, opacity .15s;
  }
  .wz-btn--primary { background: var(--red); color: #fff; }
  .wz-btn--primary:disabled { opacity: .45; cursor: not-allowed; }
  .wz-btn--ghost { background: #f0f0f0; color: var(--ink); }

  /* Espacio para que la barra fija no tape el contenido */
  body { padding-bottom: 92px; }

  /* En móvil el correo se envía desde la barra fija: ocultar el botón duplicado del panel */
  #btn-email { display: none; }
}
