/* ═══════════════════════════════════════════
   Todo Motos — estilos (catálogo + admin)
   Paleta tomada del logo: rojo, negro y blanco
   ═══════════════════════════════════════════ */

:root {
  --red: #e31b23;
  --red-hover: #c9141b;
  --wa: #137c3d;
  --wa-hover: #0f6a33;
  --danger: #d4232b;
  --radius: 14px;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --display: 'Oswald', 'Inter', system-ui, sans-serif;
}

:root[data-theme='dark'] {
  color-scheme: dark;
  --bg: #0c0c0d;
  --surface: #151517;
  --surface-2: #1e1e21;
  --border: #2b2b30;
  --text: #f5f5f6;
  --muted: #a0a0a8;
  --accent-text: #ff5a60;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
  --hero: radial-gradient(900px 300px at 85% -20%, rgba(227, 27, 35, 0.35), transparent 70%),
    linear-gradient(180deg, #151517, #0c0c0d);
}

:root[data-theme='light'] {
  color-scheme: light;
  --bg: #f3f3f5;
  --surface: #ffffff;
  --surface-2: #f0f0f3;
  --border: #dedee3;
  --text: #141416;
  --muted: #5f5f69;
  --accent-text: #c8141b;
  --shadow: 0 10px 28px rgba(20, 20, 25, 0.12);
  --hero: radial-gradient(900px 300px at 85% -20%, rgba(227, 27, 35, 0.16), transparent 70%),
    linear-gradient(180deg, #ffffff, #f3f3f5);
}

*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; touch-action: manipulation; } /* sin zoom por doble toque en el celular */

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
}

img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; user-select: none; }
[hidden] { display: none !important; }

:focus-visible {
  outline: 2px solid var(--accent-text);
  outline-offset: 2px;
}

.wrap { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

svg.icon { width: 22px; height: 22px; flex: none; }

/* ── Barra superior ─────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 3px solid var(--red);
}
.topbar__inner {
  max-width: 1200px; margin: 0 auto; padding: 8px 16px;
  display: flex; align-items: center; gap: 10px;
}
.brand { flex: none; display: block; }
.brand img {
  height: 46px; width: auto; border-radius: 8px; background: #fff;
}

.search {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 999px; padding: 0 14px; height: 44px; color: var(--muted);
}
.search:focus-within { border-color: var(--accent-text); }
.search input {
  flex: 1; min-width: 0; border: 0; outline: 0; background: transparent;
  color: var(--text); height: 100%;
}
.search input::placeholder { color: var(--muted); }

.icon-btn {
  position: relative; flex: none; width: 44px; height: 44px;
  display: grid; place-items: center;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 50%; color: var(--text);
  transition: border-color 0.15s, background 0.15s;
}
.icon-btn:hover { border-color: var(--accent-text); }
.badge {
  position: absolute; top: -4px; right: -4px; min-width: 20px; height: 20px;
  padding: 0 5px; display: grid; place-items: center;
  background: var(--red); color: #fff; border-radius: 999px;
  font-size: 12px; font-weight: 700; line-height: 1;
}
.badge.bump { animation: bump 0.35s ease; }
@keyframes bump { 50% { transform: scale(1.35); } }

:root[data-theme='dark'] .i-moon { display: none; }
:root[data-theme='light'] .i-sun { display: none; }

/* ── Hero ───────────────────────────────────── */
.hero { background: var(--hero); border-bottom: 1px solid var(--border); padding: 36px 0 30px; }
.eyebrow {
  margin: 0 0 6px; font-family: var(--display); font-weight: 500;
  letter-spacing: 0.18em; text-transform: uppercase; font-size: 13px; color: var(--accent-text);
}
.hero h1 {
  margin: 0 0 8px; font-family: var(--display); font-weight: 700;
  font-size: clamp(30px, 6vw, 52px); line-height: 1.05; text-transform: uppercase;
}
.hero p { margin: 0; max-width: 520px; color: var(--muted); }


/* ── Barra de herramientas ──────────────────── */
main { flex: 1; padding-bottom: 48px; }
.toolbar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 10px; padding: 22px 0 16px;
}
.toolbar p { margin: 0; }
.sort { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); }
.sort select {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 8px 10px; color: var(--text);
}

