/**
 * Estilos para el botón flotante de WhatsApp
 * 
 * @package MotaiListingPlugin
 */

/* Contenedor principal del botón de WhatsApp */
.motai-whatsapp-container {
    position: fixed;
    z-index: 1000000;
}

/* Botón flotante de WhatsApp */
.motai-whatsapp-float {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
    text-decoration: none;
    position: relative;
    transition: all 0.3s ease;
    background-color: #25d366 !important; /* Forzar el color verde de WhatsApp */
    border: none;
    cursor: pointer;
}

/* Efecto hover del botón */
.motai-whatsapp-float:hover {
    transform: translateY(-5px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.3);
    filter: brightness(1.05);
}

/* Badge de notificación */
.motai-whatsapp-notification-badge {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 12px;
    height: 12px;
    background-color: #ff3b30;
    border-radius: 50%;
    border: 2px solid #fff;
    animation: pulse-badge 2s infinite;
}

@keyframes pulse-badge {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.8;
    }
}

/* Icono SVG de WhatsApp */
.motai-whatsapp-icon {
    color: white;
    width: 30px;
    height: 30px;
    fill: currentColor;
}

/* Botón de WhatsApp en línea (para shortcodes) */
.motai-whatsapp-btn {
    display: inline-block;
    background: #25d366;
    color: #fff;
    padding: 12px 24px;
    border-radius: 5px;
    text-decoration: none;
    font-weight: bold;
    margin-top: 15px;
    transition: all 0.3s ease;
}

.motai-whatsapp-btn:hover {
    filter: brightness(0.95);
    color: #fff;
    text-decoration: none;
}

/* Tooltip del botón flotante */
.motai-whatsapp-tooltip {
    position: absolute;
    top: -40px;
    left: 50%;
    transform: translateX(-50%);
    background: #25d366;
    color: #fff;
    border-radius: 20px;
    padding: 5px 12px;
    font-size: 14px;
    font-weight: bold;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

/* Flecha del tooltip */
.motai-whatsapp-tooltip:after {
    content: "";
    position: absolute;
    bottom: -5px;
    left: 50%;
    margin-left: -5px;
    border-width: 5px 5px 0;
    border-style: solid;
    border-color: #25d366 transparent transparent;
}

/* Mostrar tooltip en hover */
.motai-whatsapp-float:hover .motai-whatsapp-tooltip {
    opacity: 1;
    visibility: visible;
    top: -45px;
}

/* Animación de pulso */
@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(37, 211, 102, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(37, 211, 102, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(37, 211, 102, 0);
    }
}

.motai-whatsapp-float.pulse {
    animation: pulse 2s infinite;
}

/* Animación de rebote */
@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-10px);
    }
    60% {
        transform: translateY(-5px);
    }
}

.motai-whatsapp-float.bounce {
    animation: bounce 2s infinite;
}

/* Optimización para dispositivos móviles */
@media only screen and (max-width: 768px) {
    .motai-whatsapp-float {
        width: 55px;
        height: 55px;
    }
    
    .motai-whatsapp-icon {
        width: 28px;
        height: 28px;
    }
    
    .motai-whatsapp-container {
        bottom: 90px !important;
        right: 15px !important;
        left: auto !important;
        transform: none !important;
    }
    
    .motai-whatsapp-tooltip {
        font-size: 12px;
        padding: 4px 10px;
    }
}

/* Optimización para dispositivos muy pequeños */
@media only screen and (max-width: 480px) {
    .motai-whatsapp-float {
        width: 50px;
        height: 50px;
    }
    
    .motai-whatsapp-icon {
        width: 26px;
        height: 26px;
    }
    
    .motai-whatsapp-container {
        bottom: 80px !important;
        right: 10px !important;
    }
}

