/* ==========================================================================
   MafriTienda — diseño mobile-first, colorido y vivo
   ========================================================================== */

:root {
  /* base clara tipo tienda online */
  --bg: #f6f5ff;
  --surface: #ffffff;
  --surface-2: #f2f1fb;
  --line: #e6e3f7;
  --txt: #1b1533;
  --muted: #6f6a8f;

  /* marca: degradado-violeta → fucsia → naranja */
  --brand: #7c3aed;
  --brand-2: #d946ef;
  --brand-3: #fb7185;
  --brand-4: #fbbf24;
  --grad: linear-gradient(115deg, #7c3aed 0%, #d946ef 45%, #fb7185 100%);
  --grad-soft: linear-gradient(115deg, #ede9fe 0%, #fae8ff 50%, #ffe4e6 100%);
  --grad-sun: linear-gradient(115deg, #fbbf24 0%, #fb7185 100%);

  --ok: #10b981;
  --danger: #ef4444;
  --warn: #f59e0b;

  --radius: 18px;
  --radius-sm: 13px;
  --shadow-sm: 0 1px 2px rgba(27, 21, 51, .06), 0 4px 12px rgba(124, 58, 237, .07);
  --shadow: 0 6px 24px rgba(124, 58, 237, .14);
  --shadow-lg: 0 18px 50px rgba(124, 58, 237, .25);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--txt);
  font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Roboto, sans-serif;
  line-height: 1.5;
  padding-bottom: var(--safe-b);
  overflow-x: hidden;
}

/* fondo con manchas de color suaves */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(60vw 40vh at 12% -8%, rgba(124, 58, 237, .18), transparent 65%),
    radial-gradient(55vw 38vh at 92% 2%, rgba(251, 113, 133, .16), transparent 62%),
    radial-gradient(50vw 40vh at 50% 105%, rgba(251, 191, 36, .16), transparent 65%);
}

img { max-width: 100%; }
a { color: var(--brand); }

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px 120px; }

/* ------------------------------------------------------------------ HERO */

.hero {
  position: relative;
  overflow: hidden;
  background: var(--grad);
  padding: calc(28px + var(--safe-t)) 16px 34px;
  padding-top: max(28px, calc(28px + var(--safe-t)));
  border-radius: 0 0 34px 34px;
  box-shadow: var(--shadow);
  isolation: isolate;
}

/* burbujas animadas de fondo */
.hero::before,
.hero::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  filter: blur(2px);
  z-index: -1;
  animation: float 14s ease-in-out infinite;
}
.hero::before {
  width: 230px; height: 230px;
  top: -90px; right: -60px;
  background: radial-gradient(circle, rgba(251, 191, 36, .55), transparent 65%);
}
.hero::after {
  width: 200px; height: 200px;
  bottom: -110px; left: -50px;
  background: radial-gradient(circle, rgba(56, 189, 248, .45), transparent 65%);
  animation-delay: -7s;
}

@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(-14px, 18px) scale(1.12); }
}

.hero-inner { max-width: 1180px; margin: 0 auto; position: relative; }

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: rgba(255, 255, 255, .22);
  border: 1px solid rgba(255, 255, 255, .35);
  backdrop-filter: blur(6px);
  color: #fff;
  font-size: .74rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  padding: 6px 13px;
  border-radius: 999px;
  margin-bottom: 12px;
}
.hero-badge .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 0 0 rgba(74, 222, 128, .7);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  70% { box-shadow: 0 0 0 9px rgba(74, 222, 128, 0); }
  100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0); }
}

.hero h1 {
  margin: 0 0 8px;
  font-size: clamp(1.75rem, 7vw, 2.9rem);
  line-height: 1.06;
  font-weight: 800;
  color: #fff;
  letter-spacing: -.02em;
  text-shadow: 0 3px 18px rgba(76, 29, 149, .35);
}

.hero p {
  margin: 0;
  color: rgba(255, 255, 255, .93);
  font-size: .98rem;
  max-width: 46ch;
  white-space: pre-wrap;
}

.hero-stats {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  flex-wrap: wrap;
}
.hero-stat {
  background: rgba(255, 255, 255, .18);
  border: 1px solid rgba(255, 255, 255, .3);
  backdrop-filter: blur(6px);
  border-radius: 12px;
  padding: 7px 13px;
  color: #fff;
  font-size: .8rem;
  font-weight: 700;
}

/* buscador */
.searchbar { position: relative; margin-top: 20px; }
.searchbar input {
  width: 100%;
  background: rgba(255, 255, 255, .97);
  border: 2px solid transparent;
  border-radius: 16px;
  padding: 15px 16px 15px 46px;
  font-size: 1rem;
  color: var(--txt);
  box-shadow: var(--shadow);
  min-height: 54px;
}
.searchbar input:focus {
  outline: none;
  border-color: var(--brand-3);
  box-shadow: 0 0 0 4px rgba(251, 113, 133, .25), var(--shadow);
}
.searchbar .ico {
  position: absolute;
  left: 15px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.1rem;
  opacity: .5;
  pointer-events: none;
}

