/* lean-motion.css — Tokens de animación + estados UI premium (Apple-grade)
   FUENTE ÚNICA: Suite-LeanCP/_shared/lean-motion.css (NO editar copias locales).
   Contrato de carga estándar Suite: ver .claude/rules/patron-visual-suite.md.
   Provee los indicadores de carga canónicos (boot overlay, spinner, skeleton, toast). */

:root {
  --ease-soft: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-out: cubic-bezier(0.0, 0, 0.2, 1);
  --dur-instant: 80ms;
  --dur-fast: 120ms;
  --dur-base: 220ms;
  --dur-slow: 360ms;
}

/* === ANIMACIONES BASE === */
@keyframes lm-fade-in { from { opacity: 0 } to { opacity: 1 } }
@keyframes lm-fade-out { from { opacity: 1 } to { opacity: 0 } }
@keyframes lm-fade-up { from { opacity: 0; transform: translateY(8px) } to { opacity: 1; transform: none } }
@keyframes lm-pop { 0% { opacity: 0; transform: scale(.95) } 60% { opacity: 1; transform: scale(1.02) } 100% { transform: scale(1) } }
@keyframes lm-shimmer { 0% { background-position: -800px 0 } 100% { background-position: 800px 0 } }
@keyframes lm-toast-in { from { opacity: 0; transform: translateX(20px) } to { opacity: 1; transform: none } }
@keyframes lm-toast-out { to { opacity: 0; transform: translateX(20px) } }
@keyframes lm-spin { to { transform: rotate(360deg) } }

/* === SKELETONS === */
.lm-skeleton {
  background: linear-gradient(90deg,
    rgba(255,255,255,0.04) 0%,
    rgba(255,255,255,0.08) 50%,
    rgba(255,255,255,0.04) 100%);
  background-size: 800px 100%;
  border-radius: 6px;
  animation: lm-shimmer 1.4s linear infinite;
  display: block;
}
.lm-skeleton-line { height: 12px; margin-bottom: 8px; }
.lm-skeleton-line.short { width: 40% }
.lm-skeleton-line.med { width: 70% }
.lm-skeleton-card {
  height: 80px; border-radius: 10px;
  background: linear-gradient(90deg, rgba(255,255,255,0.04) 0%, rgba(255,255,255,0.08) 50%, rgba(255,255,255,0.04) 100%);
  background-size: 800px 100%;
  animation: lm-shimmer 1.4s linear infinite;
  margin-bottom: 12px;
}

