/* === LLAMITA CHAT WIDGET - Premium Floating Design === */
#ai-chat-widget {
    position: fixed;
    bottom: 100px;
    right: 25px;
    z-index: 99999;
    font-family: 'Poppins', sans-serif;
}

.chat-bubble {
    width: 65px;
    height: 65px;
    background: linear-gradient(135deg, #d4a574 0%, #8B4513 50%, #5a3a1f 100%);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    cursor: pointer;
    box-shadow: 0 8px 25px rgba(139, 69, 19, 0.4), 0 0 20px rgba(212, 165, 116, 0.3);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    animation: floatBubble 3s ease-in-out infinite;
    position: relative;
}

.chat-bubble::before {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: 50%;
    background: linear-gradient(135deg, #d4a574, #8B4513, #d4a574);
    z-index: -1;
    animation: rotateBorder 4s linear infinite;
}

.chat-bubble:hover {
    transform: scale(1.15) rotate(5deg);
    box-shadow: 0 12px 35px rgba(139, 69, 19, 0.5), 0 0 30px rgba(212, 165, 116, 0.5);
}

.chat-bubble.active {
    animation: none;
    transform: scale(1);
}

@keyframes floatBubble {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-8px);
    }
}

@keyframes rotateBorder {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.chat-window {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    max-height: 100vh;
    background: #e5ddd5;
    z-index: 99999;
    display: none;
    flex-direction: column;
    overflow: hidden;
    /* CRITICAL: Allows flex children to scroll */
    box-shadow: none;
    border-radius: 0;
}

/* Responsive adjustments */
@media (max-width: 480px) {
    .chat-window {
        width: 100%;
        height: 100%;
        bottom: 0;
        right: 0;
        border-radius: 0;
        max-height: 100vh;
    }
}


@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.9);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.chat-window.active {
    display: flex;
}

.chat-header {
    background: linear-gradient(135deg, #4bf767 0%, #5a3a1f 100%);
    color: white;
    padding: 10px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative;
    overflow: hidden;
}

.chat-header::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 100%;
    height: 200%;
    background: radial-gradient(circle, rgba(212, 165, 116, 0.2) 0%, transparent 70%);
}

.chat-avatar {
    width: 40px !important;
    height: 40px !important;
    min-width: 40px;
    /* Prevent squeezing */
    min-height: 40px;
    /* Prevent squeezing */
    border-radius: 50%;
    object-fit: cover !important;
    /* Ensure image covers the circle without distortion */
    background: white;
    padding: 2px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
    flex-shrink: 0;
    /* Crucial for flex containers */
}

.chat-header-info h4 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
}

.chat-header-info p {
    margin: 2px 0 0 0;
    font-size: 11px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 4px;
}

.chat-header-info p::before {
    content: '';
    width: 8px;
    height: 8px;
    background: #4ade80;
    border-radius: 50%;
    animation: pulse 2s infinite;
}


.chat-messages {
    flex: 1;
    padding: 20px;
    padding-bottom: 40px;
    /* Extra space at bottom */
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background-color: #e5ddd5;
    background-image: url("https://user-images.githubusercontent.com/15075759/28719144-86dc0f70-73b1-11e7-911d-60d70fcded21.png");
    background-blend-mode: soft-light;
    color: #333;
    /* Center the container itself, not the items */
    width: 100%;
    max-width: none;
    /* Full width as requested */
    margin: 0;
    padding-left: 10px;
    padding-right: 10px;
}

.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #d4a574;
    border-radius: 3px;
}

.message {
    padding: 12px 16px;
    border-radius: 18px;
    max-width: 98%;
    font-size: 14px;
    line-height: 1.7;
    animation: fadeIn 0.3s ease-out;
    word-wrap: break-word;
}

/* Mejor espaciado para contenido del bot */
.message.bot strong {
    color: #cf9008;
    font-weight: 600;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.bot {
    background: white;
    align-self: flex-start;
    margin-top: 10px;
    margin-bottom: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    border: 1px solid #eee;
    border-bottom-left-radius: 5px;
}

.message-content {
    padding: 12px 16px;
    /* No height constraint - let content flow naturally */
    /* Scrolling is handled by parent .chat-messages container */
}

/* Custom scrollbar for message content */
.message-content::-webkit-scrollbar {
    width: 6px;
}

.message-content::-webkit-scrollbar-track {
    background: #f5f5f5;
    border-radius: 3px;
}

.message-content::-webkit-scrollbar-thumb {
    background: #d4a574;
    border-radius: 3px;
}

.message-content.collapsed {
    /* Only constrain height when collapsed */
    max-height: 400px;
    overflow: hidden;
    /* Increased from 200px to show more content */
    position: relative;
}

.message-content.collapsed::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 120px;
    background: linear-gradient(to bottom, transparent, white);
    pointer-events: none;
}

.read-more-btn {
    background: #f9fafb;
    border: none;
    border-top: 1px solid #eee;
    color: #8B4513;
    font-weight: 600;
    font-size: 13px;
    padding: 12px;
    cursor: pointer;
    width: 100%;
    text-align: center;
    transition: background 0.2s;
    display: block;
    /* Ensure it is visible */
}

.read-more-btn:hover {
    background: #f0f0f0;
}

.read-more-btn i {
    margin-right: 5px;
}

.message.user {
    background: linear-gradient(135deg, #8B4513 0%, #a0522d 100%);
    color: white;
    align-self: flex-end;
    margin-top: 10px;
    margin-bottom: 10px;
    border-bottom-right-radius: 5px;
}

.message.thinking {
    background: #f0f0f0;
    color: #888;
}

.chat-options {
    padding: 12px 20px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    border-top: 1px solid #eee;
    background: white;
}

.option-btn {
    background: white;
    border: 2px solid #8B4513;
    color: #8B4513;
    padding: 8px 18px;
    border-radius: 25px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.option-btn:hover {
    background: #8B4513;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(139, 69, 19, 0.3);
}

.chat-input-area {
    padding: 8px 12px;
    display: flex;
    gap: 10px;
    border-top: 1px solid #eee;
    background: white;
}

.chat-input {
    flex: 1;
    border: 2px solid #e0e0e0;
    padding: 10px 14px;
    border-radius: 25px;
    outline: none;
    font-size: 14px;
    transition: border-color 0.3s, box-shadow 0.3s;
}

.chat-input:focus {
    border-color: #8B4513;
    box-shadow: 0 0 0 3px rgba(139, 69, 19, 0.1);
}

.send-btn {
    background: linear-gradient(135deg, #8B4513 0%, #a0522d 100%);
    color: white;
    border: none;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.send-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 5px 20px rgba(139, 69, 19, 0.4);
}

.whatsapp-chat-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: linear-gradient(135deg, #25d366 0%, #128c7e 100%);
    color: white !important;
    padding: 8px;
    border-radius: 10px;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.whatsapp-chat-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(37, 211, 102, 0.4);
}

.chat-noti {
    position: absolute;
    top: -3px;
    right: -3px;
    width: 18px;
    height: 18px;
    background: #ef4444;
    border-radius: 50%;
    border: 3px solid white;
    animation: pulse 2s infinite;
    display: none;
}

@keyframes pulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
    }

    70% {
        transform: scale(1.1);
        box-shadow: 0 0 0 12px rgba(239, 68, 68, 0);
    }

    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
}

/* Responsive */
@media (max-width: 480px) {
    #ai-chat-widget {
        bottom: 80px;
        right: 15px;
    }

    /* .chat-window ya es fullscreen por defecto, no necesitamos override aquí */

    .chat-bubble {
        width: 55px;
        height: 55px;
        font-size: 24px;
    }
}
