/**
 * Styles pour le système de dynamisme
 * Animations, transitions, interactions
 */

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

/* Fade-in */
[data-animate="fadeIn"] {
    opacity: 0;
    transition: opacity 0.6s ease-out;
}

[data-animate="fadeIn"].animated {
    opacity: 1;
}

/* Fade-in up */
[data-animate="fadeInUp"] {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

[data-animate="fadeInUp"].animated {
    opacity: 1;
    transform: translateY(0);
}

/* Slide-in left */
[data-animate="slideInLeft"] {
    opacity: 0;
    transform: translateX(-50px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

[data-animate="slideInLeft"].animated {
    opacity: 1;
    transform: translateX(0);
}

/* Slide-in right */
[data-animate="slideInRight"] {
    opacity: 0;
    transform: translateX(50px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

[data-animate="slideInRight"].animated {
    opacity: 1;
    transform: translateX(0);
}

/* Scale-in */
[data-animate="scaleIn"] {
    opacity: 0;
    transform: scale(0.9);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

[data-animate="scaleIn"].animated {
    opacity: 1;
    transform: scale(1);
}

/* Stagger container */
[data-stagger] > * {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.5s ease-out, transform 0.5s ease-out;
}

/* Transitions entre pages */
.page-transition {
    transition: opacity 0.3s ease-out;
}

.page-exiting {
    opacity: 0;
}

/* ============================================
   DRAG & DROP
   ============================================ */

.draggable {
    cursor: grab;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.draggable:active {
    cursor: grabbing;
}

.draggable.dragging {
    opacity: 0.5;
    transform: scale(0.95);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}

.dropzone {
    min-height: 100px;
    transition: background-color 0.2s ease;
}

.dropzone.drag-over {
    background-color: rgba(212, 197, 185, 0.1);
    border: 2px dashed var(--primary);
}

/* ============================================
   RECHERCHE EN TEMPS RÉEL
   ============================================ */

.search-bar {
    position: relative;
}

.search-loading {
    position: absolute;
    right: 50px;
    top: 50%;
    transform: translateY(-50%);
    display: none;
}

.search-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    right: 0;
    background: white;
    border-radius: 0.5rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    max-height: 400px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
    animation: slideDown 0.3s ease-out;
}

/* Sur PC uniquement : le dropdown de recherche doit être au-dessus des catégories */
@media (min-width: 768px) {
    /* S'assurer que la barre de recherche elle-même a un z-index élevé et crée son propre contexte */
    .header .search-bar {
        position: relative !important;
        z-index: 2000 !important; /* Très élevé pour passer au-dessus des catégories */
        isolation: isolate; /* Créer un nouveau contexte de stacking */
    }
    
    /* Le dropdown de recherche doit être au-dessus des catégories (z-index: 1002) */
    .header .search-dropdown {
        z-index: 2001 !important; /* Au-dessus des catégories dans le contexte du header */
        position: absolute !important;
    }
    
    /* S'assurer que les résultats de recherche sont cliquables et au-dessus de tout */
    .header .search-result-item {
        position: relative;
        z-index: 2002 !important;
        pointer-events: auto !important;
    }
    
    /* S'assurer que le lien dans le résultat de recherche est cliquable */
    .header .search-result-item a {
        position: relative;
        z-index: 2003 !important;
        pointer-events: auto !important;
    }
}

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

.search-result-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    text-decoration: none;
    color: var(--dark);
    border-bottom: 1px solid #f0f0f0;
    transition: background-color 0.2s ease;
}

.search-result-item:hover {
    background-color: #f9f9f9;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 0.25rem;
}

.search-result-name {
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.search-result-price {
    color: var(--primary);
    font-weight: 600;
}

.search-no-results {
    padding: 2rem;
    text-align: center;
    color: var(--gray-600);
}

/* ============================================
   PROGRESS BARS
   ============================================ */

.progress-bar {
    width: 100%;
    height: 8px;
    background-color: #f0f0f0;
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary) 0%, var(--accent) 100%);
    border-radius: 4px;
    transition: width 0.3s ease-out;
    position: relative;
    overflow: hidden;
}

.progress-bar-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.3),
        transparent
    );
    animation: progressShine 2s infinite;
}

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

/* ============================================
   ANIMATIONS DE SUCCÈS
   ============================================ */

.success-animation {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #28a745;
    color: white;
    font-size: 2rem;
    animation: successPop 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes successPop {
    0% {
        transform: scale(0);
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
    }
}

.success-checkmark {
    width: 30px;
    height: 30px;
    border: 3px solid white;
    border-top: none;
    border-right: none;
    transform: rotate(-45deg);
    margin-left: -5px;
    margin-top: -5px;
}

/* Confetti animation */
@keyframes confetti {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(-100vh) rotate(720deg);
        opacity: 0;
    }
}

.confetti-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 10000;
}

.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    background: var(--primary);
    animation: confetti 3s ease-out forwards;
}

/* ============================================
   ÉTATS VISUELS
   ============================================ */

/* États vides */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--gray-600);
}

.empty-state-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--dark);
}

.empty-state-message {
    margin-bottom: 1.5rem;
}

.empty-state-action {
    margin-top: 1.5rem;
}

/* États d'erreur améliorés */
.error-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--gray-600);
}

.error-state-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    color: #dc3545;
}

.error-state-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #dc3545;
}

.error-state-message {
    margin-bottom: 1.5rem;
}

.error-state-action {
    margin-top: 1.5rem;
}

/* Placeholders animés */
.placeholder-animated {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: placeholderShimmer 1.5s infinite;
    border-radius: 4px;
}

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

/* ============================================
   RESPECT DES PRÉFÉRENCES
   ============================================ */

@media (prefers-reduced-motion: reduce) {
    [data-animate],
    [data-stagger] > *,
    .draggable,
    .search-dropdown,
    .progress-bar-fill,
    .success-animation,
    .confetti,
    .placeholder-animated {
        animation: none !important;
        transition: none !important;
    }
    
    [data-animate] {
        opacity: 1 !important;
        transform: none !important;
    }
}


