/* ========================================
   WHATSAPP WIDGET
   ======================================== */

/* S'assurer que html et body n'interfèrent pas avec position fixed */
html, body {
    perspective: none !important;
    -webkit-perspective: none !important;
    backface-visibility: visible !important;
    -webkit-backface-visibility: visible !important;
    transform: none !important;
    will-change: auto !important;
}

/* ========================================
   BOUTON WHATSAPP
   ======================================== */

.whatsapp-btn {
    position: fixed !important;
    bottom: 24px !important;
    right: 24px !important;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #25D366 0%, #128C7E 100%);
    border: none;
    border-radius: 50%;
    display: flex !important;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-xl);
    cursor: pointer;
    transition: all var(--transition-base);
    z-index: 9999 !important;
    visibility: visible !important;
    opacity: 1 !important;
    /* Annuler les propriétés qui créent un contexte de positionnement */
    perspective: none !important;
    -webkit-perspective: none !important;
    backface-visibility: visible !important;
    -webkit-backface-visibility: visible !important;
    will-change: auto !important;
}

.whatsapp-btn:hover {
    transform: translateY(-4px) scale(1.05);
    box-shadow: 0 12px 28px rgba(37, 211, 102, 0.4);
}

.whatsapp-btn:active {
    transform: translateY(-2px) scale(1.02);
}

.whatsapp-icon {
    color: white;
    width: 32px;
    height: 32px;
}

/* Badge de notification */
.whatsapp-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background-color: #FF3B30;
    color: white;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: var(--font-weight-bold);
    border: 2px solid white;
    animation: pulse 2s ease-in-out infinite;
}

/* ========================================
   BOUTON SCROLL TO TOP
   ======================================== */

.scroll-top-btn {
    position: fixed !important;
    bottom: 100px !important;
    right: 24px !important;
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-light) 100%);
    border: none;
    border-radius: 50%;
    display: flex !important;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    color: white;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: all var(--transition-base);
    z-index: 9998 !important;
    /* Annuler les propriétés qui créent un contexte de positionnement */
    perspective: none !important;
    -webkit-perspective: none !important;
    backface-visibility: visible !important;
    -webkit-backface-visibility: visible !important;
    will-change: auto !important;
}

.scroll-top-btn.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.scroll-top-btn:hover {
    transform: translateY(-4px) scale(1.05);
    box-shadow: var(--shadow-xl);
}

.scroll-top-btn:active {
    transform: translateY(-2px) scale(1.02);
}

/* ========================================
   POPUP WHATSAPP
   ======================================== */

.whatsapp-popup {
    position: fixed !important;
    bottom: 96px !important;
    right: 24px !important;
    width: 360px;
    max-height: 500px;
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 9999 !important;
    /* Annuler les propriétés qui créent un contexte de positionnement */
    perspective: none !important;
    -webkit-perspective: none !important;
    backface-visibility: visible !important;
    -webkit-backface-visibility: visible !important;
}

