/* ═══════════════════════════════════════════
   Site-wide motion & entrance effects
   ═══════════════════════════════════════════ */

:root {
  --anim-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --anim-duration: 0.55s;
}

/* ─── Keyframes ─── */
@keyframes anim-fade-up {
  from { opacity: 0; transform: translateY(22px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes anim-fade-down {
  from { opacity: 0; transform: translateY(-16px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes anim-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes anim-scale-in {
  from { opacity: 0; transform: scale(0.94); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes anim-slide-right {
  from { opacity: 0; transform: translateX(-18px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes anim-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}
@keyframes anim-float-slow {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(12px, -10px) scale(1.04); }
  66% { transform: translate(-8px, 6px) scale(0.98); }
}
@keyframes anim-shimmer {
  0% { background-position: -200% center; }
  100% { background-position: 200% center; }
}
@keyframes anim-pulse-ring {
  0% { box-shadow: 0 0 0 0 rgba(0, 0, 153, 0.35); }
  70% { box-shadow: 0 0 0 10px rgba(0, 0, 153, 0); }
  100% { box-shadow: 0 0 0 0 rgba(0, 0, 153, 0); }
}
@keyframes anim-preview-enter {
  from { opacity: 0; transform: translateY(8px) scale(0.99); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes anim-nav-slide {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}
@keyframes anim-row-in {
  from { opacity: 0; transform: translateX(-10px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes anim-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}
@keyframes anim-bg-shift {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}
@keyframes anim-toast-slide {
  from { opacity: 0; transform: translateY(16px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ─── Page load (body gets .page-loaded via JS) ─── */
body.page-loaded .app-header {
  animation: anim-fade-down 0.5s var(--anim-ease) both;
}

body.page-loaded .dashboard-main > * {
  animation: anim-fade-up var(--anim-duration) var(--anim-ease) both;
}
body.page-loaded .dashboard-main > *:nth-child(1) { animation-delay: 0.06s; }
body.page-loaded .dashboard-main > *:nth-child(2) { animation-delay: 0.12s; }
body.page-loaded .dashboard-main > *:nth-child(3) { animation-delay: 0.18s; }

body.page-loaded .dashboard-grid .panel:nth-child(1) {
  animation: anim-slide-right var(--anim-duration) var(--anim-ease) 0.1s both;
}
body.page-loaded .dashboard-grid .panel:nth-child(2) {
  animation: anim-fade-up var(--anim-duration) var(--anim-ease) 0.2s both;
}

body.page-loaded .ticket-form .form-section {
  animation: anim-fade-up 0.45s var(--anim-ease) both;
}
body.page-loaded .ticket-form .form-section:nth-of-type(1) { animation-delay: 0.14s; }
body.page-loaded .ticket-form .form-section:nth-of-type(2) { animation-delay: 0.22s; }
body.page-loaded .ticket-form .form-section:nth-of-type(3) { animation-delay: 0.3s; }
body.page-loaded .ticket-form .form-section:nth-of-type(4) { animation-delay: 0.38s; }

/* Login entrance */
body.page-loaded .login-hero-inner {
  animation: anim-slide-right 0.7s var(--anim-ease) 0.08s both;
}
body.page-loaded .login-ticket-mock {
  animation: anim-scale-in 0.85s var(--anim-ease) 0.25s both;
}
body.page-loaded .login-card {
  animation: anim-scale-in 0.65s var(--anim-ease) 0.12s both;
}
body.page-loaded .login-hero-logo {
  animation:
    anim-scale-in 0.55s var(--anim-ease) 0.1s both,
    anim-float 5s ease-in-out 0.8s infinite;
}
.login-hero-bg {
  animation: anim-bg-shift 20s ease infinite;
}
.login-ticket-mock-badge {
  animation: anim-float 3.5s ease-in-out infinite;
}

/* Scroll reveal */
.anim-reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.6s var(--anim-ease), transform 0.6s var(--anim-ease);
}
.anim-reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}
.anim-reveal--left {
  transform: translateX(-24px);
}
.anim-reveal--left.is-visible {
  transform: translateX(0);
}

/* Panels & cards */
.panel {
  transition: box-shadow 0.35s ease, transform 0.35s var(--anim-ease);
}
.panel:hover {
  transform: translateY(-3px);
}
.flight-search-card,
.flight-schedule-card {
  transition: border-color 0.3s ease, box-shadow 0.35s var(--anim-ease), transform 0.35s var(--anim-ease);
}
.flight-schedule-card.is-loaded {
  animation: anim-pulse-ring 0.8s ease-out;
}

/* Header logo */
.app-logo-icon {
  transition: transform 0.35s var(--anim-ease), box-shadow 0.35s ease;
}
.app-logo:hover .app-logo-icon {
  transform: rotate(-6deg) scale(1.06);
  box-shadow: 0 6px 20px rgba(0, 0, 153, 0.28);
}

/* Nav links */
.app-nav-link {
  position: relative;
  overflow: hidden;
}
.app-nav-link::after {
  content: '';
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 4px;
  height: 2px;
  background: var(--accent);
  border-radius: 2px;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.3s var(--anim-ease);
}
.app-nav-link:hover::after,
.app-nav-link.is-active::after {
  transform: scaleX(1);
}
.app-nav-link.is-active::after {
  background: rgba(255, 255, 255, 0.85);
}

/* Buttons */
.btn {
  position: relative;
  overflow: hidden;
  transition: transform 0.2s var(--anim-ease), box-shadow 0.25s ease, background 0.2s ease, color 0.2s ease;
}
.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 40%, rgba(255, 255, 255, 0.22) 50%, transparent 60%);
  transform: translateX(-120%);
  transition: transform 0.55s ease;
  pointer-events: none;
}
.btn:hover::after {
  transform: translateX(120%);
}
.btn:active {
  transform: translateY(0) scale(0.97) !important;
}
.btn-primary:hover {
  animation: anim-pulse-ring 1.2s ease-out;
}

/* Form focus glow */
.form-group input:focus,
.form-group select:focus,
.stock-search-input:focus {
  transform: translateY(-1px);
}

/* Preview tabs & panes */
.preview-tab {
  transition: color 0.25s ease, background 0.25s ease, border-color 0.25s ease, transform 0.2s var(--anim-ease);
}
.preview-tab:hover:not(.is-disabled) {
  transform: translateY(-2px);
}
.preview-tab.is-active {
  transform: translateY(-1px);
}
.preview-pane.is-active {
  animation: anim-preview-enter 0.38s var(--anim-ease);
}
.preview-pane.is-entering {
  animation: anim-preview-enter 0.38s var(--anim-ease);
}
.eticket-preview,
.invoice-preview,
.agency-preview {
  transition: box-shadow 0.4s ease, transform 0.4s var(--anim-ease);
}
.preview-pane.is-active .eticket-preview,
.preview-pane.is-active .invoice-preview,
.preview-pane.is-active .agency-preview {
  animation: anim-scale-in 0.45s var(--anim-ease);
}

/* Tables */
.recent-table tbody tr {
  transition: background 0.2s ease, transform 0.25s var(--anim-ease), box-shadow 0.25s ease;
}
.recent-table tbody tr:hover {
  transform: translateX(4px);
  box-shadow: inset 3px 0 0 var(--accent);
}
body.page-loaded .recent-table tbody tr {
  animation: anim-row-in 0.4s var(--anim-ease) backwards;
}
body.page-loaded .recent-table tbody tr:nth-child(1) { animation-delay: 0.05s; }
body.page-loaded .recent-table tbody tr:nth-child(2) { animation-delay: 0.09s; }
body.page-loaded .recent-table tbody tr:nth-child(3) { animation-delay: 0.13s; }
body.page-loaded .recent-table tbody tr:nth-child(4) { animation-delay: 0.17s; }
body.page-loaded .recent-table tbody tr:nth-child(5) { animation-delay: 0.21s; }
body.page-loaded .recent-table tbody tr:nth-child(n+6) { animation-delay: 0.25s; }

/* Stock & inbox */
.stock-stat {
  transition: transform 0.3s var(--anim-ease), box-shadow 0.3s ease;
}
.stock-stat:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: var(--shadow);
}
.stock-badge--available {
  animation: anim-pulse-ring 2.5s ease-out infinite;
}
.stock-toast:not([hidden]) {
  animation: anim-toast-slide 0.4s var(--anim-ease);
}
.stock-load-banner {
  animation: anim-fade-up 0.5s var(--anim-ease);
}

/* Alerts */
.alert-error {
  animation: anim-shake 0.55s ease;
}

/* Dashboard ambient background */
.dashboard-page {
  background-size: 200% 200%;
  animation: anim-bg-shift 18s ease infinite;
}

/* Loading overlay */
.am-loading-overlay {
  animation: anim-fade-in 0.25s ease;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .dashboard-page { animation: none; }
  .panel:hover,
  .recent-table tbody tr:hover,
  .stock-stat:hover {
    transform: none;
  }
}
