/* General body adjustments for floating widget */
html, body {
    height: 100% !important; /* Ensure html and body take full height */
    margin: 0;
    font-family: 'Inter', sans-serif;
    background-color: #f0f4f8;
}

/* Floating Chatbot Wrapper */
.navi-chatbot-wrapper {
    position: fixed !important; /* Force fixed positioning */
    bottom: 1.5rem !important; /* Distance from bottom */
    right: 1.5rem !important;  /* Distance from right */
    z-index: 99999 !important; /* Ensure it's on top of other content */
    display: flex;
    flex-direction: column;
    align-items: flex-end; /* Align avatar to the right */
    /* Removed: border: 5px solid red !important; */
}

/* Chatbot Container (the main dialog box) */
.navi-chatbot-wrapper .chat-container {
    background-color: #ffffff;
    border-radius: 1.5rem; /* More rounded corners */
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    overflow: hidden; /* Important for containing content */
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 400px; /* Max width for the chat window */
    height: 600px; /* Fixed height for the chat window */
    transform: scale(0) !important; /* Start minimized/hidden */
    transform-origin: bottom right;
    transition: transform 0.3s ease-out, opacity 0.3s ease-out;
    opacity: 0 !important;
    pointer-events: none !important; /* Disable interaction when hidden */
    margin-bottom: 1rem; /* Space between chat and avatar */
}

/* State when chat is open */
.navi-chatbot-wrapper .chat-container.is-open {
    transform: scale(1) !important;
    opacity: 1 !important;
    pointer-events: auto !important; /* Enable interaction when open */
}

/* Minimize/Maximize Avatar Button */
.navi-chatbot-wrapper .navi-toggle-button {
    width: 4rem !important; /* Size of the avatar button */
    height: 4rem !important;
    border-radius: 50%;
    background-color: #3b82f6; /* Blue-600 */
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2rem;
    cursor: pointer;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease-in-out, background-color 0.2s;
    flex-shrink: 0; /* Prevent shrinking */
}
.navi-chatbot-wrapper .navi-toggle-button:hover {
    background-color: #2563eb; /* Blue-700 */
    transform: translateY(-3px);
}
.navi-chatbot-wrapper .navi-toggle-button:active {
    transform: translateY(0);
}
.navi-chatbot-wrapper .navi-toggle-button img {
    width: 100% !important; /* Ensure image fills button */
    height: 100% !important; /* Ensure image fills button */
    border-radius: 50%;
    object-fit: cover;
}

/* Chat Header */
.navi-chatbot-wrapper .chat-header {
    background-color: #3b82f6; /* Blue-600 */
    color: white;
    padding: 1rem 1.5rem;
    border-top-left-radius: 1.5rem;
    border-top-right-radius: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between; /* Space out title and close button */
    gap: 0.75rem;
}
.navi-chatbot-wrapper .chat-header h1 {
    flex-grow: 1; /* Allow title to take space */
}
.navi-chatbot-wrapper .chat-close-button {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 50%;
    transition: background-color 0.2s;
}
.navi-chatbot-wrapper .chat-close-button:hover {
    background-color: rgba(255, 255, 255, 0.2);
}
/* New: Download button styling */
.navi-chatbot-wrapper .chat-download-button {
    background: none;
    border: none;
    color: white;
    font-size: 1.2rem; /* Slightly smaller than close button */
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 50%;
    transition: background-color 0.2s;
    margin-left: 0.5rem; /* Space from close button */
}
.navi-chatbot-wrapper .chat-download-button:hover {
    background-color: rgba(255, 255, 255, 0.2);
}


/* Chat Main Area - Ensure it's a flex container for its children */
.navi-chatbot-wrapper .chat-main {
    display: flex;
    flex-direction: column;
    height: 100%; /* Make chat-main take full height of its parent (chat-container) */
}