/* === TOASTS === */
.lm-toast-stack {
  position: fixed; top: 24px; right: 24px; z-index: 99999;
  display: flex; flex-direction: column; gap: 10px;
  pointer-events: none; max-width: 360px;
}
.lm-toast {
  pointer-events: auto;
  background: #1a1a1a;
  color: #F5F4EE;
  padding: 12px 16px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 12px 32px rgba(0,0,0,.5), 0 4px 12px rgba(0,0,0,.3);
  font-family: Inter, system-ui, sans-serif; font-size: 14px;
  display: flex; align-items: flex-start; gap: 10px;
  animation: lm-toast-in 220ms var(--ease-spring);
  min-width: 240px;
}
.lm-toast.is-leaving { animation: lm-toast-out 200ms var(--ease-soft) forwards; }
.lm-toast .lm-toast-icon { flex: 0 0 auto; width: 18px; height: 18px; margin-top: 1px; }
.lm-toast .lm-toast-body { flex: 1; min-width: 0; line-height: 1.4 }
.lm-toast .lm-toast-close { background: none; border: none; color: rgba(255,255,255,0.4); cursor: pointer; padding: 0 4px; font-size: 18px; line-height: 1 }
.lm-toast .lm-toast-close:hover { color: #fff }
.lm-toast.success { border-color: rgba(63,185,80,0.4) }
.lm-toast.success .lm-toast-icon { color: #3FB950 }
.lm-toast.error { border-color: rgba(229,72,77,0.4) }
.lm-toast.error .lm-toast-icon { color: #E5484D }
.lm-toast.info { border-color: rgba(201,162,39,0.4) }
.lm-toast.info .lm-toast-icon { color: #C9A227 }

/* === EMPTY / ERROR STATES === */
.lm-state {
  text-align: center; padding: 48px 24px;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  animation: lm-fade-up 280ms var(--ease-out);
}
.lm-state-icon {
  width: 64px; height: 64px; border-radius: 16px;
  background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.06);
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; color: rgba(255,255,255,0.5);
  margin-bottom: 4px;
}
.lm-state-title { font-family: Montserrat, sans-serif; font-size: 18px; font-weight: 700; color: #F5F4EE }
.lm-state-msg { font-size: 14px; color: rgba(245,244,238,0.6); max-width: 360px; line-height: 1.5 }
.lm-state-actions { margin-top: 8px; display: flex; gap: 8px; flex-wrap: wrap; justify-content: center }
.lm-btn {
  padding: 10px 18px; border-radius: 8px; border: 1px solid transparent;
  font-family: Inter, system-ui, sans-serif; font-size: 13px; font-weight: 600;
  cursor: pointer; transition: all var(--dur-fast) var(--ease-soft);
  min-height: 40px; line-height: 1;
}
.lm-btn-primary { background: #C9A227; color: #1a1a1a; border-color: #C9A227 }
.lm-btn-primary:hover { background: #DDB740 }
.lm-btn-secondary { background: transparent; color: #F5F4EE; border-color: rgba(255,255,255,0.12) }
.lm-btn-secondary:hover { border-color: #C9A227; color: #C9A227 }

/* === MICROANIMACIONES UI === */
button, a, [role="button"], .v2-tool-card, .v2-stat, .switcher-app, .lm-btn {
  transition: transform var(--dur-fast) var(--ease-soft), box-shadow var(--dur-fast) var(--ease-soft), background-color var(--dur-fast) var(--ease-soft), border-color var(--dur-fast) var(--ease-soft), color var(--dur-fast) var(--ease-soft);
}
.v2-tool-card:hover, .switcher-app:not(.disabled):hover { transform: translateY(-2px); box-shadow: 0 12px 24px rgba(0,0,0,.35) }
.v2-stat:hover { transform: translateY(-1px) }

/* Spinner reutilizable para botones loading */
.lm-spin { display: inline-block; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: lm-spin 0.7s linear infinite; vertical-align: middle }

/* === BOOT / CARGA GLOBAL — estándar único Suite ===
   Reemplaza los spinners ad-hoc de cada app (3 puntos / círculos de tamaño variable / nada).
   Uso: <div class="lm-loading-overlay"><div class="lm-boot-spinner"></div><div class="lm-loading-text">Cargando…</div></div>
   Ocultar: añadir clase .is-hiding y remover del DOM al terminar la animación. */
.lm-loading-overlay {
  position: fixed; inset: 0; z-index: 9500;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  background: var(--bg, #0A0A0A);
  animation: lm-fade-in var(--dur-base) var(--ease-out);
}
.lm-loading-overlay.is-hiding { animation: lm-fade-out var(--dur-base) var(--ease-out) forwards; }
.lm-loading-overlay.hidden { display: none; }   /* ocultar instantáneo (apps que no usan fade-out) */
.lm-boot-spinner {
  width: 36px; height: 36px; border-radius: 50%;
  border: 3px solid rgba(201,162,39,0.18);
  border-top-color: #C9A227;
  animation: lm-spin 0.8s linear infinite;
}
.lm-loading-text {
  font-family: Inter, system-ui, sans-serif; font-size: 13px;
  color: rgba(245,244,238,0.6); letter-spacing: .02em;
}

/* Cross-fade page transitions */
main, .v2-shell, body { animation: lm-fade-in var(--dur-base) var(--ease-out) }

/* Focus ring visible (a11y WCAG) */
:focus-visible { outline: 2px solid #C9A227; outline-offset: 2px; border-radius: 4px }

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important }
}

/* === BLOQUE D — Guard anti-scroll-horizontal (todo tamaño/zoom) ====
   Layout fluido en toda la Suite: el scroll horizontal vive en
   contenedores internos (Gantt, tablas con overflow propio), nunca en
   el body. Evita barras horizontales y cortes a cualquier zoom. Cargado
   por las 5 apps-herramienta (avance, programa, costos, bitacora,
   seguridad) vía este archivo. */
html, body { max-width: 100vw; overflow-x: hidden; }
