/* ==========================================================================
   Don Esquite POS — PANTALLA DE ACCESO
   --------------------------------------------------------------------------
   Cubre todo hasta que se sabe quién está usando la caja. Es lo primero que
   ve alguien del negocio cada mañana, así que tiene que abrir rápido, verse
   tranquila y tener UN solo botón evidente.
   ========================================================================== */

.acceso {
  position: fixed;
  inset: 0;
  z-index: 1200;            /* por encima de modales y toasts, debajo del aviso
                               de actualización (99999) */
  display: grid;
  place-items: center;
  padding: var(--s-6) var(--s-4);
  padding-bottom: calc(var(--s-6) + env(safe-area-inset-bottom));
  background: var(--surface-0);
  overflow: hidden;
}

.acceso[hidden] { display: none; }

/* Sale con un desvanecido corto: que no parpadee al entrar. */
.acceso--saliendo {
  animation: accesoSale var(--t-normal) var(--ease-out) forwards;
  pointer-events: none;
}

@keyframes accesoSale {
  to { opacity: 0; transform: scale(1.015); }
}

/* --------------------------------------------------------------------------
   Fondo: dos manchas de color muy difusas. Dan profundidad sin dibujar nada
   que compita con el contenido.
   -------------------------------------------------------------------------- */
.acceso::before,
.acceso::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.5;
  pointer-events: none;
}

.acceso::before {
  width: 46vmax; height: 46vmax;
  top: -18vmax; left: -14vmax;
  background: hsl(var(--hue-brand) var(--sat-brand) 70% / 0.55);
}

.acceso::after {
  width: 38vmax; height: 38vmax;
  bottom: -16vmax; right: -12vmax;
  background: var(--maiz);
  opacity: 0.28;
}

:root[data-theme="dark"] .acceso::before { opacity: 0.32; }
:root[data-theme="dark"] .acceso::after  { opacity: 0.16; }

/* --------------------------------------------------------------------------
   Tarjeta
   -------------------------------------------------------------------------- */
.acceso__hoja {
  position: relative;
  z-index: 1;
  width: min(100%, 400px);
  padding: var(--s-8) var(--s-7) var(--s-7);
  border-radius: var(--r-xl);
  background: var(--glass-bg);
  border: 1px solid var(--glass-brd);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  box-shadow: var(--sh-xl);
  text-align: center;
  animation: accesoEntra var(--t-slow) var(--ease-spring) both;
}

:root[data-theme="dark"] .acceso__hoja {
  background: rgba(26, 28, 34, 0.82);
  border-color: rgba(255, 255, 255, 0.08);
}

@keyframes accesoEntra {
  from { opacity: 0; transform: translateY(14px) scale(0.97); }
  to   { opacity: 1; transform: none; }
}

.acceso__logo {
  width: 78px;
  height: 78px;
  border-radius: var(--r-lg);
  object-fit: cover;
  margin: 0 auto var(--s-5);
  display: block;
  box-shadow: var(--sh-md);
}

.acceso__titulo {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 700;
  letter-spacing: var(--tracking-tight);
  color: var(--text-primary);
  margin: 0;
}

.acceso__tag {
  font-size: var(--text-md);
  color: var(--text-muted);
  margin: var(--s-1) 0 var(--s-7);
}

/* --------------------------------------------------------------------------
   Botón de Google
   Blanco con el logo a color: es el patrón que la gente reconoce. Cambiarlo
   por un botón morado "bonito" solo hace dudar de si es el correcto.
   -------------------------------------------------------------------------- */
.btn-google {
  width: 100%;
  min-height: 52px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-3);
  padding: 0 var(--s-5);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--r-full);
  background: #ffffff;
  color: #1f1f1f;
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--sh-sm);
  transition: transform var(--t-fast) var(--ease-out),
              box-shadow var(--t-fast) var(--ease-out),
              background var(--t-fast) var(--ease-out);
}

