/* ═══════════════════════════════════════════════════════════════════════════
   MOTION SYSTEM — animations orchestrées (panel + admin)
   Règles (ui-ux-pro-max) : 150–300ms interactions, ease-out entrée,
   pas d'animation infinie décorative, prefers-reduced-motion respecté.
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
  --motion-fast: .16s;
  --motion-base: .24s;
  --motion-slow: .45s;
  --motion-ease-out: cubic-bezier(.22, .61, .36, 1);
  --motion-ease-in: cubic-bezier(.4, 0, 1, 1);
  --motion-spring: cubic-bezier(.22, .8, .3, 1);
}

/* ── Keyframes ─────────────────────────────────────────────────────────── */
@keyframes lp-rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}
@keyframes lp-slide-down {
  from { opacity: 0; transform: translateY(-10px); }
  to   { opacity: 1; transform: none; }
}
@keyframes lp-slide-x {
  from { opacity: 0; transform: translateX(-12px); }
  to   { opacity: 1; transform: none; }
}
@keyframes lp-pop {
  0%   { opacity: 0; transform: scale(.96); }
  100% { opacity: 1; transform: scale(1); }
}
@keyframes lp-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes lp-shimmer {
  from { background-position: -200% 0; }
  to   { background-position: 200% 0; }
}
@keyframes lp-spin {
  to { transform: rotate(360deg); }
}
@keyframes lp-pulse-once {
  0%   { box-shadow: 0 0 0 0 rgba(var(--accent-rgb), .45); }
  70%  { box-shadow: 0 0 0 10px rgba(var(--accent-rgb), 0); }
  100% { box-shadow: 0 0 0 0 rgba(var(--accent-rgb), 0); }
}

/* ── Alertes flash ─────────────────────────────────────────────────────── */
.alert {
  animation: lp-slide-down var(--motion-base) var(--motion-ease-out) both;
}
.alert + .alert { animation-delay: .06s; }

/* ── Cartes : lift + glow au survol ────────────────────────────────────── */
.card,
.stat-card,
.quick-card,
.ck-panel {
  will-change: transform;
  transition:
    transform var(--motion-base) var(--motion-ease-out),
    border-color var(--motion-fast) ease,
    box-shadow var(--motion-base) var(--motion-ease-out);
}
.card:hover,
.stat-card:hover {
  transform: translateY(-3px);
}
[data-theme="neo"] .card:hover,
[data-theme="neo"] .stat-card:hover {
  box-shadow:
    0 14px 40px rgba(0, 0, 0, .35),
    0 0 0 1px rgba(var(--accent-rgb), .18);
}

/* ── Boutons : press + chargement ──────────────────────────────────────── */
.btn {
  transition:
    transform var(--motion-fast) var(--motion-ease-out),
    box-shadow var(--motion-base) var(--motion-ease-out),
    background var(--motion-fast) ease,
    opacity var(--motion-fast) ease;
}
.btn:active:not(:disabled) {
  transform: scale(.97) translateY(0) !important;
  transition-duration: .08s;
}
.btn.is-loading {
  pointer-events: none;
  opacity: .82;
  position: relative;
  color: transparent !important;
}
.btn.is-loading::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, .25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: lp-spin .65s linear infinite;
}
.btn-primary.is-loading::after {
  border-color: rgba(16, 18, 26, .2);
  border-top-color: #10121a;
}

/* ── Champs : focus glow ───────────────────────────────────────────────── */
input:not([type="checkbox"]):not([type="radio"]),
select,
textarea {
  transition:
    border-color var(--motion-fast) ease,
    box-shadow var(--motion-base) var(--motion-ease-out),
    background var(--motion-fast) ease;
}
input:focus,
select:focus,
textarea:focus {
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), .14);
}

/* ── Tables : survol de ligne ──────────────────────────────────────────── */
.table-wrap table tbody tr {
  transition: background var(--motion-fast) ease;
}
.table-wrap table tbody tr:hover {
  background: rgba(var(--accent-rgb), .06);
}

/* ── Nav active : indicateur glissant ────────────────────────────────── */
.nav-item {
  position: relative;
  overflow: hidden;
}
.nav-item.active::after {
  content: "";
  position: absolute;
  left: 0;
  top: 18%;
  bottom: 18%;
  width: 3px;
  border-radius: 0 4px 4px 0;
  background: linear-gradient(180deg, var(--accent-light), var(--accent));
  box-shadow: 0 0 12px rgba(var(--accent-rgb), .5);
  animation: lp-slide-x .3s var(--motion-ease-out) both;
}

/* ── Grilles KPI / stats : pop échelonné ───────────────────────────────── */
.stats-grid > .stat-card,
.adm-kpi > .stat-card {
  animation: lp-pop var(--motion-slow) var(--motion-spring) both;
}
.stats-grid > .stat-card:nth-child(1),
.adm-kpi > .stat-card:nth-child(1) { animation-delay: .03s; }
.stats-grid > .stat-card:nth-child(2),
.adm-kpi > .stat-card:nth-child(2) { animation-delay: .07s; }
.stats-grid > .stat-card:nth-child(3),
.adm-kpi > .stat-card:nth-child(3) { animation-delay: .11s; }
.stats-grid > .stat-card:nth-child(4),
.adm-kpi > .stat-card:nth-child(4) { animation-delay: .15s; }
.stats-grid > .stat-card:nth-child(5),
.adm-kpi > .stat-card:nth-child(5) { animation-delay: .19s; }
.stats-grid > .stat-card:nth-child(6),
.adm-kpi > .stat-card:nth-child(6) { animation-delay: .23s; }

