/* ============================================================
   STBMadrid — Control de Acceso (mobile-first)
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:       #0a0a0a;
  --card:     #141414;
  --border:   rgba(255,255,255,0.1);
  --gold:     #d4a017;
  --green:    #4ade80;
  --red:      #f87171;
  --text:     #ffffff;
  --muted:    rgba(255,255,255,0.5);
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Montserrat', sans-serif;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

/* ── PANTALLAS ────────────────────────── */
.screen {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
}
.screen.active { display: flex; }

/* ── COMPONENTES COMUNES ────────────────────────── */
.acc-input {
  width: 100%;
  padding: 0.85rem 1rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #1c1c1c;
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}
.acc-input:focus { border-color: var(--gold); }

.acc-btn-primary {
  width: 100%;
  padding: 0.9rem;
  border-radius: 12px;
  border: none;
  background: var(--gold);
  color: #000;
  font-family: inherit;
  font-weight: 800;
  font-size: 1rem;
  cursor: pointer;
  transition: opacity 0.2s;
}
.acc-btn-primary:active { opacity: 0.8; }
.acc-btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.acc-btn-secondary {
  width: 100%;
  padding: 0.9rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
}

.acc-error {
  color: var(--red);
  font-size: 0.85rem;
  min-height: 1.1em;
  text-align: center;
}
.gold { color: var(--gold); }
.valid-color { color: var(--green); }
.error-color { color: var(--red); }

/* ── LOGIN ────────────────────────── */
.login-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 2rem 1.5rem;
  gap: 0.75rem;
  text-align: center;
  max-width: 360px;
  margin: 0 auto;
  width: 100%;
}
.login-logo {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: #000;
  object-fit: contain;
  border: 2px solid rgba(212, 160, 23, 0.55);
  margin-bottom: 0.25rem;
}
.login-wrap h1 { font-size: 1.75rem; font-weight: 800; }
.login-sub { color: var(--muted); font-size: 0.82rem; margin-bottom: 0.5rem; }
#login-form {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  width: 100%;
}

/* ── ESCÁNER: CABECERA ────────────────────────── */
.scanner-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1rem;
  background: #111;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 0.5rem;
}
.scanner-user {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--gold);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.scanner-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.printer-btn {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.75rem;
  border-radius: 20px;
  border: 1px solid;
  background: transparent;
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}
.printer-btn.disconnected { border-color: var(--border); color: var(--muted); }
.printer-btn.connecting   { border-color: var(--gold);   color: var(--gold);   animation: pulse-gold 1s infinite; }
.printer-btn.connected    { border-color: var(--green);  color: var(--green);  }

@keyframes pulse-gold {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}

.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-size: 0.9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ── ESCÁNER: VIEWPORT ────────────────────────── */
.scanner-viewport {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: #000;
}
#qr-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Marco escaneo */
.scan-frame {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.sf-corner {
  position: absolute;
  width: 40px;
  height: 40px;
  border-style: solid;
  border-color: var(--gold);
}
/* Posición relativa al marco 230×230 centrado */
.sf-corner.tl { top: calc(50% - 115px); left: calc(50% - 115px); border-width: 3px 0 0 3px; border-radius: 4px 0 0 0; }
.sf-corner.tr { top: calc(50% - 115px); right: calc(50% - 115px); border-width: 3px 3px 0 0; border-radius: 0 4px 0 0; }
.sf-corner.bl { bottom: calc(50% - 115px); left: calc(50% - 115px); border-width: 0 0 3px 3px; border-radius: 0 0 0 4px; }
.sf-corner.br { bottom: calc(50% - 115px); right: calc(50% - 115px); border-width: 0 3px 3px 0; border-radius: 0 0 4px 0; }

.scan-line {
  position: absolute;
  width: 230px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  animation: scan 2.2s ease-in-out infinite;
}
@keyframes scan {
  0%   { transform: translateY(-115px); opacity: 0; }
  15%  { opacity: 1; }
  85%  { opacity: 1; }
  100% { transform: translateY(115px); opacity: 0; }
}

.scan-hint {
  position: absolute;
  bottom: 1.2rem;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.65);
  color: var(--muted);
  font-size: 0.78rem;
  padding: 0.4rem 1.1rem;
  border-radius: 20px;
  white-space: nowrap;
}

/* ── BARRA ÚLTIMO RESULTADO ────────────────────────── */
.last-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 1rem;
  background: #111;
  border-top: 1px solid var(--border);
  font-size: 0.82rem;
  flex-shrink: 0;
}
.last-bar-text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.last-bar-btn {
  padding: 0.25rem 0.75rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 0.78rem;
  cursor: pointer;
  flex-shrink: 0;
}

/* ── OVERLAY RESULTADO ────────────────────────── */
.overlay-result {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 1rem;
}
.result-card {
  background: var(--card);
  border-radius: 20px;
  padding: 2rem 1.5rem;
  width: 100%;
  max-width: 360px;
  text-align: center;
  border: 1px solid var(--border);
  transition: border-color 0.3s;
}
.result-card.valid   { border-color: var(--green); }
.result-card.invalid { border-color: var(--red); }

.result-state { display: flex; flex-direction: column; align-items: center; gap: 0.4rem; }
.loading-state { gap: 0.8rem; padding: 1rem 0; }

.result-big-icon { font-size: 3.5rem; line-height: 1; }
.result-title    { font-size: 1.4rem; font-weight: 800; }
.res-name   { font-size: 1.15rem; font-weight: 700; margin-top: 0.3rem; }
.res-ticket { font-size: 0.88rem; color: var(--gold); font-weight: 600; }
.res-drinks {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--green);
  margin: 0.6rem 0 0.2rem;
  padding: 0.5rem 1rem;
  border: 2px solid rgba(74,222,128,0.25);
  border-radius: 10px;
  width: 100%;
}
.res-meta  { font-size: 0.7rem; color: var(--muted); font-family: monospace; }
.res-print { font-size: 0.78rem; color: var(--muted); min-height: 1em; }
.next-btn  { margin-top: 0.8rem; }

.err-reason { font-size: 0.95rem; color: var(--red); margin-top: 0.3rem; }
.err-name   { font-size: 0.9rem; color: var(--muted); }

/* Spinner */
.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(255,255,255,0.1);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