/* ----------------------------------------------------------------- CHIPS */

.filters {
  display: flex;
  gap: 9px;
  overflow-x: auto;
  padding: 18px 16px 4px;
  margin: 0 -16px;
  scrollbar-width: none;
}
.filters::-webkit-scrollbar { display: none; }

.chip {
  flex: 0 0 auto;
  padding: 9px 17px;
  border-radius: 999px;
  border: 2px solid transparent;
  background: var(--surface);
  color: var(--muted);
  font-size: .87rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
  transition: transform .15s, box-shadow .15s;
}
.chip:active { transform: scale(.95); }
.chip[aria-pressed="true"] {
  background: var(--grad);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 6px 18px rgba(217, 70, 239, .38);
}

/* --------------------------------------------------------------- GRID */

.products {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
  padding: 16px 0 0;
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
  border: 2px solid transparent;
  cursor: pointer;
  animation: rise .38s cubic-bezier(.2, .8, .3, 1) backwards;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s;
}
.card:hover { transform: translateY(-4px); box-shadow: var(--shadow); border-color: #e9d5ff; }
.card:active { transform: scale(.98); }

@keyframes rise {
  from { opacity: 0; transform: translateY(14px) scale(.97); }
}

.card-img {
  position: relative;
  aspect-ratio: 1 / 1;
  background: var(--grad-soft);
  overflow: hidden;
}
.card-img img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  transition: transform .4s ease;
}
.card:hover .card-img img { transform: scale(1.07); }
.card-img .ph {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  padding: 22%;
}

.card-tag {
  position: absolute;
  top: 8px; left: 8px;
  background: rgba(255, 255, 255, .92);
  color: var(--brand);
  font-size: .68rem;
  font-weight: 800;
  padding: 4px 9px;
  border-radius: 999px;
  letter-spacing: .02em;
}

