/* =====================================================================
 *  LA FICHA · Catálogo web (mayorista / tienda)  —  styles.css
 *  Mobile-first. Sin frameworks. Tema claro, limpio y elegante.
 * ===================================================================== */

:root {
  --brand: #d9a521;
  --brand-700: #9a6d08;
  --brand-soft: #fbf3dd;
  --brand-ink: #2b1f00;
  --brand-hover: #e6b62f;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --line: #e6e9ee;
  --bg: #f5f6f8;
  --card: #ffffff;
  --wa: #25d366;
  --wa-dark: #1eae55;
  --danger: #dc2626;
  --amber: #8a6100;
  --radius: 16px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 10px 26px -16px rgba(15, 23, 42, .22);
  --shadow-lg: 0 24px 55px -22px rgba(15, 23, 42, .4);
  --wrap: 1180px;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, "Apple Color Emoji", sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

img { display: block; max-width: 100%; }
button { font-family: inherit; }
[hidden] { display: none !important; }

.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin-inline: auto;
  padding-inline: 16px;
}

.muted { color: var(--muted); }

/* ----------------------------- CABECERA ---------------------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}

.bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-block: 10px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
  margin-right: auto;
  min-width: 0;
}
.brand-logo {
  flex: none;
  height: 44px;
  width: auto;
  object-fit: contain;
  border-radius: 8px;
}
.brand-mark { display: none; }
.brand-txt { display: flex; flex-direction: column; line-height: 1.1; min-width: 0; }
.brand-txt strong { font-size: 15px; letter-spacing: .6px; }
.brand-txt small { font-size: 11px; color: var(--muted); font-weight: 600; }

.cartbtn {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 0;
  border-radius: 12px;
  padding: 10px 14px;
  background: var(--brand);
  color: var(--brand-ink);
  font-weight: 700;
  font-size: 13.5px;
  cursor: pointer;
  transition: background .15s, transform .1s;
}
.cartbtn:hover { background: var(--brand-hover); }
.cartbtn:active { transform: scale(.97); }
.cartbtn .count {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 999px;
  background: #f59e0b;
  color: #1f2937;
  font-size: 11px;
  font-weight: 800;
  display: grid;
  place-items: center;
  border: 2px solid #fff;
}

.searchrow { padding-bottom: 10px; }
.searchbox {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8fafc;
  color: var(--muted);
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.searchbox:focus-within {
  border-color: var(--brand);
  background: #fff;
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.searchbox input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  font-size: 15px;
  color: var(--ink);
  outline: none;
  padding: 0;
}
.searchbox input::-webkit-search-cancel-button { display: none; }
.clear {
  border: 0;
  background: #e2e8f0;
  color: var(--ink-2);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.chipsbar { border-top: 1px solid var(--line); }
.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-block: 10px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink-2);
  font-size: 13.5px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, color .15s, border-color .15s;
}
.chip:hover { border-color: #cbd5e1; }
.chip.active { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }

/* ------------------------------ HÉROE ------------------------------ */
.main { padding-top: 18px; padding-bottom: 30px; }
.hero h1 { margin: 0 0 6px; font-size: clamp(21px, 4.4vw, 30px); letter-spacing: -.4px; }
.hero p { margin: 0; color: var(--muted); font-size: 14.5px; max-width: 640px; }

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 16px 0 12px;
  font-size: 13px;
  color: var(--muted);
}
.results b { color: var(--ink); }

/* ------------------------------ REJILLA ---------------------------- */
.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
@media (min-width: 540px) { .grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 820px) { .grid { grid-template-columns: repeat(4, 1fr); gap: 14px; } }
@media (min-width: 1080px) { .grid { grid-template-columns: repeat(5, 1fr); } }

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform .16s ease, box-shadow .18s ease;
}
.card:hover { transform: translateY(-3px); box-shadow: 0 14px 34px -18px rgba(15, 23, 42, .3); }

