/* ==========================================
   LEONARDO CHATBOT - BOELTER MARCENARIA
   Humanized Conversational Widget
   ========================================== */

/* Widget Container */
.leonardo-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9998;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* Avatar Button */
.leonardo-avatar {
    position: relative;
    width: 70px;
    height: 70px;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    animation: avatarPulse 3s ease-in-out infinite;
}

.leonardo-avatar:hover {
    transform: scale(1.1);
}

.leonardo-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid #F57C00;
    box-shadow: 0 4px 20px rgba(245, 124, 0, 0.4);
}

.leonardo-avatar::after {
    content: '';
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 16px;
    height: 16px;
    background: #22C55E;
    border-radius: 50%;
    border: 3px solid #fff;
    animation: onlinePulse 2s ease-in-out infinite;
}

@keyframes avatarPulse {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

@keyframes onlinePulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* Floating Messages */
.leonardo-floating-msg {
    position: absolute;
    bottom: 80px;
    right: 0;
    background: #fff;
    padding: 14px 18px;
    border-radius: 16px 16px 4px 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    max-width: 280px;
    min-width: 200px;
    font-size: 14px;
    color: #1a1612;
    line-height: 1.5;
    opacity: 0;
    transform: translateY(10px) scale(0.9);
    transition: all 0.3s ease;
    pointer-events: none;
}

.leonardo-floating-msg.show {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.leonardo-floating-msg::after {
    content: '';
    position: absolute;
    bottom: -8px;
    right: 20px;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid #fff;
}

.leonardo-floating-msg .typing-indicator {
    display: flex;
    gap: 4px;
    padding: 4px 0;
}

.leonardo-floating-msg .typing-indicator span {
    width: 6px;
    height: 6px;
    background: #F57C00;
    border-radius: 50%;
    animation: typingBounce 1.4s ease-in-out infinite;
}

.leonardo-floating-msg .typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.leonardo-floating-msg .typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

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

/* Chat Window */
.leonardo-chat {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 380px;
    max-width: calc(100vw - 48px);
    height: 520px;
    max-height: calc(100vh - 48px);
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s ease;
}

.leonardo-chat.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* Chat Header */
.leonardo-header {
    background: linear-gradient(135deg, #F57C00, #E65100);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.leonardo-header-avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.leonardo-header-info {
    flex: 1;
}

.leonardo-header-info h4 {
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 2px 0;
}

.leonardo-header-info span {
    color: rgba(255, 255, 255, 0.85);
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.leonardo-header-info span::before {
    content: '';
    width: 8px;
    height: 8px;
    background: #22C55E;
    border-radius: 50%;
}

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

.leonardo-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Chat Messages */
.leonardo-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: #f8f7f5;
}

.leonardo-message {
    display: flex;
    gap: 10px;
    max-width: 85%;
    animation: messageIn 0.3s ease;
}

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

.leonardo-message.bot {
    align-self: flex-start;
}

.leonardo-message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.leonardo-message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.leonardo-message-content {
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
}

.leonardo-message.bot .leonardo-message-content {
    background: #fff;
    color: #1a1612;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.leonardo-message.user .leonardo-message-content {
    background: linear-gradient(135deg, #F57C00, #E65100);
    color: #fff;
    border-bottom-right-radius: 4px;
}

/* Typing Indicator */
.leonardo-typing {
    display: flex;
    gap: 10px;
    max-width: 85%;
    align-self: flex-start;
}

.leonardo-typing .leonardo-message-content {
    background: #fff;
    padding: 16px 20px;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.leonardo-typing-dots {
    display: flex;
    gap: 4px;
}

.leonardo-typing-dots span {
    width: 8px;
    height: 8px;
    background: #9a9488;
    border-radius: 50%;
    animation: typingBounce 1.4s ease-in-out infinite;
}

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

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

/* Quick Replies */
.leonardo-quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.leonardo-quick-reply {
    padding: 8px 16px;
    background: #fff;
    border: 1.5px solid #F57C00;
    border-radius: 20px;
    color: #F57C00;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
}

.leonardo-quick-reply:hover {
    background: #F57C00;
    color: #fff;
}

/* Chat Input */
.leonardo-input-area {
    padding: 16px 20px;
    background: #fff;
    border-top: 1px solid #e8e4dd;
    display: flex;
    gap: 12px;
    align-items: center;
}

.leonardo-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e8e4dd;
    border-radius: 24px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.3s;
}

.leonardo-input:focus {
    border-color: #F57C00;
}

.leonardo-input::placeholder {
    color: #9a9488;
}

.leonardo-send {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #F57C00, #E65100);
    border: none;
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s, box-shadow 0.3s;
}

.leonardo-send:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 15px rgba(245, 124, 0, 0.4);
}

.leonardo-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* WhatsApp CTA */
.leonardo-whatsapp-cta {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: linear-gradient(135deg, #25D366, #128C7E);
    border-radius: 12px;
    color: #fff;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    margin-top: 12px;
    transition: transform 0.3s, box-shadow 0.3s;
}

.leonardo-whatsapp-cta:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(37, 211, 102, 0.4);
}

.leonardo-whatsapp-cta i {
    font-size: 20px;
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .leonardo-widget {
        bottom: 16px;
        right: 16px;
    }

    .leonardo-avatar {
        width: 60px;
        height: 60px;
    }

    .leonardo-chat {
        right: 0;
        bottom: 0;
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }

    .leonardo-floating-msg {
        right: 0;
        max-width: 240px;
        min-width: 180px;
    }
}

/* Notification Badge */
.leonardo-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 22px;
    height: 22px;
    background: #EF4444;
    border-radius: 50%;
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
    animation: badgePop 0.3s ease;
}

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

/* Hide widget when chat is open */
.leonardo-widget.chat-open .leonardo-avatar,
.leonardo-widget.chat-open .leonardo-floating-msg,
.leonardo-widget.chat-open .leonardo-badge {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}
