/* Chat Search Container */
.chat-search-container {
    position: fixed; /* Fixed by default based on recent changes or needs to be floating? Original was absolute in Hero, but scrolled class made it fixed. */
    /* Wait, original was absolute inside hero. Let's keep it consistent but ensure it works on other pages.
       On other pages, it might not be inside a Hero. Only index has hero.
       For generic pages, we might want it bottom-right fixed.
    */
    bottom: 200px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 600px;
    height: 60px;
    background: rgba(20, 20, 20, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 28px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    padding: 0 20px;
    z-index: 10;
    opacity: 1;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1), border-color 0.3s ease, box-shadow 0.3s ease;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

/* If on a page without hero, we might want it to start fixed or handled by JS. */
/* The .scrolled class makes it fixed bottom right. */
.chat-search-container.scrolled, 
.chat-search-container.global-widget { /* Add global-widget class usage support */
    position: fixed;
    bottom: 30px;
    left: auto;
    right: 30px;
    transform: none;
    width: 350px;
    max-width: 90%;
    z-index: 1001; 
    background: var(--body-color);
    border-color: var(--border-color);
    opacity: 1; /* Reset opacity for global usage */
}

/* Mobile Responsive Adjustments */
@media (max-width: 768px) {
    .chat-search-container.scrolled,
    .chat-search-container.global-widget {
        width: auto;           /* Fluid width */
        left: 15px;            /* 15px margin from left */
        right: 15px;           /* 15px margin from right */
        bottom: 20px;          /* Slightly lower on mobile */
        max-width: none;       /* Override max-width */
    }
}

.chat-search-container:hover {
    border-color: rgba(255, 255, 255, 0.4);
    box-shadow: 0 4px 25px rgba(0, 0, 0, 0.3);
}

.chat-history {
    position: absolute;
    bottom: 70px; /* Above the input bar */
    left: 0;
    width: 100%;
    max-height: 400px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    padding: 10px;
    gap: 10px;
    /* Scrollbar styling */
    scrollbar-width: thin;
    scrollbar-color: var(--first-color-light) transparent;
    pointer-events: auto; /* Ensure clickable/scrollable */
}

/* Hide scrollbar for webkit but keep functionality */
.chat-history::-webkit-scrollbar {
    width: 6px;
}
.chat-history::-webkit-scrollbar-thumb {
    background-color: var(--first-color-light);
    border-radius: 3px;
}

.chat-message {
    padding: 10px 15px;
    border-radius: 15px;
    max-width: 80%;
    font-size: 0.95rem;
    line-height: 1.4;
    word-wrap: break-word;
    animation: fadeIn 0.3s ease;
}

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

.chat-message.user {
    align-self: flex-end;
    background: var(--first-color); /* Fallback or var */
    color: white;
    border-bottom-right-radius: 2px;
}

.chat-message.bot {
    align-self: flex-start;
    background: var(--container-color);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    color: var(--text-color);
    border-bottom-left-radius: 2px;
    border: 1px solid var(--border-color);
}

.chat-search-container input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-color);
    font-size: 1rem;
    font-family: 'Poppins', sans-serif;
    padding-right: 10px;
}

.chat-search-container input::placeholder {
    color: var(--text-color-light);
}

.chat-search-container button {
    background: transparent;
    border: none;
    color: var(--text-color);
    font-size: 1.2rem;
    cursor: pointer;
    transition: transform 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-search-container button:hover {
    transform: translateX(5px);
    color: var(--first-color);
}

/* Close Button Specific Style */
.chat-close-btn {
    margin-right: 10px;
    font-size: 1.2rem;
    color: var(--text-color-light);
    cursor: pointer;
    transition: color 0.3s ease;
}

.chat-close-btn:hover {
    color: var(--first-color);
    transform: scale(1.1);
}

/* Chat Launcher Button */
.chat-launcher-btn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    background: var(--first-color); /* Or brand color */
    color: white;
    border-radius: 50%;
    border: none;
    box-shadow: 0 4px 15px var(--first-color-light); /* Glow matching first-color */
    display: flex; /* Hidden by default via JS if chat is open, or use class */
    align-items: center;
    justify-content: center;
    font-size: 24px;
    cursor: pointer;
    z-index: 1000;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.chat-launcher-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px var(--first-color-alt);
}

/* Ensure Chat Animation Classes are consistent */
.chat-search-container.chat-hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px) translateX(-50%); /* Adjust based on positioning context */
}

/* For Global Widget specifically */
.chat-search-container.global-widget.chat-hidden {
    transform: translateY(20px); /* Just down */
}

.chat-search-container.chat-visible {
    opacity: 1;
    pointer-events: all;
    transform: translateY(0) translateX(-50%);
}
.chat-search-container.global-widget.chat-visible {
    transform: translateY(0);
}

/* Toggle (Chevron) Button */
.chat-toggle-btn {
    margin-right: 10px;
    font-size: 1.4rem;
    color: var(--text-color-light);
    cursor: pointer;
    transition: transform 0.3s ease, color 0.3s ease;
    background: transparent;
    border: none;
}

.chat-toggle-btn:hover {
    color: var(--first-color);
}

/* History Collapsed State */
.chat-history {
    transition: max-height 0.4s ease, opacity 0.3s ease, margin 0.3s ease;
    overflow: hidden; /* Ensure hide works */
}

.chat-history.collapsed {
    max-height: 0 !important;
    opacity: 0;
    margin-bottom: 0;
    pointer-events: none;
}
