/* 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(255, 255, 255, 0.1);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-radius: 30px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    padding: 0 20px;
    z-index: 10;
    opacity: 0; /* Hidden initially, JS makes it visible? Or keyframe? */
    /* Original logic was specific to Hero. We need to make it universal. */
    transition: all 0.5s ease-in-out;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

/* 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: 24px;
    left: auto;
    right: 24px;
    transform: none;
    width: 380px;
    max-width: calc(100vw - 48px);
    height: 60px;
    z-index: 1001;
    background:
        linear-gradient(135deg, rgba(24, 18, 22, 0.78) 0%, rgba(14, 12, 16, 0.82) 100%);
    backdrop-filter: blur(28px) saturate(1.6);
    -webkit-backdrop-filter: blur(28px) saturate(1.6);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 34px;
    padding: 0 8px 0 20px;
    box-shadow:
        0 24px 60px -18px rgba(0, 0, 0, 0.75),
        0 0 0 1px rgba(255, 255, 255, 0.04),
        inset 0 1px 0 rgba(255, 255, 255, 0.08),
        inset 0 -1px 0 rgba(0, 0, 0, 0.35);
    opacity: 1;
    overflow: hidden;
}

/* Subtle neutral top-edge highlight */
.chat-search-container.scrolled::before,
.chat-search-container.global-widget::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    padding: 1px;
    background: linear-gradient(135deg,
        rgba(255, 255, 255, 0.12) 0%,
        rgba(255, 255, 255, 0.02) 55%,
        rgba(255, 255, 255, 0.05) 100%);
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
            mask-composite: exclude;
    pointer-events: none;
    opacity: 0.9;
}

/* Mobile Responsive Adjustments */
@media (max-width: 768px) {
    .chat-search-container.scrolled,
    .chat-search-container.global-widget {
        width: auto;
        left: 12px;
        right: 12px;
        bottom: 16px;
        max-width: none;
    }
}

/* ==== Minimize / Launcher (small bubble) ==== */
.chat-minimize-btn {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.45);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 6px 8px;
    margin-left: 4px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.chat-minimize-btn:hover {
    color: var(--first-color);
    background: rgba(255, 255, 255, 0.06);
    transform: scale(1.05);
}

.chat-search-container.chat-minimized {
    opacity: 0 !important;
    pointer-events: none !important;
    transform: translateY(20px) scale(0.92) !important;
    transition:
        opacity 0.22s ease,
        transform 0.25s cubic-bezier(0.22, 1, 0.36, 1) !important;
}

.chat-launcher-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 58px;
    height: 58px;
    background:
        linear-gradient(135deg, rgba(24, 18, 22, 0.78) 0%, rgba(14, 12, 16, 0.82) 100%),
        rgba(195, 45, 65, 0.08);
    backdrop-filter: blur(22px) saturate(1.5);
    -webkit-backdrop-filter: blur(22px) saturate(1.5);
    color: rgba(255, 255, 255, 0.88);
    border-radius: 50%;
    border: 1px solid rgba(195, 45, 65, 0.45);
    box-shadow:
        0 18px 44px -14px rgba(0, 0, 0, 0.65),
        0 8px 18px -8px rgba(0, 0, 0, 0.45),
        inset 0 1px 0 rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.55rem;
    cursor: pointer;
    z-index: 1001;
    opacity: 0;
    transform: translateY(20px) scale(0.85);
    transition:
        opacity 0.25s ease,
        transform 0.3s cubic-bezier(0.22, 1, 0.36, 1),
        box-shadow 0.3s ease;
}

.chat-launcher-btn[hidden] { display: none; }

.chat-launcher-icon {
    width: 24px;
    height: 24px;
    stroke-width: 1.4;
    transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

.chat-launcher-btn:hover .chat-launcher-icon {
    transform: scale(1.08) rotate(-4deg);
}

.chat-launcher-btn.chat-launcher-visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.chat-launcher-btn:hover {
    transform: translateY(-2px);
    border-color: rgba(195, 45, 65, 0.75);
    color: #fff;
    box-shadow:
        0 22px 50px -14px rgba(0, 0, 0, 0.7),
        0 0 18px rgba(195, 45, 65, 0.25),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

@media (max-width: 768px) {
    .chat-launcher-btn {
        bottom: 16px;
        right: 16px;
        width: 52px;
        height: 52px;
        font-size: 1.4rem;
    }
}

.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: rgba(255, 255, 255, 0.3) 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: rgba(255, 255, 255, 0.3);
    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: rgba(var(--first-color-rgb, 255, 255, 255), 0.2); /* Fallback or var */
    background: #3b82f6; /* Default accent blue if var missing */
    color: white;
    border-bottom-right-radius: 2px;
}

.chat-message.bot {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    color: white;
    border-bottom-left-radius: 2px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.chat-search-container input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: rgba(255, 255, 255, 0.95);
    font-size: 0.95rem;
    font-weight: 300;
    letter-spacing: 0.25px;
    font-family: 'Poppins', sans-serif;
    padding-right: 10px;
}

.chat-search-container input::placeholder {
    color: rgba(255, 255, 255, 0.45);
    font-weight: 300;
    letter-spacing: 0.25px;
}

.chat-search-container button {
    background: transparent;
    border: none;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    transition: transform 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 1;
}

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

/* Glass Send button matching .btn-ask-ai language */
.chat-search-container #chat-submit {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: rgba(195, 45, 65, 0.08);
    border: 1px solid rgba(195, 45, 65, 0.45);
    color: rgba(255, 255, 255, 0.88);
    font-size: 1.05rem;
    margin-left: 6px;
    flex-shrink: 0;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
    transition:
        background 0.25s ease,
        border-color 0.25s ease,
        color 0.25s ease,
        transform 0.28s cubic-bezier(0.22, 1, 0.36, 1),
        box-shadow 0.28s ease;
}

.chat-search-container #chat-submit:hover {
    background: rgba(195, 45, 65, 0.18);
    border-color: rgba(195, 45, 65, 0.75);
    color: #fff;
    transform: translateX(0) translateY(-1px);
    box-shadow:
        0 0 14px rgba(195, 45, 65, 0.25),
        inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.chat-search-container #chat-submit i {
    transform: translateX(1px);
}

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

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

/* 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: rgba(255, 255, 255, 0.7);
    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;
}
