/* 
 * Imagilire Libre - Floating Action Button (FAB)
 * Bouton d'action flottant pour la transformation en syllabes
 * Compatible Android et iOS
 */

:root {
    /* Variables spécifiques au FAB */
    --fab-size: 56px;
    --fab-size-small: 48px;
    --fab-position-bottom: 80px;
    --fab-position-right: 20px;
    --fab-z-index: 900;
    --fab-animation-duration: 0.3s;
    --fab-pulse-duration: 2s;
}

/* Conteneur du FAB */
.fab-container {
    position: fixed;
    bottom: var(--fab-position-bottom);
    right: var(--fab-position-right);
    z-index: var(--fab-z-index);
    
    /* Transition pour l'apparition/disparition */
    opacity: 0;
    transform: scale(0) translateY(20px);
    transition: opacity var(--fab-animation-duration) ease,
                transform var(--fab-animation-duration) cubic-bezier(0.175, 0.885, 0.32, 1.275);
    
    /* Empêcher les interactions quand invisible */
    pointer-events: none;
    
    /* Propriétés spécifiques pour iOS/Android */
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

/* État visible */
.fab-container.visible {
    opacity: 1;
    transform: scale(1) translateY(0);
    pointer-events: auto;
}

/* État caché (transition de sortie) */
.fab-container.hidden {
    opacity: 0;
    transform: scale(0.8) translateY(10px);
    pointer-events: none;
}

/* Bouton FAB principal */
.fab-button {
    width: var(--fab-size);
    height: var(--fab-size);
    border-radius: 50%;
    background: linear-gradient(135deg, var(--secondary-color) 0%, #F9C851 100%);
    color: var(--text-color);
    border: none;
    box-shadow: 0 4px 12px rgba(247, 183, 49, 0.4),
                0 2px 4px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: visible;
    
    /* Optimisations pour mobile */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    will-change: transform, box-shadow;
    
    /* Suppression des effets par défaut sur mobile */
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    touch-action: manipulation;
}

/* Icône du FAB */
.fab-button i {
    font-size: 24px;
    transition: transform 0.3s ease;
}

/* Effet au survol (desktop uniquement) */
@media (hover: hover) and (pointer: fine) {
    .fab-button:hover {
        transform: scale(1.05);
        box-shadow: 0 6px 16px rgba(247, 183, 49, 0.5),
                    0 3px 6px rgba(0, 0, 0, 0.15);
    }
    
    .fab-button:hover i {
        transform: rotate(15deg);
    }
}

/* Effet au clic/touch - Compatible tous appareils */
.fab-button:active {
    transform: scale(0.95);
    box-shadow: 0 2px 8px rgba(247, 183, 49, 0.3),
                0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Focus pour l'accessibilité */
.fab-button:focus {
    outline: none;
}

.fab-button:focus-visible {
    outline: 3px solid rgba(247, 183, 49, 0.5);
    outline-offset: 3px;
}

/* Animation de pulsation pour attirer l'attention */
@keyframes fab-pulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 4px 12px rgba(247, 183, 49, 0.4),
                    0 2px 4px rgba(0, 0, 0, 0.1);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 6px 16px rgba(247, 183, 49, 0.6),
                    0 3px 6px rgba(0, 0, 0, 0.15);
    }
}

/* Appliquer l'animation de pulsation */
.fab-button.pulse {
    animation: fab-pulse var(--fab-pulse-duration) ease-in-out infinite;
}

/* Badge de notification (optionnel pour futures fonctionnalités) */
.fab-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background-color: var(--error-color);
    color: white;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: bold;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    opacity: 0;
    transform: scale(0);
    transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.fab-badge.visible {
    opacity: 1;
    transform: scale(1);
}

/* Label du FAB (texte optionnel) */
.fab-label {
    position: absolute;
    right: calc(100% + 12px);
    background-color: rgba(0, 0, 0, 0.85);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    opacity: 0;
    transform: translateX(10px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
    
    /* Flèche pointant vers le FAB */
    &::after {
        content: '';
        position: absolute;
        right: -6px;
        top: 50%;
        transform: translateY(-50%);
        border: 6px solid transparent;
        border-left-color: rgba(0, 0, 0, 0.85);
    }
}

/* Affichage du label au survol (desktop uniquement) */
@media (hover: hover) and (pointer: fine) {
    .fab-container:hover .fab-label {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Adaptation pour petits écrans */
@media (max-width: 480px) {
    :root {
        --fab-size: var(--fab-size-small);
        --fab-position-bottom: 70px;
        --fab-position-right: 16px;
    }
    
    .fab-button i {
        font-size: 22px;
    }
    
    .fab-label {
        font-size: 13px;
        padding: 6px 10px;
    }
}

/* Adaptation pour iOS Safari */
@supports (-webkit-touch-callout: none) {
    .fab-container {
        /* Ajustement pour la zone sûre iOS (notch, barre d'accueil) */
        bottom: calc(var(--fab-position-bottom) + env(safe-area-inset-bottom));
    }
}

/* Adaptation pour paysage sur mobile */
@media (max-width: 768px) and (orientation: landscape) {
    :root {
        --fab-position-bottom: 20px;
        --fab-position-right: 16px;
    }
}

/* État désactivé */
.fab-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* Animation d'entrée alternative (slide-in) */
@keyframes fab-slide-in {
    from {
        opacity: 0;
        transform: translateY(100px) scale(0.8);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Animation de sortie alternative (slide-out) */
@keyframes fab-slide-out {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateY(100px) scale(0.8);
    }
}

/* Variante avec animation slide (à activer si souhaité) */
.fab-container.slide-animation.visible {
    animation: fab-slide-in var(--fab-animation-duration) cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.fab-container.slide-animation.hidden {
    animation: fab-slide-out var(--fab-animation-duration) cubic-bezier(0.6, 0.04, 0.98, 0.335);
}

/* Mode sombre (si implémenté ultérieurement) */
@media (prefers-color-scheme: dark) {
    .fab-label {
        background-color: rgba(255, 255, 255, 0.9);
        color: #333;
    }
    
    .fab-label::after {
        border-left-color: rgba(255, 255, 255, 0.9);
    }
}

/* Amélioration de l'accessibilité */
.fab-button[aria-label] {
    /* S'assurer que les lecteurs d'écran peuvent accéder au bouton */
}

/* Effet de ripple au clic (Material Design) */
.fab-button::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.4);
    transform: translate(-50%, -50%);
    transition: width 0.6s ease, height 0.6s ease;
}

.fab-button:active::before {
    width: 120%;
    height: 120%;
}

/* Styles pour éviter les conflits avec d'autres éléments */
.fab-container * {
    box-sizing: border-box;
}

/* Position alternative : gauche (à activer si souhaité) */
.fab-container.position-left {
    right: auto;
    left: var(--fab-position-right);
}

.fab-container.position-left .fab-label {
    right: auto;
    left: calc(100% + 12px);
}

.fab-container.position-left .fab-label::after {
    right: auto;
    left: -6px;
    border-left-color: transparent;
    border-right-color: rgba(0, 0, 0, 0.85);
}

/* Animation de chargement (spinner) */
@keyframes fab-spinner {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

.fab-button.loading i {
    animation: fab-spinner 1s linear infinite;
}

/* Optimisations de performance */
.fab-container,
.fab-button,
.fab-label {
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    -webkit-perspective: 1000;
    perspective: 1000;
}