/* Chat Messages Area */
.navi-chatbot-wrapper .chat-messages {
    flex: 1 1 auto !important; /* Allow it to grow, shrink, and take available space */
    padding: 1.5rem;
    overflow-y: auto !important; /* Ensure scrolling is enabled */
    background-color: #e2e8f0; /* Gray-200 */
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-height: 0 !important; /* Crucial for flex items with overflow */
    /* flex-shrink: 1 !important; Removed, as flex: 1 1 auto covers this */
}
.navi-chatbot-wrapper .message-bubble {
    max-width: 85% !important; /* Increased width slightly for better wrapping */
    padding: 0.75rem 1rem;
    border-radius: 1rem;
    word-wrap: break-word !important; /* Standard property */
    overflow-wrap: break-word !important; /* CSS3 equivalent for better browser support */
    word-break: normal !important; /* IMPORTANT: Allow breaking only at word boundaries */
    hyphens: auto; /* Allow hyphenation for better word breaking */
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}
/* Ensure the content inside the bot message (text and buttons) wraps correctly */
.navi-chatbot-wrapper .bot-message > div:last-child { /* Targets the textContent div */
    flex-grow: 1; /* Allow it to take available space */
    min-width: 0; /* Allow content to shrink within flex container */
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
    word-break: normal !important; /* Ensure word breaks correctly */
    hyphens: auto; /* Allow hyphenation for better word breaking */
}
.navi-chatbot-wrapper .bot-message .flex-wrap {
    max-width: 100% !important; /* Ensure button container doesn't overflow its parent */
    overflow-x: hidden !important; /* Hide any accidental horizontal overflow within the button container */
}
.navi-chatbot-wrapper .bot-message button { /* Target buttons directly */
    max-width: 100% !important; /* Ensure individual buttons also wrap */
    box-sizing: border-box !important; /* Include padding/border in width calculation */
    white-space: normal !important; /* Allow text inside buttons to wrap */
    word-break: normal !important; /* Ensure button text wraps at words */
    overflow-wrap: break-word !important; /* Fallback for long words in buttons */
}
/* IMPORTANT FIX: Underline links */
.navi-chatbot-wrapper a {
    text-decoration: underline !important;
}


.navi-chatbot-wrapper .user-message {
    background-color: #3b82f6; /* Blue-500 */
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 0.25rem; /* Sharper corner for user */
}
.navi-chatbot-wrapper .bot-message {
    background-color: #f9fafb; /* Gray-50 */
    color: #1f2937; /* Gray-800 */
    align-self: flex-start;
    border-bottom-left-radius: 0.25rem; /* Sharper corner for bot */
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}
.navi-chatbot-wrapper .bot-avatar {
    width: 2rem !important; /* Ensure avatar size */
    height: 2rem !important; /* Ensure avatar size */
    border-radius: 50%;
    object-fit: cover;
}

/* Chat Input Area */
.navi-chatbot-wrapper .chat-input-area {
    padding: 1rem 1.5rem;
    background-color: #f0f4f8; /* Light blue-gray */
    border-top: 1px solid #e5e7eb; /* Gray-200 */
    display: flex;
    gap: 0.75rem;
    align-items: center;
}
.navi-chatbot-wrapper .chat-input {
    flex-grow: 1;
    padding: 0.75rem 1rem;
    border: 1px solid #d1d5db; /* Gray-300 */
    border-radius: 0.75rem;
    outline: none;
    transition: border-color 0.2s;
}
.navi-chatbot-wrapper .chat-input:focus {
    border-color: #3b82f6; /* Blue-500 */
}
.navi-chatbot-wrapper .send-button {
    background-color: #3b82f6; /* Blue-600 */
    color: white;
    padding: 0.75rem 1.25rem;
    border-radius: 0.75rem;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.navi-chatbot-wrapper .send-button:hover {
    background-color: #2563eb; /* Blue-700 */
    transform: translateY(-1px);
}
.navi-chatbot-wrapper .send-button:active {
    transform: translateY(0);
}

/* RV Listings Area */
.navi-chatbot-wrapper .rv-listings-container {
    /* This will now be part of the main chat container, or removed if you want a simpler chat-only popup */
    /* For a floating widget, it's often better to have a simpler chat experience */
    display: none; /* Hide RV listings by default in floating widget */
    /* If you want to show listings within the popup, you'd need to adjust max-width/height */
}

.navi-chatbot-wrapper .rv-card {
    background-color: #ffffff;
    border-radius: 0.75rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.navi-chatbot-wrapper .rv-card img {
    border-radius: 0.5rem;
    width: 100%;
    height: 150px;
    object-fit: cover;
}
.navi-chatbot-wrapper .rv-card-title {
    font-weight: 600;
    color: #1f2937;
}
.navi-chatbot-wrapper .rv-card-details {
    font-size: 0.875rem;
    color: #4b5563;
}
.navi-chatbot-wrapper .loading-dots span {
    animation: bounce 1.4s infinite ease-in-out both;
    background-color: #6b7280;
    border-radius: 50%;
    display: inline-block;
    height: 0.5rem;
    width: 0.5rem;
    margin: 0 0.125rem;
}
.navi-chatbot-wrapper .loading-dots span:nth-child(1) { animation-delay: -0.32s; }
.navi-chatbot-wrapper .loading-dots span:nth-child(2) { animation-delay: -0.16s; }
.navi-chatbot-wrapper .loading-dots span:nth-child(3) { animation-delay: 0s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* Responsive adjustments for smaller screens if needed */
@media (max-width: 767px) {
    .navi-chatbot-wrapper {
        bottom: 1rem;
        right: 1rem;
    }
    .navi-chatbot-wrapper .chat-container {
        max-width: calc(100vw - 2rem); /* Adjust for mobile padding */
        height: calc(90vh - 2rem);
    }
}
