/* Tema "maquinon" para el portal de Authelia.
   Se inyecta con nginx (sub_filter) antes de </head>. Se apoya en las variables
   de tema de Authelia y en IDs estables; si una actualizacion cambia el HTML,
   la pagina vuelve al diseno original en vez de romperse. */

/* Authelia pone data-theme en <html> y tambien en <body>; se duplica el
   atributo para ganarle en especificidad a [data-theme=dark]. */
:root,
[data-theme][data-theme] {
  --background: #07070d;
  --foreground: #eef0ff;
  --card: rgba(255, 255, 255, 0.04);
  --card-foreground: #eef0ff;
  --popover: #12121c;
  --popover-foreground: #eef0ff;
  --primary: #8b5cf6;
  --primary-foreground: #ffffff;
  --muted: rgba(255, 255, 255, 0.06);
  --muted-foreground: rgba(238, 240, 255, 0.6);
  --accent: rgba(255, 255, 255, 0.06);
  --accent-foreground: #eef0ff;
  --border: rgba(255, 255, 255, 0.1);
  --input: rgba(255, 255, 255, 0.12);
  --ring: #8b5cf6;
  --radius: 0.9rem;
  --custom-icon: #eef0ff;
  --custom-loading-bar: #8b5cf6;
  --divider: rgba(255, 255, 255, 0.08);
  --maq-grad: linear-gradient(135deg, #8b5cf6 0%, #6366f1 45%, #06b6d4 100%);
  color-scheme: dark;
}

html,
body {
  background: #07070d !important;
  min-height: 100vh;
  font-family: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* Fondo: auroras difuminadas que se mueven lento */
body::before,
body::after {
  content: "";
  position: fixed;
  z-index: 0;
  width: 60vmax;
  height: 60vmax;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.35;
  pointer-events: none;
  animation: maq-flotar 22s ease-in-out infinite alternate;
}
body::before {
  top: -20vmax;
  left: -15vmax;
  background: radial-gradient(circle, #7c3aed 0%, transparent 65%);
}
body::after {
  bottom: -25vmax;
  right: -15vmax;
  background: radial-gradient(circle, #0891b2 0%, transparent 65%);
  animation-delay: -11s;
}
@keyframes maq-flotar {
  from { transform: translate(0, 0) scale(1); }
  to   { transform: translate(6vmax, 4vmax) scale(1.15); }
}

#root {
  position: relative;
  z-index: 1;
}

/* Boton de idioma */
#language-button {
  background: rgba(255, 255, 255, 0.05) !important;
  border: 1px solid var(--border) !important;
  backdrop-filter: blur(12px);
}

/* Tarjeta de vidrio (aplica a todas las etapas: login, 2FA, consentimiento) */
[id$="-stage"] > div {
  width: 100%;
  max-width: 420px;
  margin: 0 16px;
  padding: 40px 36px 28px !important;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.02));
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 28px;
  backdrop-filter: blur(24px) saturate(140%);
  -webkit-backdrop-filter: blur(24px) saturate(140%);
  box-shadow:
    0 30px 80px -20px rgba(0, 0, 0, 0.7),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  animation: maq-entrar 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
@keyframes maq-entrar {
  from { opacity: 0; transform: translateY(14px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}

/* Marca: reemplaza el avatar generico por un logo con degradado */
div:has(> #UserSvg) {
  display: flex;
  justify-content: center;
}
#UserSvg {
  display: none !important;
}
div:has(> #UserSvg)::before {
  content: "M";
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 20px;
  background: var(--maq-grad);
  color: #fff;
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -1px;
  box-shadow: 0 12px 30px -8px rgba(139, 92, 246, 0.6);
}

/* Titulo */
[id$="-stage"] h5 {
  font-size: 1.65rem !important;
  font-weight: 650 !important;
  letter-spacing: -0.02em;
  margin-top: 8px;
}
#first-factor-stage h5::after {
  content: "maquinon · acceso seguro";
  display: block;
  margin-top: 6px;
  font-size: 0.85rem;
  font-weight: 400;
  letter-spacing: 0.01em;
  color: var(--muted-foreground);
}

/* Campos de texto */
[id$="-stage"] input:not([type="checkbox"]):not([type="hidden"]) {
  border-radius: 14px !important;
  background: rgba(255, 255, 255, 0.04) !important;
  border-color: var(--input) !important;
  color: var(--foreground) !important;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s !important;
}
[id$="-stage"] input:not([type="checkbox"]):not([type="hidden"]):hover {
  background: rgba(255, 255, 255, 0.06) !important;
}
[id$="-stage"] input:not([type="checkbox"]):not([type="hidden"]):focus {
  border-color: var(--primary) !important;
  background: rgba(139, 92, 246, 0.06) !important;
  box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.18) !important;
}
[id$="-stage"] label {
  color: var(--muted-foreground);
}

/* Boton principal */
#sign-in-button,
[id$="-stage"] button[class*="bg-primary"]:not([role="checkbox"]) {
  height: 50px;
  border: 0 !important;
  border-radius: 14px !important;
  background: var(--maq-grad) !important;
  background-size: 160% 160% !important;
  color: #fff !important;
  font-size: 1rem !important;
  font-weight: 600 !important;
  text-transform: none !important;
  letter-spacing: 0.01em;
  box-shadow: 0 12px 28px -10px rgba(99, 102, 241, 0.75);
  transition: transform 0.15s, box-shadow 0.2s, background-position 0.4s !important;
}
#sign-in-button:hover,
[id$="-stage"] button[class*="bg-primary"]:not([role="checkbox"]):hover {
  transform: translateY(-1px);
  background-position: 100% 50% !important;
  box-shadow: 0 16px 34px -10px rgba(99, 102, 241, 0.9);
}
#sign-in-button:active,
[id$="-stage"] button[class*="bg-primary"]:not([role="checkbox"]):active {
  transform: translateY(0) scale(0.99);
}

/* Enlaces y pie */
#reset-password-button {
  color: #a78bfa !important;
  text-transform: none !important;
}
#reset-password-button:hover {
  color: #c4b5fd !important;
}
a[href*="authelia.com"] {
  color: rgba(238, 240, 255, 0.35) !important;
  font-size: 0.72rem;
}

/* Movil */
@media (max-width: 480px) {
  [id$="-stage"] > div {
    padding: 32px 22px 22px !important;
    border-radius: 24px;
  }
  body::before,
  body::after {
    filter: blur(70px);
  }
}

@media (prefers-reduced-motion: reduce) {
  body::before,
  body::after,
  [id$="-stage"] > div {
    animation: none !important;
  }
}