/* ── Admin : entrée auto des blocs principaux ─────────────────────────── */
[data-panel-scope="admin"] .main > .alert,
[data-panel-scope="admin"] .main > .card,
[data-panel-scope="admin"] .main > .section-header,
[data-panel-scope="admin"] .main > .quick-grid,
[data-panel-scope="admin"] .main > .table-wrap,
[data-panel-scope="admin"] .main > .form-row,
[data-panel-scope="admin"] .main > .cockpit,
[data-panel-scope="admin"] .main > .ck-panel {
  animation: lp-rise var(--motion-slow) var(--motion-spring) both;
}
[data-panel-scope="admin"] .main > *:nth-child(1) { animation-delay: .04s; }
[data-panel-scope="admin"] .main > *:nth-child(2) { animation-delay: .09s; }
[data-panel-scope="admin"] .main > *:nth-child(3) { animation-delay: .14s; }
[data-panel-scope="admin"] .main > *:nth-child(4) { animation-delay: .19s; }
[data-panel-scope="admin"] .main > *:nth-child(5) { animation-delay: .24s; }
[data-panel-scope="admin"] .main > *:nth-child(6) { animation-delay: .29s; }
[data-panel-scope="admin"] .main > *:nth-child(n+7) { animation-delay: .34s; }

[data-panel-scope="admin"] .sidebar-nav .nav-item {
  animation: lp-slide-x .38s var(--motion-ease-out) both;
}
[data-panel-scope="admin"] .sidebar-nav .nav-item:nth-child(1) { animation-delay: .04s; }
[data-panel-scope="admin"] .sidebar-nav .nav-item:nth-child(2) { animation-delay: .08s; }
[data-panel-scope="admin"] .sidebar-nav .nav-item:nth-child(3) { animation-delay: .12s; }
[data-panel-scope="admin"] .sidebar-nav .nav-item:nth-child(4) { animation-delay: .16s; }
[data-panel-scope="admin"] .sidebar-nav .nav-item:nth-child(5) { animation-delay: .20s; }
[data-panel-scope="admin"] .sidebar-nav .nav-item:nth-child(6) { animation-delay: .24s; }
[data-panel-scope="admin"] .sidebar-nav .nav-item:nth-child(n+7) { animation-delay: .28s; }

/* ── Classes utilitaires (JS / templates) ─────────────────────────────── */
.anim-stagger > * {
  animation: lp-rise var(--motion-slow) var(--motion-spring) both;
}
.anim-stagger > *:nth-child(1)  { animation-delay: .02s; }
.anim-stagger > *:nth-child(2)  { animation-delay: .06s; }
.anim-stagger > *:nth-child(3)  { animation-delay: .10s; }
.anim-stagger > *:nth-child(4)  { animation-delay: .14s; }
.anim-stagger > *:nth-child(5)  { animation-delay: .18s; }
.anim-stagger > *:nth-child(6)  { animation-delay: .22s; }
.anim-stagger > *:nth-child(7)  { animation-delay: .26s; }
.anim-stagger > *:nth-child(8)  { animation-delay: .30s; }
.anim-stagger > *:nth-child(n+9) { animation-delay: .34s; }

.anim-pop > * {
  animation: lp-pop .4s var(--motion-spring) both;
}
.anim-pop > *:nth-child(2) { animation-delay: .05s; }
.anim-pop > *:nth-child(3) { animation-delay: .10s; }
.anim-pop > *:nth-child(4) { animation-delay: .15s; }
.anim-pop > *:nth-child(n+5) { animation-delay: .20s; }

.anim-reveal {
  opacity: 0;
  transform: translateY(12px);
  transition:
    opacity var(--motion-slow) var(--motion-ease-out),
    transform var(--motion-slow) var(--motion-ease-out);
}
.anim-reveal.is-visible {
  opacity: 1;
  transform: none;
}

.anim-fade-in {
  animation: lp-fade-in var(--motion-base) var(--motion-ease-out) both;
}

.anim-pulse-once {
  animation: lp-pulse-once .6s var(--motion-ease-out) both;
}

/* Skeleton shimmer (chargement > 1s) */
.lp-skeleton {
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  background: rgba(255, 255, 255, .06);
}
.lp-skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, .08) 45%,
    transparent 90%
  );
  background-size: 200% 100%;
  animation: lp-shimmer 1.4s ease-in-out infinite;
}

/* Lookup / résultats dynamiques */
.lookup-results.anim-pop > .lookup-card,
.lookup-results.anim-stagger > .lookup-card {
  animation: lp-pop .42s var(--motion-spring) both;
}
.lookup-empty {
  animation: lp-fade-in var(--motion-base) var(--motion-ease-out) both;
}
.lookup-status {
  transition: color var(--motion-fast) ease, opacity var(--motion-fast) ease;
}
.lookup-status.is-updating {
  opacity: .55;
}

/* Copie réussie */
.is-copied {
  animation: lp-pulse-once .5s var(--motion-ease-out) both;
}

/* ── Reduced motion ────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
  .anim-reveal {
    opacity: 1;
    transform: none;
  }
  .lp-skeleton::after {
    animation: none;
  }
}
