/* Base styles */
:root {
    --message-padding: 1em;
    --message-radius: 8px;
    --ai-message-radius: 8px 8px 8px 2px;
    --user-message-radius: 8px 8px 2px 8px;
    --user-msg-bg: #005DC4;
    --assistant-msg-bg: #024898;
    --header-bg: #024898;
    --header-height: 60px;
    --avatar-size: 64px;
    --input-height: 40px;
    --button-bg: #009652;
    --button-hover: #24B874;
    --accent: var(--button-bg) !important;
    --accent-foreground: white !important;
    --muted-foreground: white !important;
}

/* Sidebar */
div[data-sidebar="sidebar"] {
    color: gray; /* test rule to show match - bar is hidden now anyway */
}

/* Layout */
.message-step {
    margin: 1em 0;
}

.message-container {
    max-width: min(48rem, 100vw);
}

/* Message styling */
.assistant-message {
    display: flex;
    gap: 1em;
    width: 100%;
    padding: 0.5em;
}

.message-content-wrapper {
    display: flex;
    flex-direction: column;
    gap: 0.5em;
    flex-grow: 1;
    min-width: 150px;
}

/* Avatar styling */
.avatar-outer-wrapper {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.avatar-wrapper {
    display: inline-block;
    width: var(--avatar-size) !important;
    height: var(--avatar-size) !important;
    border-radius: 5px !important;
    overflow: hidden;
}

.avatar-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: transparent;
}

/* Catch any rounded avatars that haven't been processed by JS yet */
.rounded-full {
    border-radius: 5px !important;
}

/* Message content */
.assistant-content {
    width: 100%;
}

/* The entire text response from AI */
.message-prose:has(div.message-paragraph) {
    width: 75%;
}

.message-prose div.message-paragraph:has(span.avatar-title) {
    margin-top: 2px;
    color: #80A3CB !important;
    padding: 0;
    background: none !important;
}

.ai-message .prose div[role="article"] {
    background-color: var(--assistant-msg-bg) !important;
    border-radius: var(--ai-message-radius);
    color: white !important;
    padding: var(--message-padding);
    font-size: 14px;
    line-height: 1.5;
}

.message-paragraph {
    background-color: var(--assistant-msg-bg);
    border-radius: var(--message-radius);
    color: white;
    padding: var(--message-padding);
    margin: 0.5em 0;
    width:100%;
    font-size: 14px;
    line-height: 1.5;
}

.message-heading {
    color: white;
    font-size: 1.5em;
    margin: 1em 0;
    padding-bottom: 0.5em;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

/* User messages - target both old and new structure */
.user-message,
div[id^="step-"] .bg-accent.rounded-3xl {
    background-color: var(--user-msg-bg) !important;
    border-radius: var(--user-message-radius);
    color: white !important;
    padding: var(--message-padding);
    font-size: 14px;
    line-height: 1.5;
}

/* Action buttons */
.message-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    margin-left: -0.375rem;
}

.action-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 2.25rem;
    padding: 0 0.75rem;
    font-size: 0.875rem;
    border-radius: 0.375rem;
    color: var(--muted-foreground);
    transition: background-color 0.2s;
}

.action-button:hover {
    background-color: var(--accent);
}

.copy-button {
    display: none;
}

/* Chat interface */
.chat-interface {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
}

.input-container {
    border-radius: 1.5rem;
    padding: 0.75rem 1rem;
    width: 100%;
    min-height: var(--input-height);
    display: flex;
    flex-direction: column;
}

.message-input {
    width: 100%;
    min-height: 2.5rem;
    max-height: 250px;
    overflow-y: auto;
    border: none;
    background: transparent;
    color: inherit;
    font-size: 0.875rem;
    line-height: 1.5;
    resize: none;
}

.message-input:focus {
    outline: none;
}

.message-input::placeholder {
    color: var(--muted-foreground);
}

/* Submit button */
.submit-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 9999px;
    background-color: var(--primary);
    color: var(--primary-foreground);
    transition: background-color 0.2s;
}

