/* ============================================
   WHATSAPP CHAT WIDGET - STILE UFFICIALE
   File: whatsapp-widget.css
   ============================================ */

/* Reset base */
.whatsapp-button,
.whatsapp-chat-widget,
.whatsapp-button *,
.whatsapp-chat-widget * {
    box-sizing: border-box;
}

/* Pulsante Floating WhatsApp */
.whatsapp-button {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    background: #25D366;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.4);
    z-index: 9998;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

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

.whatsapp-button svg {
    width: 32px;
    height: 32px;
    fill: white;
}

/* Animazione pulsante */
@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(37, 211, 102, 0.7);
    }
    70% {
        box-shadow: 0 0 0 15px rgba(37, 211, 102, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(37, 211, 102, 0);
    }
}

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

/* Badge notifica */
.notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff4444;
    color: white;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    font-family: Arial, sans-serif;
    border: 2px solid white;
    animation: bounce 0.5s ease;
}

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

/* Widget Chat */
.whatsapp-chat-widget {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 350px;
    max-width: calc(100vw - 40px);
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
    z-index: 9999;
    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;
    overflow: hidden;
}

.whatsapp-chat-widget.show {
    opacity: 1;
    transform: scale(1) translateY(0);
    pointer-events: auto;
}

/* Header del widget */
.chat-header {
    background: #075E54;
    color: white;
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
}

.chat-info {
    flex: 1;
    min-width: 0;
}

.chat-name {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-status {
    font-size: 13px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 6px;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: #25D366;
    border-radius: 50%;
    animation: blink 1.5s infinite;
    flex-shrink: 0;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.close-button {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
    flex-shrink: 0;
}

.close-button:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Area messaggi */
.chat-body {
    background: #ECE5DD;
    padding: 20px;
    min-height: 200px;
    max-height: 300px;
    overflow-y: auto;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="260" height="260" opacity="0.05"><path d="M130 0C58.203 0 0 58.203 0 130s58.203 130 130 130 130-58.203 130-130S201.797 0 130 0zm0 242C71.034 242 18 188.966 18 130S71.034 18 130 18s112 53.034 112 112-53.034 112-112 112z"/></svg>');
}

/* Messaggio */
.message {
    background: white;
    padding: 10px 14px;
    border-radius: 8px;
    margin-bottom: 12px;
    position: relative;
    max-width: 85%;
    animation: slideIn 0.3s ease;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

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

.message::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;
}

.message-text {
    font-size: 14px;
    line-height: 1.5;
    color: #303030;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    word-wrap: break-word;
}

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

/* Footer con pulsante */
.chat-footer {
    padding: 12px 16px;
    background: white;
    border-top: 1px solid #e9edef;
}

.whatsapp-link {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: #25D366;
    color: white;
    text-decoration: none;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    transition: background 0.2s;
}

.whatsapp-link:hover {
    background: #20BA5A;
}

.whatsapp-link svg {
    width: 20px;
    height: 20px;
    fill: white;
    flex-shrink: 0;
}

/* Typing indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 10px 14px;
    background: white;
    border-radius: 8px;
    width: fit-content;
    margin-bottom: 12px;
    animation: slideIn 0.3s ease;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: #90949c;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-10px);
    }
}

/* Responsive */
@media (max-width: 480px) {
    .whatsapp-chat-widget {
        width: calc(100vw - 40px);
        bottom: 85px;
    }

    .whatsapp-button {
        bottom: 15px;
        right: 15px;
        width: 56px;
        height: 56px;
    }

    .whatsapp-button svg {
        width: 28px;
        height: 28px;
    }
}

/* Scrollbar personalizzata */
.chat-body::-webkit-scrollbar {
    width: 6px;
}

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

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

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