@keyframes animateGlow {
    0% {
        background-position: 0 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0 50%;
    }
}

@keyframes typingDot {

    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: 0.5;
    }

    30% {
        transform: translateY(-4px);
        opacity: 1;
    }
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/*Chat Main*/
.chat-container {
    position: relative;
    width: 100%;
    height: 700px;
    border-radius: 20px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    will-change: height;
    border: 0.5px solid #73b236;
    background: #fff;
    background: linear-gradient(103deg, rgba(114, 178, 53, 0.1) 0%, 15%, rgba(255, 255, 255, 0) 100%);
    isolation: isolate;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 0px 30px 10px 30px;
    box-sizing: border-box;
    transition: padding-top 0.6s cubic-bezier(0.4, 0, 0.2, 1);

    @media (max-width: 768px) {
        padding-left: 20px;
        padding-right: 20px;
    }

    .chat-background-glow {
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        z-index: -1;
        height: 350px;
        width: 350px;
        border-radius: 50%;
        filter: blur(90px);
        background: linear-gradient(270deg, #73b236, #9FF3D3FF);
        background-size: 200% 200%;
        animation: animateGlow 6s ease infinite;
        pointer-events: none;
        transition: top 2s ease-out, left 2s ease-out, transform 0.5s ease;

        @media (max-width: 768px) {
            width: 170px;
            height: 170px;
        }
    }

    .chat-container-intro {
        opacity: 0;
        visibility: hidden;
        transform: translateY(-20px);
        transition: opacity 0.4s ease, transform 0.4s ease, visibility 0.4s;
        margin: 0;
        height: 0;
        overflow: hidden;
    }

    &.pure {
        display: flex;
        flex-direction: column;
        align-items: center;
        /* Use padding-top instead of justify-content for smooth animation */
        padding-top: 220px;
        gap: 60px;

        @media (max-width: 768px) {
            gap: 40px;
            padding-top: 200px;
        }

        .chat-container-intro {
            display: block;
            opacity: 1;
            visibility: visible;
            transform: translateY(0);
            height: auto;
            text-align: center;
            font-family: "OpenSans-Bold", sans-serif;
            font-weight: bold;
            font-size: 28px;
            margin-bottom: -60px;

            @media (max-width: 768px) {
                margin-bottom: -40px;
            }
        }

        .chat-box {
            opacity: 0;
            visibility: hidden;
            height: 0;
            padding: 0;
            pointer-events: none;
        }

        .input-box {
            position: relative;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            width: 100%;
            max-width: 520px;
            margin: 0;
            transform: translateY(0px);
            transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);

            textarea {
                height: 100px;
                min-height: 100px;
                max-height: 300px;
                padding: 12px 40px 12px 20px;
                border-radius: 12px;
                transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);

                &::placeholder {
                    color: #73b236;
                    font-size: 12px;
                }
            }

            span {
                display: block;
            }

            button {
                border-radius: 10px;
                margin-top: auto;
                margin-bottom: 0;
                bottom: 6px;

                &:hover {
                    border-radius: 50%;

                    svg {
                        transform: rotate(-90deg);
                    }
                }
            }
        }
    }

}

/*Sidebar*/
.toggle-sidebar {
    position: absolute;
    top: 20px;
    left: 20px;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 7px;
    background: #f8f8f8aa;
    backdrop-filter: blur(20px);
    cursor: pointer;
    transition: .34s cubic-bezier(0.215, 0.610, 0.355, 1.000);
    border: none;
    z-index: 9;

    &:focus,
    &:active {
        outline: none;
    }

    svg {
        width: 20px;
        height: auto;
        transition: .34s cubic-bezier(0.215, 0.610, 0.355, 1.000);

        path {
            transition: .34s cubic-bezier(0.215, 0.610, 0.355, 1.000);
        }
    }

    &:hover {
        transform: scale(1.1, 1.1);

        svg {

            path {
                transform: translateX(3px);
            }
        }
    }

    &.toggled {
        left: calc(20% + 10px);

        @media (max-width: 1350px) {
            left: calc(25% + 10px);
        }

        @media (max-width: 1024px) {
            left: calc(40% + 10px);
        }

        @media (max-width: 768px) {
            left: calc(100% - 40px);
        }

        svg {

            path {
                transform: translateX(3px);
            }
        }

        &:hover {

            svg {

                path {
                    transform: translateX(0px);
                }
            }
        }
    }
}

