/**
 * WhatsApp Chat - Frontend CSS
 */

/* Variables */
.whatsapp-widget {
    --whatsapp-bottom: 20px;
    --whatsapp-side: 20px;
    --whatsapp-color: #25D366;
}

/* Widget Container */
.whatsapp-widget {
    position: fixed;
    bottom: var(--whatsapp-bottom);
    z-index: 99999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

.whatsapp-widget.whatsapp-right {
    right: var(--whatsapp-side);
}

.whatsapp-widget.whatsapp-left {
    left: var(--whatsapp-side);
}

/* WhatsApp Button */
.whatsapp-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: var(--whatsapp-color);
    color: white;
    border: none;
    border-radius: 50px;
    padding: 14px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(37, 211, 102, 0.4);
    transition: all 0.3s ease;
    position: relative;
}

.whatsapp-button:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(37, 211, 102, 0.5);
}

.whatsapp-button:active {
    transform: scale(0.98);
}

.whatsapp-button-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

.whatsapp-button-icon svg {
    display: block;
}

.whatsapp-button-text {
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    padding-right: 4px;
}

/* Offline Badge */
.whatsapp-offline-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 14px;
    height: 14px;
    background: #ff6b6b;
    border-radius: 50%;
    border: 2px solid white;
}

/* Tooltip */
.whatsapp-tooltip {
    position: absolute;
    bottom: 100%;
    margin-bottom: 10px;
    background: #333;
    color: white;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 13px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    pointer-events: none;
}

.whatsapp-right .whatsapp-tooltip {
    right: 0;
}

.whatsapp-left .whatsapp-tooltip {
    left: 0;
}

.whatsapp-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    border: 6px solid transparent;
    border-top-color: #333;
}

.whatsapp-right .whatsapp-tooltip::after {
    right: 20px;
}

.whatsapp-left .whatsapp-tooltip::after {
    left: 20px;
}

.whatsapp-widget:hover .whatsapp-tooltip {
    opacity: 1;
    visibility: visible;
}

/* Popup */
.whatsapp-popup {
    position: absolute;
    bottom: 70px;
    width: 320px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 5px 30px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s ease;
}

.whatsapp-right .whatsapp-popup {
    right: 0;
}

.whatsapp-left .whatsapp-popup {
    left: 0;
}

.whatsapp-popup.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* Popup Header */
.whatsapp-popup-header {
    background: linear-gradient(135deg, #075E54 0%, #128C7E 100%);
    padding: 16px;
    color: white;
    position: relative;
}

.whatsapp-popup-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 0.2s;
    border-radius: 50%;
}

.whatsapp-popup-close:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.1);
}

.whatsapp-popup-agent {
    display: flex;
    align-items: center;
    gap: 12px;
}

.whatsapp-popup-avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    overflow: hidden;
    background: #DFE5E7;
}

.whatsapp-popup-avatar img,
.whatsapp-popup-avatar svg {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.whatsapp-popup-name {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 2px;
}

.whatsapp-popup-status {
    font-size: 12px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 6px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.status-dot.online {
    background: #4ADE80;
    box-shadow: 0 0 0 2px rgba(74, 222, 128, 0.3);
}

.status-dot.offline {
    background: #9CA3AF;
}

/* Popup Body */
.whatsapp-popup-body {
    background: #E5DDD5;
    background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23D4CDC4' fill-opacity='0.4'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    padding: 16px;
    min-height: 80px;
}

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

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

.message-content {
    font-size: 14px;
    line-height: 1.5;
    color: #333;
    word-wrap: break-word;
}

.message-time {
    font-size: 11px;
    color: #999;
    text-align: right;
    margin-top: 4px;
}

/* Popup Footer */
.whatsapp-popup-footer {
    padding: 12px 16px;
    background: #F5F5F5;
}

.whatsapp-start-chat {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--whatsapp-color);
    color: white;
    text-decoration: none;
    padding: 12px 20px;
    border-radius: 24px;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s ease;
}

.whatsapp-start-chat:hover {
    background: #20BD5A;
    color: white;
    text-decoration: none;
    transform: translateY(-1px);
}

.whatsapp-start-chat svg {
    display: none;
}

/* Pulse Animation */
.whatsapp-button.pulse::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: var(--whatsapp-color);
    animation: whatsapp-pulse 2s infinite;
    z-index: -1;
}

@keyframes whatsapp-pulse {
    0% {
        transform: scale(1);
        opacity: 0.5;
    }
    100% {
        transform: scale(1.5);
        opacity: 0;
    }
}

/* Mobile Styles */
@media (max-width: 480px) {
    .whatsapp-popup {
        width: calc(100vw - 40px);
        max-width: 320px;
    }

    .whatsapp-widget.whatsapp-right .whatsapp-popup {
        right: 0;
    }

    .whatsapp-widget.whatsapp-left .whatsapp-popup {
        left: 0;
    }

    .whatsapp-button-text {
        display: none;
    }
}

/* Desktop only */
.whatsapp-widget.hide-desktop {
    display: none !important;
}

/* Mobile only */
@media (max-width: 768px) {
    .whatsapp-widget.hide-mobile {
        display: none !important;
    }
}

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

/* Animation on load */
.whatsapp-widget {
    animation: whatsapp-slide-in 0.5s ease forwards;
}

.whatsapp-widget.whatsapp-right {
    animation-name: whatsapp-slide-in-right;
}

.whatsapp-widget.whatsapp-left {
    animation-name: whatsapp-slide-in-left;
}

@keyframes whatsapp-slide-in-right {
    from {
        opacity: 0;
        transform: translateX(50px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes whatsapp-slide-in-left {
    from {
        opacity: 0;
        transform: translateX(-50px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Attention Seeker Animation */
.whatsapp-button.attention {
    animation: whatsapp-attention 1s ease;
}

@keyframes whatsapp-attention {
    0%, 100% {
        transform: scale(1);
    }
    25% {
        transform: scale(1.15);
    }
    50% {
        transform: scale(1);
    }
    75% {
        transform: scale(1.1);
    }
}
