/**
 * Leaftide UI Polish - Animation Enhancements
 * Focus on smooth, purposeful micro-interactions
 */

/* === FOUNDATION ANIMATIONS === */

/* Respect reduced motion preference */
@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;
  }
}

/* === BUTTON ENHANCEMENTS === */

.btn-hover-lift {
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-hover-lift:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn-hover-lift:active {
  transform: translateY(0);
  transition-duration: 0.1s;
}

/* Enhanced button focus states */
.btn-focus-ring {
  transition: all 0.2s ease;
}

.btn-focus-ring:focus {
  outline: none;
  ring: 2px;
  ring-offset: 2px;
  transform: scale(1.02);
}

/* === CARD ANIMATIONS === */

.card-hover {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.card-hover:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.12);
}

.dashboard-card {
  transition: all 0.3s ease;
  transform-origin: center;
}

.dashboard-card:hover {
  transform: translateY(-3px) scale(1.01);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
}

/* === TAB TRANSITIONS === */

.tab-content {
  animation: fadeInSlide 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.tab-button {
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.tab-button::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.5s;
}

.tab-button:hover::before {
  left: 100%;
}

/* === LOADING STATES === */

.loading-shimmer {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

.skeleton {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

/* === NOTIFICATION ENHANCEMENTS === */

.notification-slide-in {
  animation: slideInFromRight 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.notification-slide-out {
  animation: slideOutToRight 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

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

/* === PROGRESS INDICATORS === */

.progress-bar {
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.progress-bar::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
  transform: translateX(-100%);
  animation: progressShine 2s infinite;
}

@keyframes progressShine {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}

/* Plant lifecycle progress */
.lifecycle-progress {
  background: linear-gradient(90deg, #f0fdf4, #bbf7d0, #86efac, #4ade80, #22c55e);
  height: 6px;
  border-radius: 3px;
  position: relative;
  overflow: hidden;
}

.lifecycle-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #059669, #10b981);
  border-radius: 3px;
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.4);
}

.lifecycle-stage-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  position: absolute;
  top: -1px;
  transform: translateX(-50%);
  transition: all 0.3s ease;
  border: 2px solid white;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.lifecycle-stage-indicator.completed {
  background: #10b981;
  transform: translateX(-50%) scale(1.2);
}

.lifecycle-stage-indicator.current {
  background: #f59e0b;
  transform: translateX(-50%) scale(1.4);
  animation: pulse-glow 2s infinite;
}

.lifecycle-stage-indicator.upcoming {
  background: #e5e7eb;
}

@keyframes pulse-glow {
  0%, 100% {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2), 0 0 0 0 rgba(245, 158, 11, 0.4);
  }
  50% {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2), 0 0 0 4px rgba(245, 158, 11, 0.2);
  }
}

/* === MODAL IMPROVEMENTS === */

.modal-backdrop {
  animation: fadeIn 0.3s ease;
  will-change: opacity, transform;
  transform: translateZ(0);
  backface-visibility: hidden;
}

.modal-content {
  animation: modalSlideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Fix Chrome first-open flicker on Leaftide plant details modal.
   Force the fixed overlay + inner content to stay on their own composited layer
   during the initial opacity transition to prevent Chrome from briefly dropping
   the layer on first promotion. Tested in Chrome; safe in Firefox/Safari. */
.gc-plant-details-backdrop {
  will-change: opacity, transform !important;
  transform: translateZ(0) !important;
  backface-visibility: hidden !important;
}

.gc-plant-details-backdrop > * {
  will-change: opacity, transform !important;
  transform: translateZ(0) !important;
  backface-visibility: hidden !important;
}

/* Additional fix for the modal content specifically */
.gc-plant-details-backdrop .modal-content {
  will-change: opacity, transform !important;
  transform: translateZ(0) !important;
  backface-visibility: hidden !important;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

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

/* === LIST ANIMATIONS === */

.stagger-item {
  animation: staggerFadeIn 0.5s cubic-bezier(0.4, 0, 0.2, 1) both;
}

.stagger-item:nth-child(1) { animation-delay: 0.1s; }
.stagger-item:nth-child(2) { animation-delay: 0.2s; }
.stagger-item:nth-child(3) { animation-delay: 0.3s; }
.stagger-item:nth-child(4) { animation-delay: 0.4s; }
.stagger-item:nth-child(5) { animation-delay: 0.5s; }

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

/* === ICON ANIMATIONS === */

.icon-bounce {
  transition: transform 0.2s ease;
}

.icon-bounce:hover {
  transform: scale(1.1);
  animation: gentleBounce 0.6s ease;
}

@keyframes gentleBounce {
  0%, 20%, 50%, 80%, 100% {
    transform: scale(1.1);
  }
  40% {
    transform: scale(1.15);
  }
  60% {
    transform: scale(1.12);
  }
}

/* === NUMBER COUNTING === */

.count-up {
  animation: countPulse 0.3s ease;
}

@keyframes countPulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
  100% {
    transform: scale(1);
  }
}

/* === SMOOTH HEIGHT TRANSITIONS === */

.accordion {
  transition: height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.expand-collapse {
  transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

/* === DASHBOARD SPECIFIC ANIMATIONS === */

.plant-card-item {
  transition: all 0.2s ease;
  border-radius: 0.375rem;
}

.plant-card-item:hover {
  background-color: rgba(255, 255, 255, 0.8);
  transform: translateX(2px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.action-card-button {
  transition: all 0.2s ease;
}

.action-card-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* === FORM ENHANCEMENTS === */

.form-field {
  transition: all 0.2s ease;
}

.form-field:focus {
  transform: scale(1.01);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-error {
  animation: shakeError 0.5s ease;
}

@keyframes shakeError {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* === UTILITY CLASSES === */

.animate-spin-slow {
  animation: spin 3s linear infinite;
}

.animate-float {
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-5px);
  }
}

/* === RESPONSIVE OPTIMIZATIONS === */

@media (max-width: 768px) {
  .card-hover:hover,
  .dashboard-card:hover {
    transform: none; /* Reduce animations on mobile */
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  }
}

/* === DARK MODE SUPPORT === */
@media (prefers-color-scheme: dark) {
  .loading-shimmer {
    background: linear-gradient(90deg, #374151 25%, #4b5563 50%, #374151 75%);
    background-size: 200% 100%;
  }
}

/* === STANDARDIZED BUTTON CLASSES === */
/*
 * Button component styling now lives in garden/static/src/tailwind.css so that
 * Tailwind can compile the utility-based rules into the generated bundle.
 */

/* === PROGRESSIVE IMAGE LOADING === */

.image-placeholder {
  opacity: 0;
  transition: opacity 300ms ease-in-out;
}

.image-placeholder.is-loaded {
  opacity: 1;
}
}
