/**
 * WhatsApp Widget Styles
 * Transforma de círculo flotante a popup de chat
 */

/* Widget Container */
.whatsapp-widget {
    position: fixed;
    bottom: 25px;
    right: 25px;
    z-index: 9999;
    font-family: 'Open Sans', sans-serif;
}

/* Botón Flotante */
.whatsapp-float-btn {
    width: 60px;
    height: 60px;
    background: #25D366;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 30px;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(37, 211, 102, 0.5);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    animation: pulse-whatsapp 2s infinite;
}

.whatsapp-float-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 30px rgba(37, 211, 102, 0.7);
}

.whatsapp-float-btn.hidden {
    transform: scale(0);
    opacity: 0;
    pointer-events: none;
}

/* Badge de notificación */
.whatsapp-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #FF3B30;
    color: white;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    border: 2px solid white;
    animation: bounce-badge 1s ease-in-out infinite;
}

/* Animación del botón */
@keyframes pulse-whatsapp {
    0%, 100% {
        box-shadow: 0 4px 20px rgba(37, 211, 102, 0.5);
    }
    50% {
        box-shadow: 0 4px 20px rgba(37, 211, 102, 0.5), 0 0 0 15px rgba(37, 211, 102, 0.1);
    }
}

@keyframes bounce-badge {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.2);
    }
}

/* Popup de Chat */
.whatsapp-popup {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 360px;
    max-width: calc(100vw - 40px);
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    transform: scale(0) translateY(20px);
    transform-origin: bottom right;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}

.whatsapp-popup.active {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: auto;
}

/* Header */
.whatsapp-header {
    background: linear-gradient(135deg, #25D366 0%, #128C7E 100%);
    color: white;
    padding: 15px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.whatsapp-header-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.whatsapp-avatar {
    position: relative;
    width: 45px;
    height: 45px;
}

.whatsapp-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2px solid white;
    object-fit: cover;
}

.whatsapp-status {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    background: #4ADE80;
    border: 2px solid white;
    border-radius: 50%;
}

.whatsapp-info h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.whatsapp-info p {
    margin: 0;
    font-size: 13px;
    opacity: 0.9;
}

.whatsapp-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 16px;
}

.whatsapp-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

/* Body */
.whatsapp-body {
    background: #ECE5DD url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAKklEQVQoU2NkYGD4z4AHMDIMVDUJHFH4PwMDw38GBob/DAwM/4cqHAZDFQBqpQYLsB8XPgAAAABJRU5ErkJggg==') repeat;
    padding: 20px;
    min-height: 200px;
    max-height: 300px;
    overflow-y: auto;
}

/* Mensaje Recibido */
.whatsapp-message-received {
    display: flex;
    justify-content: flex-start;
    margin-bottom: 10px;
}

.whatsapp-message-bubble {
    background: white;
    padding: 10px 14px;
    border-radius: 8px;
    max-width: 80%;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    position: relative;
}

.whatsapp-message-bubble::before {
    content: '';
    position: absolute;
    left: -8px;
    top: 0;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 0 8px 8px 0;
    border-color: transparent white transparent transparent;
}

.whatsapp-message-bubble p {
    margin: 0 0 5px 0;
    font-size: 14px;
    line-height: 1.5;
    color: #333;
}

.whatsapp-message-bubble p:last-of-type {
    margin-bottom: 0;
}

.whatsapp-time {
    display: block;
    font-size: 11px;
    color: #999;
    text-align: right;
    margin-top: 5px;
}

/* Footer */
.whatsapp-footer {
    background: #F0F0F0;
    padding: 10px;
    display: flex;
    align-items: flex-end;
    gap: 10px;
    border-top: 1px solid #DDD;
}

#whatsappMessage {
    flex: 1;
    background: white;
    border: 1px solid #DDD;
    border-radius: 20px;
    padding: 10px 15px;
    font-family: 'Open Sans', sans-serif;
    font-size: 14px;
    resize: none;
    max-height: 100px;
    overflow-y: auto;
    outline: none;
    transition: border-color 0.3s ease;
}

#whatsappMessage:focus {
    border-color: #25D366;
}

#whatsappMessage::placeholder {
    color: #999;
}

.whatsapp-send-btn {
    background: #25D366;
    border: none;
    color: white;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    flex-shrink: 0;
    font-size: 16px;
}

.whatsapp-send-btn:hover {
    background: #128C7E;
    transform: scale(1.05);
}

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

/* Scrollbar personalizado */
.whatsapp-body::-webkit-scrollbar {
    width: 6px;
}

.whatsapp-body::-webkit-scrollbar-track {
    background: transparent;
}

.whatsapp-body::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

.whatsapp-body::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

#whatsappMessage::-webkit-scrollbar {
    width: 4px;
}

#whatsappMessage::-webkit-scrollbar-track {
    background: transparent;
}

#whatsappMessage::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 2px;
}

/* Responsive */
@media (max-width: 480px) {
    .whatsapp-widget {
        bottom: 15px;
        right: 15px;
    }
    
    .whatsapp-float-btn {
        width: 55px;
        height: 55px;
        font-size: 26px;
    }
    
    .whatsapp-popup {
        width: calc(100vw - 30px);
        max-width: 360px;
    }
    
    .whatsapp-body {
        max-height: 250px;
    }
}

/* Animación de entrada de mensaje */
@keyframes slideInUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.whatsapp-message-received {
    animation: slideInUp 0.3s ease-out;
}
