/* Dashboard — estética Pixeleo: azul marino profundo, dorado, Space Grotesk. */
@font-face {
  font-family: "Space Grotesk"; font-weight: 300 700; font-style: normal; font-display: swap;
  src: url("/static/fonts/space-grotesk-latin-wght-normal.woff2") format("woff2");
}

:root {
  --navy: #1b2d52;
  --navy-d: #0d1b33;
  --gold: #f5a623;
  --orange: #e8820c;
  --blue: #4bafd9;
  --cream: #f5f0e8;
  --green: #34d399;
  --red: #ff7a59;
  --ease: cubic-bezier(.4, 0, .2, 1);

  /* Tokens semánticos (tema oscuro). Los modales los reemplazan por la versión clara. */
  --surface: rgba(255, 255, 255, .05);
  --surface-2: rgba(255, 255, 255, .09);
  --line: rgba(255, 255, 255, .11);
  --text: #fff;
  --muted: rgba(255, 255, 255, .68);
  --faint: rgba(255, 255, 255, .5);
  --accent: var(--gold);
  --accent-text: var(--gold);
  --on-accent: var(--navy-d);
  --input-bg: rgba(255, 255, 255, .06);
  --danger: var(--red);
  --ok: var(--green);
  --warn: var(--gold);
  --sheet: rgba(13, 27, 51, .92);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body.admin {
  margin: 0; min-height: 100vh; min-height: 100dvh;
  font: 400 16px/1.55 "Space Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--text);
  background: linear-gradient(150deg, var(--navy), #14223f 45%, var(--navy-d)) fixed, var(--navy-d);
  -webkit-font-smoothing: antialiased;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
/* Fondo del sitio de Pixeleo, estático: resplandores dorado/azul y una grilla muy tenue. */
body.admin::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(60vmax 60vmax at 0% -10%, rgba(245, 166, 35, .13), transparent 60%),
    radial-gradient(70vmax 60vmax at 105% 25%, rgba(75, 175, 217, .12), transparent 60%),
    radial-gradient(55vmax 55vmax at 20% 115%, rgba(232, 130, 12, .09), transparent 60%),
    linear-gradient(rgba(245, 166, 35, .03) 1px, transparent 1px) 0 0 / 44px 44px,
    linear-gradient(90deg, rgba(245, 166, 35, .03) 1px, transparent 1px) 0 0 / 44px 44px;
}
::selection { background: var(--gold); color: var(--navy-d); }
h1, h2 { line-height: 1.15; letter-spacing: -.02em; margin: 0; }
h1 { font-size: clamp(1.6rem, 6vw, 2.1rem); font-weight: 700; margin-bottom: .75rem; }
h2 { font-size: 1.05rem; font-weight: 700; margin-bottom: .75rem; }
a { color: var(--accent-text); text-underline-offset: 3px; }
p { margin: 0 0 .75rem; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* Etiqueta de sección, como los "kicker" de la web de Pixeleo. */
.kicker {
  display: inline-flex; align-items: center; margin: 0 0 .35rem;
  font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .18em; color: var(--accent-text);
}
.kicker::before { content: ""; width: 1.4rem; height: 1px; margin-right: .6rem; background: currentColor; opacity: .55; }

/* --- Botones: píldora dorada, como los de pixeleo.com.ar --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: 48px; padding: 0 1.6rem; border: 1px solid var(--gold); border-radius: 999px;
  background: var(--gold); color: var(--on-accent); font-family: inherit; font-weight: 700; font-size: .95rem; line-height: 1; text-decoration: none; white-space: nowrap; cursor: pointer;
  transition: transform .25s var(--ease), background .25s, box-shadow .25s, color .25s, border-color .25s;
}
.btn:hover { background: var(--orange); border-color: var(--orange); transform: translateY(-2px); box-shadow: 0 12px 30px rgba(245, 166, 35, .25); }
.btn:active { transform: translateY(0); }
.btn.ghost { background: transparent; color: var(--text); border-color: rgba(255, 255, 255, .3); }
.btn.ghost:hover { background: transparent; border-color: var(--gold); color: var(--gold); box-shadow: none; }
.btn.small { min-height: 42px; padding: 0 1.15rem; font-size: .9rem; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger:hover { filter: brightness(1.08); box-shadow: 0 12px 30px rgba(255, 122, 89, .25); }
.btn[disabled] { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }
.link { background: none; border: 0; color: var(--muted); font-family: inherit; font-size: .9rem; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; padding: .5rem; }
.link:hover { color: var(--gold); }

/* --- Encabezado --- */
.bar {
  position: sticky; top: 0; z-index: 20; display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding: .6rem max(1rem, calc((100vw - 760px) / 2 + 1rem)); background: rgba(13, 27, 51, .82); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand-link { display: flex; align-items: center; gap: .7rem; color: var(--text); text-decoration: none; min-width: 0; }
.brand-link img { width: 38px; height: 40px; object-fit: contain; flex: none; filter: drop-shadow(0 1px 10px rgba(0, 0, 0, .4)); }
.brand-link span { display: grid; line-height: 1.15; min-width: 0; }
.brand-link small { font-size: .66rem; font-weight: 600; line-height: 1.2; letter-spacing: .18em; text-transform: uppercase; color: var(--gold); }
.brand-link strong { font-size: 1rem; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar form { margin: 0; }
.wrap { position: relative; max-width: 760px; margin: 0 auto; padding: 1.25rem 1rem 3rem; }
.wrap.narrow { max-width: 420px; padding-top: 2.5rem; }

/* --- Login --- */
.login { text-align: center; }
.login img { display: block; width: 96px; height: auto; margin: 0 auto 1rem; filter: drop-shadow(0 8px 24px rgba(0, 0, 0, .35)); }
.login .kicker { display: flex; justify-content: center; }
.login h1 { margin-bottom: 1.5rem; }
.login form { text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 1.25rem; }

/* --- Estructura --- */
.head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; margin-bottom: 1rem; }
.head h1 { margin: 0; }
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: .7rem; }
.item {
  display: flex; align-items: center; gap: .5rem; padding: .4rem .5rem .4rem 1.1rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px;
  transition: border-color .25s var(--ease), background .25s var(--ease);
}
.item:hover { border-color: rgba(245, 166, 35, .35); background: var(--surface-2); }
.item .row-main { flex: 1; padding: .6rem 0; }
.row-main { display: grid; min-width: 0; }
.row-main strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.muted, .hint { color: var(--muted); font-size: .88rem; }
.hint { display: block; margin-top: .35rem; font-weight: 400; }

.icon {
  flex: none; display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px;
  border-radius: 50%; border: 1px solid transparent; color: var(--text); background: none; cursor: pointer;
  transition: border-color .2s, color .2s, background .2s;
}
.icon:hover, .icon:focus-visible { border-color: var(--gold); color: var(--gold); background: rgba(245, 166, 35, .08); }
.icon.danger { color: var(--danger); }
.icon.danger:hover, .icon.danger:focus-visible { border-color: var(--danger); color: var(--danger); background: rgba(255, 122, 89, .1); }

.badge { flex: none; font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; padding: .28rem .65rem; border-radius: 999px; border: 1px solid currentColor; }
.badge.active { color: var(--ok); }
.badge.expired { color: var(--warn); }
.badge.purged { color: var(--faint); }
.badge.permanent { color: var(--blue); }

/* --- Formularios --- */
.stack { display: grid; gap: 1rem; }
label { display: grid; gap: .4rem; font-weight: 600; font-size: .92rem; }
input {
  width: 100%; min-height: 48px; padding: .5rem .9rem; font-family: inherit; font-weight: 400; font-size: 1rem; line-height: 1.3; color: var(--text);
  border: 1px solid var(--line); border-radius: 14px; background: var(--input-bg);
  transition: border-color .2s, box-shadow .2s;
}
input::placeholder { color: var(--faint); }
input:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(245, 166, 35, .2); }
input[readonly] { opacity: .8; }
input[type=file] { padding: .55rem .75rem; }
input[type=file]::file-selector-button {
  margin-right: .75rem; padding: .5rem 1rem; border: 1px solid rgba(255, 255, 255, .3); border-radius: 999px;
  background: transparent; color: var(--text); font-family: inherit; font-weight: 600; font-size: .85rem; cursor: pointer;
}
input[type=file]::file-selector-button:hover { border-color: var(--gold); color: var(--gold); }

/* --- Paneles --- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 1.1rem; margin: 0 0 1rem; }
.panel h2 {
  display: flex; align-items: center; margin-bottom: .9rem; font-size: .75rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .18em; color: var(--accent-text);
}
.panel h2::before { content: ""; width: 1.4rem; height: 1px; margin-right: .6rem; background: currentColor; opacity: .55; }
.panel .player { width: 100%; max-height: 60vh; border-radius: 14px; background: #000; display: block; }
.panel audio.player { background: transparent; }
.qr { display: block; width: 240px; height: auto; max-width: 100%; margin: 0 auto 1rem; padding: 12px; image-rendering: pixelated; background: #fff; border-radius: 16px; }
.actions { display: grid; gap: .6rem; margin-bottom: 1rem; }
.copy { display: flex; gap: .5rem; }
.facts { display: grid; grid-template-columns: 7.5rem 1fr; gap: .45rem 1rem; margin: 0; }
.facts dt { color: var(--muted); font-size: .9rem; }
.facts dd { margin: 0; min-width: 0; }
.facts .hint { display: block; margin-top: .25rem; }
/* Datos editables: la etiqueta arriba y, debajo, el input ya cargado con su botón. */
.facts dt.field, .facts dd.field { grid-column: 1 / -1; }
.facts dt.field { margin-top: .4rem; margin-bottom: -.3rem; }
.facts dt.field label { font-weight: 400; color: var(--muted); font-size: .9rem; }
/* Barra "Guardar cambios / Cancelar": fija abajo de todo, siempre a la vista aunque se scrollee. */
.modal-actions { position: sticky; bottom: 0; z-index: 2; display: flex; gap: .6rem; margin: 0; padding: .9rem 0 .35rem; background: linear-gradient(to bottom, transparent, var(--sheet) 32%); }
.modal-actions .btn { flex: 1; padding: 0 .6rem; white-space: normal; line-height: 1.15; }
.modal-actions .btn:first-child { flex: 1.5; }
.notice { padding: .8rem 1rem; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); margin: 0 0 1rem; }
.notice.ok { border-color: rgba(52, 211, 153, .55); background: rgba(52, 211, 153, .08); }
.notice.err { border-color: rgba(255, 122, 89, .6); background: rgba(255, 122, 89, .1); }
.notice a { font-weight: 600; }
details.danger summary { cursor: pointer; font-weight: 600; color: var(--danger); padding: .5rem 0; min-height: 44px; }
details.danger p { color: var(--muted); font-size: .9rem; }

/* --- Código de acceso y QR del comercio --- */
.mono { white-space: nowrap; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-weight: 700; letter-spacing: .06em; color: var(--text); }
.access-code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 1.7rem; font-weight: 700; letter-spacing: .1em; text-align: center; min-height: 64px; padding-inline: .4rem; }
.code-actions { display: flex; gap: .5rem; margin: .5rem 0; }
.code-actions .btn { flex: 1; padding: 0 .6rem; white-space: normal; text-align: center; line-height: 1.15; }
.regen-confirm { margin: 0 0 .5rem; padding: .75rem; border: 1px solid var(--danger); border-radius: 14px; background: rgba(196, 61, 28, .06); }
.regen-confirm p { color: var(--muted); font-size: .9rem; margin: 0 0 .6rem; }
.regen-form { display: flex; gap: .5rem; margin: 0; }
.regen-form .btn { flex: 1; padding: 0 .6rem; }
.regen-cancel { display: none; }
/* Con JavaScript la confirmación aparece al tocar "Generar otro código"; sin él queda a la vista (el botón no abriría nada). */
.js .regen-confirm:not(.open) { display: none; }
.js .regen-cancel { display: inline-flex; }
.direct-link { margin-top: .75rem; font-weight: 400; color: var(--muted); font-size: .85rem; }
.qr-thumb { color: var(--navy-d); }
.qr-box { display: flex; justify-content: center; margin: 0 0 .5rem; }
.qr-url { text-align: center; word-break: break-all; margin: 0 0 1rem; }
.steps { margin: .25rem 0 1rem; padding-left: 1.2rem; display: grid; gap: .45rem; font-size: .92rem; color: var(--muted); }
.steps strong { color: var(--text); }
.nowrap { white-space: nowrap; }

