/* --- Chatbot Overlay Styles --- */
.chatbot-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9997; /* Below dashboard if on same page */
    background-color: rgba(210, 210, 210, 0.7);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    backdrop-filter: saturate(180%) blur(20px);
    overflow-y: scroll;
    display: flex;
    flex-direction: column;
    justify-content: flex-start; /* Align content to the top */
    align-items: center; /* Center content horizontally */
    padding: 2rem;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0s linear 0.3s;
    pointer-events: none;
    box-sizing: border-box;
}
.chatbot-overlay::-webkit-scrollbar{
background: transparent;
visibility: hidden;
}

.chatbot-overlay.is-visible {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.3s ease, visibility 0s;
    pointer-events: auto;
}

.chatbot-close-btn {
    position: fixed;
    top: 2rem;
    right: 2rem;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    background-color: rgba(210, 210, 210, 0.4);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    backdrop-filter: saturate(180%) blur(20px);
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    padding: 0;
    cursor: pointer;
    transition: transform 0.2s ease;
    z-index: 10000;
}
.chatbot-close-btn svg {
    width: 16px;
    height: 16px;
    fill: #495057;
    transition: fill 0.2s ease;
}
.chatbot-close-btn:hover {
    transform: scale(1.05);
    background-color: rgba(0, 0, 0, 0.7);
}
.chatbot-close-btn:hover svg {
    fill: #fcc209;
}

/* --- Chatbot Layout Styles --- */
.chatbot-content {
    width: 100%;
    padding-right: 5rem;
    box-sizing: border-box;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding-bottom:1.5rem;
    position: relative; /* For positioning the welcome message */
}

/* --- Welcome Message Styles --- */
.chatbot-welcome {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding-right:5rem;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    z-index: 2;
}
.chatbot-welcome img {
    height:80px;
    margin-bottom:24px;
}
.chatbot-welcome h3 {
    font-size: 1.5rem;
    margin: 0 0 0.5rem 0;
}
.chatbot-welcome p {
    font-size: 1rem;
    color: #6e6e73;
    margin: 0;
}

/* Hide welcome message when chat is active */
.chatbot-content.chat-active .chatbot-welcome {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}
.chat-messages {
    background-color: rgba(255, 255, 255, 0.1);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    backdrop-filter: saturate(180%) blur(20px);
    border-radius: 28px;
    flex-grow: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.69rem; /* Reduced gap for consecutive messages */
    width: 100%;
    
}

/* --- Custom Scrollbar Styles --- */
.chat-messages::-webkit-scrollbar {
  width: 6px;
}
.chat-messages::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.1);
  margin-top:28px;margin-bottom:28px;
  border-radius: 3px;
}
.chat-messages::-webkit-scrollbar-thumb {
  background: #888;
  border-radius: 3px;
}
.chat-messages::-webkit-scrollbar-thumb:hover {
  background: #555;
}


.chat-message {
    padding: 0.55rem 1.25rem;
    border-radius: 28px;
    max-width:500px;
    position: relative; /* For the tail */
}

/* --- Simplified Chatbot Message Styling --- */

/* Sets the base font size and line height for the entire response. */
.bot-message {
    font-size: 0.94rem;
    line-height: 1.6;
}

/* Targets all common elements for consistent spacing. */
.bot-message p,
.bot-message ul,
.bot-message ol,
.bot-message h1,
.bot-message h2,
.bot-message h3 {
    font-size: 1em;
    margin-top: 0; /* We'll control top margin on headings separately */
    margin-bottom: 0.75em;
}

/* --- THIS IS THE MODIFIED PART --- */
/* Ensures headings are bold and adds space above them,
   but NOT if the heading is the very first thing in the message. */
.bot-message h1,
.bot-message h2,
.bot-message h3 {
    font-weight: bold;
    margin-top: 1.25em; /* Adds space on top */
}
.bot-message > *:first-child {
    margin-top: 0; /* Removes top margin from the first element */
}
/* --- END OF MODIFICATION --- */

