/* ============================================================
   Identidad de Cafetería Fadwa (cafeteriafadwa.com)
   - Portal del cliente (body.tema-sitio): réplica del sitio, fondo turquesa.
   - Caja (tema por defecto): misma marca en versión clara, para trabajar.
   ============================================================ */

/* Fuentes autoalojadas (SIL Open Font License, ver /fonts/OFL-*.txt) */
@font-face {
  font-family: 'Jost';
  src: url('/fonts/jost.woff2') format('woff2');
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: 'Cormorant Garamond';
  src: url('/fonts/cormorant-garamond.woff2') format('woff2');
  font-weight: 300 700;
  font-display: swap;
}

:root {
  /* Paleta de marca, tomada del sitio */
  --teal: #4facad;
  --teal-deep: #3e9698;
  --teal-oscuro: #22696b; /* derivado: texto turquesa con contraste AA sobre crema */
  --brown: #362114;
  --brown-soft: #4a2f1d;
  --gold: #c9a45c;
  --gold-light: #ebd9ac;
  --cream: #f7f0e2;

  --serif: 'Cormorant Garamond', Georgia, serif;
  --sans: 'Jost', system-ui, -apple-system, sans-serif;

  /* Tokens semánticos: versión clara (caja) */
  --fondo: var(--cream);
  --superficie: #fffdf8;
  --superficie-2: #f3ead8;
  --texto: var(--brown);
  --texto-suave: #6e5646;
  --borde: #e6d7b9;
  --borde-tarjeta: rgb(201 164 92 / 70%);
  --adorno: var(--gold);
  --acento: var(--brown);
  --acento-hover: var(--brown-soft);
  --acento-texto: var(--cream);
  --enlace: var(--teal-oscuro);
  --pista: #ece1ca;
  --progreso: linear-gradient(90deg, #b38a3e, var(--gold));
  --campo-fondo: #fffdf8;
  --campo-borde: #d9c59c;
  --exito: #256b45;
  --exito-fondo: #e3f1e8;
  --error: #a3261c;
  --error-fondo: #fbe7e4;
  --aviso: #5c3f0c;
  --aviso-fondo: #f3e3b8;
  --bronce: #9a5a26;
  --plata: #5f6b78;
  --oro: #8c6a1f;
  --trama: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='72' height='72' viewBox='0 0 72 72'%3E%3Cg fill='none' stroke='%233E9698' stroke-width='1'%3E%3Cpath d='M36 4 L44 28 L68 36 L44 44 L36 68 L28 44 L4 36 L28 28 Z'/%3E%3Ccircle cx='36' cy='36' r='6'/%3E%3C/g%3E%3C/svg%3E");
  --trama-opacidad: 0.07;
  --sombra: 0 1px 2px rgb(54 33 20 / 6%), 0 6px 18px rgb(54 33 20 / 8%);
  --radio: 2px;
}

/* Portal del cliente: igual que cafeteriafadwa.com */
body.tema-sitio {
  --fondo: var(--teal-deep);
  --superficie: rgb(54 33 20 / 55%);
  --superficie-2: rgb(247 240 226 / 8%);
  --texto: var(--cream);
  --texto-suave: rgb(247 240 226 / 80%);
  --borde: rgb(201 164 92 / 30%);
  --borde-tarjeta: rgb(201 164 92 / 55%);
  --adorno: var(--gold-light);
  --acento: var(--gold);
  --acento-hover: var(--gold-light);
  --acento-texto: var(--brown);
  --enlace: var(--gold-light);
  --pista: rgb(247 240 226 / 15%);
  --progreso: linear-gradient(90deg, var(--gold), var(--gold-light));
  --campo-fondo: rgb(247 240 226 / 96%);
  --campo-borde: var(--gold);
  --exito: #c8f2d6;
  --exito-fondo: rgb(30 90 58 / 60%);
  --error: #ffd6d0;
  --error-fondo: rgb(130 30 20 / 60%);
  --aviso: var(--brown);
  --aviso-fondo: var(--gold-light);
  --bronce: #e6aa7a;
  --plata: #dde4ea;
  --oro: var(--gold-light);
  --trama: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='72' height='72' viewBox='0 0 72 72'%3E%3Cg fill='none' stroke='%23F7F0E2' stroke-width='1'%3E%3Cpath d='M36 4 L44 28 L68 36 L44 44 L36 68 L28 44 L4 36 L28 28 Z'/%3E%3Ccircle cx='36' cy='36' r='6'/%3E%3C/g%3E%3C/svg%3E");
  --trama-opacidad: 0.05;
  --sombra: 0 6px 18px rgb(20 40 40 / 18%);
  background: radial-gradient(ellipse 120% 70% at 50% -10%, var(--teal) 0%, var(--teal-deep) 100%);
}

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

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

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--fondo);
  color: var(--texto);
  font: 16px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  position: relative;
}