.submit-button:hover {
    background-color: color-mix(in srgb, var(--primary) 90%, transparent);
}

.submit-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Header */
#header {
    height: var(--header-height);
    padding: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    position: relative;
}

/* Logo styling */
#header > div:first-child {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
}

#header > div:first-child::before {
    content: '';
    width: 80px;
    height: 40px;
    background-image: url('logo_dark.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: 0px 5px;
    display: block;
}

/* Hack header title */
#header>div.absolute::before {
    content: 'Terra Vida: GenAI ESG Game';
    display: block;
    color: white;
}

/* Style the header title */
#header>div.absolute {
    position: absolute;
    left: 50%;
    transform: translateX(-50%) translateY(-50%);
    color: white;
    font-weight: bold;
    font-size: 1.2rem;
    white-space: nowrap;
}

/* Fix H2 sizing */
.prose h2.text-3xl {
    font-size: 1.5rem;
}

/* Hide unnecessary buttons */
button#new-chat-button,
button#theme-toggle,
button#readme-button,
.new-chat-button,
.theme-toggle,
.readme-button {
    display: none !important;
}

button#chat-submit {
    color: white;
    border: solid 1px;
}

/* Hide Chainlit watermark */
.watermark {
    display: none !important;
}

/* Code blocks */
.prose pre {
    background-color: #1e1e1e;
    border-radius: var(--message-radius);
    padding: 1em;
    margin: 0.5em 0;
    overflow-x: auto;
}

.prose code {
    font-family: 'Courier New', Courier, monospace;
    padding: 0.25em !important;
}

/* Links in messages */
.message-paragraph a {
    color: white;
    text-decoration: underline;
}

/* Separator */
.separator {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 1em 0;
}

.separator::before,
.separator::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid var(--user-msg-bg);
}

.separator:not(:empty)::before {
    margin-right: 0.25em;
}

.separator:not(:empty)::after {
    margin-left: 0.25em;
}

/* chainlit footer watermark */
div.watermark {
    visibility: hidden !important;
}

button:has(svg.lucide-copy) {
    display:none;
}

div.ai-message div.bg-muted:has(img) {
    background-color: transparent;
    width:250px;
}

div.ai-message div.bg-muted img {
    padding-top:0.7rem;
}

div#header img::after {
    content: '.';
    color: white;
    display: block;
    position: absolute;
    top: 20px;
    left: 20px;
}

div#header img + div {
    font-weight: bold;
    color: white;
}

#actions-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#actions-list>span {
    display: block;
}

/* Message stream buttons only */
.message-actions button.action-button {
    background-color: var(--button-bg) !important;
    color: white !important;
    border-radius: 18px !important;
    padding: 0.5em 1.5em !important;
    margin-left: 0.5em;
    margin-bottom: 0.5em;
}

.message-actions button.action-button:hover {
    background-color: var(--button-hover) !important;
}

/* Remove global button styling */
button[type="button"],
button[id="chat-submit"] {
    background-color: initial;
    color: initial;
}

/* Dark mode button text */
@media (prefers-color-scheme: dark) {
    .theme-toggle,
    .readme-button,
    button[type="button"] {
        color: white !important;
    }
}

.user-message-container .prose div[role="article"] {
    background-color: var(--user-msg-bg) !important;
    border-radius: var(--user-message-radius);
    color: white !important;
    font-size: 14px;
    line-height: 1.5;
    width: 100%;
}

/* Error message lists */
.message-prose ul.list-disc {
    list-style-position: inside !important;
    padding: 1em 1em 1em 0.5em !important;
    background-color: var(--assistant-msg-bg) !important;
    border-radius: var(--ai-message-radius) !important;
    font-size: 14px;
    line-height: 1.5;
}

.message-prose ul.list-disc li {
    color: white !important;
    margin: 0.25em 0 0.25em 1em !important;
}

.message-prose ul.list-disc li::marker {
    color: white !important;
}