.chat-sidebar {
    position: absolute;
    left: 0;
    top: 0;
    width: 20%;
    height: 100%;
    max-height: 700px;
    box-sizing: border-box;
    background: rgba(248, 248, 248, .4);
    backdrop-filter: blur(10px);
    padding: 20px;
    z-index: 4;
    border-right: 0.5px solid rgba(114, 178, 53, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: .45s cubic-bezier(0.215, 0.610, 0.355, 1.000);
    transform: translateX(-100%);
    pointer-events: none;
    display: flex;
    flex-direction: column;
    gap: 10px;

    @media (max-width: 1350px) {
        width: 25%;
    }

    @media (max-width: 1024px) {
        width: 40%;
    }

    @media (max-width: 768px) {
        width: 90%;
    }

    &.open {
        pointer-events: auto;
        transform: translateX(0);
        opacity: 1;
        visibility: visible;
    }

    button {
        position: relative;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 5px;
        width: 100%;
        height: 40px;
        border-radius: 7px;
        background: var(--c-green);
        border: none;
        cursor: pointer;
        font-size: 14px;
        color: white;
        transition: .34s cubic-bezier(0.215, 0.610, 0.355, 1.000);

        &:hover {
            background: #000;
        }
    }

    .chat-sidebar-newchat {
        position: relative;
        width: 100%;
        min-height: 40px;
    }

    .chat-sidebar-search {
        position: relative;
        display: flex;
        flex-direction: column-reverse;
        align-items: center;
        gap: 10px;
        width: 100%;
        margin-bottom: 0;

        input {
            position: relative;
            width: 100%;
            border-radius: 7px;
            border: 0.8px solid #73b236;
            padding: 11.5px 12px;
            box-sizing: border-box;
            color: #535353;
            font-family: inherit;
            font-size: 12px;
            height: auto;
            text-align: center;
            background: rgba(255, 255, 255, 0.6);
            backdrop-filter: blur(10px);

            &:focus,
            &:active {
                outline: none;
            }

            &::placeholder {
                color: rgba(83, 83, 83, 0.2);
            }
        }
    }

    .no-chats {
        text-align: center;
        font-size: 12px;
        color: #18233b;
    }

    .conversation-list {
        position: relative;
        display: flex;
        flex-direction: column;
        gap: 10px;
        width: 100%;
        height: -webkit-fill-available;
        overflow-y: scroll;

        .conversation-item {
            position: relative;
            background: rgba(243, 245, 242, 0.7);
            backdrop-filter: blur(5px);
            border-radius: 7px;
            padding: 8px;
            display: flex;
            align-items: flex-start;
            justify-content: space-between;
            gap: 7px;
            cursor: pointer;
            transition: .34s cubic-bezier(0.215, 0.610, 0.355, 1.000);

            input {
                width: 10px;
                height: 10px;
                min-width: 10px;
                min-height: 10px;
                max-width: 10px;
                max-height: 10px;
                cursor: pointer;
            }

            .conv-info {
                display: flex;
                flex-direction: column;
                gap: 3px;
                margin-left: 0;
                margin-right: auto;
                transform: translateY(-2px);

                @media (max-width: 1350px) {
                    max-width: 84%;
                }

                @media (max-width: 1150px) {
                    max-width: 80%;
                }

                .conv-title {
                    font-size: 12px;
                    font-family: "OpenSans-Bold", sans-serif;
                    font-weight: bold;
                    text-overflow: ellipsis;
                    overflow: hidden;
                    white-space: nowrap;
                    width: 100%;
                    max-width: 149px;

                    @media (max-width: 1350px) {
                        max-width: 100%;
                    }
                }

                .conv-date {
                    color: #bbbbbb;
                    font-size: 10px;
                }
            }

            button {
                background: none;
                padding: 0;
                height: auto;
                width: fit-content;
                color: var(--c-black);
            }

            &:hover {
                transform: scale(1.01, 1.01);
                opacity: .9;
            }
        }
    }

    .chat-sidebar-footer {
        margin-top: auto;
        display: flex;
        flex-direction: column;
        align-items: center;
        width: 100%;
        gap: 10px;

        button {
            background: #000;

            &#delete-selected-btn {
                background: none;
                border: 1px solid #000;
                color: #000;

                &:hover {
                    background: #000;
                    color: #fff;
                }
            }

            &:hover {
                background: var(--c-green);
            }
        }
    }
}

