/**
 * Native WhatsApp Widget Premium Styling
 * Focus on UX, Modern Design, and CRO
 */

/* Container & Base resets */
.pn-wa-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 999998; /* Ensures it stays on top of page content but below WordPress admin bar if logged in */
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    pointer-events: none; /* Allows clicks to pass through empty areas */
}

.pn-wa-container * {
    box-sizing: border-box;
    pointer-events: auto; /* Restores pointer events to widget elements */
}

/* Floating Bubble Button */
.pn-wa-bubble {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: #25D366;
    color: #FFFFFF;
    border: none;
    outline: none;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(37, 211, 102, 0.4), 0 2px 4px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: center;
    align-items: center;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), background-color 0.2s ease, box-shadow 0.3s ease;
    position: relative;
    padding: 0;
    margin: 0;
}

.pn-wa-bubble:hover {
    transform: scale(1.08) rotate(5deg);
    background-color: #20BA5A;
    box-shadow: 0 6px 20px rgba(37, 211, 102, 0.5), 0 3px 6px rgba(0, 0, 0, 0.15);
}

.pn-wa-bubble:active {
    transform: scale(0.95);
}

.pn-wa-bubble svg {
    display: block !important;
    width: 32px !important;
    height: 32px !important;
    fill: #FFFFFF !important;
}

.pn-wa-bubble svg path {
    fill: #FFFFFF !important;
}

/* Attention Pulse Ring */
.pn-wa-bubble::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2px solid #25D366;
    opacity: 0;
    animation: wa-pulse-ring 2.5s infinite ease-out;
    pointer-events: none;
}

@keyframes wa-pulse-ring {
    0% {
        transform: scale(0.95);
        opacity: 0.8;
    }
    50% {
        transform: scale(1.3);
        opacity: 0;
    }
    100% {
        transform: scale(1.3);
        opacity: 0;
    }
}

/* Notification Badge */
.pn-wa-badge {
    position: absolute;
    top: -3px;
    right: -3px;
    background-color: #FF3B30;
    color: #FFFFFF;
    font-size: 11px;
    font-weight: bold;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 2px solid #FFFFFF;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    z-index: 2;
    animation: wa-badge-bounce 0.5s ease-out forwards;
    transform-origin: center;
}

.pn-wa-badge-hidden {
    display: none;
    opacity: 0;
    transform: scale(0);
}

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

/* Chat Card (Popup Window) */
.pn-wa-card {
    width: 350px;
    max-width: 90vw;
    background-color: #FFFFFF;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15), 0 4px 12px rgba(0, 0, 0, 0.08);
    margin-bottom: 16px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.165, 0.84, 0.44, 1), visibility 0.3s;
    transform: translateY(15px);
    opacity: 0;
    visibility: hidden;
    z-index: 1;
}

.pn-wa-card.pn-wa-active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.pn-wa-hidden {
    opacity: 0;
    visibility: hidden;
    transform: translateY(15px);
}

/* Card Header */
.pn-wa-header {
    background-color: #128C7E;
    color: #FFFFFF;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
}

.pn-wa-profile-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.pn-wa-avatar-wrapper {
    position: relative;
    display: flex;
}

.pn-wa-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    overflow: visible;
    display: block;
}

.pn-wa-avatar svg {
    width: 100%;
    height: 100%;
}

.pn-wa-status-dot {
    width: 11px;
    height: 11px;
    background-color: #4AD954;
    border-radius: 50%;
    border: 2px solid #128C7E;
    position: absolute;
    bottom: 0;
    right: 0;
    display: block;
    animation: wa-status-pulse 2s infinite ease-in-out;
}

@keyframes wa-status-pulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.15); opacity: 0.8; }
    100% { transform: scale(1); opacity: 1; }
}

.pn-wa-info {
    display: flex;
    flex-direction: column;
}

.pn-wa-name {
    font-weight: 600;
    font-size: 15px;
    line-height: 1.2;
    display: block;
}

