* {
    box-sizing: border-box;
}

html, body, #app {
    height: 100%;
}

body {
    margin: 0;
    font-family: sans-serif;
    font-size: 14px;
}

textarea, select {
    font: inherit;
}

p {
    margin: 0;
}

#app {
    display: grid;
    grid-template-columns: auto 1fr;
}

#sidebar {
    background-color: #f4f4f4;
    padding-top: 1rem;
    padding-bottom: 1rem;
    display: flex;
    flex-direction: column;
    width: 250px;
}

#sidebar > #add-conversation {
    padding: 0.5rem;
    margin-left: 0.5rem;
    margin-right: 0.5rem;
    margin-bottom: 0.5rem;
    user-select: none;
    display: flex;
    align-items: center;
}

#sidebar > #conversations > div {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem;
    margin-bottom: 0.25rem;
    user-select: none;
}

#sidebar > #conversations > div.active, #sidebar > #conversations > div:hover {
    background-color: #b5e2ff;
}

#sidebar > #conversations > div > div:first-child {
    width: 72%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#sidebar > #conversations button {
    border: none;
    background-color: transparent;
    cursor: pointer;
    font-size: 1rem;
}

#main-container {
    display: grid;
    grid-template-rows: auto 1fr auto;
    overflow: auto;
}

#model-selector {
    margin-left: auto;
    margin-right: auto;
    margin-top: 1rem;
    margin-bottom: 1rem;
}

#models, #prompts {
    width: 10rem;
}

#messages {
    overflow: auto;
}

#messages > .system, #messages > .message > .user, #messages > .assistant {
    line-height: 1.2;
}

#messages > .message {
    display: grid;
    grid-template-columns: 1fr auto;
}

#messages > .message > .actions > button {
    visibility: hidden;
    border: none;
    background-color: transparent;
    cursor: pointer;
}

#messages > .message:hover > .actions > button {
    visibility: visible;
}

#messages > .system {
    color: grey;
    font-size: 0.8rem;
}

#messages > .system > textarea {
    font: inherit;
    color: inherit;
    width: 100%;
    outline: 0;
    resize: none;
    border: 0;
    padding: 0;
}

#messages > .message > .user {
    white-space: pre-wrap;
}

#messages > .assistant {
    background-color: #b5e2ff;
    padding: 0.5rem;
}

#messages > .assistant .code-block {
    margin-top: 0.5rem;
}

#messages > .assistant .code-block > .code-block-header {
    background-color: #ffb5b5;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.25rem 0.5rem;
    border-left: 1px solid darkgrey;
    border-right: 1px solid darkgrey;
    border-top: 1px solid darkgrey;
}

#messages > .assistant .code-block > .code-block-header > button {
    display: flex;
    align-items: center;
}

#messages > .assistant pre {
    margin: 0;
}

#messages > .assistant pre > code {
    width: 100%;
    display: inline-block;
    overflow-x: auto;
    border: 1px solid darkgrey;
    padding: 0.5rem;
    background-color: white;
}

#messages > .error {
    background-color: #ffb5b5;
    padding: 0.5rem;
}

#messages > div:not(:first-child) {
    margin-top: 0.5rem;
}

#messages > div p:not(:first-child) {
    margin-top: 0.5rem;
}

#messages, #user-input-container-container {
    padding: 0 30%;
}

#messages {
    padding-bottom: 2.5rem;
}

#action-buttons {
    display: grid;
    place-items: center;
    position: relative;
}

#action-buttons > button {
    position: absolute;
    display: none;
    align-items: center;
    justify-content: center;
    bottom: 0;
}

#user-input-container-container {
    margin-top: 1rem;
    margin-bottom: 2rem;
}

#user-input-container {
    display: grid;
    grid-template-columns: 1fr auto;
    border: 1px solid darkgrey;
}

#user-input {
    resize: none;
    padding: 0.5rem;
    outline: 0;
    border: 0;
}

#top-bar {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 50px;
    background-color: #b5e2ff;
    justify-content: space-between;
    align-items: center;
    padding: 0 15px;
    z-index: 3;
}

/* Mobile devices */
@media (max-width: 768px) {
    #top-bar {
        display: flex;
    }

    #sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 1;
    }

    #sidebar {
        position: fixed;
        left: -250px;
        top: 50px; /* Adjust the top position to account for the top bar */
        height: calc(100% - 50px); /* Adjust the height to account for the top bar */
        transition: left 0.3s;
        z-index: 2;
        box-shadow: 4px 0 8px rgba(0, 0, 0, 0.2);
    }

    #sidebar.open {
        left: 0;
    }

    #sidebar-overlay.open {
        display: block;
    }

    #app {
        grid-template-columns: 1fr;
        padding-top: 50px; /* Add padding to account for the top bar */
    }

    #messages, #user-input-container-container {
        padding: 0 10%;
    }

    #messages {
        padding-bottom: 2.5rem;
    }
}

@keyframes pulse {
    50% {
        opacity: 0.5;
    }
}

.animate-pulse {
    opacity: 1;
    animation: pulse 2s cubic-bezier(.4,0,.6,1) infinite;
}
