/* =========================================================
   Café con Cereza — tarjeta de lealtad
   Misma idea que la página web: el logo es un bordado.
   Las puntadas (líneas discontinuas) marcan lo "cosido":
   la tarjeta, el talón del QR y las cerezas vacías.
   ========================================================= */

:root {
  --cereza: #A01E38;
  --cereza-oscura: #7A1229;
  --crema: #F4EEE4;
  --madera: #4A2523;
  --blanco: #FFFFFF;
  --harina: #EADCCB;
  --hilo: rgba(160, 30, 56, 0.42);   /* puntada sin rellenar */
  --texto-suave: #6E4B47;            /* madera aclarada, contraste AA sobre crema */
  --exito: #1F6B3A;

  --f-titulo: "Ultra", "Rockwell Extra Bold", Georgia, serif;
  --f-texto: "Libre Franklin", "Segoe UI", system-ui, sans-serif;
  --f-lema: "Yellowtail", "Brush Script MT", cursive;

  --t-xs: 0.8125rem;
  --t-s: 0.9375rem;
  --t-m: 1.0625rem;
  --t-l: 1.3125rem;
  --t-xl: 1.75rem;
  --t-xxl: 2.25rem;

  --puntada: 2px dashed;
  --radio: 14px;
  --gutter: 16px;
  color-scheme: light;
}

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

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