.pn-wa-status-text {
    font-size: 12px;
    opacity: 0.9;
    margin-top: 2px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.pn-wa-close-btn {
    background: none;
    border: none;
    color: #FFFFFF;
    opacity: 0.8;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s ease, opacity 0.2s ease;
}

.pn-wa-close-btn:hover {
    opacity: 1;
    background-color: rgba(255, 255, 255, 0.15);
}

/* Card Body (Chat Area) */
.pn-wa-body {
    background-color: #E5DDD5;
    /* Clean CSS Whatsapp tile-like background pattern using inline SVG */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='80' viewBox='0 0 80 80'%3E%3Cg fill='%23b4b4b4' fill-opacity='0.08'%3E%3Cpath d='M0 0h40v40H0V0zm40 40h40v40H40V40zm0-40h2v2h-2V0zm0 4h2v2h-2V4zm0 4h2v2h-2V8zm0 12h2v2h-2v-2zm0 12h2v2h-2v-2zm-4 4h2v2h-2v-2zm-4 0h2v2h-2v-2zm-12 0h2v2h-2v-2zm-12 0h2v2h-2v-2zM0 40h2v2H0v-2zm0 4h2v2H0v-2zm0 4h2v2H0v-2zm0 12h2v2H0v-2zm0 12h2v2H0v-2zm4-4h2v2H4v-2zm4 0h2v2H8v-2zm12 0h2v2h-2v-2zm12 0h2v2h-2v-2zm4-24h2v2h-2v-2zm0-4h2v2h-2V8zm0-4h2v2h-2V4zm0-4h2v2h-2V0zm4 4h2v2h-2V4zm4 0h2v2h-2V4zm12 0h2v2h-2V4zm12 0h2v2h-2V4z'/%3E%3C/g%3E%3C/svg%3E");
    padding: 20px;
    max-height: 250px;
    overflow-y: auto;
}

.pn-wa-chat-bubble {
    background-color: #FFFFFF;
    padding: 12px 14px;
    border-radius: 0 10px 10px 10px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
    position: relative;
    max-width: 90%;
    animation: wa-bubble-slide 0.3s ease-out forwards;
}

/* Chat bubble small speech tail */
.pn-wa-chat-bubble::before {
    content: '';
    position: absolute;
    top: 0;
    left: -8px;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 0 8px 10px 0;
    border-color: transparent #FFFFFF transparent transparent;
}

.pn-wa-chat-bubble p {
    margin: 0 0 6px 0;
    color: #262626;
    font-size: 13.5px;
    line-height: 1.45;
}

.pn-wa-chat-bubble p:last-of-type {
    margin-bottom: 0;
}

.pn-wa-chat-time {
    display: block;
    text-align: right;
    font-size: 10px;
    color: #8C8C8C;
    margin-top: 4px;
}

@keyframes wa-bubble-slide {
    0% { transform: translateY(10px); opacity: 0; }
    100% { transform: translateY(0); opacity: 1; }
}

/* Card Footer (CTA Action) */
.pn-wa-footer {
    background-color: #F0F0F0;
    padding: 14px 20px;
    display: flex;
    justify-content: center;
}

.pn-wa-btn-send {
    background-color: #25D366;
    color: #FFFFFF;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 11px 16px;
    border-radius: 24px;
    font-weight: 600;
    font-size: 14px;
    box-shadow: 0 3px 8px rgba(37, 211, 102, 0.25);
    transition: background-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
    border: none;
}

.pn-wa-btn-send:hover {
    background-color: #20BA5A;
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.35);
    transform: translateY(-1px);
    color: #FFFFFF !important;
}

.pn-wa-btn-send:active {
    transform: translateY(1px);
}

.pn-wa-btn-send svg {
    fill: currentColor;
    display: block;
}

/* Responsive adjustments */
@media (max-width: 480px) {
    .pn-wa-container {
        bottom: 16px;
        right: 16px;
    }
    
    .pn-wa-card {
        width: calc(100vw - 32px);
        right: 0;
    }
}