/* Adds proper indentation to lists. */
.bot-message ul,
.bot-message ol {
    padding-left: 0;    list-style-position: inside;

}

/* Removes the space after the very last line for clean padding. */
.bot-message > *:last-child {
    margin-bottom: 0;
}

.chat-message p {
    margin: 0;
    font-size: 0.94rem;
    line-height: 1.5;
}

/* --- Chat Bubble Tails --- */
.chat-message::after {
    content: '';
    position: absolute;
    bottom: -5px;
    width: 13px;
    height: 13px;
    background-repeat: no-repeat;
}

.bot-message {
    background-color: rgba(255, 255, 255, 0.8);
    align-self: flex-start;
}
.bot-message::after {
left: 8px;
    background-position: left bottom;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='13' height='13' viewBox='0 0 13 13'%3e%3cpath fill='rgba(255, 255, 255, 0.8)' fill-rule='evenodd' d='M5 0q0 9.025-5 13s7.232.022 11.382-3.564Q15.532 5.85 5 0'/%3e%3c/svg%3e");
}

.user-message {
    background-color: #ff6f00;
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    backdrop-filter: saturate(180%) blur(20px);
    color: white;
    align-self: flex-end;
}
.user-message::after {
right: 8px;
    background-position: right bottom;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='13' height='13' viewBox='0 0 13 13'%3e%3cpath fill='%23ff6f00' fill-rule='evenodd' d='M8 0q0 9.025 5 13s-7.232.022-11.382-3.564Q-2.532 5.85 8 0'/%3e%3c/svg%3e");
}

.chat-message.in-sequence {
    border-radius: 28px !important;
}
.chat-message.in-sequence::after {
    display: none;
}


.chat-input-form {
    display: flex;
    gap: 0.5rem;
    padding: 0.5rem;
    background-color: rgba(255, 255, 255, 0.1);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    backdrop-filter: saturate(180%) blur(20px);
    border-radius: 28px;
    width: 100%;
    margin-bottom: 1rem;
    position: relative;
    align-items: flex-end;
    z-index: 3;
}
/* --- Disable Input Form While Thinking --- */
.chat-input-form.is-thinking {
    opacity: 0.6;
    pointer-events: none;
}

/* --- Disable Input Form While Thinking --- */
.chat-input-form.is-thinking {
    opacity: 0.6;
    pointer-events: none;
    
    /* Change this color for the form's background */
    background-color: rgba(0, 0, 0, 0.1); 
}

.chat-input-form.is-thinking .chat-input {
    /* Change this color for the text input area's background */
    background-color: rgba(0, 0, 0, 0);
}

.chat-input {
    flex-grow: 1;
    border: none;
    background: transparent;
    padding: 0.75rem;
    font-size: 0.94rem;
    resize: none;
    overflow: hidden;
    line-height: 1.5;
    transition: height 0.2s ease;
    max-height: 150px;
    overflow-y: auto;
}
.chat-input:focus {
    outline: none;
}

.chat-input::-webkit-scrollbar {
  width: 6px;
}
.chat-input::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.1);
  border-radius: 3px;
}
.chat-input::-webkit-scrollbar-thumb {
  background: #888;
  border-radius: 3px;
}
.chat-input::-webkit-scrollbar-thumb:hover {
  background: #555;
}


.chat-send-btn {
    background-color: transparent;
    border: none;
    width: 50px;
    height: 40px;
    border-radius: 99px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.3s ease;
    position: relative;
    flex-shrink: 0;
    margin-bottom: 5px;
}

.chat-send-btn svg {
    width: 20px;
    height: 20px;
    position: absolute;
    transition: opacity 0.3s ease, transform 0.3s ease;
}
.chat-send-btn svg.sparkle-icon {
    width: 28px;
    height: 28px;
    position: absolute;
    transition: opacity 0.3s ease, transform 0.3s ease;
left: 13px;
    top: 10.5px;
}

