/* =============================================================
   QUEVAZ — CAPA "LEGENDARIA" DE DISEÑO
   Fondo 3D animado, glassmorphism, tilt cards, shine, count-up,
   pensado SOLO para: login.php  y  index.php (Dashboard)
   No modifica nada del layout/datos existentes, solo lo viste.
============================================================= */

/* ---------- Fondo aurora + malla 3D (capa fija detrás de todo) ---------- */
.legend-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  background: var(--bg-page, var(--bg-base, #f8fafc));
}

.legend-bg canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: .55;
}

.legend-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  opacity: .35;
  will-change: transform;
  animation: legend-float 16s ease-in-out infinite;
}
.legend-orb.o1 { width: 480px; height: 480px; top: -160px; left: -120px; background: radial-gradient(circle, var(--accent) 0%, transparent 70%); animation-duration: 18s; }
.legend-orb.o2 { width: 380px; height: 380px; bottom: -140px; right: -80px;  background: radial-gradient(circle, #3b82f6 0%, transparent 70%); animation-duration: 22s; animation-delay: -4s; }
.legend-orb.o3 { width: 300px; height: 300px; top: 40%; right: 15%; background: radial-gradient(circle, #f59e0b 0%, transparent 70%); animation-duration: 20s; animation-delay: -9s; opacity: .18; }

body.dark-mode .legend-orb { opacity: .28; }

@keyframes legend-float {
  0%   { transform: translate3d(0,0,0) scale(1); }
  33%  { transform: translate3d(30px,-40px,0) scale(1.08); }
  66%  { transform: translate3d(-25px,25px,0) scale(0.96); }
  100% { transform: translate3d(0,0,0) scale(1); }
}

.legend-grid-overlay {
  position: absolute;
  inset: -2px;
  background-image:
    linear-gradient(to right, rgba(120,120,140,.06) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(120,120,140,.06) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 20%, black 40%, transparent 85%);
}
body.dark-mode .legend-grid-overlay {
  background-image:
    linear-gradient(to right, rgba(255,255,255,.05) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255,255,255,.05) 1px, transparent 1px);
}

/* ================= LOGIN ================= */
body.legend-login {
  background: transparent !important;
}

.legend-login-stage {
  position: relative;
  z-index: 2;
  perspective: 1400px;
}

.legend-tilt-wrap {
  transform-style: preserve-3d;
  transition: transform .12s ease-out;
  will-change: transform;
}

.login-container.legend-card {
  position: relative;
  background: rgba(255,255,255,0.72);
  backdrop-filter: blur(22px) saturate(160%);
  -webkit-backdrop-filter: blur(22px) saturate(160%);
  border: 1px solid rgba(255,255,255,0.5);
  box-shadow:
    0 30px 60px -15px rgba(15,23,42,.25),
    0 0 0 1px rgba(255,255,255,.4) inset,
    0 1px 0 rgba(255,255,255,.6) inset;
  animation: legend-card-in .8s cubic-bezier(.16,1,.3,1) both;
  overflow: hidden;
}
.login-container.legend-card::before {
  content: '';
  position: absolute;
  inset: 0;
  padding: 1px;
  border-radius: inherit;
  background: linear-gradient(135deg, var(--accent), transparent 40%, transparent 60%, var(--accent));
  opacity: .5;
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

body.dark-mode .login-container.legend-card,
.legend-dark-login .login-container.legend-card {
  background: rgba(20,26,40,0.55);
  border-color: rgba(255,255,255,0.08);
}

@keyframes legend-card-in {
  0%   { opacity: 0; transform: translateY(40px) rotateX(8deg) scale(.94); }
  100% { opacity: 1; transform: translateY(0) rotateX(0) scale(1); }
}

.legend-logo-float {
  animation: legend-logo-bob 4.5s ease-in-out infinite;
  filter: drop-shadow(0 12px 20px rgba(227,47,47,.25));
}
@keyframes legend-logo-bob {
  0%,100% { transform: translateY(0) rotate(0deg); }
  50%     { transform: translateY(-8px) rotate(-1.5deg); }
}

.legend-field {
  opacity: 0;
  animation: legend-field-in .55s ease forwards;
}
.legend-field:nth-of-type(1) { animation-delay: .15s; }
.legend-field:nth-of-type(2) { animation-delay: .25s; }
@keyframes legend-field-in {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

.btn-login.legend-btn {
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, var(--accent, #e32f2f), #8a0303);
  background-size: 220% 220%;
  animation: legend-btn-in .5s ease .35s both, legend-gradient-shift 6s ease infinite;
}
@keyframes legend-btn-in { from { opacity: 0; transform: translateY(10px);} to { opacity:1; transform: translateY(0);} }
@keyframes legend-gradient-shift {
  0%,100% { background-position: 0% 50%; }
  50%     { background-position: 100% 50%; }
}
.btn-login.legend-btn::after {
  content: '';
  position: absolute;
  top: 0; left: -60%;
  width: 40%; height: 100%;
  background: linear-gradient(120deg, transparent, rgba(255,255,255,.55), transparent);
  transform: skewX(-20deg);
  animation: legend-shine 3.2s ease-in-out infinite;
}
@keyframes legend-shine {
  0%   { left: -60%; }
  40%  { left: 130%; }
  100% { left: 130%; }
}
.btn-login.legend-btn.is-loading {
  pointer-events: none;
  color: transparent !important;
}
.btn-login.legend-btn.is-loading .legend-spinner {
  display: inline-block;
}
.legend-spinner {
  display: none;
  position: absolute;
  left: 50%; top: 50%;
  width: 18px; height: 18px;
  margin: -9px 0 0 -9px;
  border: 2.5px solid rgba(255,255,255,.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: legend-spin .7s linear infinite;
}
@keyframes legend-spin { to { transform: rotate(360deg); } }

.legend-ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(255,255,255,.55);
  transform: scale(0);
  animation: legend-ripple .6s ease-out forwards;
  pointer-events: none;
}
@keyframes legend-ripple { to { transform: scale(2.6); opacity: 0; } }

.footer.legend-footer i { color: var(--accent, #e32f2f); margin-right: 4px; }

/* ================= DASHBOARD ================= */
.content { position: relative; z-index: 1; }

.welcome-banner.legend-banner {
  position: relative;
  overflow: hidden;
  background: linear-gradient(120deg, #8a0303 0%, #e32f2f 55%, #b91c1c 100%);
  background-size: 200% 200%;
  animation: legend-gradient-shift 10s ease infinite;
}
.welcome-banner.legend-banner::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 85% 20%, rgba(255,255,255,.16) 0%, transparent 45%),
    radial-gradient(circle at 15% 90%, rgba(255,255,255,.10) 0%, transparent 40%);
  animation: legend-float 14s ease-in-out infinite;
}
.welcome-banner.legend-banner > * { position: relative; z-index: 1; }

/* Tilt 3D genérico para tarjetas */
.legend-tilt {
  transform-style: preserve-3d;
  transition: transform .15s ease-out, box-shadow .2s ease;
  will-change: transform;
}
.legend-tilt:hover {
  box-shadow: 0 22px 40px -12px rgba(15,23,42,.18);
}
body.dark-mode .legend-tilt:hover {
  box-shadow: 0 22px 40px -12px rgba(0,0,0,.5);
}
.legend-tilt .stat-icon,
.legend-tilt .quick-icon {
  transition: transform .2s ease;
  transform: translateZ(18px);
}

.stat-card.legend-tilt, .quick-card.legend-tilt, .card.legend-tilt {
  opacity: 0;
  animation: legend-rise .55s cubic-bezier(.16,1,.3,1) forwards;
}
@keyframes legend-rise {
  from { opacity: 0; transform: translateY(22px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* pulso al refrescar datos cada 10s */
.legend-pulse {
  animation: legend-value-pulse .5s ease;
}
@keyframes legend-value-pulse {
  0%   { transform: scale(1); color: var(--accent, #e32f2f); }
  40%  { transform: scale(1.16); color: var(--accent, #e32f2f); }
  100% { transform: scale(1); }
}

/* Barra de stock: brillo recorriendo la barra llena */
.stock-bar-fill { position: relative; overflow: hidden; }
.stock-bar-fill::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.55), transparent);
  transform: translateX(-100%);
  animation: legend-bar-shine 2.6s ease-in-out infinite;
}
@keyframes legend-bar-shine {
  0%   { transform: translateX(-100%); }
  55%  { transform: translateX(160%); }
  100% { transform: translateX(160%); }
}

/* Botones primarios con leve shine, sin romper estilo actual */
.btn-primary { position: relative; overflow: hidden; }
.btn-primary.legend-ripple-host .legend-ripple { background: rgba(255,255,255,.5); }

/* Reduce motion */
@media (prefers-reduced-motion: reduce) {
  .legend-orb, .legend-bg canvas, .welcome-banner.legend-banner,
  .welcome-banner.legend-banner::before, .btn-login.legend-btn,
  .btn-login.legend-btn::after, .stock-bar-fill::after,
  .legend-logo-float, .login-container.legend-card {
    animation: none !important;
  }
  .legend-tilt { transition: none !important; }
}

@media (max-width: 640px) {
  .legend-orb { display: none; }
}
