/* Overlay background */
#page-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(2px);
    /* Dulling effect */
    z-index: 999;
    /* Ensure it's behind the chatbot but above other elements */
    transition: opacity 0.3s ease-in-out;
}

.chatbot-logo img {
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#chatbot-overlay {
    position: fixed;
    z-index: 9999;
    bottom: 16px;
    right: 0%;
    width: 400px;
    max-width: 400px;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.25);
    transition: all 0.35s ease;
}

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

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

.header-container {
    padding: 12px 16px;
    background: linear-gradient(135deg, #4CAF50, #81C784);
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: white;
}

.logo-section {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.chat-container {
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background-color: #ffffff;
}

.chat-header {
    color: #FFFFFF;
    text-align: center;
    font-weight: 400;
    font-size: 24px;
}

.chat-body {
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    background: #fafafa;
}

.chat-sub-body {
    height: 64vh;
    max-height: 70vh;
    border-radius: 16px;
    padding: 12px 16px;
    overflow-y: auto;
    scrollbar-width: none;
    /* For Firefox */
    -ms-overflow-style: none;
    /* For IE and Edge */
    scroll-behavior: smooth;
    /* Smooth scroll */
}

/* Message bubbles */
.chat-message {
    display: flex;
    flex-direction: column;
    margin: 8px 0;
    animation: fadeSlide 0.3s ease;
}

@keyframes fadeSlide {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

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

.chat-message.user {
    align-items: flex-end;
}

.chat-message.bot {
    align-items: flex-start;
}

.chat-message .message-bubble {
    max-width: 360px;
    width: max-content;
    padding: 8px;
    border-radius: 16px;
    font-size: 14px;
    font-weight: 400;
    line-height: 22px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.user-message {
    font-size: 14px;
    font-weight: 400;
    line-height: 22px;
    margin: 0px;
}

.res-message {
    font-size: 14px;
    font-weight: 400;
    line-height: 21px;
    margin: 0px;
    margin-top: 6px;
}

.chat-message.user .message-bubble {
    background: #4CAF50;
    color: #fff;
    border-bottom-right-radius: 4px;
    transition: transform 0.2s;
}

.chat-message.user .message-bubble:hover {
    transform: scale(1.02);
}

.chat-message.bot .message-bubble {
    background: #e8f5e9;
    color: #333;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.chat-footer {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    padding-top: 0px;
    background: #fff;
    border-top: 1px solid #eee;
}

.chat-footer input {
    flex: 1;
    border: 1px solid #ccc;
    border-radius: 40px;
    padding: 10px 12px;
    font-size: 14px;
    transition: all 0.3s ease;
}

.chat-footer input:focus {
    border-color: #4CAF50;
    box-shadow: 0 0 6px rgba(76, 175, 80, 0.3);
    outline: none;
}

.chat-footer button {
    background: #4CAF50;
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    margin-left: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 16px;
    transition: transform 0.2s, background 0.3s;
}

.chat-footer button img {
    width: 20px;
}

.chat-footer button:hover {
    background: #388E3C;
    transform: scale(1.1);
}

.close-btn {
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: end;
}

/* Close button */
.close-in {
    width: 42px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: end;
}

.close-in img {
    transition: transform 0.2s ease;
}

.close-in:hover img {
    transform: rotate(90deg) scale(1.1);
}

.chat-date-header {
    text-align: center;
    color: #888;
    font-size: 12px;
    font-weight: 400;
}

.message-time {
    font-size: 10px;
    font-weight: 400;
    color: #888;
    padding-left: 8px;
}

.chat-date-container {
    display: flex;
    align-items: center;
    margin: 0px;
}

.chat-date-line {
    flex: 1;
    border: none;
    border-top: 1px solid #ccc;
    margin: 0px;
    padding: 0px;
}

.chat-sub-body::-webkit-scrollbar {
    display: none;
    /* Hide scrollbar in Chrome/Safari */
}

/* Responsive adjustments */

@media (max-width: 1280px) {
    .chat-sub-body {
        height: 64vh;
    }
}

@media (max-width: 768px) {
    #chatbot-overlay {
        width: 100%;
    }

    .chat-sub-body {
        height: 55vh;
    }

    .chat-footer {
        flex-wrap: wrap;
        padding: 8px 12px;
    }

    .chat-footer input {
        flex: 1;
        margin-bottom: 8px;
    }

    .close-btn {
        justify-content: flex-end;
        padding: 8px 12px;
    }
}

@media (min-width: 320px) and (max-width: 480px) {
    #chatbot-overlay {
        width: 100%;
        height: 100%;
        max-width: 100%;
        top: 0px;
        border-radius: 0px;
    }

    .chat-container {
        height: 100%;
    }

    .chat-message .message-bubble {
        max-width: 320px;
    }

    .chat-sub-body {
        height: 72vh;
        max-height: 100%;
    }

    .chat-footer {
        padding: 12px;
    }

    .chat-footer input {
        font-size: 14px;
    }

    .chat-footer button {
        font-size: 14px;
        width: 36px;
        height: 36px;
    }

    .close-btn {
        padding: 8px 12px;
    }
}

/* Dots Animation Using CSS */
.dots-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 5px;
    height: 20px;
}

.dots-loading span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: #333333;
    animation: dotColorChange 1.5s infinite ease-in-out;
}

.dots-loading span:nth-child(1) {
    animation-delay: 0s;
}

.dots-loading span:nth-child(2) {
    animation-delay: 0.3s;
}

.dots-loading span:nth-child(3) {
    animation-delay: 0.6s;
}

.dots-loading span {
    background-color: #4CAF50;
}

.dots-loading span:nth-child(2) {
    background-color: #81C784;
}

.dots-loading span:nth-child(3) {
    background-color: #FFEB3B;
}

@keyframes dotColorChange {

    0%,
    80%,
    100% {
        transform: scale(1);
        background-color: #333333;
        /* Default */
    }

    40% {
        transform: scale(1.5);
        background-color: #4CAF50;
        /* Active */
    }
}