@import url('https://fonts.googleapis.com/css2?family=Inter:wght@100..900&display=swap');

:root {
    --color-1: rgb(0, 0, 0);
    --color-2: rgb(10, 11, 13);
    --color-3: rgb(20, 22, 25);
    --color-4: rgb(40, 44, 50);
    --color-5: rgb(100, 103, 107);
    --color-6: rgb(225, 232, 245);
    --color-7: rgb(248, 251, 255);
    --color-8: rgb(20, 200, 100);
    --color-9: rgb(10, 40, 60);
    --color-10: rgb(0, 160, 255);
    --animation-duration: .2s;
    --animation-function: ease-in-out;
}

* {
    font-family: "Inter", sans-serif;
    box-sizing: border-box;
    margin: 0;  
    padding: 0;
    border: none;
    outline: none;
    background: none;
}

body {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100dvh;
    overflow: hidden;
    background: var(--color-6);
}

button {
    cursor: pointer;
}

.chat {
    display: flex;
    flex-direction: column;
    width: 350px;
    height: 600px;
    --side-padding: 20px;
    --panel-height: 70px;
    --border-radius: 10px;
    transition:
        width var(--animation-duration) var(--animation-function),
        height var(--animation-duration) var(--animation-function);
}

.chat > * {
    width: 100%;
}

.chat .header, .chat .input {
    height: var(--panel-height);
    flex-shrink: 0;
    transition:
        border-radius var(--animation-duration) var(--animation-function);
}

.chat .messages, .chat .input {
    background: var(--color-2);
}

.chat .header {
    display: flex;
    align-items: center;
    padding: 0 var(--side-padding);
    background: var(--color-1);
    border-top-left-radius: var(--border-radius);
    border-top-right-radius: var(--border-radius);
}

.chat .avatar {
    --size: 38px;
    width: var(--size);
    height: var(--size);
    flex-shrink: 0;
    transition:
        transform var(--animation-duration) var(--animation-function),
        opacity var(--animation-duration) var(--animation-function);
}

.chat .avatar.hidden,
.chat .message-group .message .content.hidden,
.chat .typing-indicator.hidden img {
    transform: scale(0.85);
    opacity: 0;
}

.chat .avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    image-rendering: -webkit-optimize-contrast;
}

.chat .avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    image-rendering: -webkit-optimize-contrast;
}

.chat .header .info {
    display: flex;
    flex-direction: column;
    margin-left: var(--side-padding);
}

.chat .header .info .name {
    font-size: 16px;
    font-weight: 500;
    color: var(--color-7);
}

.chat .header .info .status {
    margin-top: 4px;
    font-size: 12px;
    color: var(--color-7);
}

.chat .header .info .status:before {
    content: '';
    --size: 8px;
    width: var(--size);
    height: var(--size);
    border-radius: 50%;
    display: inline-block;
    margin-right: 6px;
    background: var(--color-8);
}

.chat .messages {
    display: flex;
    height: 100%;
    overflow: hidden;
}

.chat .messages-scroller {
    display: flex;
    flex-direction: column;
    width: 100%;
    min-height: 100%;
    max-height: 100%;
    overflow-y: scroll;
    --large-border-radius: 12px;
    --small-border-radius: 4px;
    --scrollbar-width: 6px;
    --avatar-size: 26px;
    padding-left: var(--side-padding);
    padding-right: calc(var(--side-padding) - var(--scrollbar-width));
    padding-bottom: var(--side-padding);
    scroll-behavior: smooth;
}

.chat .messages-scroller::-webkit-scrollbar {
    width: var(--scrollbar-width);
}

.chat .messages-scroller::-webkit-scrollbar-track {
    background: var(--color-2);
}

.chat .messages-scroller::-webkit-scrollbar-thumb {
    background: var(--color-4);
}

.chat .messages-scroller::-webkit-scrollbar-thumb:hover {
    background: var(--color-5);
}

.chat .date-separator {
    width: 100%;
    height: 30px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 10px 0;
    font-size: 12px;
    font-weight: 500;
    color: var(--color-5);
}

.chat .message-group {
    display: flex;
    flex-direction: column;
}

.chat .messages .message-group:not(:first-child) {
    margin-top: 10px;
}

.chat .message-group .message {
    display: flex;
    width: fit-content;
    height: var(--height);
    overflow: hidden;
}

.chat .message-group .message:not(:last-child) {
    margin-bottom: 10px;
}

.chat .message-group .message .content {
    display: block;
    width: fit-content;
    padding: 10px 14px;
    align-items: baseline;
    font-size: 14px;
    line-height: 20px;
    color: var(--color-7);
    background: var(--color-3);
    border-radius: var(--large-border-radius);
    transition:
        transform var(--animation-duration) var(--animation-function),
        opacity var(--animation-duration) var(--animation-function),
        border-radius var(--animation-duration) var(--animation-function);
}

.chat .message-group .message .content:after {
    content: var(--time);
    margin-top: auto;
    margin-left: 10px;
    line-height: 20px;
    font-size: 10px;
    font-weight: 600;
    color: var(--color-5);
    float: right;
}