/* --- Logo del comercio --- */
.logo-panel { display: flex; align-items: center; gap: .9rem; flex-wrap: wrap; }
.logo-thumb, .logo-stage { display: flex; align-items: center; justify-content: center; background: var(--cream); color: #6f6458; border-radius: 14px; overflow: hidden; }
.logo-thumb { width: 96px; height: 56px; flex: none; padding: 6px; font-size: .75rem; }
.logo-thumb img { max-width: 100%; max-height: 100%; width: auto; height: auto; }
.logo-copy { flex: 1 1 160px; display: grid; min-width: 0; }
.logo-copy .kicker { margin-bottom: .15rem; }
.logo-preview { margin: 0 0 1rem; }
.logo-stage { margin-top: .4rem; min-height: 136px; padding: 1rem; border: 1px dashed var(--line); background: #fbf3e8; font: 600 1.15rem Georgia, serif; color: #3b2a22; }
/* Mismo recuadro (300×112) que en la página de los clientes. */
.logo-stage img { width: 300px; max-width: 100%; height: 112px; object-fit: contain; object-position: center; }
.logo-actions { position: static; background: none; padding: .25rem 0 0; }
.btn.ghost.danger-outline { color: var(--danger); border-color: var(--danger); }
.btn.ghost.danger-outline:hover { color: var(--danger); border-color: var(--danger); background: rgba(196, 61, 28, .08); }

/* --- Saldo: la tarjeta destacada, como la "oferta" del sitio de Pixeleo --- */
.balance { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem .9rem; border-color: rgba(245, 166, 35, .35); background: rgba(245, 166, 35, .07); }
.balance .kicker { margin: 0; letter-spacing: .14em; }
.balance .kicker::before { display: none; }
/* La cifra va a la derecha de la etiqueta, en Space Grotesk. */
.balance .count { font-size: 2.4rem; font-weight: 700; line-height: 1; letter-spacing: -.02em; color: var(--gold); }
.balance .btn { margin-left: auto; }
.balance .hint { flex: 1 0 100%; margin-top: 0; }
@media (max-width: 520px) { .balance .btn { flex: 1 0 100%; margin-left: 0; } }
.balance.low { border-color: rgba(232, 130, 12, .7); }
.balance.low .count { color: var(--orange); }
.balance.empty { border-color: rgba(255, 122, 89, .65); background: rgba(255, 122, 89, .09); }
.balance.empty .count { color: var(--danger); }
.packs, .orders { list-style: none; margin: 0 0 1rem; padding: 0; display: grid; gap: 0; }
.pack, .orders li { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .85rem 0; border-top: 1px solid var(--line); }
.pack:first-child, .orders li:first-child { border-top: 0; }
.pack > div { display: grid; }
.pack strong { font-weight: 700; }
.pack form { margin: 0; }
.orders li { font-size: .9rem; color: var(--muted); }

/* --- Modales: crema con texto marino, como los popups del sitio de Pixeleo --- */
dialog {
  --surface: #fff; --surface-2: #efe8dc; --line: rgba(13, 27, 51, .13);
  --text: var(--navy-d); --muted: rgba(13, 27, 51, .66); --faint: rgba(13, 27, 51, .5);
  --sheet: var(--cream);
  --accent-text: #a85a00; --input-bg: #fff; --danger: #c43d1c; --ok: #14795a; --warn: #a85a00;
  color-scheme: light;
  width: min(92vw, 440px); padding: 1.4rem; border: 0; border-radius: 24px; background: var(--cream); color: var(--text);
  box-shadow: 0 30px 80px rgba(0, 0, 0, .5);
}
dialog:focus-visible { outline: none; }
dialog::backdrop { background: rgba(13, 27, 51, .72); backdrop-filter: blur(4px); }
dialog.wide { width: min(94vw, 580px); max-height: 92vh; max-height: 92dvh; overflow-y: auto; padding: 1rem; }
dialog.wide .panel { margin-bottom: .75rem; box-shadow: 0 1px 0 rgba(13, 27, 51, .04); }
dialog .head { padding: .25rem .25rem 0; }
dialog h2 { margin: 0; font-size: 1.2rem; letter-spacing: -.01em; text-transform: none; color: var(--text); display: block; }
dialog h2::before { content: none; }
dialog p { margin: 0; }
dialog .panel > p { margin-bottom: 1rem; }
dialog .badge.active { color: #14795a; }
dialog .badge.permanent { color: #0f6f94; }
dialog .btn.ghost { color: var(--navy-d); border-color: rgba(13, 27, 51, .3); }
dialog .btn.ghost:hover { color: var(--orange); border-color: var(--orange); }
dialog .btn:not(.ghost):not(.danger) { background: var(--navy-d); border-color: var(--navy-d); color: #fff; }
dialog .btn:not(.ghost):not(.danger):hover { background: var(--navy); border-color: var(--navy); box-shadow: 0 12px 30px rgba(13, 27, 51, .25); }
dialog .icon:hover, dialog .icon:focus-visible { border-color: var(--navy-d); color: var(--navy-d); background: rgba(13, 27, 51, .06); }
dialog input:focus { border-color: var(--orange); box-shadow: 0 0 0 3px rgba(232, 130, 12, .22); }
dialog input[type=file]::file-selector-button { border-color: rgba(13, 27, 51, .3); color: var(--navy-d); }
.modal-title { flex: 1; min-width: 0; font-size: 1.3rem; font-weight: 700; line-height: 1.2; }

@media (min-width: 600px) {
  .actions { grid-template-columns: 1fr 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}
