/* ==========================================================
   Aestheramed · base compartida (tokens de marca, botones, formularios)
   Paleta y tipografía según la Guía de identidad v1.0
   ========================================================== */
:root {
  --plum: #75455F;          /* Ciruela: marca, títulos y botones */
  --plum-600: #683B53;
  --plum-700: #5A3248;
  --plum-50: #F4ECF0;
  --ivory: #F7F3F0;         /* Marfil: fondos cálidos */
  --rose: #E8D6DE;          /* Rosa empolvado: tarjetas y acentos */
  --rose-200: #F0E4E9;
  --graphite: #302B30;      /* Grafito: textos y datos */
  --muted: #6B6168;
  --line: #E7DDE2;
  --white: #FFFFFF;
  --ok: #3F7A5C;  --ok-bg: #E6F0EA;
  --warn: #8A5A12; --warn-bg: #F7EBD6;
  --bad: #A23B4B;  --bad-bg: #F6E3E6;
  --wa: #1F9D55;

  --font: Arial, "Helvetica Neue", Helvetica, sans-serif;
  --r-sm: 10px; --r: 16px; --r-lg: 24px;
  --shadow-sm: 0 1px 2px rgba(48, 43, 48, .06), 0 2px 8px rgba(48, 43, 48, .04);
  --shadow: 0 10px 30px -12px rgba(48, 43, 48, .22), 0 2px 6px rgba(48, 43, 48, .05);
  --shadow-lg: 0 24px 60px -20px rgba(48, 43, 48, .35);
  --ease: cubic-bezier(.2, .7, .2, 1);
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; background: var(--ivory); color: var(--graphite);
  font-family: var(--font); font-size: 16px; line-height: 1.5;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
img, svg { display: block; max-width: 100%; }
[hidden]:not(.cartbar) { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
h1, h2, h3, h4 { margin: 0; line-height: 1.15; font-weight: 400; letter-spacing: -.01em; }
p { margin: 0; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--plum) 45%, transparent); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.wrap { width: min(1180px, 100% - 32px); margin-inline: auto; }
.ico { width: 22px; height: 22px; flex: none; }
.ico svg { width: 100%; height: 100%; }

/* ---------- Botones ---------- */
.btn {
  --h: 48px;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: var(--h); padding: 0 22px; border-radius: 999px; border: 1.5px solid transparent;
  font-weight: 700; font-size: 16px; text-decoration: none; cursor: pointer; user-select: none;
  transition: background .2s var(--ease), color .2s var(--ease), border-color .2s var(--ease), transform .15s var(--ease), box-shadow .2s;
  white-space: nowrap;
}
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .55; cursor: not-allowed; transform: none; }
.btn .ico { width: 20px; height: 20px; }
.btn-primary { background: var(--plum); color: var(--white); }
.btn-primary:hover { background: var(--plum-700); }
.btn-outline { background: transparent; color: var(--plum); border-color: color-mix(in srgb, var(--plum) 35%, transparent); }
.btn-outline:hover { border-color: var(--plum); background: var(--plum-50); }
.btn-soft { background: var(--plum-50); color: var(--plum); }
.btn-soft:hover { background: var(--rose); }
.btn-ghost { background: transparent; color: var(--graphite); }
.btn-ghost:hover { background: rgba(48, 43, 48, .05); }
.btn-white { background: var(--white); color: var(--plum); }
.btn-danger { background: var(--bad-bg); color: var(--bad); }
.btn-danger:hover { background: #F0D3D8; }
.btn-wa { background: var(--plum); color: #fff; }
.btn-wa:hover { background: var(--plum-700); }
.btn-block { width: 100%; }
.btn-lg { --h: 56px; font-size: 17px; padding: 0 26px; }
.btn-sm { --h: 38px; font-size: 14px; padding: 0 14px; gap: 6px; }
.btn-icon { --h: 44px; width: var(--h); padding: 0; border-radius: 50%; }
.btn-icon.btn-sm { --h: 36px; }

/* Selector de cantidad */
.qty {
  display: inline-flex; align-items: center; height: 44px; border-radius: 999px;
  background: var(--plum-50); color: var(--plum); font-weight: 700;
}
.qty button { width: 44px; height: 44px; border: 0; background: transparent; border-radius: 50%; cursor: pointer; display: grid; place-items: center; color: inherit; }
.qty button:hover { background: var(--rose); }
.qty button[disabled] { opacity: .35; cursor: not-allowed; background: transparent; }
.qty button svg { width: 18px; height: 18px; }
.qty output, .qty input { min-width: 30px; text-align: center; font-variant-numeric: tabular-nums; }
.qty-sm { height: 36px; } .qty-sm button { width: 36px; height: 36px; }

/* ---------- Formularios ---------- */
.field { display: grid; gap: 6px; }
.field > label, .label { font-size: 14px; font-weight: 700; color: var(--graphite); }
.hint { font-size: 13px; color: var(--muted); }
.input, .select, .textarea {
  width: 100%; min-height: 50px; padding: 12px 14px; border-radius: 12px;
  border: 1.5px solid var(--line); background: var(--white); font-size: 16px; /* 16px evita zoom en iOS */
  transition: border-color .2s, box-shadow .2s;
}
.textarea { min-height: 96px; resize: vertical; line-height: 1.45; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--plum); box-shadow: 0 0 0 4px color-mix(in srgb, var(--plum) 14%, transparent); }
.input[aria-invalid="true"] { border-color: var(--bad); box-shadow: 0 0 0 4px var(--bad-bg); }
.select { appearance: none; -webkit-appearance: none; padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2375455F' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 20px; }
.err { color: var(--bad); font-size: 13px; font-weight: 700; }

/* Interruptor */
.switch { position: relative; display: inline-flex; align-items: center; gap: 12px; cursor: pointer; font-weight: 700; font-size: 15px; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { width: 46px; height: 28px; border-radius: 99px; background: #D8CDD2; position: relative; transition: background .2s; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform .2s var(--ease); }
.switch input:checked + .track { background: var(--plum); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:focus-visible + .track { outline: 3px solid color-mix(in srgb, var(--plum) 45%, transparent); outline-offset: 2px; }

/* ---------- Etiquetas ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 99px; font-size: 12.5px; font-weight: 700; line-height: 1.3; white-space: nowrap; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.no-dot::before { display: none; }
.pill-in { background: var(--ok-bg); color: var(--ok); }
.pill-low { background: var(--warn-bg); color: var(--warn); }
.pill-order { background: var(--plum-50); color: var(--plum); }
.pill-out { background: #EEEAEC; color: #6B6168; }
.pill-bad { background: var(--bad-bg); color: var(--bad); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(18px + var(--safe-b)); z-index: 90;
  transform: translate(-50%, 140%); opacity: 0;
  display: flex; align-items: center; gap: 14px; max-width: calc(100% - 32px);
  padding: 12px 12px 12px 18px; border-radius: 16px; background: var(--graphite); color: #fff;
  box-shadow: var(--shadow-lg); font-size: 15px; transition: transform .35s var(--ease), opacity .25s;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.toast:not(.show) { pointer-events: none; }
.toast[popover] { inset: auto auto calc(18px + var(--safe-b)) 50%; margin: 0; border: 0; overflow: visible; width: max-content; height: auto; }
.toast button { border: 0; background: rgba(255, 255, 255, .14); color: #fff; font-weight: 700; padding: 8px 14px; border-radius: 99px; cursor: pointer; }
.toast:not(:has(button)) { padding-right: 18px; }

/* ---------- Esqueletos de carga ---------- */
.skel { background: linear-gradient(90deg, #EFE7EB 0%, #F7F1F4 50%, #EFE7EB 100%); background-size: 200% 100%; animation: skel 1.3s infinite linear; border-radius: 12px; }
@keyframes skel { to { background-position: -200% 0; } }

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