.thumb { position: relative; aspect-ratio: 1 / 1; background: #eef2f6; overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.ph {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  background: linear-gradient(140deg, #eef2f6, #e2e8f2);
  color: #b6c0cd;
  position: relative;
}
.ph .ph-letters { font-size: 30px; font-weight: 800; letter-spacing: 1px; opacity: .55; }
.badge {
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(15, 23, 42, .74);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .3px;
  padding: 3px 8px;
  border-radius: 999px;
}
.badge.out { background: rgba(154, 109, 8, .95); }

.card-body {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 10px 11px 12px;
  flex: 1;
}
.name {
  margin: 0;
  font-size: 13.5px;
  font-weight: 700;
  line-height: 1.28;
  color: var(--ink);
  min-height: 2.5em;
  overflow-wrap: anywhere;
}
.meta { margin: 0; font-size: 11px; color: var(--muted); display: flex; gap: 6px; flex-wrap: wrap; }
.ref { font-variant-numeric: tabular-nums; }
.det {
  margin: 0;
  font-size: 12.5px;
  color: #4b5563;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 4.2em;
}
.det.open {
  -webkit-line-clamp: unset;
  display: block;
  overflow: visible;
  min-height: 0;
}
.det-more {
  align-self: flex-start;
  border: 0;
  background: none;
  color: var(--brand-700);
  font-size: 11.5px;
  font-weight: 800;
  line-height: 1;
  padding: 0;
  margin-top: 1px;
  cursor: pointer;
  text-decoration: underline;
}
.det-more:hover { color: var(--brand); }
.cardfoot {
  margin-top: auto;
  padding-top: 10px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}
.cardfoot .price { min-width: 0; }
.cardfoot .actions { display: flex; }
.cardfoot .actions .addbtn { width: 100%; justify-content: center; }
.cardfoot .actions .stepper { width: 100%; justify-content: space-between; }
.cardfoot .actions .stepper .qty { flex: 1; }
.cardfoot .actions .stepper .qty-input { flex: 1; width: auto; min-width: 38px; max-width: 90px; }
.cardbody { display: flex; flex-direction: column; gap: 6px; flex: 1; padding: 10px 11px 12px; }
.small { font-size: 12px; }
.price { font-size: 15.5px; font-weight: 800; color: var(--brand-700); letter-spacing: -.3px; }
.price small { display: block; font-size: 10.5px; font-weight: 600; color: var(--muted); letter-spacing: 0; }
.minhint {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  color: var(--amber);
  background: #fffbeb;
  border: 1px solid #fde68a;
  padding: 1px 6px;
  border-radius: 999px;
  margin-top: 3px;
}

.addbtn {
  border: 0;
  background: var(--brand);
  color: var(--brand-ink);
  font-weight: 700;
  font-size: 13px;
  padding: 9px 13px;
  border-radius: 11px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  transition: background .15s, transform .1s;
}
.addbtn:hover { background: var(--brand-hover); }
.addbtn:active { transform: scale(.96); }
.addbtn:disabled { opacity: .6; cursor: default; }