/*Chats*/
.chat-box {
    width: 100%;
    height: 100%;
    max-height: 700px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding-top: 50px;
    padding-bottom: 190px;
    opacity: 1;
    visibility: visible;
    transition: opacity 0.5s ease 0.2s, visibility 0.5s ease 0.2s;
    overflow-y: scroll;
    overflow-x: hidden;
    scrollbar-color: #74b23609 transparent;
    scrollbar-width: thin;

    @media (max-width: 768px) {
        padding-top: 30px;
        padding-bottom: 150px;
    }

    .loading-history {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 100%;
        height: 100%;
        min-height: 100px;

        &::after {
            content: "";
            width: 30px;
            height: 30px;
            border: 3px solid #f3f3f3;
            border-top: 3px solid #73b236;
            border-radius: 50%;
            animation: spin 1s linear infinite;
        }
    }

    .chat-box-date {
        text-align: center;
        font-size: 8px;
        color: #7E7E7E;
        font-weight: normal;
    }

    .chat-message {
        position: relative;
        display: flex;
        width: 100%;
        max-width: 100%;
        font-size: 12px;
        flex-wrap: wrap;

        .chat-message-container {
            position: relative;
            padding: 4px 10px;
            border-radius: 10px;
            width: 100%;
            font-size: 12px;
            background: #EDEDED;
            display: flex;
            flex-direction: column;
            gap: 20px;

            * {
                margin: 0 !important;
            }

            p {
                margin: 5px 0 !important;

                strong {
                    font-weight: normal !important;
                }
            }
        }

        .chat-message-time {
            margin: 3px 0 0 0;
            width: 100%;
            color: #7E7E7E;
            font-size: 8px;
            text-align: left;
        }

        &.user {
            align-self: flex-end;
            width: fit-content;
            max-width: 750px;

            .chat-message-container {
                background: #73b236;
                color: white;
                padding-top: 10px;
                padding-bottom: 10px;
                font-size: 12px !important;

                * {
                    font-size: 12px !important;
                    color: white !important;
                }

                p {
                    margin: 0 !important;
                    line-height: 1.5 !important;
                }
            }

            .chat-message-time {
                text-align: right;
                margin: 3px 0 0 0;
            }
        }

        &.assistant {
            align-self: flex-start;
            gap: 0;
            width: 100%;
            max-width: calc(100% - 200px);
            margin-inline: auto;

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

            .chat-message-container {
                width: 100%;
                padding: 0;
                background: none !important;
                display: flex;
                flex-direction: column;
                gap: 15px;

                @media (max-width: 768px) {
                    gap: 10px;
                }

                h1,
                h2 {
                    font-size: 22px !important;
                    font-family: "OpenSans-Bold", sans-serif;
                    font-weight: bold;
                    text-transform: uppercase;
                    margin-top: 10px !important;

                    @media (max-width: 768px) {
                        font-size: 20px !important;
                    }
                }

                h3,
                h4,
                h5,
                h6 {
                    font-family: "OpenSans-Bold", sans-serif;
                    font-size: 18px !important;
                    font-weight: bold;
                    margin-top: 10px !important;

                    @media (max-width: 768px) {
                        font-size: 16px !important;
                    }
                }

                p {
                    margin: 0 !important;
                }

                p,
                div,
                a {
                    font-size: 16px !important;

                    @media (max-width: 768px) {
                        line-height: 1.8 !important;
                        font-size: 14px !important;
                    }
                }

                ul,
                ol {
                    display: flex;
                    flex-direction: column;
                    gap: 10px;
                    list-style-position: inside;

                    li {
                        font-size: 16px !important;

                        p {
                            display: inline !important;
                            margin: 0 !important;
                            padding: 0 !important;
                        }
                    }
                }

                strong {
                    font-family: "OpenSans-Bold", sans-serif;
                    font-weight: bold;
                }
            }

            a {
                color: #000;
                text-decoration: underline;

                &.is-private-link {
                    position: relative;
                    text-decoration: none;

                    &:before {
                        font-family: "FontAwesome";
                        /* or "Font Awesome 6 Free" */
                        font-weight: 900;
                        /* Solid icons need font-weight 900 */
                        content: "\f023";
                        /* Unicode for fa-lock */
                        background: #ff0000;
                        color: #fff;
                        padding: 3px 4px;
                        border-radius: 5px;
                        margin-right: 5px;

                    }

                    &:after {
                        content: "";
                        width: calc(100% - 25px);
                        height: 2px;
                        background: #ff0000;
                        position: absolute;
                        bottom: 1.5px;
                        right: 0;
                        z-index: -1;
                        transition: .34s cubic-bezier(0.215, 0.610, 0.355, 1.000);
                    }

                    &:hover {

                        &:after {
                            background: #000;
                            transform: translateY(1.5px);
                        }
                    }
                }
            }

            .chat-message-feedback {
                display: flex;
                gap: 10px;
                margin-top: 10px !important;

                .feedback-btn {
                    background: none;
                    border: 1px solid #ddd;
                    border-radius: 5px;
                    padding: 4px 6px;
                    cursor: pointer;
                    color: #7E7E7E;
                    transition: .34s cubic-bezier(0.4, 0, 0.2, 1);
                    display: flex;
                    align-items: center;
                    justify-content: center;

                    &:hover {
                        border-color: #73b236;
                        color: #73b236;
                        background: rgba(115, 178, 54, 0.05);
                    }

                    &.active {
                        background: #73b236;
                        color: #fff;
                        border-color: #73b236;
                    }

                    svg {
                        width: 14px;
                        height: 14px;
                    }
                }
            }
        }

        h1,
        h2,
        h3 {
            font-size: 18px;
        }

        h4 {
            font-size: 15px;
        }
    }
}

