/* Appylisto styles — mobile-first, brand via CSS vars set per tenant.
   Design tokens first; component classes keep their original names. */

* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Per-tenant (overridden inline): */
  --brand: #7c3aed;
  --bg: #ffffff;
  /* Neutrals */
  --ink: #16161d;
  --muted: #5d5d68;
  --line: #e9e9f0;
  --surface: #ffffff;
  /* Brand tints */
  --brand-06: color-mix(in srgb, var(--brand) 6%, white);
  --brand-10: color-mix(in srgb, var(--brand) 10%, white);
  --brand-16: color-mix(in srgb, var(--brand) 16%, white);
  --brand-ink: color-mix(in srgb, var(--brand) 78%, black);
  /* Depth */
  --shadow-s: 0 1px 2px rgb(22 22 29 / 0.05), 0 2px 8px rgb(22 22 29 / 0.05);
  --shadow-m: 0 2px 6px rgb(22 22 29 / 0.06), 0 10px 24px rgb(22 22 29 / 0.08);
  --shadow-brand: 0 8px 24px color-mix(in srgb, var(--brand) 35%, transparent);
  /* Shape */
  --radius-s: 10px;
  --radius-m: 16px;
  --radius-l: 22px;
  /* Layout */
  --header-h: 58px;
  --tabbar-h: 62px;
  /* Motion */
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

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

body {
  font-family: "Nunito Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100dvh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a, button { transition: color 180ms var(--ease), background 180ms var(--ease),
  box-shadow 180ms var(--ease), transform 120ms var(--ease), border-color 180ms var(--ease); }
button { cursor: pointer; font: inherit; }

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 4px;
}

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

/* ---------- App shell ---------- */
.app { padding-bottom: calc(var(--tabbar-h) + 76px); }

.app-header {
  display: flex; align-items: center; gap: 10px;
  height: var(--header-h); padding: 0 16px;
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
}
.app-logo {
  width: 34px; height: 34px; border-radius: 10px; object-fit: cover;
  box-shadow: var(--shadow-s);
}
.app-name {
  font-weight: 800; font-size: 17px; flex: 1;
  letter-spacing: -0.01em;
}
.app-info-link {
  display: grid; place-items: center; width: 36px; height: 36px;
  border-radius: 50%; color: var(--muted); text-decoration: none;
}
.app-info-link:active { background: var(--brand-10); color: var(--brand); }
.lang-switch {
  font-size: 11px; font-weight: 800; letter-spacing: 0.06em; color: var(--muted);
  text-decoration: none; border: 1px solid var(--line);
  border-radius: 999px; padding: 5px 10px; background: var(--surface);
}
.lang-switch:active { border-color: var(--brand); color: var(--brand); }
.app-main { padding: 18px 16px; display: grid; gap: 18px; }

.tab-bar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: flex;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  border-top: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  gap: 3px; padding: 9px 0 10px; min-height: var(--tabbar-h);
  text-decoration: none; color: var(--muted); font-size: 10.5px; font-weight: 700;
  letter-spacing: 0.01em;
}
.tab-icon { display: grid; place-items: center; width: 44px; height: 26px; border-radius: 999px; }
.tab-icon svg { width: 21px; height: 21px; }
.tab:active .tab-icon { transform: scale(0.92); }
.tab-active { color: var(--brand); }
.tab-active .tab-icon { background: var(--brand-16); }

.cta-button {
  position: fixed; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 12px);
  left: 16px; right: 16px; z-index: 20;
  background: linear-gradient(135deg, var(--brand), color-mix(in srgb, var(--brand) 78%, #1c0a3a));
  color: #fff; text-align: center;
  padding: 15px; border-radius: var(--radius-m); font-weight: 800; font-size: 15px;
  letter-spacing: 0.01em;
  text-decoration: none; box-shadow: var(--shadow-brand);
}
.cta-button:active { transform: scale(0.985); }

/* ---------- Cards & content ---------- */
.card {
  border: 1px solid color-mix(in srgb, var(--line) 80%, transparent);
  border-radius: var(--radius-l); overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow-s);
}
.card-img { width: 100%; aspect-ratio: 16/9; object-fit: cover; display: block; }
.card-body { padding: 16px; display: grid; gap: 7px; }
.card-title { font-size: 17px; font-weight: 800; letter-spacing: -0.015em; line-height: 1.3; }
.card-meta { font-size: 12.5px; color: var(--muted); }
.section-title {
  font-size: 12px; font-weight: 800; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.1em;
  margin-top: 4px;
}
.badge {
  display: inline-block; font-size: 11px; font-weight: 800;
  background: var(--brand-10); color: var(--brand-ink);
  border-radius: 999px; padding: 4px 11px; width: fit-content;
  letter-spacing: 0.03em; text-transform: uppercase;
}
.empty { color: var(--muted); text-align: center; padding: 32px 0; font-size: 14px; }

