/* Rualé Café · estilos compartidos (cliente y panel) */
:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #eef0f4;
  --line: rgba(27, 35, 64, 0.12);
  --ink: #1b2340;
  --ink-2: #4b5470;
  --ink-3: #7d869c;
  --navy: #1f2d55;
  --navy-2: #2b3d70;
  --tan: #d9a25f;
  --brass: #9a6b2a;
  --coral: #d8434a;
  --ok: #2f8f5b;
  --warn: #b7791f;
  --display: 'Cormorant Garamond', 'Cormorant', Georgia, serif;
  --text: 'Ubuntu', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --r-sm: 10px;
  --r-md: 16px;
  --r-lg: 22px;
  --arch: 999px 999px 16px 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--text); font-size: 16px; line-height: 1.5; -webkit-font-smoothing: antialiased;
}
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--navy); }
:focus-visible { outline: 3px solid var(--tan); 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; }
.num { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }

/* Botones */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 18px; border: 0; border-radius: 999px;
  font-weight: 500; font-size: 16px; text-decoration: none; line-height: 1.1;
  transition: transform 0.12s ease, background-color 0.15s ease; -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.97); }
.btn svg { width: 20px; height: 20px; flex: none; }
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-2); }
.btn-gold { background: var(--tan); color: #2a1c08; }
.btn-ghost { background: var(--surface-2); color: var(--ink); }
.btn-ghost:hover { background: #e3e6ed; }
.btn-line { background: var(--surface); color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line); }
.btn-wa { background: #1f9d55; color: #fff; }
.btn-wa:hover { background: #1a8a4a; }
.btn-danger { background: var(--surface); color: #b3261e; box-shadow: inset 0 0 0 1.5px rgba(179, 38, 30, 0.4); }
.btn-block { width: 100%; }
.btn-sm { min-height: 38px; padding: 0 14px; font-size: 14.5px; }
.btn[disabled] { opacity: 0.45; pointer-events: none; }

/* Formularios */
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field > span { font-size: 14px; color: var(--ink-2); font-weight: 500; }
.input {
  width: 100%; min-height: 48px; padding: 12px 14px; background: var(--surface); color: var(--ink);
  border: 1.5px solid var(--line); border-radius: var(--r-sm); font-size: 16px;
}
.input::placeholder { color: var(--ink-3); }
.input:focus { outline: none; border-color: var(--navy); }
textarea.input { min-height: 74px; resize: vertical; }
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; }
.seg span {
  display: inline-flex; align-items: center; min-height: 42px; padding: 0 14px; border-radius: 999px;
  background: var(--surface); border: 1.5px solid var(--line); font-weight: 500; font-size: 15px; color: var(--ink-2);
}
.seg input:checked + span { background: var(--navy); color: #fff; border-color: var(--navy); }
.seg input:focus-visible + span { outline: 3px solid var(--tan); outline-offset: 2px; }
.form-error { color: #b3261e; font-size: 14px; margin: -4px 0 12px; }

/* Hojas inferiores y diálogos */
.backdrop { position: fixed; inset: 0; background: rgba(15, 20, 38, 0.45); z-index: 80; opacity: 0; transition: opacity 0.2s ease; }
.backdrop.show { opacity: 1; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 90; max-height: 92vh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface); border-radius: 22px 22px 0 0; padding: 10px 18px calc(22px + var(--safe-b));
  transform: translateY(105%); transition: transform 0.26s cubic-bezier(0.2, 0.8, 0.2, 1); max-width: 560px; margin: 0 auto;
  box-shadow: 0 -10px 40px rgba(15, 20, 38, 0.15);
}
.sheet.show { transform: none; }
.sheet-grip { width: 42px; height: 5px; border-radius: 9px; background: var(--surface-2); margin: 0 auto 10px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.sheet-head h2 { margin: 0; font-family: var(--display); font-weight: 700; font-size: 30px; line-height: 1.05; }
.icon-btn { width: 42px; height: 42px; flex: none; display: grid; place-items: center; border-radius: 50%; border: 0; background: var(--surface-2); color: var(--ink); }
.icon-btn svg { width: 20px; height: 20px; }
.dialog {
  position: fixed; z-index: 100; left: 50%; top: 50%; width: min(92vw, 400px); transform: translate(-50%, -46%) scale(0.98); opacity: 0;
  background: var(--surface); border-radius: var(--r-lg); padding: 22px; box-shadow: 0 24px 60px rgba(15, 20, 38, 0.3);
  transition: opacity 0.16s ease, transform 0.16s ease;
}
.dialog.show { opacity: 1; transform: translate(-50%, -50%); }
.dialog h2 { margin: 0 0 6px; font-size: 20px; line-height: 1.25; font-weight: 700; }
.dialog p { margin: 0 0 18px; color: var(--ink-2); }
.dialog-actions { display: flex; gap: 10px; }
.dialog-actions .btn { flex: 1; }
.dialog .btn-primary.danger { background: #b3261e; }

/* Avisos */
.toast-wrap { position: fixed; left: 0; right: 0; top: 12px; z-index: 120; display: grid; justify-items: center; pointer-events: none; padding: 0 12px; }
.toast {
  max-width: 460px; background: var(--ink); color: #fff; font-weight: 500; padding: 12px 16px; border-radius: 14px;
  box-shadow: 0 10px 30px rgba(15, 20, 38, 0.25); margin-bottom: 8px; animation: toast-in 0.25s ease both; pointer-events: none;
}
.toast.ok { background: #18402c; }
.toast.err { background: #7a1d17; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-10px); } }

/* Tarjeta de sellos */
.lcard { position: relative; aspect-ratio: 1.586; width: 100%; max-width: 420px; perspective: 1200px; margin: 0 auto; }
.lcard-inner { position: absolute; inset: 0; transform-style: preserve-3d; transition: transform 0.6s cubic-bezier(0.3, 0.7, 0.2, 1); }
.lcard.flipped .lcard-inner { transform: rotateY(180deg); }
.lcard-face {
  position: absolute; inset: 0; border-radius: 20px; overflow: hidden; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  padding: 18px 18px 16px; display: flex; flex-direction: column; box-shadow: 0 16px 34px rgba(15, 20, 38, 0.22);
}
.lcard-front { color: #fff; background: linear-gradient(150deg, #2b3d70 0%, #1f2d55 55%, #16203e 100%); }
.lcard-front::after {
  content: ''; position: absolute; right: -40px; top: -10px; width: 210px; height: 300px; pointer-events: none;
  border: 1.5px solid rgba(217, 162, 95, 0.35); border-radius: 999px 999px 0 0;
  box-shadow: inset 0 0 0 14px rgba(255, 255, 255, 0.02), 0 0 0 14px rgba(217, 162, 95, 0.06);
}
.lcard-back { transform: rotateY(180deg); background: #fff; color: var(--ink); align-items: center; justify-content: center; text-align: center; gap: 8px; box-shadow: 0 16px 34px rgba(15, 20, 38, 0.22), inset 0 0 0 1.5px var(--line); }
.lcard-back .qr { width: 52%; max-width: 190px; }
.lcard-back small { font-size: 13px; color: var(--ink-2); }
.lcard-top { display: flex; align-items: center; gap: 10px; position: relative; z-index: 1; }
.lcard-top img { width: 42px; height: 42px; border-radius: 50%; background: #fff; }
.lcard-brand { font-weight: 700; font-size: 21px; letter-spacing: 1px; line-height: 1; }
.lcard-brand small { display: block; font-weight: 400; font-size: 13px; letter-spacing: 0.5px; color: #d6dbea; margin-top: 2px; }
.lcard-kind { margin-left: auto; font-size: 12.5px; text-align: right; color: #c9cfe0; line-height: 1.25; }
.stamps { position: relative; z-index: 1; margin: auto 0; display: grid; grid-template-columns: repeat(var(--cols, 4), 1fr); gap: 8px 10px; padding: 10px 2px; }
.stamp {
  aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center; border: 1.5px dashed rgba(217, 162, 95, 0.6);
  max-height: 44px; margin: 0 auto; width: 100%; max-width: 44px; color: var(--tan);
}
.stamp svg { width: 56%; height: 56%; }
.stamp.on { border: 0; background: radial-gradient(circle at 35% 30%, #f3d6a6, var(--tan) 70%, #a8763a); box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3); color: #3a2410; }
.stamp.prize { border-style: solid; border-color: var(--tan); }
.stamp.pop { animation: stamp-pop 0.5s cubic-bezier(0.2, 1.6, 0.4, 1) both; }
@keyframes stamp-pop { from { transform: scale(0.2) rotate(-40deg); opacity: 0; } }
.lcard-foot { position: relative; z-index: 1; display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; }
.lcard-name { font-weight: 700; font-size: 18px; line-height: 1.15; }
.lcard-name small { display: block; font-weight: 400; font-size: 12.5px; color: #c9cfe0; }
.lcard-count { font-family: var(--display); font-weight: 700; font-size: 34px; line-height: 1; color: #f0cf98; white-space: nowrap; }
.lcard-count small { font-family: var(--text); font-size: 13px; font-weight: 500; color: #c9cfe0; }

/* Estados de pedido */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 13px; font-weight: 500; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.pill::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.s-nuevo { background: #fbf0dc; color: #8a5a10; }
.pill.s-pagado, .pill.s-horno { background: #f8e6d6; color: #9a4a12; }
.pill.s-camino { background: #e2eaf8; color: #2c4f9a; }
.pill.s-entregado { background: #dcf0e3; color: #1f6b40; }
.pill.s-anulado { background: var(--surface-2); color: var(--ink-3); }

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