/* ============================================================
   BYMETAL ERP - MOTION FINAL
   Capa final de animaciones suaves y submenús visibles
   ============================================================ */

:root {
  --bm-transition-fast: 160ms ease;
  --bm-transition-normal: 260ms ease;
  --bm-transition-slow: 620ms cubic-bezier(.2,.8,.2,1);
  --bm-accent: #38bdf8;
  --bm-accent-strong: #0ea5e9;
  --bm-panel-border: rgba(148, 163, 184, 0.16);
  --bm-soft-glow: 0 0 0 3px rgba(56, 189, 248, 0.08);
}

/* =========================
   LOGIN
========================= */

.login-shell {
  animation: bmFadeUp 680ms cubic-bezier(.2,.8,.2,1) both;
}

.login-panel,
.login-card {
  animation: bmFadeUp 760ms cubic-bezier(.2,.8,.2,1) 90ms both;
}

.login-card img,
.login-card .logo,
.login-card [class*="logo"] img {
  animation: bmSoftFloat 4.2s ease-in-out infinite;
}

.login-card input,
.login-panel input {
  transition:
    border-color var(--bm-transition-normal),
    box-shadow var(--bm-transition-normal),
    transform var(--bm-transition-normal),
    background var(--bm-transition-normal);
}

.login-card input:focus,
.login-panel input:focus {
  border-color: rgba(56, 189, 248, 0.55) !important;
  box-shadow: var(--bm-soft-glow), 0 16px 34px rgba(14, 165, 233, 0.10) !important;
  transform: translateY(-1px);
}

#btn-login,
.login-button,
button[type="submit"] {
  transition:
    transform var(--bm-transition-fast),
    box-shadow var(--bm-transition-fast),
    filter var(--bm-transition-fast),
    border-color var(--bm-transition-fast);
}

#btn-login:hover,
.login-button:hover,
button[type="submit"]:hover {
  transform: translateY(-1px);
  filter: brightness(1.06);
}

#btn-login:active,
.login-button:active,
button[type="submit"]:active {
  transform: translateY(0);
}

/* =========================
   TRANSICIÓN LOGIN
========================= */

.login-transition.welcome-transition {
  position: fixed;
  inset: 0;
  z-index: 2147483647;
  display: grid;
  place-items: center;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  background:
    linear-gradient(135deg, rgba(2, 6, 23, 0.74), rgba(2, 6, 23, 0.88)),
    url("/static/img/bymetal-transition-bg.webp") center center / cover no-repeat,
    radial-gradient(circle at 18% 18%, rgba(14, 165, 233, 0.22), transparent 30%),
    linear-gradient(135deg, #020617, #030712) !important;
  backdrop-filter: blur(0);
  transition:
    opacity 360ms ease,
    visibility 360ms ease,
    backdrop-filter 520ms ease;
}

.login-transition.welcome-transition.is-active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  backdrop-filter: blur(14px);
}

.login-transition.welcome-transition::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at center, transparent 24%, rgba(0, 0, 0, 0.34) 72%),
    linear-gradient(135deg, rgba(2, 6, 23, 0.78), rgba(2, 6, 23, 0.28) 45%, rgba(2, 6, 23, 0.84));
  pointer-events: none;
}

.welcome-gradient {
  position: absolute;
  inset: -40%;
  background:
    linear-gradient(
      135deg,
      transparent 0%,
      transparent 34%,
      rgba(255, 255, 255, 0.07) 43%,
      rgba(255, 183, 77, 0.18) 50%,
      rgba(14, 165, 233, 0.08) 58%,
      transparent 68%,
      transparent 100%
    );
  opacity: 0;
  mix-blend-mode: screen;
}

.welcome-transition.is-active .welcome-gradient {
  animation: bmDiagonalSweep 1.65s cubic-bezier(.2,.8,.2,1) forwards;
}

.welcome-line {
  position: absolute;
  width: 150vw;
  height: 1px;
  top: 50%;
  left: 50%;
  background:
    linear-gradient(
      90deg,
      transparent,
      rgba(255, 183, 77, 0.42),
      rgba(255, 255, 255, 0.70),
      rgba(125, 211, 252, 0.70),
      transparent
    );
  box-shadow:
    0 0 24px rgba(255, 183, 77, 0.38),
    0 0 48px rgba(14, 165, 233, 0.18);
  transform: translate(-120%, -120%) rotate(45deg);
  opacity: 0;
}

.welcome-transition.is-active .welcome-line {
  animation: bmLineMove 1.55s cubic-bezier(.2,.8,.2,1) forwards;
}

.welcome-content {
  position: relative;
  z-index: 2;
  text-align: center;
  min-width: min(92vw, 460px);
  padding: 40px 58px;
  border-radius: 34px;
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.10), transparent 42%),
    linear-gradient(145deg, rgba(15, 23, 42, 0.66), rgba(2, 6, 23, 0.42));
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow:
    0 34px 95px rgba(0, 0, 0, 0.48),
    0 0 70px rgba(255, 183, 77, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(14px) saturate(1.1);
  opacity: 0;
  transform: translateY(18px) scale(.98);
  filter: blur(8px);
}

.welcome-transition.is-active .welcome-content {
  animation: bmBlurReveal 860ms cubic-bezier(.2,.8,.2,1) 220ms forwards;
}

.welcome-kicker {
  display: block;
  margin-bottom: 14px;
  color: #7dd3fc;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  text-shadow: 0 0 18px rgba(14, 165, 233, 0.34);
}

.welcome-content h3 {
  margin: 0;
  color: #f8fafc;
  font-size: clamp(44px, 6vw, 82px);
  line-height: 1;
  font-weight: 720;
  letter-spacing: -0.06em;
  text-shadow:
    0 22px 52px rgba(0, 0, 0, 0.68),
    0 0 28px rgba(255, 183, 77, 0.16);
}