.stepper {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 11px;
  overflow: hidden;
  background: #fff;
}
.stepbtn {
  width: 32px;
  height: 34px;
  border: 0;
  background: #fff;
  color: var(--brand-700);
  font-size: 18px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.stepbtn:hover { background: var(--brand-soft); }
.stepbtn:disabled { color: #cbd5e1; cursor: not-allowed; }
.qty { min-width: 34px; text-align: center; font-weight: 700; font-size: 13.5px; font-variant-numeric: tabular-nums; }

/* Esqueleto */
.skcard {
  aspect-ratio: 3 / 4.1;
  border-radius: var(--radius);
  background: linear-gradient(100deg, #eceff3 30%, #f7f9fb 50%, #eceff3 70%);
  background-size: 220% 100%;
  animation: shimmer 1.2s infinite linear;
}
@keyframes shimmer { to { background-position: -220% 0; } }

/* Vacío / más */
.empty { text-align: center; padding: 48px 16px; color: var(--muted); }
.empty svg { opacity: .4; margin-bottom: 8px; }
.more-wrap { text-align: center; margin: 20px 0; }

/* ------------------------------ BOTONES ---------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 14px;
  padding: 10px 16px;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, border-color .15s, transform .1s, box-shadow .15s;
}
.btn:active { transform: scale(.98); }
.btn.ghost { background: #fff; border-color: var(--line); color: var(--ink-2); }
.btn.ghost:hover { border-color: #cbd5e1; background: #fbfcfd; }
.btn.primary { background: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { background: var(--brand-hover); }
.btn.wa { background: var(--wa); color: #fff; }
.btn.wa:hover { background: var(--wa-dark); }
.btn.block { width: 100%; }
.btn.lg { padding: 14px 18px; font-size: 15px; border-radius: 13px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ------------------------------ PIE -------------------------------- */
.foot { border-top: 1px solid var(--line); background: #fff; margin-top: 20px; padding: 22px 0 30px; font-size: 13px; }
.foot p { margin: 3px 0; }

/* -------------------------- BARRA INFERIOR ------------------------- */
.sumbar {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom));
  z-index: 60;
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 0;
  border-radius: 14px;
  padding: 13px 16px;
  background: var(--ink);
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
}
.sumbar b { color: #fff; }
.sumbar-right { font-weight: 700; }
.sumbar-right b { color: #f2d16b; }
@media (max-width: 760px) {
  .sumbar.open { display: flex; }
}

/* ------------------------------ DRAWER ----------------------------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 105;
  background: rgba(15, 23, 42, .45);
  opacity: 0;
  visibility: hidden;
  transition: opacity .25s, visibility .25s;
}
.overlay.show { opacity: 1; visibility: visible; }

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 110;
  height: 100dvh;
  width: min(420px, 100%);
  background: #fff;
  display: flex;
  flex-direction: column;
  transform: translateX(102%);
  transition: transform .28s cubic-bezier(.4, 0, .2, 1);
  box-shadow: var(--shadow-lg);
}
.drawer.open { transform: none; }

#cliNombre:invalid:not(:placeholder-shown) { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(220,38,38,.12); }

.drawer-head {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.drawer-head h2 { margin: 0; font-size: 17px; }

.xbtn {
  border: 0;
  background: #f1f5f9;
  color: var(--ink-2);
  width: 36px;
  height: 36px;
  border-radius: 11px;
  font-size: 21px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.xbtn:hover { background: #e2e8f0; }

.drawer-body { flex: 1; overflow-y: auto; padding: 4px 16px 10px; }
.drawer-foot {
  flex: none;
  border-top: 1px solid var(--line);
  padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
  background: #fcfdfe;
}

.cart-empty { text-align: center; color: var(--muted); padding: 50px 16px; }
.cart-empty svg { opacity: .4; margin-bottom: 10px; }

.cartitem {
  display: grid;
  grid-template-columns: 54px 1fr auto;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  align-items: start;
}
.cartitem:last-child { border-bottom: 0; }
.ci-thumb {
  width: 54px;
  height: 54px;
  border-radius: 10px;
  overflow: hidden;
  background: #f1f5f9;
  color: #94a3b8;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 16px;
}
.ci-thumb img { width: 100%; height: 100%; object-fit: cover; }
.ci-info { min-width: 0; }
.ci-name { font-size: 13.5px; font-weight: 700; line-height: 1.25; }
.ci-price { font-size: 12px; color: var(--muted); margin-top: 2px; }
.ci-total { font-weight: 800; color: var(--brand-700); font-size: 13.5px; white-space: nowrap; }
.ci-actions { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.ci-remove { border: 0; background: none; color: var(--danger); font-size: 12.5px; font-weight: 600; cursor: pointer; padding: 2px 0; }
.ci-remove:hover { text-decoration: underline; }

.qty-input {
  width: 52px;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 6px 4px;
  font-weight: 700;
  font-size: 13.5px;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  min-width: 0;
}
.qty-input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.stepper .qty-input {
  width: 46px;
  min-width: 34px;
  border: 0;
  border-radius: 0;
  background: #fff;
  padding: 0 2px;
  height: 34px;
  text-align: center;
}
.stepper .qty-input:focus { box-shadow: none; background: var(--brand-soft); }

.cart-tot { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; font-size: 15px; }
.cart-tot b { font-size: 20px; color: var(--brand-700); letter-spacing: -.4px; }
.stock-warn { font-size: 11.5px; color: var(--amber); margin-top: 3px; }

/* ------------------------------ MODALES ---------------------------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(15, 23, 42, .5);
  backdrop-filter: blur(2px);
  overflow-y: auto;
}
.modal-card {
  width: min(460px, 100%);
  background: #fff;
  border-radius: 18px;
  padding: 18px;
  box-shadow: var(--shadow-lg);
  animation: pop .2s ease;
}
@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.modal-head h2 { margin: 0; font-size: 18px; }

.field { display: block; margin-bottom: 12px; }
.field > span { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field > span b { color: var(--danger); }
.field > span small { color: var(--muted); font-weight: 500; }
.field input,
.field textarea {
  width: 100%;
  margin-top: 6px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfcfd;
  font-size: 15px;
  font-family: inherit;
  color: var(--ink);
  resize: vertical;
}
.field input:focus,
.field textarea:focus { outline: none; border-color: var(--brand); background: #fff; box-shadow: 0 0 0 3px var(--brand-soft); }

.mini-cart { border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; max-height: 168px; overflow-y: auto; margin: 4px 0 12px; }
.mini-row { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; padding: 5px 0; border-bottom: 1px dashed var(--line); }
.mini-row:last-child { border-bottom: 0; }
.mini-row .mn { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-row .mv { color: var(--muted); flex: none; }

.modal-total { display: flex; align-items: baseline; justify-content: space-between; border-top: 1px solid var(--line); padding-top: 10px; margin-bottom: 12px; font-size: 15px; }
.modal-total b { font-size: 20px; color: var(--brand-700); }
.form-error { color: var(--danger); background: #fef2f2; border: 1px solid #fecaca; border-radius: 10px; padding: 9px 11px; font-size: 13px; margin: 0 0 10px; }
.legal { font-size: 11.5px; color: var(--muted); text-align: center; margin: 10px 0 0; }

.success-card { text-align: center; }
.check-badge { width: 64px; height: 64px; margin: 6px auto 12px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-700); display: grid; place-items: center; }
.success-card h2 { margin: 0 0 4px; font-size: 20px; }
.success-num { margin: 0 0 6px; }
.success-num b { color: var(--brand-700); font-size: 17px; }
.success-card .btn { margin-top: 14px; }

/* ------------------------------ AVISOS ----------------------------- */
.toasts {
  position: fixed;
  left: 50%;
  bottom: calc(84px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
  width: max-content;
  max-width: calc(100vw - 24px);
}
@media (min-width: 761px) { .toasts { bottom: 24px; } }
.toast {
  background: var(--ink);
  color: #fff;
  font-size: 13.5px;
  font-weight: 600;
  padding: 10px 15px;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  border-left: 4px solid #64748b;
  animation: toastIn .2s ease;
}
.toast.ok { border-left-color: var(--brand); }
.toast.err { border-left-color: var(--danger); }
.toast.fade { animation: toastOut .25s ease forwards; }
@keyframes toastIn { from { transform: translateY(10px); opacity: 0; } }
@keyframes toastOut { to { transform: translateY(10px); opacity: 0; } }

.hint-tap { display: none; }
@media (min-width: 761px) { .hint-tap { display: inline; } }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
