/* =============================================
   HIVARENOV - STYLES GLOBAUX & ANIMATIONS
   ============================================= */

/* ----------------------------------------
   1. VARIABLES CSS PERSONNALISÉES
   ---------------------------------------- */
:root {
    --primary-50: #ecfdf5;
    --primary-100: #d1fae5;
    --primary-200: #a7f3d0;
    --primary-300: #6ee7b7;
    --primary-400: #34d399;
    --primary-500: #10b981;
    --primary-600: #059669;
    --primary-700: #047857;
    --primary-800: #065f46;
    --primary-900: #064e3b;
    
    --accent-500: #3b82f6;
    --accent-600: #2563eb;
}

/* ----------------------------------------
   2. ANIMATIONS AU SCROLL (AOS-like)
   ---------------------------------------- */
[data-aos] {
    opacity: 0;
    transition: opacity 0.6s ease, transform 0.6s ease;
    will-change: opacity, transform; /* Optimisation GPU */
}

[data-aos="fade-up"] { transform: translateY(30px); }
[data-aos="fade-down"] { transform: translateY(-30px); }
[data-aos="fade-left"] { transform: translateX(30px); }
[data-aos="fade-right"] { transform: translateX(-30px); }
[data-aos="zoom-in"] { transform: scale(0.9); }

[data-aos].aos-animate {
    opacity: 1;
    transform: translateY(0) translateX(0) scale(1);
}

/* Réduire les animations si l'utilisateur préfère moins de mouvement */
@media (prefers-reduced-motion: reduce) {
    [data-aos] {
        opacity: 1 !important;
        transform: none !important;
        transition: none !important;
    }
}

[data-aos-delay="100"] { transition-delay: 100ms; }
[data-aos-delay="200"] { transition-delay: 200ms; }
[data-aos-delay="300"] { transition-delay: 300ms; }
[data-aos-delay="400"] { transition-delay: 400ms; }
[data-aos-delay="500"] { transition-delay: 500ms; }

/* ----------------------------------------
   3. BOUTONS AVEC EFFETS
   ---------------------------------------- */
.btn-hover-lift {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s ease;
    will-change: transform; /* Optimisation GPU */
}

.btn-hover-lift:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

.btn-hover-lift:active {
    transform: translateY(-1px);
}

@media (prefers-reduced-motion: reduce) {
    .btn-hover-lift {
        transition: none;
    }
    .btn-hover-lift:hover {
        transform: none;
    }
}

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

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

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

/* ----------------------------------------
   4. CARTES AVEC EFFETS
   ---------------------------------------- */
.card-hover-grow {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.card-hover-grow:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.12);
}

.card-hover-glow:hover {
    box-shadow: 0 0 30px rgba(16, 185, 129, 0.2);
}

/* ----------------------------------------
   5. IMAGE COMPARISON SLIDER
   ---------------------------------------- */
.image-comparison {
    position: relative;
    overflow: hidden;
    cursor: ew-resize;
    user-select: none;
}

.image-comparison .img-before {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    overflow: hidden;
    z-index: 2;
}

.image-comparison .img-before img {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: auto;
    max-width: none;
}