/*Input*/
.input-box {
    position: absolute;
    left: 0;
    right: 0;
    top: auto;
    bottom: 10px;
    margin: auto auto 0 auto;
    width: calc(100% - 200px);
    max-width: calc(100% - 200px);
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);

    @media (max-width: 768px) {
        width: calc(100% - 20px);
        max-width: calc(100% - 20px);
    }

    label {
        position: relative;
        display: flex;
        width: 100%;
        height: auto;
    }

    textarea {
        position: relative;
        width: 100%;
        border-radius: 30px;
        border: 0.8px solid #73b236;
        background: rgba(255, 255, 255, 0.6);
        padding: 10px 40px 12px 20px;
        color: #535353;
        font-family: inherit;
        font-size: 14px;
        font-weight: bold;
        height: 43px;
        min-height: 43px;
        max-height: 43px;
        box-sizing: border-box;
        resize: none;
        backdrop-filter: blur(10px);

        &:focus,
        &:active {
            outline: none;
        }

        &::placeholder {
            color: rgba(83, 83, 83, 0.2);
        }
    }

    span {
        display: none;
        text-align: center;
        font-size: 10px;
        color: #3f542da8;
        margin-top: 5px;
    }

    button {
        position: absolute;
        right: 6px;
        bottom: 0;
        top: 0;
        margin: auto;
        background: #73b236;
        width: 35px;
        height: 35px;
        display: flex;
        align-items: center;
        justify-content: center;
        border: none;
        border-radius: 50%;
        cursor: pointer;
        transition: .34s cubic-bezier(0.215, 0.610, 0.355, 1.000);

        svg {
            width: 18px;
            height: auto;
            transition: .34s cubic-bezier(0.215, 0.610, 0.355, 1.000);
        }

        &:hover {
            background: #0095ff;

            svg {
                transform: rotate(-90deg);
            }
        }
    }
}

/* Typing Dots */
.typing-dots {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0;
    border-radius: 10px;
    width: fit-content;

    span {
        width: 8px;
        height: 8px;
        background: #7E7E7E;
        border-radius: 50%;
        display: inline-block;
        animation: typingDot 1.4s infinite ease-in-out both;

        &:nth-child(1) {
            animation-delay: -0.32s;
        }

        &:nth-child(2) {
            animation-delay: -0.16s;
        }
    }
}

.chat-message.assistant .typing-dots {
    margin-inline: 0;
}