/* ---------- Stamp card ---------- */
.stamps { display: flex; flex-wrap: wrap; gap: 10px; padding: 8px 0; }
.stamp {
  width: 46px; height: 46px; border-radius: 50%;
  border: 2px dashed color-mix(in srgb, var(--muted) 40%, transparent);
  display: grid; place-items: center; font-size: 20px;
  background: color-mix(in srgb, var(--line) 30%, transparent);
}
.stamp-filled {
  border: 2px solid var(--brand);
  background: linear-gradient(145deg, var(--brand-16), var(--brand-06));
  box-shadow: 0 2px 8px color-mix(in srgb, var(--brand) 25%, transparent);
}
.qr-box { display: grid; place-items: center; padding: 12px 0; }
.qr-box svg {
  width: 220px; height: 220px; border-radius: var(--radius-m);
  box-shadow: var(--shadow-s); padding: 8px; background: #fff;
}
.codigo-corto {
  text-align: center; font-size: 34px; font-weight: 900;
  letter-spacing: 0.22em; color: var(--brand-ink);
  font-variant-numeric: tabular-nums;
}
.historial { display: grid; gap: 9px; }
.historial-item {
  display: flex; justify-content: space-between; font-size: 13px;
  border-bottom: 1px solid var(--line); padding-bottom: 9px;
}
.historial-item:last-child { border-bottom: 0; padding-bottom: 0; }

/* ---------- Forms & buttons ---------- */
.form { display: grid; gap: 14px; }
.form label { font-size: 13px; font-weight: 700; display: grid; gap: 5px; color: var(--ink); }
.form input[type="text"], .form input[type="tel"], .form input[type="email"],
.form input[type="password"], .form input[type="date"], .form input[type="url"],
.form input[type="number"], .form input[type="datetime-local"],
.form select, .form textarea {
  width: 100%; padding: 13px 14px; border: 1.5px solid var(--line);
  border-radius: var(--radius-s);
  font-size: 16px; font-family: inherit; background: var(--surface); color: var(--ink);
  transition: border-color 180ms var(--ease), box-shadow 180ms var(--ease);
}
.form input:focus, .form select:focus, .form textarea:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-16);
}
.form textarea { min-height: 90px; }
.check { display: flex; gap: 9px; align-items: flex-start; font-size: 13px; font-weight: 400; }
.check input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--brand); flex-shrink: 0; margin-top: 1px; }