.sparkle-icon {
    fill: #495057;
    opacity: 1;
    transform: scale(1);
    transition: fill 0.2s ease;
}
.chat-send-btn:hover .sparkle-icon {
    fill: #000;
}

.send-icon {
    fill: white;
    opacity: 0;
    transform: scale(0.5);
}

.chat-input-form.has-text .chat-send-btn {
    background-color: #ff6f00;
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    backdrop-filter: saturate(180%) blur(20px);
}
.chat-input-form.has-text .chat-send-btn:hover {
    background-color: #ff6f00;
}

.chat-input-form.has-text .sparkle-icon {
    opacity: 0;
    transform: scale(0.5);
}
.chat-input-form.has-text .send-icon {
    opacity: 1;
    transform: scale(1);
}

.suggestions-dialog {
    position: absolute;
    bottom: calc(100% + 10px); /* This is correct, keeps it above the form */
    
    /* --- REPLACED CODE --- */
    /* Remove the old, fragile positioning */
    /* left: 50%; */
    /* transform: translateX(45%); */
    
    /* Add the new, robust positioning */
    right: 0;
    /* --- END OF REPLACED CODE --- */
    
    width: fit-content; /* Makes the dialog width fit the buttons */
    max-width: 500px; /* Still good to have a max width */


    background-color: rgba(255, 255, 255, 0.423);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    backdrop-filter: saturate(180%) blur(20px);
    border-radius: 28px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    box-shadow: 0 8px 32px rgba(0,0,0,0.1);

    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    z-index: 3;
    
    /* --- UPDATED TRANSFORM FOR ANIMATION --- */
    transform: translateY(10px); /* Pushes it down slightly when hidden */
    transition: all 0.3s ease-out;
}

.chat-input-form.suggestions-open .suggestions-dialog {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    
    /* --- UPDATED TRANSFORM FOR ANIMATION --- */
    transform: translateY(0); /* Moves it to its final position when visible */
}

.suggestion-btn {
    width: 100%;    white-space: normal; /* Allow text to wrap */

    padding: 0.55rem 1.25rem;
        background-color: rgba(255, 255, 255, 0.8);
    border: none;
    border-radius: 28px;
    text-align: left;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}
.suggestion-btn:hover {
    background-color: #ff6f00;
    color: #fff;
}


.chatbot-welcome img {
    height:80px;
    margin-bottom:24px;
}

.typing-indicator {
    display: flex;
    align-items: center;
    justify-content: flex-start; /* Aligns dots to the left */
    padding: 10px 0; /* Adds some vertical space */
}

.typing-indicator span {
    height: 10px;
    width: 10px;
    background-color: #ced4da;
    border-radius: 50%;
    margin: 0 2px;
    animation: bounce 1.2s infinite ease-in-out;
}

/* Adds a slight delay to each dot's animation */
.typing-indicator span:nth-child(2) {
    animation-delay: -0.2s;
}

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

/* The bouncing animation keyframes */
@keyframes bounce {
    0%, 80%, 100% {
        transform: scale(0);
    }
    40% {
        transform: scale(1.0);
    }
}

.chat-message.new-message {
    animation: popIn 0.3s ease-out forwards;
}

@keyframes popIn {
    0% {
        opacity: 0;
        transform: translateY(10px) scale(0.99);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}
/* --- Chatbot Disclaimer Styles --- */
.chatbot-disclaimer {
    width: 100%;
    text-align: center;
}

.chatbot-disclaimer p {
    font-size: 0.75rem;  /* Makes the text small and unobtrusive */
    color: #6e6e73;      /* A muted gray color */
    line-height: 1.5;
    margin: 0;
}

.chatbot-disclaimer a {
        color: #6e6e73;      /* A muted gray color */
    text-decoration: underline;
    font-weight: 500;
    transition: color 0.2s ease;
}
/* 
.chatbot-disclaimer a:hover {
color: #ff6f00; 
} */

@media (max-width: 768px) {
    .chat-message {
    max-width: 85%;
}


}