.card-off {
  position: absolute;
  inset: 0;
  background: rgba(27, 21, 51, .58);
  backdrop-filter: blur(1px);
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 800;
  font-size: .8rem;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.card-body { padding: 11px 12px 14px; display: flex; flex-direction: column; gap: 5px; flex: 1; }

.card-name {
  font-weight: 700;
  font-size: .93rem;
  line-height: 1.28;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-desc {
  font-size: .79rem;
  color: var(--muted);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-price {
  margin-top: auto;
  padding-top: 7px;
  font-size: 1.12rem;
  font-weight: 800;
  letter-spacing: -.01em;
  background: var(--grad-sun);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.card-meta { font-size: .73rem; color: var(--muted); font-weight: 600; }

.badges { display: flex; gap: 5px; flex-wrap: wrap; }
.badge {
  font-size: .67rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
}
.badge.on { background: #d1fae5; color: #047857; }
.badge.off { background: #fef3c7; color: #b45309; }

/* --------------------------------------------------------------- MODAL */

.sheet { position: fixed; inset: 0; z-index: 60; display: none; }
.sheet.open { display: block; }

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(27, 21, 51, .55);
  backdrop-filter: blur(3px);
  animation: fade .2s;
}
@keyframes fade { from { opacity: 0; } }

.sheet-panel {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  max-height: 93vh;
  overflow-y: auto;
  background: var(--bg);
  border-radius: 26px 26px 0 0;
  padding: 10px 16px calc(28px + var(--safe-b));
  animation: slideup .26s cubic-bezier(.2, .8, .3, 1);
  box-shadow: var(--shadow-lg);
}
.sheet-panel::before {
  content: "";
  display: block;
  width: 44px; height: 5px;
  border-radius: 999px;
  background: var(--line);
  margin: 0 auto 14px;
}
.sheet-panel.full { top: 0; border-radius: 0; max-height: 100%; padding-top: 18px; }

@keyframes slideup { from { transform: translateY(40px); opacity: .5; } }

.sheet-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  padding-top: 6px;
}
.sheet-head h2 { margin: 0; font-size: 1.1rem; font-weight: 800; flex: 1; }

@media (min-width: 760px) {
  .sheet { display: flex; align-items: center; justify-content: center; padding: 20px; }
  .sheet-panel {
    position: relative;
    max-width: 760px;
    width: 94vw;
    max-height: 88vh;
    border-radius: 24px;
    padding: 24px;
  }
  .sheet-panel::before { display: none; }
}

/* ------------------------------------------------------------- FOTOS */

.photos { display: flex; gap: 9px; overflow-x: auto; padding: 4px 2px 8px; }
.photo-item {
  position: relative;
  flex: 0 0 auto;
  width: 96px; height: 96px;
  border-radius: 14px;
  overflow: hidden;
  border: 2px solid var(--line);
  background: var(--grad-soft);
}
.photo-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-item .del {
  position: absolute;
  top: 4px; right: 4px;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: rgba(239, 68, 68, .92);
  color: #fff;
  border: 0;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .3);
}
.photo-item.cover { border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(217, 70, 239, .2); }
.photo-item.cover::after {
  content: "Portada";
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: var(--grad);
  color: #fff;
  font-size: .6rem;
  font-weight: 800;
  text-align: center;
  padding: 2px;
  letter-spacing: .03em;
}

/* ------------------------------------------------------------- BOTONES */

.btn {
  appearance: none;
  border: 2px solid transparent;
  background: var(--surface);
  color: var(--txt);
  border-radius: 15px;
  padding: 12px 18px;
  font-size: .95rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  box-shadow: var(--shadow-sm);
  transition: transform .14s, box-shadow .14s, filter .14s;
}
.btn:hover { box-shadow: var(--shadow); }
.btn:active { transform: translateY(2px) scale(.98); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }

.btn.primary { background: var(--grad); color: #fff; }
.btn.ok { background: var(--grad-sun); color: #4a1d0a; }
.btn.ghost { background: transparent; box-shadow: none; color: var(--muted); }
.btn.danger { background: #fef2f2; color: var(--danger); border-color: #fecaca; box-shadow: none; }
.btn.block { width: 100%; }
.btn.lg { min-height: 56px; font-size: 1.03rem; }

.fab {
  position: fixed;
  right: 16px;
  bottom: calc(18px + var(--safe-b));
  z-index: 40;
  height: 58px;
  padding: 0 24px;
  border-radius: 999px;
  background: var(--grad);
  color: #fff;
  border: 0;
  font-size: 1rem;
  font-weight: 800;
  font-family: inherit;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  animation: bob 2.6s ease-in-out infinite;
}
.fab:active { transform: scale(.95); }
@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

/* -------------------------------------------------------------- CAMPOS */

.field { margin-bottom: 15px; }

label {
  display: block;
  font-size: .78rem;
  font-weight: 800;
  color: var(--muted);
  margin: 0 0 7px;
  letter-spacing: .03em;
  text-transform: uppercase;
}

input, select, textarea {
  width: 100%;
  background: var(--surface);
  border: 2px solid var(--line);
  color: var(--txt);
  border-radius: var(--radius-sm);
  padding: 14px;
  font-size: 1rem;
  font-family: inherit;
  min-height: 50px;
  transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 100px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand-2);
  box-shadow: 0 0 0 4px rgba(217, 70, 239, .14);
}

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.stack { display: flex; flex-direction: column; gap: 11px; }
.hint { font-size: .78rem; color: var(--muted); margin-top: 6px; line-height: 1.4; }

.check {
  display: flex;
  align-items: center;
  gap: 11px;
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 13px 14px;
  cursor: pointer;
  font-size: .92rem;
  font-weight: 700;
  color: var(--txt);
  text-transform: none;
  letter-spacing: 0;
}
.check input { width: 24px; height: 24px; min-height: 24px; flex: 0 0 auto; accent-color: var(--brand-2); }

/* ------------------------------------------------------------- MENSAJES */

.msg {
  padding: 13px 15px;
  border-radius: var(--radius-sm);
  font-size: .88rem;
  margin-bottom: 14px;
  font-weight: 600;
  border: 2px solid;
  animation: rise .25s;
}
.msg.error { background: #fef2f2; border-color: #fecaca; color: #b91c1c; }
.msg.ok { background: #ecfdf5; border-color: #a7f3d0; color: #047857; }

.empty { text-align: center; padding: 56px 20px; color: var(--muted); grid-column: 1 / -1; }
.empty .emo { font-size: 2.4rem; display: block; margin-bottom: 10px; line-height: 1.2; }
.empty .emo svg { width: 64px; height: 64px; stroke: #c4b5fd; }
.empty h2 { color: var(--txt); font-size: 1.12rem; margin: 0 0 6px; font-weight: 800; }
.empty p { margin: 0; }

.spinner { color: var(--muted); text-align: center; padding: 40px; grid-column: 1 / -1; }

.skeleton { border-radius: var(--radius); overflow: hidden; background: var(--grad-soft); aspect-ratio: 3/4; }
.skeleton::after {
  content: "";
  display: block;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .65), transparent);
  animation: shimmer 1.3s infinite;
}
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }

/* --------------------------------------------------------------- PIE */

.foot {
  text-align: center;
  color: var(--muted);
  font-size: .84rem;
  padding: 26px 0 10px;
  white-space: pre-wrap;
  line-height: 1.6;
}
.foot .tag {
  display: inline-block;
  margin-top: 12px;
  background: var(--grad-soft);
  border: 1px solid #e9d5ff;
  color: var(--brand);
  font-weight: 700;
  font-size: .78rem;
  padding: 5px 13px;
  border-radius: 999px;
}

/* ficha ampliada del producto */
.detail-hero {
  border-radius: 20px;
  overflow: hidden;
  box-shadow: var(--shadow);
  background: var(--grad-soft);
}
.detail-hero img { width: 100%; display: block; aspect-ratio: 1/1; object-fit: cover; }
.detail-price {
  font-size: 1.6rem;
  font-weight: 800;
  margin: 16px 0 10px;
  background: var(--grad-sun);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.detail-body { line-height: 1.6; white-space: pre-wrap; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}