.btn {
  display: inline-block; background: var(--brand); color: #fff; border: 0;
  padding: 14px 18px; border-radius: var(--radius-s); font-weight: 800; font-size: 15px;
  text-align: center; text-decoration: none; cursor: pointer; width: 100%;
  letter-spacing: 0.01em;
  box-shadow: 0 2px 10px color-mix(in srgb, var(--brand) 28%, transparent);
}
.btn:hover { background: color-mix(in srgb, var(--brand) 88%, black); }
.btn:active { transform: scale(0.985); }
.btn-secondary {
  background: var(--surface); color: var(--brand-ink);
  border: 1.5px solid color-mix(in srgb, var(--brand) 45%, var(--line));
  box-shadow: none;
}
.btn-secondary:hover { background: var(--brand-06); }
.btn-danger { background: #dc2626; box-shadow: 0 2px 10px rgb(220 38 38 / 0.28); }
.btn-danger:hover { background: #b91c1c; }
.btn-row { display: grid; gap: 10px; }
.error { color: #dc2626; font-size: 13px; font-weight: 700; }
.ok { color: #15803d; font-size: 13px; font-weight: 700; }
.hint { font-size: 12.5px; color: var(--muted); }

/* ---------- Admin ---------- */
.admin { background: var(--bg); }
.admin-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 18px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.admin-header .app-name { font-weight: 800; letter-spacing: -0.01em; }
.admin-logout { font-size: 13px; font-weight: 700; color: var(--muted); text-decoration: none; }
.admin-logout:hover { color: var(--brand); }
.admin-nav {
  display: flex; gap: 6px; overflow-x: auto; padding: 10px 14px;
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
  scrollbar-width: none;
}
.admin-nav::-webkit-scrollbar { display: none; }
.admin-nav-item {
  white-space: nowrap; padding: 8px 14px; border-radius: 999px;
  text-decoration: none; color: var(--muted); font-size: 14px; font-weight: 700;
}
.admin-nav-item:hover { color: var(--brand-ink); background: var(--brand-06); }
.admin-nav-item.tab-active { background: var(--brand-16); color: var(--brand-ink); }
.admin-main { padding: 20px 16px; display: grid; gap: 18px; max-width: 720px; margin: 0 auto; }
.admin-main h1 { font-size: 26px; font-weight: 900; letter-spacing: -0.02em; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.stat {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-m); padding: 14px 16px;
  box-shadow: var(--shadow-s);
}
.stat-num {
  font-size: 30px; font-weight: 900; letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums; color: var(--brand-ink);
}
.stat-label { font-size: 12px; font-weight: 700; color: var(--muted); }

.list-item {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-m); padding: 13px 16px;
  text-decoration: none; color: inherit;
  box-shadow: var(--shadow-s);
}
a.list-item:hover { border-color: color-mix(in srgb, var(--brand) 40%, var(--line)); }

.table {
  width: 100%; border-collapse: collapse; background: var(--surface);
  border-radius: var(--radius-m); overflow: hidden; box-shadow: var(--shadow-s);
}
.table th { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); }
.table th, .table td { text-align: left; padding: 11px 13px; border-bottom: 1px solid var(--line); font-size: 14px; }
.table tr:last-child td { border-bottom: 0; }

/* ---------- Video feed (TikTok-style) ---------- */
.app-main--full { padding: 0; gap: 0; }
.video-feed {
  height: calc(100dvh - var(--header-h) - var(--tabbar-h));
  overflow-y: auto; overscroll-behavior: contain;
  scroll-snap-type: y mandatory; background: #000;
}
.video-slide {
  position: relative; height: 100%; scroll-snap-align: start;
  scroll-snap-stop: always; display: grid; place-items: center;
}
.video-slide video {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.video-overlay {
  position: absolute; left: 16px; right: 16px; bottom: 20px;
  display: flex; justify-content: space-between; align-items: flex-end;
  gap: 12px; pointer-events: none;
}
.video-title {
  color: #fff; font-weight: 800; font-size: 15px;
  text-shadow: 0 1px 6px rgb(0 0 0 / 0.75); margin: 0;
}
.video-like {
  pointer-events: auto; background: rgb(0 0 0 / 0.45); color: #fff;
  border: 0; border-radius: 999px; padding: 10px 15px; font-size: 15px;
  font-weight: 800; cursor: pointer;
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
.video-like:active { transform: scale(0.94); }
.video-like--on { background: var(--brand); box-shadow: var(--shadow-brand); }
.video-mute-hint {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%);
  background: rgb(0 0 0 / 0.5); color: #fff; font-size: 12px; font-weight: 700;
  border-radius: 999px; padding: 6px 13px; pointer-events: none;
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}

/* ---------- Scanner ---------- */
#scanner-video {
  width: 100%; border-radius: var(--radius-m); background: #000;
  aspect-ratio: 3/4; object-fit: cover; box-shadow: var(--shadow-m);
}

/* ---------- Plain (login / landing / super) ---------- */
.plain-main { max-width: 480px; margin: 0 auto; padding: 40px 20px; display: grid; gap: 20px; }
.plain h1 { font-size: 28px; font-weight: 900; letter-spacing: -0.02em; }