.btn-google:hover:not(:disabled) { box-shadow: var(--sh-md); transform: translateY(-1px); }
.btn-google:active:not(:disabled) { transform: translateY(0) scale(0.985); background: #f3f3f3; }
.btn-google:disabled { opacity: 0.6; cursor: default; }

.btn-google svg { width: 20px; height: 20px; flex: none; }

/* En oscuro el botón sigue siendo claro (así lo pide la guía de Google),
   solo se le baja un punto el blanco puro para que no encandile. */
:root[data-theme="dark"] .btn-google { background: #f1f1f1; border-color: transparent; }

.acceso__pie {
  margin: var(--s-6) 0 0;
  font-size: var(--text-xs);
  line-height: var(--leading-normal);
  color: var(--text-faint);
}

/* --------------------------------------------------------------------------
   Estados: cargando, sin acceso, desactivado
   -------------------------------------------------------------------------- */
.acceso__cargando {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-3);
  min-height: 52px;
  color: var(--text-muted);
  font-size: var(--text-md);
}

.acceso__giro {
  width: 20px; height: 20px;
  border: 2px solid var(--hairline-strong);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: accesoGira 0.7s linear infinite;
}

@keyframes accesoGira { to { transform: rotate(360deg); } }

.acceso__aviso {
  display: flex;
  gap: var(--s-3);
  text-align: left;
  padding: var(--s-4);
  margin-bottom: var(--s-5);
  border-radius: var(--r-md);
  background: var(--error-soft);
  color: var(--text-primary);
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
  animation: accesoEntra var(--t-normal) var(--ease-out) both;
}

.acceso__aviso--espera { background: var(--warning-soft); }
.acceso__aviso--info   { background: var(--info-soft); }

.acceso__aviso svg { width: 20px; height: 20px; flex: none; color: var(--error); }
.acceso__aviso--espera svg { color: var(--warning); }
.acceso__aviso--info svg   { color: var(--info); }

.acceso__aviso b { display: block; margin-bottom: 2px; }

.acceso__correo {
  font-family: var(--font-body);
  font-weight: 600;
  color: var(--brand-text);
  word-break: break-all;
}

/* Botón secundario "Probar con otra cuenta" */
.acceso__otra {
  width: 100%;
  min-height: 44px;
  margin-top: var(--s-3);
  border: none;
  border-radius: var(--r-full);
  background: transparent;
  color: var(--brand-text);
  font-family: var(--font-body);
  font-size: var(--text-md);
  font-weight: 600;
  cursor: pointer;
  transition: background var(--t-fast) var(--ease-out);
}

.acceso__otra:hover { background: var(--brand-soft); }

/* Aviso de que se está trabajando con el perfil guardado, sin señal. */
.acceso__offline {
  margin-top: var(--s-4);
  font-size: var(--text-xs);
  color: var(--warning);
}

/* --------------------------------------------------------------------------
   Pantalla chica
   -------------------------------------------------------------------------- */
@media (max-width: 480px) {
  .acceso__hoja {
    padding: var(--s-7) var(--s-5) var(--s-6);
    border-radius: var(--r-lg);
  }
  .acceso__logo { width: 64px; height: 64px; }
  .acceso__titulo { font-size: var(--text-xl); }
}

@media (prefers-reduced-motion: reduce) {
  .acceso__hoja, .acceso__aviso { animation: none; }
  .acceso__giro { animation-duration: 1.6s; }
}

/* ==========================================================================
   OPCIONES DEL MENÚ DEL PERFIL
   ========================================================================== */

.menu-item--salir { color: var(--error); }
.menu-item--salir svg { color: var(--error); }

/* ==========================================================================
   TABLA DE USUARIOS (módulo Admin)
   ========================================================================== */
.celda-usuario {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  min-width: 0;
}

.celda-usuario__av {
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 50%;
  object-fit: cover;
  display: grid;
  place-items: center;
  background: var(--brand-soft);
  color: var(--brand-text);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.02em;
  overflow: hidden;
}

.celda-usuario__texto { min-width: 0; display: flex; flex-direction: column; }

.celda-usuario__nombre {
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.celda-usuario__correo {
  font-size: var(--text-xs);
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tag-rol {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: var(--r-full);
  font-size: var(--text-2xs);
  font-weight: 600;
  background: var(--surface-2);
  color: var(--text-secondary);
  white-space: nowrap;
}

.tag-rol--superadmin { background: var(--brand-soft); color: var(--brand-text); }
.tag-rol--admin      { background: var(--info-soft);  color: var(--info); }
.tag-rol--bodega     { background: var(--warning-soft); color: var(--warning); }
.tag-rol--cajero     { background: var(--success-soft); color: var(--success); }

.fila-admin[data-activo="no"] .celda-usuario__nombre,
.fila-admin[data-activo="no"] .celda-usuario__correo { opacity: 0.5; }

/* Tarjetas de rol dentro del formulario de usuario */
.roles-lista {
  display: grid;
  gap: var(--s-2);
}

.rol-opcion {
  display: flex;
  align-items: flex-start;
  gap: var(--s-3);
  width: 100%;
  padding: var(--s-3) var(--s-4);
  border: 1.5px solid var(--hairline);
  border-radius: var(--r-md);
  background: var(--surface-1);
  text-align: left;
  cursor: pointer;
  transition: border-color var(--t-fast) var(--ease-out),
              background var(--t-fast) var(--ease-out);
}

.rol-opcion:hover { background: var(--surface-2); }

.rol-opcion[aria-selected="true"] {
  border-color: var(--brand);
  background: var(--brand-softer);
}

.rol-opcion__marca {
  width: 20px; height: 20px;
  flex: none;
  margin-top: 1px;
  border-radius: 50%;
  border: 2px solid var(--hairline-strong);
  display: grid;
  place-items: center;
}

.rol-opcion[aria-selected="true"] .rol-opcion__marca {
  border-color: var(--brand);
  background: var(--brand);
}

.rol-opcion__marca svg { width: 12px; height: 12px; color: var(--on-brand); opacity: 0; }
.rol-opcion[aria-selected="true"] .rol-opcion__marca svg { opacity: 1; }

.rol-opcion__nombre { display: block; font-weight: 600; color: var(--text-primary); }
.rol-opcion__detalle {
  display: block;
  font-size: var(--text-xs);
  color: var(--text-muted);
  line-height: var(--leading-normal);
}

/* Fila con el interruptor dentro del formulario */
.campo-switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  padding: var(--s-4);
  border-radius: var(--r-md);
  background: var(--surface-2);
}

.campo-switch__txt { display: flex; flex-direction: column; }
.campo-switch__nombre { font-weight: 600; color: var(--text-primary); }
.campo-switch__nota {
  font-size: var(--text-xs);
  color: var(--text-muted);
  line-height: var(--leading-normal);
}

/* Pista debajo de un campo del formulario. */
.field__nota {
  font-size: var(--text-xs);
  color: var(--text-muted);
  line-height: var(--leading-snug);
}

/* ==========================================================================
   SELECTOR DE PUNTO DE VENTA
   ========================================================================== */
.acceso__pregunta {
  margin: 0 0 var(--s-4);
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--text-primary);
}

.acceso__puntos {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  text-align: left;
}

.punto-op {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  width: 100%;
  min-height: 60px;
  padding: var(--s-3) var(--s-4);
  border: 1.5px solid var(--hairline);
  border-radius: var(--r-md);
  background: var(--surface-1);
  cursor: pointer;
  text-align: left;
  transition: border-color var(--t-fast) var(--ease-out),
              background var(--t-fast) var(--ease-out),
              transform var(--t-fast) var(--ease-out);
}

.punto-op:hover {
  border-color: var(--brand);
  background: var(--brand-softer);
  transform: translateY(-1px);
}

.punto-op:active { transform: translateY(0) scale(0.99); }

.punto-op__ico {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: none;
  border-radius: var(--r-sm);
  background: var(--brand-soft);
  color: var(--brand-text);
}

.punto-op__ico svg { width: 20px; height: 20px; }

.punto-op__txt { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.punto-op__nombre {
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.punto-op__detalle {
  font-size: var(--text-xs);
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.punto-op > svg { width: 18px; height: 18px; flex: none; color: var(--text-faint); }

/* ==========================================================================
   ACCESO CON PIN
   Para la PC del kiosko: nadie tiene que dejar su cuenta de Google ahí.
   ========================================================================== */
.acceso__cuerpo { display: flex; flex-direction: column; gap: var(--s-3); width: 100%; }

/* El separador entre el PIN y Google. */
.acceso__o {
  display: flex; align-items: center; gap: var(--s-3);
  color: var(--text-muted); font-size: var(--text-xs);
  margin: var(--s-1) 0;
}
.acceso__o::before, .acceso__o::after {
  content: ""; flex: 1; height: 1px; background: var(--hairline);
}

/* Google pasa a segundo plano: se usa poco y no debe competir con el PIN. */
.btn-google--secundario { opacity: .85; }
.btn-google--secundario:hover { opacity: 1; }

/* --------------------------------------------------------------------------
   Las casillas: se ve cuántos dígitos van, nunca cuáles
   -------------------------------------------------------------------------- */
.pin { display: flex; flex-direction: column; gap: var(--s-2); align-items: center; }
.pin__etiqueta { font-size: var(--text-xs); color: var(--text-muted); }
.pin__casillas { display: flex; gap: var(--s-3); }

.pin__casilla {
  width: 16px; height: 16px;
  border-radius: var(--r-full, 999px);
  border: 2px solid var(--hairline);
  transition: background var(--t-fast), border-color var(--t-fast), transform var(--t-fast);
}
.pin__casilla--puesta {
  background: var(--brand); border-color: var(--brand);
  transform: scale(1.12);
}

/* --------------------------------------------------------------------------
   Teclado propio
   El de Android tapa media pantalla y trae autocorrector y micrófono; para
   cuatro dígitos eso estorba más de lo que ayuda.
   -------------------------------------------------------------------------- */
.pin-teclado {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--s-2);
  width: 100%;
  max-width: 280px;
  margin: 0 auto;
}

.pin-tecla {
  min-height: 56px;                /* se toca con el pulgar, no con el mouse */
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--text-primary);
  font-size: var(--text-lg); font-weight: 600;
  cursor: pointer;
  display: grid; place-items: center;
  transition: background var(--t-fast), transform var(--t-fast);
}
.pin-tecla:active { background: var(--surface-3); transform: scale(.95); }
.pin-tecla--borrar svg { width: 20px; height: 20px; }

.acceso__entrar { width: 100%; }

/* La lista de personas, abierta dentro de la hoja.
   Se despliega en el lugar del teclado: en una pantalla de 5" los dos juntos
   no caben, y un modal encima no sirve porque esta capa va por encima de los
   modales a propósito (ver el z-index de arriba). */
.acceso__lista {
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  background: var(--surface-1);
  padding: var(--s-1);
  max-height: 46vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.acceso__lista .opcion-lista { border-radius: var(--r-sm); }