body {
  margin: 0;
  min-height: 100dvh;
  color: var(--madera);
  font-family: var(--f-texto);
  font-size: var(--t-m);
  line-height: 1.55;
  /* Tela de manta: un tejido muy tenue, como el fondo del logo */
  background-color: var(--crema);
  background-image:
    repeating-linear-gradient(0deg, rgba(74, 37, 35, 0.025) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(90deg, rgba(74, 37, 35, 0.025) 0 1px, transparent 1px 3px);
}

h1, h2, h3, p, ul, ol, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
img, svg { display: block; max-width: 100%; }
a { color: var(--cereza); text-underline-offset: 3px; }
button, input { font: inherit; color: inherit; }
[hidden] { display: none !important; }

:focus-visible {
  outline: 3px solid var(--cereza);
  outline-offset: 3px;
  border-radius: 6px;
}

.oculto {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.contenedor {
  width: 100%;
  max-width: 440px;
  margin: 0 auto;
  padding: 24px var(--gutter) 48px;
}

/* ---------- Tipografía ---------- */

.titulo {
  font-family: var(--f-titulo);
  font-weight: 400;
  font-size: var(--t-xxl);
  line-height: 1.08;
  color: var(--cereza);
  letter-spacing: 0.01em;
}

.lema {
  font-family: var(--f-lema);
  font-size: 1.45rem;
  line-height: 1.2;
  color: var(--cereza-oscura);
}

.subtitulo {
  font-family: var(--f-titulo);
  font-weight: 400;
  font-size: var(--t-l);
  color: var(--madera);
  line-height: 1.2;
}

.suave { color: var(--texto-suave); }
.pequeno { font-size: var(--t-s); }

/* ---------- Parche del logo ---------- */

.parche {
  width: 132px;
  aspect-ratio: 1;
  border-radius: 50%;
  overflow: hidden;
  background: var(--crema);
  box-shadow: 0 0 0 5px var(--crema), 0 0 0 7px var(--cereza);
  outline: var(--puntada) var(--hilo);
  outline-offset: 12px;
}
.parche img { width: 100%; height: 100%; object-fit: cover; transform: scale(1.12); }
.parche--chico { width: 56px; box-shadow: 0 0 0 3px var(--blanco), 0 0 0 4px var(--cereza); outline: none; }

/* ---------- Formularios ---------- */

.campo { display: grid; gap: 6px; margin-bottom: 16px; }
.campo label { font-weight: 600; font-size: var(--t-s); }
.campo .ayuda { font-size: var(--t-xs); color: var(--texto-suave); }

.entrada {
  width: 100%;
  min-height: 52px;
  padding: 12px 14px;
  border: 2px solid #CDB9A6;
  border-radius: 10px;
  background: var(--blanco);
  font-size: 1.125rem;
}
.entrada:focus { border-color: var(--cereza); outline: none; box-shadow: 0 0 0 3px rgba(160, 30, 56, 0.18); }
.entrada--pin { letter-spacing: 0.5em; font-size: 1.4rem; text-align: center; font-weight: 700; }

.casilla {
  display: grid;
  grid-template-columns: 26px 1fr;
  gap: 10px;
  align-items: start;
  margin: 4px 0 20px;
  font-size: var(--t-s);
}
.casilla input { width: 22px; height: 22px; margin: 2px 0 0; accent-color: var(--cereza); }

.boton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 54px;
  padding: 12px 20px;
  border: 0;
  border-radius: 999px;
  background: var(--cereza);
  color: var(--blanco);
  font-weight: 700;
  font-size: 1.0625rem;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s, transform 0.1s;
}
.boton:hover { background: var(--cereza-oscura); }
.boton:active { transform: scale(0.98); }
.boton:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.boton svg { width: 24px; height: 24px; flex: none; }

.boton--madera { background: var(--madera); }
.boton--madera:hover { background: #331816; }
.boton--borde { background: transparent; color: var(--cereza); box-shadow: inset 0 0 0 2px var(--cereza); }
.boton--borde:hover { background: rgba(160, 30, 56, 0.07); }
.boton--texto {
  width: auto; min-height: 44px; padding: 8px 4px;
  background: none; color: var(--cereza); text-decoration: underline; font-weight: 600;
}
.boton--texto:hover { background: none; color: var(--cereza-oscura); }

.mensaje {
  margin: 0 0 16px;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: var(--t-s);
  font-weight: 600;
}
.mensaje--error { background: #FBE3E6; color: #7A1229; border-left: 4px solid var(--cereza); }
.mensaje--ok { background: #E3F1E7; color: var(--exito); border-left: 4px solid var(--exito); }

/* ---------- Pestañas (crear / entrar) ---------- */

.pestanas {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin: 28px 0 20px;
  padding: 4px;
  border-radius: 999px;
  background: var(--harina);
}
.pestanas button {
  min-height: 46px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  font-weight: 600;
  cursor: pointer;
}
.pestanas button[aria-selected="true"] {
  background: var(--blanco);
  color: var(--cereza);
  box-shadow: 0 1px 3px rgba(74, 37, 35, 0.18);
}

/* =========================================================
   LA TARJETA
   ========================================================= */

.tarjeta {
  position: relative;
  padding: 22px 20px 20px;
  border-radius: 18px 18px 6px 6px;
  background: var(--blanco);
  box-shadow: 0 1px 0 rgba(74, 37, 35, 0.08), 0 12px 28px -14px rgba(74, 37, 35, 0.45);
}
/* La puntada que rodea la tarjeta */
.tarjeta::before {
  content: "";
  position: absolute;
  inset: 8px 8px 4px;
  border: var(--puntada) var(--hilo);
  border-bottom: 0;
  border-radius: 12px 12px 0 0;
  pointer-events: none;
}

.tarjeta__cabeza {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-bottom: 14px;
}
.tarjeta__marca { font-family: var(--f-titulo); color: var(--cereza); font-size: 1.15rem; line-height: 1.1; }
.tarjeta__tipo { font-size: var(--t-xs); color: var(--texto-suave); font-weight: 600; }

.tarjeta__nombre {
  font-family: var(--f-lema);
  font-size: 2rem;
  line-height: 1.1;
  color: var(--madera);
  margin: 4px 0 14px;
  overflow-wrap: anywhere;
}

.cerezas {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px 8px;
  padding: 0 10px 0 2px; /* las hojas salen a la derecha: que no pisen la puntada */
}
.cereza { position: relative; aspect-ratio: 1; }
.cereza svg { width: 100%; height: 100%; overflow: visible; }

.cereza__num {
  position: absolute;
  left: 46%; top: 66%;
  transform: translate(-50%, -50%);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--hilo);
}
.cereza--llena .cereza__num { display: none; }

/* Las partes del dibujo */
.c-fruta, .c-tallo, .c-hoja { fill: none; stroke: var(--hilo); stroke-width: 1.6; stroke-dasharray: 3 2.6; stroke-linecap: round; }
.cereza--llena .c-fruta { fill: var(--cereza); stroke: var(--cereza-oscura); stroke-dasharray: none; }
.cereza--llena .c-satin { opacity: 1; }
.cereza--llena .c-tallo { stroke: var(--madera); stroke-dasharray: none; stroke-width: 1.8; }
.cereza--llena .c-hoja { fill: var(--cereza); stroke: var(--cereza-oscura); stroke-dasharray: none; }
.cereza--llena .c-brillo { opacity: 1; }
.c-satin, .c-brillo { opacity: 0; }

/* El único momento animado: la cereza nueva se borda */
@media (prefers-reduced-motion: no-preference) {
  .cereza--nueva svg { animation: bordar 0.9s cubic-bezier(0.2, 0.9, 0.3, 1.3) both; }
  .cereza--nueva .c-fruta { animation: rellenar 0.9s ease-out both; }
}
@keyframes bordar {
  0% { transform: scale(0.4) rotate(-12deg); opacity: 0; }
  60% { transform: scale(1.12) rotate(3deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); }
}
@keyframes rellenar {
  0%, 30% { fill: transparent; }
  100% { fill: var(--cereza); }
}

.tarjeta__progreso {
  margin-top: 14px;
  font-size: var(--t-s);
  text-align: center;
}
.tarjeta__progreso strong { color: var(--cereza); }

/* Perforación entre la tarjeta y el talón */
.perforacion {
  position: relative;
  height: 18px;
  background:
    radial-gradient(circle at 0 50%, transparent 9px, var(--blanco) 9.5px) left / 51% 100% no-repeat,
    radial-gradient(circle at 100% 50%, transparent 9px, var(--blanco) 9.5px) right / 51% 100% no-repeat;
}
.perforacion::after {
  content: "";
  position: absolute;
  left: 16px; right: 16px; top: 50%;
  border-top: 2px dotted #D6C4B2;
}

.talon {
  display: grid;
  grid-template-columns: 132px 1fr;
  gap: 16px;
  align-items: center;
  padding: 14px 20px 20px;
  border-radius: 6px 6px 18px 18px;
  background: var(--blanco);
  box-shadow: 0 12px 28px -14px rgba(74, 37, 35, 0.45);
}
.talon__qr {
  padding: 6px;
  border-radius: 8px;
  background: var(--blanco);
  outline: var(--puntada) var(--hilo);
  outline-offset: 3px;
}
.talon__qr svg, .talon__qr img { width: 100%; height: auto; }
.talon p { font-size: var(--t-s); }
.talon strong { display: block; font-size: var(--t-m); margin-bottom: 2px; }

/* Listón de premio (como el listón del logo) */
.liston {
  position: relative;
  margin: 26px 10px 0;
  padding: 14px 18px;
  background: var(--cereza);
  color: var(--blanco);
  text-align: center;
  border-radius: 4px;
  box-shadow: inset 0 0 0 4px var(--cereza), inset 0 0 0 5px rgba(255, 255, 255, 0.55);
}
.liston::before, .liston::after {
  content: "";
  position: absolute;
  top: 10px; bottom: -10px;
  width: 22px;
  background: var(--cereza-oscura);
  z-index: -1;
}
.liston::before { left: -14px; clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%, 40% 50%); }
.liston::after { right: -14px; clip-path: polygon(0 0, 100% 0, 60% 50%, 100% 100%, 0 100%); }
.liston__grande { display: block; font-family: var(--f-titulo); font-size: var(--t-l); line-height: 1.2; }
.liston__chico { font-size: var(--t-s); }

/* ---------- Secciones bajo la tarjeta ---------- */

.bloque { margin-top: 32px; }
.bloque > h2 { margin-bottom: 10px; }

.historial li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px dashed #D6C4B2;
  font-size: var(--t-s);
}
.historial li:last-child { border-bottom: 0; }
.historial .tipo-canje { color: var(--cereza); font-weight: 700; }
.historial time { color: var(--texto-suave); white-space: nowrap; }

.desplegable {
  border-radius: var(--radio);
  background: rgba(255, 255, 255, 0.6);
  border: var(--puntada) #D6C4B2;
}
.desplegable summary {
  padding: 14px 16px;
  font-weight: 700;
  cursor: pointer;
  list-style-position: inside;
}
.desplegable[open] summary { border-bottom: 1px dashed #D6C4B2; }
.desplegable__cuerpo { padding: 12px 16px 16px; font-size: var(--t-s); }
.desplegable__cuerpo h3 { font-size: var(--t-s); margin: 10px 0 4px; }
.desplegable__cuerpo ol { list-style: decimal; padding-left: 20px; display: grid; gap: 4px; }

.pie {
  margin-top: 36px;
  text-align: center;
  font-size: var(--t-s);
  color: var(--texto-suave);
}
.pie a { color: inherit; }

.cargando { padding: 80px 0; text-align: center; color: var(--texto-suave); }

/* =========================================================
   PANEL DEL CAFÉ
   ========================================================= */

.panel-barra {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px var(--gutter);
  background: var(--madera);
  color: var(--crema);
}
.panel-barra__titulo { flex: 1; font-family: var(--f-titulo); font-size: 1.05rem; line-height: 1.1; }
.panel-barra__titulo span { display: block; font-family: var(--f-texto); font-size: var(--t-xs); opacity: 0.8; }
.panel-barra button {
  min-height: 44px; padding: 6px 14px;
  border: 1px solid rgba(244, 238, 228, 0.5); border-radius: 999px;
  background: transparent; color: var(--crema); font-weight: 600; cursor: pointer;
}

.panel .contenedor { max-width: 560px; }

.panel .pestanas { margin-top: 4px; }
.panel .pestanas button { min-height: 52px; font-size: 1.0625rem; }

.boton--enorme { min-height: 76px; font-size: 1.25rem; border-radius: 20px; }
.boton--enorme svg { width: 30px; height: 30px; }

.separador {
  display: flex; align-items: center; gap: 12px;
  margin: 22px 0 14px;
  color: var(--texto-suave); font-size: var(--t-s);
}
.separador::before, .separador::after { content: ""; flex: 1; border-top: 1px dashed #CDB9A6; }

.buscador { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.buscador .boton { width: auto; min-width: 104px; }

.lector {
  margin-top: 16px;
  overflow: hidden;
  border-radius: var(--radio);
  background: #000;
}
.lector video { border-radius: var(--radio); }

/* Ficha del cliente */
.ficha {
  padding: 20px;
  border-radius: 18px;
  background: var(--blanco);
  box-shadow: 0 12px 28px -16px rgba(74, 37, 35, 0.5);
}
.ficha__nombre { font-family: var(--f-titulo); font-size: var(--t-xl); color: var(--madera); line-height: 1.15; overflow-wrap: anywhere; }
.ficha__dato { color: var(--texto-suave); font-size: var(--t-s); margin-top: 2px; }
.ficha .cerezas { margin: 18px 0 6px; }
.ficha__cuenta { text-align: center; font-weight: 600; }
.ficha__cuenta strong { font-family: var(--f-titulo); font-weight: 400; color: var(--cereza); font-size: var(--t-xl); }

.premios {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin: 16px 0;
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--crema);
}
.premios strong { font-family: var(--f-titulo); font-weight: 400; font-size: 2rem; color: var(--cereza); line-height: 1; }
.premios--hay { background: var(--cereza); color: var(--blanco); }
.premios--hay strong { color: var(--blanco); }

.acciones { display: grid; gap: 12px; }

/* Confirmación grande */
.aviso {
  position: fixed;
  left: var(--gutter); right: var(--gutter); bottom: 24px;
  z-index: 30;
  max-width: 528px;
  margin: 0 auto;
  display: flex; align-items: center; gap: 14px;
  padding: 18px 20px;
  border-radius: 18px;
  background: var(--exito);
  color: var(--blanco);
  font-size: 1.125rem;
  font-weight: 700;
  line-height: 1.3;
  box-shadow: 0 16px 36px -10px rgba(0, 0, 0, 0.45);
}
.aviso svg { width: 40px; height: 40px; flex: none; }
.aviso small { display: block; font-weight: 500; font-size: var(--t-s); opacity: 0.92; }
.aviso--error { background: var(--cereza-oscura); }
.aviso--premio { background: var(--cereza); }
@media (prefers-reduced-motion: no-preference) {
  .aviso { animation: subir 0.25s ease-out; }
}
@keyframes subir { from { transform: translateY(24px); opacity: 0; } }

/* Estadísticas y lista */
.estadisticas {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 18px;
}
.estadistica {
  padding: 12px 8px;
  border-radius: 12px;
  background: var(--blanco);
  text-align: center;
  font-size: var(--t-xs);
  font-weight: 600;
  color: var(--texto-suave);
  line-height: 1.3;
}
.estadistica strong { display: block; font-family: var(--f-titulo); font-weight: 400; font-size: 1.75rem; color: var(--madera); line-height: 1.2; }

.lista-clientes { margin-top: 12px; }
.lista-clientes button {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 12px;
  width: 100%;
  min-height: 64px;
  padding: 10px 14px;
  margin-bottom: 8px;
  border: 0;
  border-radius: 12px;
  background: var(--blanco);
  text-align: left;
  cursor: pointer;
}
.lista-clientes button:hover { box-shadow: inset 0 0 0 2px var(--hilo); }
.lista-clientes .n { font-weight: 700; overflow-wrap: anywhere; }
.lista-clientes .c { grid-column: 1; font-size: var(--t-s); color: var(--texto-suave); }
.lista-clientes .s { grid-column: 2; grid-row: 1 / span 2; align-self: center; text-align: right; font-size: var(--t-s); font-weight: 600; }
.lista-clientes .s em { display: block; font-style: normal; color: var(--cereza); }

.vacio { padding: 24px 8px; text-align: center; color: var(--texto-suave); }

/* Diálogo de borrar */
dialog {
  width: min(420px, calc(100% - 32px));
  padding: 22px;
  border: 0;
  border-radius: 18px;
  background: var(--blanco);
  color: var(--madera);
}
dialog::backdrop { background: rgba(74, 37, 35, 0.55); }
dialog h2 { margin-bottom: 8px; }
dialog p { margin-bottom: 18px; }
dialog .acciones { grid-template-columns: 1fr 1fr; }

.zona-peligro { margin-top: 28px; text-align: center; }

/* ---------- Páginas de texto (privacidad, 404) ---------- */

.texto h1 { margin: 20px 0 6px; font-size: var(--t-xl); }
.texto h2 { margin: 26px 0 8px; font-family: var(--f-titulo); font-weight: 400; font-size: var(--t-l); color: var(--cereza); }
.texto p, .texto li { margin-bottom: 10px; }
.texto ul { list-style: disc; padding-left: 22px; }

/* Promociones por WhatsApp: casilla opcional, interruptor y exportar */
.casilla--opcional {
  margin-top: -6px;
  padding: 12px 12px 12px 10px;
  border: 1px dashed #D6C4B2;
  border-radius: 12px;
  color: var(--texto-suave);
}
.casilla__etiqueta {
  display: block;
  margin-bottom: 2px;
  font-size: var(--t-xs);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--madera);
}

.interruptor {
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 14px;
  align-items: start;
  padding: 14px;
  border-radius: var(--radio);
  background: var(--blanco);
  font-size: var(--t-s);
  cursor: pointer;
}
.interruptor__texto strong { display: block; color: var(--madera); }
.interruptor input {
  appearance: none;
  position: relative;
  width: 52px;
  height: 30px;
  margin: 0;
  border-radius: 999px;
  background: #CDBBAA;
  cursor: pointer;
  transition: background 0.2s;
}
.interruptor input::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--blanco);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 0.2s;
}
.interruptor input:checked { background: var(--exito); }
.interruptor input:checked::after { transform: translateX(22px); }
.interruptor input:focus-visible { outline: 3px solid var(--cereza); outline-offset: 2px; }
.interruptor input:disabled { opacity: 0.6; }

.exportar {
  margin-bottom: 18px;
  padding: 14px;
  border-radius: var(--radio);
  background: var(--blanco);
}
.exportar__cuenta { margin-bottom: 10px; font-size: var(--t-s); }
.exportar__cuenta strong { font-family: var(--f-titulo); font-weight: 400; font-size: 1.4rem; color: var(--exito); }
.exportar__botones { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.exportar__botones .boton { min-height: 48px; padding: 10px 12px; font-size: var(--t-s); }
.exportar .ayuda { display: block; margin-top: 8px; font-size: var(--t-xs); color: var(--texto-suave); }