/* ── Cuadrícula y tarjetas ──────────────────── */
.grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
@media (min-width: 640px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; } }
@media (min-width: 960px) { .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

.card {
  display: flex; flex-direction: column; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
}
.card:hover { transform: translateY(-3px); border-color: var(--red); box-shadow: var(--shadow); }
.card__main {
  display: flex; flex-direction: column; flex: 1; text-align: left;
  background: none; border: 0; padding: 0;
}
.card__media, .pd__media {
  position: relative; aspect-ratio: 1; background: var(--surface-2); overflow: hidden;
}
.card__media img, .pd__media img { width: 100%; height: 100%; object-fit: contain; }
.img-fallback { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); }
.img-fallback svg { width: 48px; height: 48px; }
.tag-out {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: rgba(0, 0, 0, 0.62);
}
.tag-out span {
  background: var(--danger); color: #fff; padding: 6px 14px; border-radius: 6px;
  font-family: var(--display); letter-spacing: 0.12em; text-transform: uppercase; font-size: 13px;
}
.card__body { padding: 12px 12px 4px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.card__title {
  margin: 0; font-size: 15px; font-weight: 600; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card__meta { font-size: 12.5px; color: var(--muted); margin: 0; }
.price { font-family: var(--display); font-weight: 600; font-size: 22px; color: var(--accent-text); margin: 4px 0 0; }
.card__actions { padding: 8px 12px 12px; }

/* ── Botones ────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border-radius: 10px; border: 1px solid transparent;
  font-weight: 600; text-decoration: none; transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}
.btn--block { width: 100%; }
.btn--primary { background: var(--red); color: #fff; }
.btn--primary:hover:not(:disabled) { background: var(--red-hover); }
.btn--wa { background: var(--wa); color: #fff; }
.btn--wa:hover:not(:disabled) { background: var(--wa-hover); }
.btn--ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn--ghost:hover:not(:disabled) { border-color: var(--accent-text); }
.btn--danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn--danger:hover:not(:disabled) { background: var(--danger); color: #fff; }
.btn--sm { min-height: 36px; padding: 0 12px; font-size: 14px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Estados (cargando / vacío / error) ─────── */
.state { text-align: center; padding: 56px 16px; color: var(--muted); }
.state h2 { margin: 0 0 6px; color: var(--text); font-family: var(--display); font-size: 24px; }
.state .btn { margin-top: 14px; }
.skeleton { pointer-events: none; }
.skeleton .card__media, .skeleton .sk-line {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 50%, var(--surface-2) 75%);
  background-size: 200% 100%; animation: shimmer 1.3s infinite linear;
}
.sk-line { height: 14px; border-radius: 6px; margin: 10px 12px 0; }
.sk-line.short { width: 40%; margin-bottom: 14px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ── Diálogos (producto y carrito) ──────────── */
dialog.dialog {
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 0; border-radius: var(--radius); box-shadow: var(--shadow);
}
dialog.dialog::backdrop { background: rgba(0, 0, 0, 0.62); backdrop-filter: blur(2px); }
dialog.dialog[open] { animation: fade 0.2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } }
.dialog__close {
  position: absolute; top: 10px; right: 10px; z-index: 2; width: 40px; height: 40px;
  display: grid; place-items: center; border-radius: 50%;
  background: var(--surface-2); border: 1px solid var(--border);
}
.dialog__close:hover { border-color: var(--accent-text); }

.dialog--product { width: min(820px, calc(100vw - 24px)); max-height: 92dvh; overflow: auto; margin: auto; }
.pd { display: grid; grid-template-columns: 1fr; }
@media (min-width: 720px) { .pd { grid-template-columns: 1fr 1fr; } }
.pd__media { aspect-ratio: 1; }
.pd__body { padding: 22px; display: flex; flex-direction: column; gap: 12px; }
.pd__body h2 { margin: 0; padding-right: 36px; font-family: var(--display); font-size: 28px; line-height: 1.15; }
.meta { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 14px; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; font-weight: 600; }
.pd__body .price { font-size: 34px; margin: 0; }
.pd__buy { display: flex; flex-wrap: wrap; gap: 10px; margin-top: auto; }
.pd__buy .btn { flex: 1; min-width: 160px; }

.stepper {
  display: inline-flex; align-items: center; border: 1px solid var(--border);
  border-radius: 10px; overflow: hidden; height: 44px; background: var(--surface-2);
}
.stepper button {
  width: 40px; height: 100%; display: grid; place-items: center;
  background: transparent; border: 0;
}
.stepper button:hover:not(:disabled) { background: var(--border); }
.stepper button:disabled { opacity: 0.4; cursor: not-allowed; }
.stepper__qty { min-width: 36px; text-align: center; font-weight: 700; font-size: 16px; }
/* En las tarjetas el selector ocupa todo el ancho, igual que el botón "Agregar". */
.card__actions .stepper { display: flex; width: 100%; height: 44px; }
.card__actions .stepper button { width: 25%; min-width: 48px; }
.card__actions .stepper .stepper__qty { flex: 1; }
.stepper--sm { height: 36px; }
.stepper--sm button { width: 34px; }

dialog.dialog--cart[open] {
  display: flex; flex-direction: column;
  margin: 0 0 0 auto; height: 100dvh; max-height: none;
  width: min(440px, 100vw); border-radius: 0; border-width: 0 0 0 1px;
  animation: slide 0.25s ease;
}
@keyframes slide { from { transform: translateX(40px); opacity: 0; } }
.cart__head { padding: 18px 64px 14px 18px; border-bottom: 1px solid var(--border); }
.cart__head h2 { margin: 0; font-family: var(--display); font-size: 26px; text-transform: uppercase; }
.cart__list { flex: 1; overflow: auto; padding: 8px 18px; margin: 0; list-style: none; }
.cart__empty { flex: 1; display: grid; place-content: center; text-align: center; padding: 24px; color: var(--muted); }
.cart__empty h3 { margin: 0 0 4px; color: var(--text); font-family: var(--display); font-size: 22px; }
.cart-item { display: grid; grid-template-columns: 68px 1fr; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.cart-item__img { width: 68px; height: 68px; border-radius: 10px; overflow: hidden; background: var(--surface-2); position: relative; }
.cart-item__img img { width: 100%; height: 100%; object-fit: contain; }
.cart-item__img .img-fallback svg { width: 28px; height: 28px; }
.cart-item h3 { margin: 0; font-size: 15px; line-height: 1.3; }
.cart-item small { color: var(--muted); display: block; }
.cart-item__row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; }
.cart-item__sub { font-weight: 700; color: var(--accent-text); }
.link-btn { background: none; border: 0; color: var(--muted); text-decoration: underline; padding: 6px 0; font-size: 13px; }
.link-btn:hover { color: var(--danger); }
.cart__foot { padding: 16px 18px calc(16px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); display: grid; gap: 10px; background: var(--surface); }
.cart__total { display: flex; justify-content: space-between; align-items: baseline; font-size: 15px; }
.cart__row { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; color: var(--muted); }
.cart__row--disc { color: var(--accent-text); font-weight: 600; }
.cart__total strong { font-family: var(--display); font-size: 30px; color: var(--accent-text); }

/* ── Aviso emergente ────────────────────────── */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px);
  background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 10px;
  font-weight: 600; font-size: 14px; opacity: 0; pointer-events: none; z-index: 100;
  transition: opacity 0.2s, transform 0.2s; max-width: calc(100vw - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); color: #fff; }