/* Estilos para accesibilidad */
.motai-whatsapp-float:focus {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

/* Reducir animaciones para usuarios que prefieren menos movimiento */
@media (prefers-reduced-motion: reduce) {
    .motai-whatsapp-float {
        transition: none;
    }
    
    .motai-whatsapp-float.pulse,
    .motai-whatsapp-float.bounce {
        animation: none;
    }
    
    .motai-whatsapp-tooltip {
        transition: none;
    }
}

/* Estilos para modo oscuro (si el sitio lo soporta) */
@media (prefers-color-scheme: dark) {
    .motai-whatsapp-tooltip {
        background: #25d366;
        color: #fff;
    }
    
    .motai-whatsapp-tooltip:after {
        border-color: #25d366 transparent transparent;
    }
}

/* ========================================
   WIDGET DE CHAT EXPANDIDO
   ======================================== */

/* Widget principal */
.motai-whatsapp-chat-widget {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 350px;
    max-width: calc(100vw - 30px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.18);
    overflow: hidden;
    opacity: 0;
    transform: scale(0.8) translateY(20px);
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    pointer-events: none;
}

.motai-whatsapp-chat-widget.active {
    opacity: 1;
    transform: scale(1) translateY(0);
    pointer-events: all;
    display: block !important;
}

/* Header del chat */
.motai-whatsapp-chat-header {
    background: linear-gradient(135deg, #00A884 0%, #008069 100%);
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #fff;
    position: relative;
}

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

.motai-whatsapp-chat-avatar {
    position: relative;
    width: 50px;
    height: 50px;
    flex-shrink: 0;
}

.motai-whatsapp-chat-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.motai-whatsapp-default-avatar {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.motai-whatsapp-default-avatar svg {
    width: 30px;
    height: 30px;
    fill: #fff;
}

.motai-whatsapp-online-badge {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 14px;
    height: 14px;
    background: #25d366;
    border: 2px solid #fff;
    border-radius: 50%;
}

.motai-whatsapp-chat-info {
    flex: 1;
}

.motai-whatsapp-chat-info h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #fff;
    line-height: 1.3;
}

.motai-whatsapp-chat-info p {
    margin: 2px 0 0;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.85);
    line-height: 1.4;
}

.motai-whatsapp-chat-close {
    background: transparent;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
    margin-left: 8px;
}

.motai-whatsapp-chat-close:hover {
    background: rgba(255, 255, 255, 0.15);
}

.motai-whatsapp-chat-close svg {
    width: 20px;
    height: 20px;
    fill: #fff;
}

/* Body del chat */
.motai-whatsapp-chat-body {
    background: #ECE5DD url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzYwIiBoZWlnaHQ9IjM2MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZGVmcz48cGF0dGVybiBpZD0icGF0dGVybiIgcGF0dGVyblVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgd2lkdGg9IjM2MCIgaGVpZ2h0PSIzNjAiPjxwYXRoIGQ9Ik0yMCAyMGgxIHYxIGgtMXoiIGZpbGw9IiNEMEM5QzQiLz48L3BhdHRlcm4+PC9kZWZzPjxyZWN0IHdpZHRoPSIxMDAlIiBoZWlnaHQ9IjEwMCUiIGZpbGw9InVybCgjcGF0dGVybikiLz48L3N2Zz4=');
    padding: 20px;
    min-height: 200px;
    max-height: 300px;
    overflow-y: auto;
}

.motai-whatsapp-chat-messages {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.motai-whatsapp-message-time {
    text-align: center;
    color: #667781;
    font-size: 12px;
    margin-bottom: 8px;
    font-weight: 500;
}

.motai-whatsapp-message {
    background: #fff;
    padding: 10px 14px;
    border-radius: 8px;
    max-width: 85%;
    align-self: flex-start;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    position: relative;
    animation: slideIn 0.3s ease forwards;
    opacity: 0;
}

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

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

.motai-whatsapp-message p {
    margin: 0;
    color: #111b21;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

/* Footer del chat */
.motai-whatsapp-chat-footer {
    padding: 16px;
    background: #fff;
    border-top: 1px solid #e9edef;
}

.motai-whatsapp-start-chat-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px 20px;
    background: #25d366;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(37, 211, 102, 0.3);
}

.motai-whatsapp-start-chat-btn:hover {
    background: #20bd5f;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.4);
    color: #fff;
    text-decoration: none;
}

.motai-whatsapp-start-chat-btn:active {
    transform: translateY(0);
}

.motai-whatsapp-btn-icon {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

/* Ocultar el widget cuando está en modo simple */
.motai-whatsapp-container[data-widget-style="simple"] .motai-whatsapp-chat-widget {
    display: none !important;
}

/* Responsive para el widget */
@media only screen and (max-width: 768px) {
    .motai-whatsapp-chat-widget {
        width: calc(100vw - 30px);
        bottom: 70px;
        right: 15px;
    }
    
    .motai-whatsapp-chat-header {
        padding: 16px;
    }
    
    .motai-whatsapp-chat-avatar {
        width: 45px;
        height: 45px;
    }
    
    .motai-whatsapp-chat-info h3 {
        font-size: 15px;
    }
    
    .motai-whatsapp-chat-info p {
        font-size: 12px;
    }
    
    .motai-whatsapp-chat-body {
        padding: 16px;
        min-height: 180px;
        max-height: 250px;
    }
    
    .motai-whatsapp-chat-footer {
        padding: 12px;
    }
}

@media only screen and (max-width: 480px) {
    .motai-whatsapp-chat-widget {
        bottom: 60px;
        right: 10px;
    }
}