.image-comparison .img-after {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.image-comparison .img-after img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.image-comparison .comparison-slider {
    position: absolute;
    top: 0;
    width: 4px;
    height: 100%;
    background: white;
    z-index: 10;
    cursor: ew-resize;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
}

/* ----------------------------------------
   6. FORMULAIRES STYLISÉS
   ---------------------------------------- */
.form-input-modern {
    transition: all 0.2s ease;
    border: 2px solid #e5e7eb;
}

.form-input-modern:focus {
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
    outline: none;
}

.form-input-modern:hover:not(:focus) {
    border-color: #d1d5db;
}

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

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

/* ----------------------------------------
   8. FAQ ACCORDION
   ---------------------------------------- */
.faq-item {
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    margin-bottom: 1rem;
    overflow: hidden;
    transition: all 0.3s ease;
}

.faq-item:hover {
    border-color: var(--primary-500);
}

.faq-question {
    padding: 1.25rem;
    background: #f9fafb;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    color: #1f2937;
    transition: all 0.3s ease;
}

.faq-question:hover {
    background: #f3f4f6;
}

.faq-question .icon {
    transition: transform 0.3s ease;
}

.faq-item.active .faq-question .icon {
    transform: rotate(180deg);
}

.faq-answer {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease, padding 0.3s ease;
    padding: 0 1.25rem;
}

.faq-item.active .faq-answer {
    max-height: 500px;
    padding: 0 1.25rem 1.25rem;
}

/* ----------------------------------------
   9. TOAST NOTIFICATIONS
   ---------------------------------------- */
.toast-container {
    position: fixed;
    top: 100px;
    right: 30px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    padding: 1rem 1.5rem;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 12px;
    transform: translateX(120%);
    transition: transform 0.4s ease;
    max-width: 350px;
}

.toast.show { transform: translateX(0); }
.toast.success { border-left: 4px solid var(--primary-500); }
.toast.error { border-left: 4px solid #ef4444; }
.toast.info { border-left: 4px solid var(--accent-500); }

/* ----------------------------------------
   10. LOADING SPINNER
   ---------------------------------------- */
.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e5e7eb;
    border-top-color: var(--primary-500);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* ----------------------------------------
   11. GRADIENT TEXT
   ---------------------------------------- */
.gradient-text {
    background: linear-gradient(135deg, var(--primary-500) 0%, var(--accent-500) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ----------------------------------------
   12. GLASS EFFECT
   ---------------------------------------- */
.glass {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* ----------------------------------------
   13. PULSE ANIMATION
   ---------------------------------------- */
.pulse {
    animation: pulse 2s infinite;
}

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

/* ----------------------------------------
   14. SHAKE ANIMATION
   ---------------------------------------- */
.shake {
    animation: shake 0.5s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-5px); }
    40%, 80% { transform: translateX(5px); }
}

/* ----------------------------------------
   15. LINE CLAMP UTILITIES
   ---------------------------------------- */
.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.line-clamp-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ----------------------------------------
   16. SMOOTH SCROLL
   ---------------------------------------- */
html {
    scroll-behavior: smooth;
}

/* ----------------------------------------
   17. SELECTION STYLE
   ---------------------------------------- */
::selection {
    background: var(--primary-200);
    color: var(--primary-900);
}

/* ----------------------------------------
   18. FOCUS VISIBLE
   ---------------------------------------- */
:focus-visible {
    outline: 2px solid var(--primary-500);
    outline-offset: 2px;
}

/* ----------------------------------------
   19. CUSTOM SCROLLBAR
   ---------------------------------------- */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}

/* ----------------------------------------
   20. RESPONSIVE HELPERS
   ---------------------------------------- */
@media (max-width: 768px) {
    .hide-mobile { display: none !important; }

    /* Ajustement des boutons flottants sur mobile - position en bas à GAUCHE */
    .whatsapp-float {
        bottom: 1rem !important;
        right: auto !important;
        left: 1rem !important;
        width: 3rem !important;
        height: 3rem !important;
        opacity: 0.9 !important;
    }

    #scrollToTop {
        bottom: 1rem !important;
        right: 1rem !important;
        left: auto !important;
        width: 2.75rem !important;
        height: 2.75rem !important;
    }

    .whatsapp-float svg {
        width: 1.5rem !important;
        height: 1.5rem !important;
    }

    #scrollToTop svg {
        width: 1.25rem !important;
        height: 1.25rem !important;
    }
}

@media (min-width: 769px) {
    .hide-desktop { display: none !important; }
}

/* ----------------------------------------
   21. FLOATING BUTTONS RESPONSIVE POSITIONING
   ---------------------------------------- */
.whatsapp-float {
    isolation: isolate;
    /* Le bouton n'interfère plus avec le scroll */
    pointer-events: auto;
}

/* Sur mobile, réduire encore plus l'opacité au défilement */
@media (max-width: 768px) {
    .whatsapp-float {
        transition: all 0.3s ease, opacity 0.3s ease;
    }

    /* Ajouter une classe pour cacher temporairement pendant le scroll */
    .whatsapp-float.scrolling {
        opacity: 0.4 !important;
        transform: scale(0.85);
    }
}

/* ----------------------------------------
   22. LAZY LOADING IMAGES
   ---------------------------------------- */
img[loading="lazy"] {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
}

img[loading="lazy"].loaded {
    animation: none;
    background: transparent;
}

/* Image fade-in effect */
img {
    opacity: 0;
    transition: opacity 0.3s ease-in;
}

img.loaded,
img[src] {
    opacity: 1;
}

/* ----------------------------------------
   23. ASPECT RATIO CONTAINERS
   ---------------------------------------- */
.aspect-ratio-16-9 {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%; /* 16:9 */
    overflow: hidden;
}

.aspect-ratio-4-3 {
    position: relative;
    width: 100%;
    padding-bottom: 75%; /* 4:3 */
    overflow: hidden;
}

.aspect-ratio-1-1 {
    position: relative;
    width: 100%;
    padding-bottom: 100%; /* 1:1 */
    overflow: hidden;
}

.aspect-ratio-16-9 > *,
.aspect-ratio-4-3 > *,
.aspect-ratio-1-1 > * {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}