/* Trama geométrica sutil, eco de celosía árabe (igual que el sitio) */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: var(--trama-opacidad);
  background-image: var(--trama);
  background-size: 72px 72px;
}
body > * {
  position: relative;
  z-index: 1;
}

[hidden] {
  display: none !important;
}

h1,
h2 {
  font-family: var(--serif);
  font-weight: 600;
  font-variant-numeric: lining-nums; /* Cormorant usa números de estilo antiguo por defecto */
  line-height: 1.15;
  letter-spacing: 0.01em;
  margin: 0 0 0.5rem;
}
h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--texto-suave);
  margin: 0 0 0.5rem;
}
* + h3 {
  margin-top: 1.25rem;
}

p { margin: 0 0 0.75rem; }

a { color: var(--enlace); }

.suave { color: var(--texto-suave); }
.pequeno { font-size: 0.875rem; }
.num { font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------ Caja: barra superior */

.barra {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  padding: 0.5rem 1rem;
  background: var(--teal);
  color: var(--brown);
  border-bottom: 2px solid var(--gold);
  box-shadow: 0 2px 10px rgb(20 40 40 / 15%);
}
.marca {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-right: auto;
  color: var(--brown);
  text-decoration: none;
}
.marca img {
  height: 46px;
  width: auto;
  filter: drop-shadow(0 2px 6px rgb(20 40 40 / 25%));
}
.marca span {
  font-family: var(--serif);
  font-size: 1.45rem;
  font-weight: 700;
  line-height: 1;
}
.marca small {
  display: block;
  font-family: var(--sans);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin-top: 0.2rem;
}
.barra .usuario {
  font-size: 0.85rem;
}
.barra button.texto {
  color: var(--brown);
}

.pestanas {
  display: flex;
  gap: 0.25rem;
}
.pestanas button {
  background: none;
  border: 1px solid transparent;
  color: var(--brown);
  padding: 0.4rem 0.8rem;
}
.pestanas button:hover:not(:disabled) {
  background: rgb(247 240 226 / 45%);
  border-color: transparent;
}
.pestanas button[aria-selected='true'],
.pestanas button[aria-selected='true']:hover:not(:disabled) {
  background: var(--cream);
  border-color: var(--gold);
}

/* ------------------------------------------------------------ Portal: cabecera y pie */

.cabecera-portal {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2.5rem 1rem 0.5rem;
}
.cabecera-portal .logo {
  width: min(220px, 60vw);
  height: auto;
  filter: drop-shadow(0 6px 18px rgb(20 40 40 / 25%));
  animation: subir 0.8s ease both;
  transition: width 0.3s ease;
}
.tagline {
  margin: 1rem 0 0;
  max-width: 30ch;
  text-align: center;
  font-size: 0.95rem;
  line-height: 1.5;
  color: rgb(247 240 226 / 90%);
  text-shadow: 0 1px 2px rgb(20 40 40 / 30%);
  animation: subir 0.8s 0.15s ease both;
}
.en-panel .cabecera-portal {
  padding-top: 1.25rem;
}
.en-panel .cabecera-portal .logo {
  width: 120px;
}
.en-panel .tagline {
  display: none;
}
.salir {
  position: absolute;
  top: 1rem;
  right: 1rem;
  padding: 0.35rem 0.8rem;
  font-size: 0.85rem;
  color: var(--cream);
  background: rgb(54 33 20 / 35%);
  border: 1px solid rgb(235 217 172 / 60%);
}
.salir:hover:not(:disabled) {
  background: rgb(54 33 20 / 60%);
  border-color: var(--gold-light);
  color: var(--cream);
}

.saludo {
  font-size: 1.8rem;
  text-align: center;
  text-shadow: 0 1px 2px rgb(20 40 40 / 30%);
}

.pie {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 2rem 1rem 2.5rem;
}
.divisor-grano {
  display: flex;
  align-items: center;
  gap: 12px;
}
.divisor-grano::before,
.divisor-grano::after {
  content: '';
  width: 46px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgb(201 164 92 / 70%));
}
.divisor-grano::after {
  background: linear-gradient(90deg, rgb(201 164 92 / 70%), transparent);
}
.divisor-grano svg {
  width: 16px;
  height: 16px;
}
.pie p {
  margin: 0;
  font-size: 0.74rem;
  letter-spacing: 0.18em;
  text-indent: 0.18em;
  text-transform: uppercase;
  color: rgb(247 240 226 / 70%);
}
.pie a {
  color: inherit;
}