.chat .message-group.left {
    position: relative;
    padding-left: var(--avatar-size);
}

.chat .message-group.left .avatar {
    --size: var(--avatar-size);
    position: absolute;
    left: 0;
}

.chat .message-group.left .message {
    margin-left: 10px;
}

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

.chat .message-group.right .message .content {
    background: var(--color-9);
}

.chat .message-group.right .message .content:after {
    color: var(--color-7);
    font-weight: 400;
    opacity: 0.4;
}

.message-group.left + .message-group.right,
.message-group.right + .message-group.left {
    margin-top: 20px;
}

.message-group.left .content {
    transform-origin: top left;
}

.message-group.right .content {
    transform-origin: top right;
}

.date-separator + .message-group {
    margin-top: 0px !important;
}

.message-group.left:not(:has(.message:nth-child(3))) .message .content,
.message-group.right:not(:has(.message:nth-child(2))) .message .content {
    border-radius: var(--large-border-radius) !important;
}

.message-group.left .message .content {
    border-top-left-radius: var(--small-border-radius);
    border-bottom-left-radius: var(--small-border-radius);
}

.message-group.left .message:nth-child(2) .content {
    border-top-left-radius: var(--large-border-radius);
    border-bottom-left-radius: var(--small-border-radius);
}

.message-group.left .message:last-child .content {
    border-top-left-radius: var(--small-border-radius);
    border-bottom-left-radius: var(--large-border-radius);
}

.message-group.right .message .content {
    border-top-right-radius: var(--small-border-radius);
    border-bottom-right-radius: var(--small-border-radius);
}

.message-group.right .message:first-child .content {
    border-top-right-radius: var(--large-border-radius);
    border-bottom-right-radius: var(--small-border-radius);
}

.message-group.right .message:last-child .content {
    border-top-right-radius: var(--small-border-radius);
    border-bottom-right-radius: var(--large-border-radius);
}

.chat .input {
    position: relative;
    display: flex;
    padding: var(--side-padding);
    padding-top: 0;
    border-bottom-left-radius: var(--border-radius);
    border-bottom-right-radius: var(--border-radius);
}

.chat .input:before {
    content: '';
    position: absolute;
    left: 0;
    bottom: 100%;
    width: 100%;
    height: 20px;
    background: linear-gradient(to top, var(--color-2), transparent);
}

.chat .input-wrap {
    display: flex;
    width: 100%;
    height: 100%;
}

.chat textarea {
    width: 100%;
    height: 100%;
    --font-size: 14px;
    --line-height: 20px;
    --center-y-padding: calc((var(--panel-height) - var(--side-padding)) / 2 - var(--line-height ) / 2);
    padding: var(--center-y-padding) var(--side-padding);
    font-size: var(--font-size);
    line-height: var(--line-height);
    color: var(--color-7);
    outline: 2px solid var(--color-3);
    border-radius: var(--panel-height);
    text-overflow: ellipsis;
    z-index: 2;
    resize: none;
}

.chat textarea::-webkit-scrollbar {
    width: 0;
    height: 0;
    background: transparent;
}

.chat textarea::placeholder {
    font-size: 14px;
    font-weight: 500;
    color: var(--color-5);
}

.chat .send-btn {
    display: flex;
    justify-content: center;
    align-items: center;
    aspect-ratio: 1 / 1;
    height: 100%;
    flex-shrink: 0;
    background: var(--color-7);
    margin-left: var(--side-padding);
    border-radius: 50%;
}

.chat .send-btn svg {
    width: 24px;
    height: 24px;
    color: var(--color-0);
}

.chat code {
    background: rgba(0, 0, 0, 0.3);
    padding: 2px 4px;
    border-radius: 4px;
}

.chat hr {
    height: 1px;
    background: var(--color-7);
    opacity: 0.05;
}

.chat .typing-indicator {
    display: flex;
    --height: 40px;
    height: var(--height);
    transition: height var(--animation-duration) var(--animation-function);
}

/* .chat .typing-indicator.hidden { height: 0; } */

.chat .message-group.left + .typing-indicator {
    padding-left: calc(var(--avatar-size) + 10px);
}

.message-group.left:has(.message) + .typing-indicator {
    margin-top: 10px;
}

.chat .typing-indicator img {
    height: var(--height);
    padding: 15px;
    height: 100%;
    background: var(--color-3);
    border-radius: var(--large-border-radius);
    transform-origin: top left;
    transition:
        transform var(--animation-duration) var(--animation-function),
        opacity var(--animation-duration) var(--animation-function);
}

.chat .message .content .emoji {
    --size: 20px;
    width: var(--size);
    height: var(--size);
    display: inline-block;
    vertical-align: bottom;
}

.chat .message .content a {
    color: var(--color-10);
    font-weight: 500;
    text-decoration: none;
}

.chat .message .content a:hover {
    text-decoration: underline !important;
}

@media (max-width: 800px) {
    .chat {
        width: 100%;
        height: 100%;
    }

    .chat .header, .chat .input {
        border-radius: 0;
    }
}

img.loading {
    opacity: 0;
}