.whatsapp-popup[data-state="open"] {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* Header du popup */
.whatsapp-popup-header {
    background: linear-gradient(135deg, #25D366 0%, #128C7E 100%);
    color: white;
    padding: var(--spacing-3);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.popup-header-content {
    display: flex;
    align-items: center;
    gap: var(--spacing-2);
}

.popup-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: white;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.popup-avatar img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.popup-header-text {
    display: flex;
    flex-direction: column;
}

.popup-header-text h3 {
    font-size: 1rem;
    font-weight: var(--font-weight-semibold);
    margin: 0;
    line-height: 1.2;
}

.popup-status {
    font-size: 0.8125rem;
    opacity: 0.9;
    line-height: 1.2;
}

.popup-close-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.popup-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

/* Corps du popup */
.whatsapp-popup-body {
    padding: var(--spacing-3);
    background: #E5DDD5;
    min-height: 180px;
    background-image: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 10px,
        rgba(0, 0, 0, 0.02) 10px,
        rgba(0, 0, 0, 0.02) 20px
    );
}

.popup-message-bubble {
    background: white;
    border-radius: var(--radius-md);
    padding: var(--spacing-2) var(--spacing-3);
    position: relative;
    max-width: 85%;
    box-shadow: var(--shadow-sm);
    animation: slideInMessage 0.4s ease-out 0.3s both;
}

.popup-message-bubble::before {
    content: '';
    position: absolute;
    top: 0;
    left: -8px;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 0 8px 8px 0;
    border-color: transparent white transparent transparent;
}

.popup-greeting {
    font-weight: var(--font-weight-semibold);
    color: var(--color-black);
    margin-bottom: 4px;
    font-size: 0.9375rem;
}

.popup-text {
    color: var(--color-dark-gray);
    line-height: 1.5;
    margin: 0 0 8px 0;
    font-size: 0.9375rem;
}

.popup-time {
    display: block;
    font-size: 0.6875rem;
    color: var(--color-medium-gray);
    text-align: right;
    margin-top: 4px;
}

/* Footer du popup */
.whatsapp-popup-footer {
    padding: var(--spacing-2);
    background: white;
    border-top: 1px solid var(--color-gray);
}

.whatsapp-form {
    width: 100%;
}

.form-input-wrapper {
    display: flex;
    align-items: center;
    gap: var(--spacing-1);
}

.whatsapp-input {
    flex: 1;
    padding: 0.75rem var(--spacing-3);
    border: 1px solid var(--color-gray);
    border-radius: 24px;
    font-family: var(--font-primary);
    font-size: 0.9375rem;
    transition: all var(--transition-fast);
    outline: none;
}

.whatsapp-input:focus {
    border-color: #25D366;
    box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.1);
}

.whatsapp-input::placeholder {
    color: var(--color-medium-gray);
}

.whatsapp-send-btn {
    width: 44px;
    height: 44px;
    background: #25D366;
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-base);
    flex-shrink: 0;
}

.whatsapp-send-btn:hover {
    background: #128C7E;
    transform: rotate(15deg) scale(1.05);
}

.whatsapp-send-btn:active {
    transform: rotate(15deg) scale(0.95);
}

.whatsapp-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ========================================
   ANIMATIONS
   ======================================== */

/* Animation du badge */
@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

/* Animation de la bulle de message */
@keyframes slideInMessage {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Animation du bouton WhatsApp au clic */
.whatsapp-btn.pulse {
    animation: buttonPulse 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes buttonPulse {
    0% {
        transform: scale(1) rotate(0deg);
    }
    50% {
        transform: scale(1.1) rotate(180deg);
    }
    100% {
        transform: scale(1) rotate(360deg);
    }
}

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */

@media (max-width: 768px) {
    .whatsapp-popup {
        width: calc(100vw - 32px);
        right: 16px;
        bottom: 88px;
    }

    .whatsapp-btn {
        width: 56px;
        height: 56px;
        bottom: 20px;
        right: 20px;
    }

    .whatsapp-icon {
        width: 28px;
        height: 28px;
    }

    .scroll-top-btn {
        width: 44px;
        height: 44px;
        bottom: 88px;
        right: 20px;
    }
}

@media (max-width: 480px) {
    .whatsapp-popup {
        width: calc(100vw - 24px);
        right: 12px;
        bottom: 84px;
        max-height: 440px;
    }

    .whatsapp-btn {
        width: 52px;
        height: 52px;
        bottom: 16px;
        right: 16px;
    }

    .whatsapp-icon {
        width: 26px;
        height: 26px;
    }

    .scroll-top-btn {
        width: 42px;
        height: 42px;
        bottom: 80px;
        right: 16px;
    }

    .whatsapp-popup-body {
        min-height: 150px;
    }
}

/* ========================================
   ACCESSIBILITÉ
   ======================================== */

/* Respect des préférences de mouvement réduit */
@media (prefers-reduced-motion: reduce) {
    .whatsapp-btn,
    .whatsapp-popup,
    .scroll-top-btn,
    .whatsapp-badge,
    .popup-message-bubble {
        transition: none;
        animation: none;
    }

    .whatsapp-btn.pulse {
        animation: none;
    }
}

/* Focus visible pour la navigation au clavier */
.whatsapp-btn:focus-visible,
.scroll-top-btn:focus-visible,
.popup-close-btn:focus-visible,
.whatsapp-send-btn:focus-visible {
    outline: 3px solid #25D366;
    outline-offset: 2px;
}

.whatsapp-input:focus-visible {
    outline: 2px solid #25D366;
    outline-offset: 2px;
}