/* ------------------------------------------------------------ Estructura */

.contenedor {
  width: 100%;
  max-width: 440px;
  margin: 0 auto;
  padding: 1rem;
}
.contenedor.ancho {
  max-width: 1120px;
}

.pila > * + * {
  margin-top: 1.25rem;
}

.grilla-ficha {
  display: grid;
  gap: 1.25rem;
}
@media (min-width: 900px) {
  .grilla-ficha {
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }
}

.fila {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
}
.fila > .crece {
  flex: 1 1 12rem;
}

/* ------------------------------------------------------------ Tarjetas con esquinas doradas */

.tarjeta {
  position: relative;
  background: var(--superficie);
  border: 1px solid var(--borde-tarjeta);
  box-shadow: var(--sombra);
  padding: 1.25rem 1.35rem;
}
/* Esquinas ornamentales, firma tomada del marco del logo */
.tarjeta::before {
  --largo: 14px;
  --grosor: 2px;
  content: '';
  position: absolute;
  inset: -4px;
  pointer-events: none;
  background:
    linear-gradient(var(--adorno) 0 0) left top / var(--largo) var(--grosor),
    linear-gradient(var(--adorno) 0 0) left top / var(--grosor) var(--largo),
    linear-gradient(var(--adorno) 0 0) right top / var(--largo) var(--grosor),
    linear-gradient(var(--adorno) 0 0) right top / var(--grosor) var(--largo),
    linear-gradient(var(--adorno) 0 0) left bottom / var(--largo) var(--grosor),
    linear-gradient(var(--adorno) 0 0) left bottom / var(--grosor) var(--largo),
    linear-gradient(var(--adorno) 0 0) right bottom / var(--largo) var(--grosor),
    linear-gradient(var(--adorno) 0 0) right bottom / var(--grosor) var(--largo);
  background-repeat: no-repeat;
}
.tema-sitio .tarjeta {
  backdrop-filter: blur(2px);
  animation: subir 0.6s ease both;
}
.tema-sitio .pila > :nth-child(2) { animation-delay: 0.05s; }
.tema-sitio .pila > :nth-child(3) { animation-delay: 0.1s; }
.tema-sitio .pila > :nth-child(4) { animation-delay: 0.15s; }
.tema-sitio .pila > :nth-child(5) { animation-delay: 0.2s; }

.tarjeta-nivel {
  border-top: 3px solid var(--color-nivel, var(--gold));
}
.nivel-bronce { --color-nivel: var(--bronce); }
.nivel-plata { --color-nivel: var(--plata); }
.nivel-oro { --color-nivel: var(--oro); }

.saldo {
  font-family: var(--serif);
  font-size: 3.6rem;
  font-weight: 600;
  font-variant-numeric: lining-nums;
  line-height: 1;
  margin: 0.5rem 0 0.75rem;
}
.saldo small {
  font-family: var(--sans);
  font-size: 1rem;
  font-weight: 500;
  color: var(--texto-suave);
  margin-left: 0.35rem;
  letter-spacing: 0.08em;
}

.insignia {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.15rem 0.75rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  color: var(--color-nivel, var(--gold));
  background: var(--superficie-2);
  border: 1px solid currentColor;
}

.metricas {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr));
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.metrica {
  background: var(--superficie-2);
  border: 1px solid var(--borde);
  padding: 0.7rem 0.8rem;
}
.metrica .valor {
  font-size: 1.3rem;
  font-weight: 600;
}
.metrica .etiqueta {
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--texto-suave);
}

/* ------------------------------------------------------------ Progreso */

.progreso {
  height: 8px;
  border-radius: 999px;
  background: var(--pista);
  overflow: hidden;
  margin: 0.4rem 0 0.6rem;
}
.progreso > span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: var(--progreso);
  transition: width 0.6s ease;
}
.progreso.delgado {
  height: 5px;
}

/* ------------------------------------------------------------ Avisos */