/* ── Pie de página ──────────────────────────── */
.footer { border-top: 1px solid var(--border); padding: 22px 0; text-align: center; color: var(--muted); font-size: 14px; }

.footer__text { margin: 0; }

/* Acceso al panel: invisible hasta que pasas el cursor (o enfocas con el teclado) */
.admin-link {
  display: inline-block; margin-top: 6px; padding: 6px 12px;
  font-size: 12px; color: inherit; text-decoration: none;
  opacity: 0; transition: opacity 0.25s;
}
.admin-link:hover, .admin-link:focus-visible { opacity: 0.55; }

/* ═══ Panel de administración ═══ */
.login {
  width: min(400px, calc(100vw - 32px)); margin: 8vh auto 0; padding: 28px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  display: grid; gap: 16px; text-align: center;
}
.login img { height: 90px; width: auto; margin: 0 auto; border-radius: 12px; background: #fff; }
.login h1 { margin: 0; font-family: var(--display); font-size: 26px; text-transform: uppercase; }

.field { display: grid; gap: 6px; text-align: left; }
.field > span, .field > label { font-size: 14px; font-weight: 600; }
.field small { color: var(--muted); font-weight: 400; }
.input {
  width: 100%; min-height: 46px; padding: 0 14px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 10px; color: var(--text);
}
.input:focus { outline: 0; border-color: var(--accent-text); }
.error-msg { color: var(--danger); font-size: 14px; margin: 0; min-height: 1.4em; font-weight: 600; }

.grow { flex: 1; }
.stack { display: grid; gap: 10px; }

.admin { padding: 22px 0 56px; display: grid; gap: 22px; }
.admin__bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.admin__bar h1 { margin: 0; font-family: var(--display); font-size: 28px; text-transform: uppercase; }
.admin__bar .actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.panel h2 { margin: 0 0 14px; font-family: var(--display); font-size: 22px; text-transform: uppercase; }
.form-grid { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 720px) { .form-grid { grid-template-columns: 1fr 1fr; } .span-2 { grid-column: 1 / -1; } }
.preview {
  width: 140px; height: 140px; border-radius: 12px; overflow: hidden; background: var(--surface-2);
  border: 1px dashed var(--border); position: relative;
}
.preview img { width: 100%; height: 100%; object-fit: contain; }
.image-row { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 600; min-height: 44px; }
.check input { width: 20px; height: 20px; accent-color: var(--red); }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.list { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.row {
  display: grid; grid-template-columns: 64px 1fr; gap: 12px; align-items: center;
  padding: 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px;
}
.row__img { width: 64px; height: 64px; border-radius: 10px; overflow: hidden; position: relative; background: var(--surface); }
.row__img img { width: 100%; height: 100%; object-fit: contain; }
.row__img .img-fallback svg { width: 26px; height: 26px; }
.row h3 { margin: 0; font-size: 15px; line-height: 1.3; }
.row small { color: var(--muted); display: block; }
.row__tools { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; }
.row__tools .btns { display: flex; gap: 8px; }
@media (min-width: 720px) {
  .row { grid-template-columns: 64px 1fr auto; }
  .row__tools { grid-column: auto; flex-wrap: nowrap; gap: 18px; }
}
.switch { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; cursor: pointer; min-height: 36px; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { width: 42px; height: 24px; border-radius: 999px; background: var(--border); position: relative; transition: background 0.15s; }
.switch .track::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px;
  border-radius: 50%; background: #fff; transition: transform 0.15s;
}
.switch input:checked + .track { background: var(--danger); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent-text); outline-offset: 2px; }

/* Fotos de producto: siempre completas (object-fit: contain, nunca recortadas) sobre fondo blanco */
.card__media, .pd__media, .cart-item__img, .row__img, .preview { background: #fff; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
