/**
 * LICITAR - Animations & Microinteractions
 * Responsividade e microinterações premium
 */

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

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

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

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

@keyframes slideInRight {
  from {
    transform: translateX(100%);
  }
  to {
    transform: translateX(0);
  }
}

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

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.8;
    transform: scale(1.05);
  }
}

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

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

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

/* ===== PAGE LOAD ANIMATIONS ===== */

.page-header {
  animation: fadeInDown 0.6s ease-out;
}

.kpi-grid > * {
  animation: fadeInUp 0.6s ease-out;
}

.kpi-grid > *:nth-child(1) { animation-delay: 0.1s; }
.kpi-grid > *:nth-child(2) { animation-delay: 0.2s; }
.kpi-grid > *:nth-child(3) { animation-delay: 0.3s; }
.kpi-grid > *:nth-child(4) { animation-delay: 0.4s; }

.dashboard-section {
  animation: fadeIn 0.8s ease-out;
}

.opportunity-card {
  animation: fadeInUp 0.5s ease-out;
  animation-fill-mode: both;
}

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

/* ===== HOVER MICROINTERACTIONS ===== */

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

.btn::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

.btn:active::before {
  width: 300px;
  height: 300px;
}

/* Card hover effects */
.card,
.kpi-card,
.opportunity-card {
  transition: all var(--transition-base);
}

.card:hover,
.kpi-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.opportunity-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-xl);
}

/* Button group hover effect */
.page-actions {
  gap: var(--space-3);
}

.page-actions .btn {
  transition: all var(--transition-base);
}

.page-actions .btn:hover {
  transform: translateY(-2px);
}

/* Badge pulse on new items */
.badge-dot {
  position: relative;
}

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

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

.skeleton-loader {
  background: linear-gradient(
    90deg,
    var(--color-neutral-100) 0%,
    var(--color-neutral-200) 50%,
    var(--color-neutral-100) 100%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--border-radius-md);
}

.spinner-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-8);
}

.spinner {
  animation: spin 1s linear infinite;
}

/* ===== TRANSITION EFFECTS ===== */

.nav-link,
.filter-chip,
.btn-icon,
.user-menu,
a {
  transition: all var(--transition-fast);
}

.form-input,
.form-select,
.form-textarea {
  transition: all var(--transition-fast);
}

/* Smooth focus states */
*:focus-visible {
  outline: 2px solid var(--color-primary-500);
  outline-offset: 2px;
  border-radius: var(--border-radius-sm);
  transition: outline var(--transition-fast);
}

/* ===== SCROLL ANIMATIONS ===== */

@media (prefers-reduced-motion: no-preference) {
  .fade-in-on-scroll {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
  }

  .fade-in-on-scroll.visible {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===== ALERT/NOTIFICATION ANIMATIONS ===== */

.alert-item {
  transition: all var(--transition-base);
}

.alert-item:hover {
  transform: translateX(4px);
  box-shadow: var(--shadow-md);
}

/* ===== INTERACTIVE ELEMENTS ===== */

/* Checkbox animation */
.form-check-input {
  transition: all var(--transition-fast);
}

.form-check-input:checked {
  animation: scaleIn 0.2s ease-out;
}

/* Badge hover */
.badge {
  transition: all var(--transition-fast);
}

.badge:hover {
  transform: scale(1.05);
}

/* Icon button ripple effect */
.btn-icon {
  position: relative;
  overflow: hidden;
}

.btn-icon::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(30, 136, 229, 0.3);
  transform: translate(-50%, -50%);
  transition: width 0.4s, height 0.4s;
}

.btn-icon:active::after {
  width: 100px;
  height: 100px;
}

/* ===== RESPONSIVE ANIMATIONS ===== */

@media (max-width: 768px) {
  /* Reduce animation intensity on mobile */
  .card:hover,
  .kpi-card:hover,
  .opportunity-card:hover {
    transform: translateY(-2px);
  }

  .btn:hover {
    transform: none;
  }

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

/* ===== ACCESSIBILITY ===== */

/* Respect user preference for 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;
  }
}

/* High contrast mode adjustments */
@media (prefers-contrast: high) {
  .btn {
    border-width: 2px;
  }

  .card,
  .kpi-card,
  .opportunity-card {
    border-width: 2px;
  }
}

/* ===== CUSTOM SCROLLBAR ===== */

::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

::-webkit-scrollbar-track {
  background: var(--color-neutral-50);
  border-radius: var(--border-radius-md);
}

::-webkit-scrollbar-thumb {
  background: var(--color-neutral-300);
  border-radius: var(--border-radius-md);
  border: 3px solid var(--color-neutral-50);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--color-neutral-400);
}

/* ===== SELECTION HIGHLIGHT ===== */

::selection {
  background-color: var(--color-primary-100);
  color: var(--color-primary-900);
}

::-moz-selection {
  background-color: var(--color-primary-100);
  color: var(--color-primary-900);
}

/* ===== FOCUS INDICATORS ===== */

.btn:focus-visible {
  box-shadow: var(--shadow-focus);
}

.btn-primary:focus-visible {
  box-shadow: 0 0 0 3px rgba(30, 136, 229, 0.3);
}

.btn-danger:focus-visible {
  box-shadow: 0 0 0 3px rgba(244, 67, 54, 0.3);
}

/* ===== GLASSMORPHISM EFFECTS (PREMIUM) ===== */

.glass-effect {
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.3);
}

