/**
 * ADMIN ANIMATIONS - INFINITY CONSTRUTORA
 * OBSIDIAN VAULT v4.0 — Refined micro-interactions
 */

/* ============================================================
   BASE
   ============================================================ */

html { scroll-behavior: smooth; }

/* ============================================================
   PAGE ENTRANCE
   ============================================================ */

.page-enter {
  animation: pageEnter 0.5s cubic-bezier(0, 0, 0.2, 1) both;
}

@keyframes pageEnter {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Staggered children */
.stagger-children > * {
  animation: cardReveal 0.45s cubic-bezier(0, 0, 0.2, 1) both;
}
.stagger-children > *:nth-child(1)  { animation-delay: 0.05s; }
.stagger-children > *:nth-child(2)  { animation-delay: 0.10s; }
.stagger-children > *:nth-child(3)  { animation-delay: 0.15s; }
.stagger-children > *:nth-child(4)  { animation-delay: 0.20s; }
.stagger-children > *:nth-child(5)  { animation-delay: 0.25s; }
.stagger-children > *:nth-child(6)  { animation-delay: 0.30s; }
.stagger-children > *:nth-child(n+7){ animation-delay: 0.35s; }

@keyframes cardReveal {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   SKELETON LOADING
   ============================================================ */

.skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-elevated) 25%,
    var(--bg-hover)    50%,
    var(--bg-elevated) 75%
  );
  background-size: 200% 100%;
  animation: skeletonShimmer 1.6s ease-in-out infinite;
  border-radius: var(--radius-xs);
  color: transparent !important;
  user-select: none;
  pointer-events: none;
}

@keyframes skeletonShimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}

/* ============================================================
   FADE IN
   ============================================================ */

.fade-in {
  animation: fadeIn 0.35s ease both;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.blur-in {
  animation: blurIn 0.5s cubic-bezier(0, 0, 0.2, 1) both;
}

@keyframes blurIn {
  from { opacity: 0; filter: blur(8px); }
  to   { opacity: 1; filter: blur(0); }
}

/* ============================================================
   SLIDE ANIMATIONS
   ============================================================ */

.slide-up {
  animation: slideUp 0.4s cubic-bezier(0, 0, 0.2, 1) both;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

.slide-in-left {
  animation: slideInLeft 0.4s cubic-bezier(0, 0, 0.2, 1) both;
}

@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-16px); }
  to   { opacity: 1; transform: translateX(0); }
}

.slide-in-right {
  animation: slideInRight 0.4s cubic-bezier(0, 0, 0.2, 1) both;
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(16px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ============================================================
   BOUNCE IN (for modals, toasts)
   ============================================================ */

.bounce-in {
  animation: bounceIn 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes bounceIn {
  from { opacity: 0; transform: scale(0.88); }
  to   { opacity: 1; transform: scale(1); }
}

/* ============================================================
   GLOW PULSE (for active status indicators)
   ============================================================ */

@keyframes glowPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 171, 0, 0); }
  50%       { box-shadow: 0 0 0 6px rgba(255, 171, 0, 0); }
}

.glow-pulse {
  animation: glowPulse 2.5s ease-in-out infinite;
}

/* Status dot pulse */
@keyframes dotPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.4; transform: scale(0.75); }
}

.dot-pulse {
  animation: dotPulse 2s ease-in-out infinite;
}

/* ============================================================
   NOTIFICATION BADGE
   ============================================================ */

@keyframes badgePop {
  0%   { transform: scale(0); }
  70%  { transform: scale(1.15); }
  100% { transform: scale(1); }
}

.badge-pop {
  animation: badgePop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

/* ============================================================
   TOAST / NOTIFICATION SLIDE IN
   ============================================================ */

@keyframes toastSlideIn {
  from { opacity: 0; transform: translateX(120%); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes toastSlideOut {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(120%); }
}

.toast-in  { animation: toastSlideIn  0.35s cubic-bezier(0, 0, 0.2, 1) both; }
.toast-out { animation: toastSlideOut 0.3s  cubic-bezier(0.4, 0, 1, 1) both; }

/* ============================================================
   PROGRESS BAR ENTRANCE
   ============================================================ */

@keyframes progressGrow {
  from { width: 0 !important; }
}

.progress-animate .progress-bar-fill {
  animation: progressGrow 0.8s cubic-bezier(0, 0, 0.2, 1) both;
}

/* ============================================================
   TOOLTIP
   ============================================================ */

[data-tooltip] { position: relative; }

[data-tooltip]::before {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  padding: 0.35rem 0.625rem;
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-size: 0.6875rem;
  font-weight: 500;
  white-space: nowrap;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 9999;
  font-family: 'Montserrat', sans-serif;
}

[data-tooltip]:hover::before {
  opacity: 1;
  transform: translateX(-50%) translateY(-2px);
}

/* Sidebar nav links use ::before for accent bar — suppress global tooltip */
.admin-sidebar [data-tooltip]::before {
  display: none;
}

/* ============================================================
   RIPPLE ON BUTTONS (CSS only)
   ============================================================ */

.ripple {
  position: relative;
  overflow: hidden;
}

.ripple::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle, rgba(255,255,255,0.15) 0%, transparent 70%);
  opacity: 0;
  transform: scale(0);
  transition: transform 0.5s ease, opacity 0.5s ease;
  border-radius: inherit;
}

.ripple:active::after {
  opacity: 1;
  transform: scale(2.5);
  transition-duration: 0s;
}

/* ============================================================
   TYPING INDICATOR
   ============================================================ */

.typing-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.typing-indicator span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gold);
  animation: typingDot 1.2s ease-in-out infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.15s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.30s; }

@keyframes typingDot {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30%            { transform: translateY(-6px); opacity: 1; }
}

/* ============================================================
   SIDEBAR ENTRANCE
   ============================================================ */

@keyframes sidebarEnter {
  from { opacity: 0; transform: translateX(-100%); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ============================================================
   COUNTER NUMBER ROLL (applied via JS)
   ============================================================ */

@keyframes countUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.count-up {
  animation: countUp 0.5s cubic-bezier(0, 0, 0.2, 1) both;
}

/* ============================================================
   TABLE ROW ENTRANCE
   ============================================================ */

.admin-table tbody tr {
  animation: rowEnter 0.3s cubic-bezier(0, 0, 0.2, 1) both;
}

.admin-table tbody tr:nth-child(1)  { animation-delay: 0.02s; }
.admin-table tbody tr:nth-child(2)  { animation-delay: 0.04s; }
.admin-table tbody tr:nth-child(3)  { animation-delay: 0.06s; }
.admin-table tbody tr:nth-child(4)  { animation-delay: 0.08s; }
.admin-table tbody tr:nth-child(5)  { animation-delay: 0.10s; }
.admin-table tbody tr:nth-child(n+6){ animation-delay: 0.12s; }

@keyframes rowEnter {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ============================================================
   LOADING SPINNER VARIANTS
   ============================================================ */

.spinner-gold {
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 2px solid var(--border);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============================================================
   REDUCED MOTION SUPPORT
   ============================================================ */

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