.welcome-content p {
  margin: 18px 0 0;
  color: #dbeafe;
  font-size: clamp(20px, 2.3vw, 32px);
  font-weight: 620;
  letter-spacing: -0.025em;
}

/* =========================
   DASHBOARD / ERP
========================= */

.motion-reveal {
  opacity: 1;
  transform: translateY(0);
  filter: blur(0);
  transition:
    opacity 620ms cubic-bezier(.2,.8,.2,1),
    transform 620ms cubic-bezier(.2,.8,.2,1),
    filter 620ms cubic-bezier(.2,.8,.2,1);
  transition-delay: var(--motion-delay, 0ms);
}

.motion-reveal.motion-entered {
  opacity: 1;
  transform: translateY(0);
  filter: blur(0);
}

.glass,
.bm-panel,
section[class*="glass"],
main table,
.kpi-card,
.card,
.panel {
  transition:
    transform var(--bm-transition-normal),
    border-color var(--bm-transition-normal),
    box-shadow var(--bm-transition-normal),
    background var(--bm-transition-normal);
}

.glass:hover,
.bm-panel:hover,
.kpi-card:hover,
.card:hover,
.panel:hover {
  border-color: rgba(56, 189, 248, 0.22) !important;
}

main table tbody tr,
tbody tr {
  transition:
    background var(--bm-transition-fast),
    color var(--bm-transition-fast);
}

main table tbody tr:hover,
tbody tr:hover {
  background: rgba(14, 165, 233, 0.055) !important;
}

button,
a,
.submenu button,
.submenu-link {
  transition:
    transform var(--bm-transition-fast),
    border-color var(--bm-transition-fast),
    background var(--bm-transition-fast),
    color var(--bm-transition-fast),
    box-shadow var(--bm-transition-fast);
}

/* =========================
   SIDEBAR Y SUBMENÚS
========================= */

#sidebar-nav .submenu,
#menu-empresas-dinamicas .submenu,
.submenu {
  margin-top: 8px !important;
  padding: 8px 8px 10px 12px !important;
  border-left: 1px solid rgba(56, 189, 248, 0.22) !important;
  background: rgba(2, 6, 23, 0.18);
  border-radius: 0 14px 14px 0;
}

#sidebar-nav .submenu:not(.hidden),
#menu-empresas-dinamicas .submenu:not(.hidden),
.submenu.bm-submenu-open {
  display: block !important;
  animation: bmSubmenuOpen 220ms ease both;
}

#sidebar-nav .submenu button,
#sidebar-nav .submenu .submenu-link,
#menu-empresas-dinamicas .submenu button,
#menu-empresas-dinamicas .submenu .submenu-link,
.submenu button,
.submenu .submenu-link {
  display: block;
  width: 100%;
  min-height: 34px;
  margin: 3px 0;
  padding: 8px 10px !important;
  border-radius: 11px !important;
  color: #b6c3d6 !important;
  border: 1px solid rgba(148, 163, 184, 0.10);
  background: rgba(15, 23, 42, 0.50);
  font-size: 12px;
}

#sidebar-nav .submenu button:hover,
#sidebar-nav .submenu .submenu-link:hover,
#menu-empresas-dinamicas .submenu button:hover,
#menu-empresas-dinamicas .submenu .submenu-link:hover,
.submenu button:hover,
.submenu .submenu-link:hover {
  color: #ffffff !important;
  background: rgba(14, 165, 233, 0.13) !important;
  border-color: rgba(56, 189, 248, 0.24) !important;
  transform: translateX(2px);
}

.submenu-link-active,
.submenu button.active,
.submenu .submenu-link.active {
  color: #ffffff !important;
  background:
    linear-gradient(135deg, rgba(14, 165, 233, 0.24), rgba(15, 23, 42, 0.58)) !important;
  border-color: rgba(56, 189, 248, 0.34) !important;
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.06);
}

button[aria-expanded="true"] {
  color: #ffffff !important;
  background: rgba(14, 165, 233, 0.10) !important;
  border-color: rgba(56, 189, 248, 0.20) !important;
}

/* Alertas reales */
.subtlePulse {
  animation: bmSubtlePulse 2.4s ease-in-out infinite;
}

/* =========================
   KEYFRAMES
========================= */

@keyframes bmFadeUp {
  from {
    opacity: 0;
    transform: translateY(18px);
    filter: blur(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
    filter: blur(0);
  }
}

@keyframes bmSoftFloat {
  0%, 100% {
    transform: translateY(0) scale(1);
  }

  50% {
    transform: translateY(-4px) scale(1.015);
  }
}

@keyframes bmDiagonalSweep {
  0% {
    opacity: 0;
    transform: translate(-48%, -48%);
  }

  22% {
    opacity: 1;
  }

  100% {
    opacity: .62;
    transform: translate(48%, 48%);
  }
}

@keyframes bmLineMove {
  0% {
    opacity: 0;
    transform: translate(-120%, -120%) rotate(45deg);
  }

  20% {
    opacity: 1;
  }

  100% {
    opacity: .18;
    transform: translate(20%, 20%) rotate(45deg);
  }
}

@keyframes bmBlurReveal {
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
  }
}

@keyframes bmSubmenuOpen {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes bmSubtlePulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
  }

  50% {
    box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.08);
  }
}

@media (max-width: 560px) {
  .welcome-content {
    min-width: min(92vw, 360px);
    padding: 34px 26px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }

  .motion-reveal {
    opacity: 1 !important;
    transform: none !important;
    filter: none !important;
  }
}