/* ===== GRADIENT ANIMATIONS ===== */

@keyframes gradientShift {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

.animated-gradient {
  background: linear-gradient(
    270deg,
    var(--color-primary-500),
    var(--color-primary-600),
    var(--color-primary-700)
  );
  background-size: 200% 200%;
  animation: gradientShift 3s ease infinite;
}

/* ===== STAGGER ANIMATIONS ===== */

.stagger-animation > * {
  animation: fadeInUp 0.5s ease-out;
  animation-fill-mode: both;
}

.stagger-animation > *:nth-child(1) { animation-delay: 0.05s; }
.stagger-animation > *:nth-child(2) { animation-delay: 0.1s; }
.stagger-animation > *:nth-child(3) { animation-delay: 0.15s; }
.stagger-animation > *:nth-child(4) { animation-delay: 0.2s; }
.stagger-animation > *:nth-child(5) { animation-delay: 0.25s; }
.stagger-animation > *:nth-child(6) { animation-delay: 0.3s; }
.stagger-animation > *:nth-child(7) { animation-delay: 0.35s; }
.stagger-animation > *:nth-child(8) { animation-delay: 0.4s; }

/* ===== SMOOTH SCROLL ===== */

html {
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

/* ===== IMAGE HOVER EFFECTS ===== */

.user-avatar {
  transition: all var(--transition-fast);
}

.user-avatar:hover {
  transform: scale(1.05);
  box-shadow: var(--shadow-md);
}

/* ===== LINK UNDERLINE ANIMATION ===== */

a {
  position: relative;
}

a::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: 2px;
  background: currentColor;
  transition: width var(--transition-fast);
}

a:hover::after {
  width: 100%;
}

.nav-link::after,
.btn::after {
  display: none;
}

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

.tooltip-content {
  animation: fadeIn 0.2s ease-out;
}

/* ===== MODAL ANIMATIONS ===== */

.modal.active {
  animation: fadeIn 0.3s ease-out;
}

.modal.active .modal-dialog {
  animation: scaleIn 0.3s ease-out;
}

/* ===== RESPONSIVE UTILITIES ===== */

@media (max-width: 1024px) {
  .hide-on-tablet {
    display: none !important;
  }
}

@media (max-width: 768px) {
  .hide-on-mobile {
    display: none !important;
  }

  /* Simplify animations on mobile */
  .page-header,
  .kpi-grid > *,
  .dashboard-section,
  .opportunity-card {
    animation: fadeIn 0.3s ease-out;
  }
}

@media (min-width: 769px) {
  .show-on-mobile-only {
    display: none !important;
  }
}
