/* ========================================
   AutoPY - Animações e Transições
   Fase 8: Polish
   ======================================== */

/* Fade In */
@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 fadeInLeft {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

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

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

/* Pulse */
@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

/* Shake */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

/* Skeleton loading */
@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* Classes de animação */
.animate-fade-in {
    animation: fadeIn 0.3s ease-out;
}

.animate-fade-in-up {
    animation: fadeInUp 0.4s ease-out;
}

.animate-fade-in-down {
    animation: fadeInDown 0.4s ease-out;
}

.animate-fade-in-left {
    animation: fadeInLeft 0.4s ease-out;
}

.animate-fade-in-right {
    animation: fadeInRight 0.4s ease-out;
}

.animate-scale-in {
    animation: scaleIn 0.3s ease-out;
}

.animate-pulse {
    animation: pulse 2s infinite;
}

.animate-shake {
    animation: shake 0.5s ease-in-out;
}

/* Staggered animations para listas */
.stagger-item {
    opacity: 0;
    animation: fadeInUp 0.4s ease-out forwards;
}

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

/* Transições suaves */
.transition-all {
    transition: all 0.3s ease;
}

.transition-fast {
    transition: all 0.15s ease;
}

.transition-slow {
    transition: all 0.5s ease;
}

/* Hover effects — apenas em dispositivos com ponteiro real */
.hover-lift {
    transition: transform 200ms ease, box-shadow 200ms ease;
}

@media (hover: hover) and (pointer: fine) {
    .hover-lift:hover {
        transform: translateY(-4px);
        box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    }
}

.hover-scale {
    transition: transform 200ms ease;
}

@media (hover: hover) and (pointer: fine) {
    .hover-scale:hover {
        transform: scale(1.02);
    }
}

.hover-glow {
    transition: box-shadow 200ms ease;
}

@media (hover: hover) and (pointer: fine) {
    .hover-glow:hover {
        box-shadow: 0 0 20px rgba(59, 130, 246, 0.4);
    }
}

/* Card vehicle animation */
.vehicle-card {
    transition: transform 200ms ease, box-shadow 200ms ease;
}

@media (hover: hover) and (pointer: fine) {
    .vehicle-card:hover {
        transform: translateY(-5px);
        box-shadow: 0 15px 35px rgba(0, 0, 0, 0.12);
    }

    .vehicle-card:hover .card-img-top {
        transform: scale(1.05);
    }
}

.vehicle-card .card-img-top {
    transition: transform 300ms cubic-bezier(0.22, 1, 0.36, 1);
}

/* Botão favorito */
.btn-favorite {
    transition: all 0.2s ease;
}

.btn-favorite:hover {
    transform: scale(1.1);
}

.btn-favorite.active {
    animation: pulse 0.3s ease;
}

/* Loading skeleton */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 4px;
}

.skeleton-text {
    height: 1em;
    margin-bottom: 0.5em;
}

.skeleton-title {
    height: 1.5em;
    width: 60%;
    margin-bottom: 0.75em;
}

.skeleton-image {
    height: 200px;
    width: 100%;
}

/* Page transitions */
.page-enter {
    opacity: 0;
    transform: translateY(10px);
}

.page-enter-active {
    opacity: 1;
    transform: translateY(0);
    transition: all 0.3s ease;
}

/* Toast notifications */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
}

.toast-item {
    animation: fadeInRight 0.3s ease-out;
    margin-bottom: 10px;
}

.toast-item.hiding {
    animation: fadeInRight 0.3s ease-out reverse forwards;
}

/* Button loading state */
.btn-loading {
    position: relative;
    pointer-events: none;
}

.btn-loading::after {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin: -8px 0 0 -8px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

/* Smooth scroll */
html {
    scroll-behavior: smooth;
}

/* Focus states */
.form-control:focus,
.form-select:focus,
.btn:focus {
    transition: box-shadow 0.15s ease;
}

/* Image lazy load fade */
img[loading="lazy"] {
    opacity: 0;
    transition: opacity 0.3s ease;
}

img[loading="lazy"].loaded,
img[loading="lazy"]:not([src=""]) {
    opacity: 1;
}

/* Accordion animations */
.accordion-button:not(.collapsed) {
    transition: background-color 0.15s ease;
}

.accordion-collapse {
    transition: height 0.3s ease;
}

/* Modal animations — inicia em 0.88 para entrada mais natural */
.modal.fade .modal-dialog {
    transform: scale(0.88);
    transition: transform 220ms cubic-bezier(0.22, 1, 0.36, 1), opacity 220ms ease;
}

.modal.show .modal-dialog {
    transform: scale(1);
}

/* Dropdown animations */
.dropdown-menu {
    animation: fadeInDown 0.15s ease-out;
}

/* Progress bar animation */
.progress-bar {
    transition: width 0.6s ease;
}

/* Badge pulse for notifications */
.badge-pulse {
    animation: pulse 2s infinite;
}

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