/* ============================================================
   MODAL DE AUTORIZACION DE SUPER USUARIO
   ------------------------------------------------------------
   Dialogo compartido para cualquier accion que exija la clave de
   un usuario con `admin = 1`: cambiar el precio en el POS, subir
   el limite de credito de un contacto, editar una factura ya
   cerrada, etc.

   Se carga de forma GLOBAL desde vistas/plantilla.php porque el
   dialogo lo abre app.js, que vive en todas las paginas.

   El popup de SweetAlert se monta al final del <body>, fuera de
   cualquier contenedor de modulo, asi que las reglas no pueden
   colgar de uno. Por lo mismo los colores se declaran como
   variables SOBRE EL PROPIO POPUP y no en :root: asi el archivo
   es autonomo y no pisa ni depende de los tokens de ningun
   modulo (ventas-view.css define los suyos con estos nombres).
   ============================================================ */

.swal2-popup.auth-popup {
  --auth-grad: linear-gradient(135deg, #4e65d9 0%, #633c8c 100%);
  --auth-accent: #3b4ba4;
  --auth-soft: #f0f3ff;
  --auth-danger: #c12a42;
  --auth-line: #e9ecef;
  --auth-border: #dee2e6;
  --auth-muted: #666666;
  --auth-text: #222222;
  --auth-icon: #ced4da;
  --auth-hover: #f6f9fc;
  --auth-radius: 0.375rem;
  --auth-transition: 0.25s ease;

  width: 27rem;
  max-width: calc(100vw - 2rem);
  padding: 0;
  border-radius: 1rem;
  overflow: hidden;
  box-shadow: 0 24px 56px rgba(26, 31, 54, 0.28);
  font-family: 'Open Sans', sans-serif;
}

/* El contenedor html de SweetAlert trae margen y padding propios: sin
   anularlos la cabecera con degradado no llega a los bordes del modal. */
.auth-popup .auth-html {
  margin: 0;
  padding: 0;
  font-size: inherit;
  line-height: inherit;
  color: inherit;
  text-align: left;
  overflow: visible;
}

/* ── Cabecera ─────────────────────────────────────────────────────────── */
.auth-head {
  background: var(--auth-grad);
  padding: 1.75rem 1.5rem 1.5rem;
  text-align: center;
  color: #fff;
}

.auth-icon {
  width: 3.25rem;
  height: 3.25rem;
  margin: 0 auto 0.875rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  color: #fff;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.28);
}

.auth-popup .auth-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #fff;
}

.auth-popup .auth-sub {
  margin: 0.3rem 0 0;
  font-size: 0.82rem;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.78);
}

/* ── Cuerpo ───────────────────────────────────────────────────────────── */
.auth-body {
  padding: 1.25rem 1.5rem 0.25rem;
  text-align: left;
}

.auth-note {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  padding: 0.7rem 0.85rem;
  margin-bottom: 1.15rem;
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--auth-muted);
  background: var(--auth-soft);
  border-radius: var(--auth-radius);
}

.auth-note i {
  margin-top: 0.12rem;
  color: var(--auth-accent);
}

.auth-popup .auth-label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--auth-muted);
}

/* Campo con icono a la izquierda */
.auth-field {
  position: relative;
  margin-bottom: 1rem;
}

.auth-field > i {
  position: absolute;
  top: 50%;
  left: 0.9rem;
  transform: translateY(-50%);
  font-size: 0.85rem;
  color: var(--auth-icon);
  pointer-events: none;
  transition: color var(--auth-transition);
}

.auth-popup .auth-field select,
.auth-popup .auth-field input {
  width: 100%;
  height: 2.85rem;
  margin: 0;
  padding: 0 2.5rem 0 2.4rem;
  font-size: 0.9rem;
  color: var(--auth-text);
  background: #fff;
  border: 1px solid var(--auth-border);
  border-radius: var(--auth-radius);
  box-shadow: none;
  outline: none;
  transition: border-color var(--auth-transition), box-shadow var(--auth-transition);
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

/* Punta del desplegable, dibujada porque appearance:none quita la nativa */
.auth-field.auth-select::after {
  content: '';
  position: absolute;
  top: 50%;
  right: 1.1rem;
  width: 0.45rem;
  height: 0.45rem;
  margin-top: -0.3rem;
  border-right: 2px solid var(--auth-muted);
  border-bottom: 2px solid var(--auth-muted);
  transform: rotate(45deg);
  pointer-events: none;
}

.auth-popup .auth-field select:focus,
.auth-popup .auth-field input:focus {
  border-color: var(--auth-accent);
  box-shadow: 0 0 0 3px rgba(59, 75, 164, 0.15);
}

.auth-field:focus-within > i {
  color: var(--auth-accent);
}

/* Ojo para mostrar u ocultar la clave */
.auth-popup .auth-eye {
  position: absolute;
  top: 50%;
  right: 0.35rem;
  transform: translateY(-50%);
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-size: 0.85rem;
  color: var(--auth-icon);
  background: none;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  transition: color var(--auth-transition), background-color var(--auth-transition);
}

.auth-popup .auth-eye:hover,
.auth-popup .auth-eye:focus {
  color: var(--auth-accent);
  background: var(--auth-hover);
  outline: none;
}

/* ── Error ────────────────────────────────────────────────────────────── */
/* Reemplaza al cuadro amarillo por defecto de SweetAlert. La visibilidad la
   sigue gestionando SweetAlert sobre este mismo nodo, asi que aqui no se
   declara `display`. */
.auth-popup .auth-error {
  align-items: center;
  gap: 0.5rem;
  margin: 0 1.5rem 0.25rem;
  padding: 0.65rem 0.85rem;
  font-size: 0.8rem;
  font-weight: 400;
  text-align: left;
  color: var(--auth-danger);
  background: rgba(193, 42, 66, 0.08);
  border: 0;
  border-radius: var(--auth-radius);
}

/* El proyecto carga FontAwesome 6 (fontawesome-free-6.7.2-web); las familias
   anteriores quedan como respaldo por si se revierte la version. */
.auth-popup .auth-error::before {
  content: '\f071';
  font-family: 'Font Awesome 6 Free', 'Font Awesome 5 Free', 'FontAwesome';
  font-weight: 900;
  flex-shrink: 0;
}

/* ── Botonera ─────────────────────────────────────────────────────────── */
.auth-popup .swal2-actions {
  margin: 1rem 1.5rem 1.5rem;
  padding: 1rem 0 0;
  border-top: 1px solid var(--auth-line);
  width: auto;
}

.auth-popup .auth-confirm,
.auth-popup .auth-cancel {
  height: 2.6rem;
  padding: 0 1.15rem;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: var(--auth-radius);
  box-shadow: none;
  transition: filter var(--auth-transition), background-color var(--auth-transition);
}

.auth-popup .auth-confirm {
  background: var(--auth-grad);
  border: 0;
  color: #fff;
}

.auth-popup .auth-confirm:hover {
  filter: brightness(1.08);
}

.auth-popup .auth-cancel {
  background: transparent;
  border: 1px solid var(--auth-border);
  color: var(--auth-muted);
}

.auth-popup .auth-cancel:hover {
  background: var(--auth-hover);
  color: var(--auth-text);
}

@media (max-width: 480px) {
  .auth-popup .swal2-actions {
    flex-direction: column-reverse;
  }
  .auth-popup .auth-confirm,
  .auth-popup .auth-cancel {
    width: 100%;
    margin: 0.25rem 0;
  }
}
