/* ColisBled - Animations et Transitions Avancées */

/* ===========================================
   ANIMATIONS D'ENTRÉE
   =========================================== */

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

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

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

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

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

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

/* ===========================================
   CLASSES D'ANIMATION
   =========================================== */

.animate-fade-in {
    animation: fadeIn 0.6s ease-out;
}

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

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

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

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

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

/* Délais pour animations séquentielles */
.animate-delay-1 { animation-delay: 0.1s; }
.animate-delay-2 { animation-delay: 0.2s; }
.animate-delay-3 { animation-delay: 0.3s; }
.animate-delay-4 { animation-delay: 0.4s; }
.animate-delay-5 { animation-delay: 0.5s; }

/* ===========================================
   ANIMATIONS DE CHARGEMENT
   =========================================== */

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

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

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

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

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

.animate-bounce {
    animation: bounce 1s ease-in-out infinite;
}

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

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

.skeleton {
    background: linear-gradient(
        90deg,
        var(--gray-200) 0%,
        var(--gray-100) 20%,
        var(--gray-200) 40%,
        var(--gray-200) 100%
    );
    background-size: 800px 100px;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: var(--radius);
}

.skeleton-text {
    height: 1rem;
    margin-bottom: var(--space-2);
}

.skeleton-title {
    height: 2rem;
    width: 60%;
    margin-bottom: var(--space-4);
}

.skeleton-avatar {
    width: 64px;
    height: 64px;
    border-radius: var(--radius-full);
}

.skeleton-card {
    height: 200px;
    border-radius: var(--radius-lg);
}

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

.hover-lift {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

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

.hover-scale {
    transition: transform 0.3s ease;
}

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

.hover-glow {
    transition: box-shadow 0.3s ease;
}

.hover-glow:hover {
    box-shadow: 0 0 20px rgba(79, 70, 229, 0.3);
}

.hover-shine {
    position: relative;
    overflow: hidden;
}

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

.hover-shine:hover::before {
    left: 100%;
}

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

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

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

.btn-ripple:active::after {
    width: 300px;
    height: 300px;
}

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

.btn-bounce:active {
    transform: scale(0.95);
}

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

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

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

.modal-fade-in {
    animation: modalFadeIn 0.3s ease-out;
}

.modal-slide-in {
    animation: modalSlideIn 0.3s ease-out;
}

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

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

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

.notification-enter {
    animation: slideInRight 0.3s ease-out;
}

.notification-exit {
    animation: slideOutRight 0.3s ease-in;
}

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

@keyframes progress {
    from {
        transform: scaleX(0);
    }
    to {
        transform: scaleX(1);
    }
}

.progress-bar-animated {
    transform-origin: left;
    animation: progress 1s ease-out;
}

@keyframes indeterminate {
    0% {
        left: -35%;
        right: 100%;
    }
    60% {
        left: 100%;
        right: -90%;
    }
    100% {
        left: 100%;
        right: -90%;
    }
}

.progress-indeterminate {
    position: relative;
    overflow: hidden;
}

.progress-indeterminate::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    background: var(--primary);
    animation: indeterminate 2.1s cubic-bezier(0.65, 0.815, 0.735, 0.395) infinite;
}

/* ===========================================
   CARD FLIP
   =========================================== */

.card-flip {
    perspective: 1000px;
}

.card-flip-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.6s;
    transform-style: preserve-3d;
}

.card-flip:hover .card-flip-inner {
    transform: rotateY(180deg);
}

.card-flip-front,
.card-flip-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: var(--radius-lg);
}

.card-flip-back {
    transform: rotateY(180deg);
}

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

@keyframes accordionOpen {
    from {
        max-height: 0;
        opacity: 0;
    }
    to {
        max-height: 500px;
        opacity: 1;
    }
}

.accordion-content {
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease;
}

.accordion-content.open {
    animation: accordionOpen 0.3s ease-out;
}

/* ===========================================
   COUNTER ANIMATION
   =========================================== */

.counter {
    font-variant-numeric: tabular-nums;
}

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

.counter.animate {
    animation: countUp 0.5s ease-out;
}

/* ===========================================
   TYPING ANIMATION
   =========================================== */

@keyframes typing {
    from {
        width: 0;
    }
    to {
        width: 100%;
    }
}

@keyframes blink {
    50% {
        border-color: transparent;
    }
}

.typing-animation {
    overflow: hidden;
    border-right: 2px solid var(--primary);
    white-space: nowrap;
    animation: typing 3.5s steps(40, end), blink 0.75s step-end infinite;
}

/* ===========================================
   SCROLL REVEAL
   =========================================== */

.scroll-reveal {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.scroll-reveal.revealed {
    opacity: 1;
    transform: translateY(0);
}

/* Variantes directionnelles */
.scroll-reveal-left {
    opacity: 0;
    transform: translateX(-30px);
}

.scroll-reveal-right {
    opacity: 0;
    transform: translateX(30px);
}

.scroll-reveal-left.revealed,
.scroll-reveal-right.revealed {
    opacity: 1;
    transform: translateX(0);
}

/* ===========================================
   PARALLAX EFFECT
   =========================================== */

.parallax {
    transition: transform 0.1s ease-out;
    will-change: transform;
}

/* ===========================================
   GRADIENT ANIMATION
   =========================================== */

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

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

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

.stagger-item {
    opacity: 0;
    transform: translateY(20px);
    animation: fadeInUp 0.6s ease-out forwards;
}

.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; }
.stagger-item:nth-child(6) { animation-delay: 0.6s; }

/* ===========================================
   OPTIMISATIONS PERFORMANCE
   =========================================== */

/* Préférer transform et opacity pour performances */
.will-animate {
    will-change: transform, opacity;
}

/* Réduire animations sur mobile pour économiser batterie */
@media (max-width: 767px) {
    .reduce-motion-mobile * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Respecter les préférences utilisateur */
@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;
    }
}

/* ===========================================
   MICRO-INTERACTIONS
   =========================================== */

.interactive {
    cursor: pointer;
    user-select: none;
}

.interactive:active {
    transform: scale(0.98);
}

/* Bouton avec loading */
.btn-loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

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

/* Checkbox animé */
.checkbox-animated input[type="checkbox"] {
    appearance: none;
    width: 20px;
    height: 20px;
    border: 2px solid var(--gray-300);
    border-radius: var(--radius-sm);
    position: relative;
    cursor: pointer;
    transition: all 0.2s ease;
}

.checkbox-animated input[type="checkbox"]:checked {
    background: var(--primary);
    border-color: var(--primary);
}

.checkbox-animated input[type="checkbox"]:checked::after {
    content: '✓';
    position: absolute;
    top: -2px;
    left: 3px;
    color: white;
    font-size: 14px;
    animation: scaleIn 0.2s ease;
}

/* Toggle switch animé */
.toggle-switch {
    position: relative;
    width: 50px;
    height: 24px;
    background: var(--gray-300);
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: background 0.3s ease;
}

.toggle-switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    transition: transform 0.3s ease;
    box-shadow: var(--shadow-sm);
}

.toggle-switch.active {
    background: var(--primary);
}

.toggle-switch.active::after {
    transform: translateX(26px);
}