.aviso {
  padding: 0.7rem 1rem;
  font-weight: 500;
  background: var(--aviso-fondo);
  color: var(--aviso);
  border-left: 3px solid var(--gold);
}
.aviso.descuento {
  margin-bottom: 0.9rem;
}
.codigo-descuento {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 600;
  letter-spacing: 0.12em;
}
.codigo-descuento.grande {
  font-size: 1.6rem;
  margin: 0.4rem 0;
}
.aviso.exito {
  background: var(--exito-fondo);
  color: var(--exito);
  border-left-color: currentColor;
}
.aviso.error {
  background: var(--error-fondo);
  color: var(--error);
  border-left-color: currentColor;
}

/* ------------------------------------------------------------ Listas */

.lista {
  list-style: none;
  margin: 0;
  padding: 0;
}
.lista > li {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--borde);
}
.lista > li:last-child {
  border-bottom: none;
}
.lista .principal {
  flex: 1;
  min-width: 0;
}
.lista .positivo { color: var(--exito); font-weight: 600; }
.lista .negativo { color: var(--error); font-weight: 600; }

.recompensa.alcanzable .principal strong::after {
  content: ' ✓';
  color: var(--exito);
}

.beneficios {
  margin: 0.4rem 0 0;
  padding-left: 1.2rem;
}
.beneficios li {
  margin: 0.15rem 0;
}

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

label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 0.3rem;
}
.campo {
  margin-bottom: 0.9rem;
}
.campo .ayuda {
  font-size: 0.8rem;
  color: var(--texto-suave);
  margin: 0.25rem 0 0;
}

input,
select {
  width: 100%;
  font: inherit;
  color: var(--brown);
  background: var(--campo-fondo);
  border: 1px solid var(--campo-borde);
  border-radius: var(--radio);
  padding: 0.65rem 0.8rem;
}
input:focus,
select:focus,
button:focus-visible {
  outline: 2px solid var(--adorno);
  outline-offset: 2px;
}
input[type='checkbox'] {
  width: 1.15rem;
  height: 1.15rem;
  padding: 0;
  flex: none;
  accent-color: var(--acento);
}
label.casilla {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.5rem 0 0;
  font-size: 0.95rem;
  font-weight: 500;
  letter-spacing: normal;
  text-transform: none;
  cursor: pointer;
}
input.grande {
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: 0.03em;
}

button {
  font: inherit;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  border-radius: var(--radio);
  padding: 0.65rem 1.2rem;
  border: 1px solid var(--acento);
  background: var(--acento);
  color: var(--acento-texto);
  white-space: nowrap;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}
button:hover:not(:disabled) {
  background: var(--acento-hover);
  border-color: var(--acento-hover);
}
button:active:not(:disabled) {
  transform: translateY(1px);
}
button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
button.secundario {
  background: transparent;
  color: var(--enlace);
  border-color: currentColor;
}
button.secundario:hover:not(:disabled) {
  background: var(--superficie-2);
  color: var(--enlace);
  border-color: currentColor;
}
button.texto {
  background: none;
  border: none;
  color: var(--enlace);
  padding: 0.25rem 0.5rem;
}
button.texto:hover:not(:disabled) {
  background: none;
  text-decoration: underline;
}
button.bloque {
  width: 100%;
}
button.chico {
  padding: 0.35rem 0.8rem;
  font-size: 0.85rem;
}

.error-form {
  color: var(--error);
  font-weight: 600;
  font-size: 0.9rem;
  margin: 0.25rem 0 0.75rem;
}
.error-form:empty {
  margin: 0;
}

/* ------------------------------------------------------------ Toast */

#toasts {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  display: grid;
  gap: 0.5rem;
  z-index: 100;
  width: min(92vw, 420px);
}
.toast {
  padding: 0.8rem 1rem;
  font-weight: 500;
  background: var(--brown);
  color: var(--cream);
  border: 1px solid var(--gold);
  box-shadow: 0 6px 18px rgb(20 40 40 / 30%);
  animation: subir 0.25s ease-out both;
}
.toast.error {
  background: #7a1f16;
  border-color: #e7a197;
}

/* ------------------------------------------------------------ Tablas (admin) */

.tabla {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.tabla th,
.tabla td {
  text-align: left;
  padding: 0.5rem;
  border-bottom: 1px solid var(--borde);
}
.tabla th {
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--texto-suave);
  font-weight: 600;
}
.desplazable {
  overflow-x: auto;
}

@keyframes subir {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
