:root {
    --bg-color-sidebar: #202123;
    --bg-color-main: #343541;
    --bg-color-input: #40414f;
    --text-color-primary: #ececf1;
    --text-color-secondary: #c5c5d2;
    --hover-color: #2a2b32;
    --border-color: #4d4d4f;
    --user-msg-bg: #343541;
    --assistant-msg-bg: #444654;
    --accent-color: #10a37f;
    --accent-hover: #1a7f64;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color-main);
    color: var(--text-color-primary);
    height: 100vh;
    display: flex;
    overflow: hidden;
}

.app-container {
    display: flex;
    width: 100%;
    height: 100%;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--bg-color-sidebar);
    display: flex;
    flex-direction: column;
    padding: 0.5rem;
    transition: transform 0.3s ease;
    z-index: 100;
}

.new-chat-container {
    padding: 0.5rem;
    margin-bottom: 0.5rem;
}

.btn-new-chat {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    background: transparent;
    color: var(--text-color-primary);
    cursor: pointer;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.875rem;
    transition: background-color 0.2s;
}

.btn-new-chat:hover {
    background-color: var(--hover-color);
}

.history-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.history-item {
    padding: 0.75rem;
    margin: 0 0.5rem;
    border-radius: 0.375rem;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--text-color-primary);
    transition: background-color 0.2s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.history-item i {
    color: var(--text-color-secondary);
}

.history-item:hover, .history-item.active {
    background-color: var(--hover-color);
}

.history-item .delete-btn {
    margin-left: auto;
    background: transparent;
    border: none;
    color: var(--text-color-secondary);
    cursor: pointer;
    opacity: 0; 
    transition: opacity 0.2s;
}

.history-item:hover .delete-btn {
    opacity: 1;
}

.sidebar-footer {
    padding: 0.5rem;
    border-top: 1px solid var(--border-color);
    margin-top: auto;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border-radius: 0.375rem;
    cursor: pointer;
}

.user-profile:hover {
    background-color: var(--hover-color);
}

.avatar {
    width: 2rem;
    height: 2rem;
    background-color: var(--accent-color);
    color: white;
    border-radius: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

/* Chat Area */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    background-color: var(--bg-color-main);
}

.chat-header {
    display: none; /* Hidden on desktop */
    padding: 0.5rem;
    border-bottom: 1px solid var(--border-color);
    align-items: center;
    gap: 1rem;
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    scroll-behavior: smooth;
    padding-bottom: 120px; /* Space for input */
}

/* Welcome Screen */
.welcome-screen {
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-color-primary);
    gap: 2rem;
}

.welcome-logo {
    width: 64px;
    height: 64px;
    background-color: var(--accent-color); /* Updated per user request */
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
}

/* Messages */
.message-row {
    padding: 1.5rem;
    border-bottom: 1px solid rgba(0,0,0,0.1);
}

.message-row.assistant {
    background-color: var(--assistant-msg-bg);
}

.message-content {
    max-width: 48rem; /* ~768px */
    margin: 0 auto;
    display: flex;
    gap: 1.5rem;
}

.msg-avatar {
    width: 30px;
    height: 30px;
    border-radius: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.msg-avatar.user {
    background-color: #5436DA;
}

.msg-avatar.assistant {
    background-color: var(--accent-color);
}

.msg-text {
    flex: 1;
    line-height: 1.6;
    font-size: 1rem;
    overflow-wrap: break-word; /* Prevents overflow */
}

.msg-text p {
    margin-bottom: 0.75rem;
}

.msg-text p:last-child {
    margin-bottom: 0;
}

.msg-text pre {
    background: black;
    padding: 1rem;
    border-radius: 0.375rem;
    overflow-x: auto;
    margin: 0.75rem 0;
}

.msg-text code {
    font-family: 'Courier New', Courier, monospace;
}

/* Input Area */
.input-area {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background-image: linear-gradient(180deg, rgba(53,53,65,0), #343541 50%);
    padding: 2rem 1rem 1rem;
}

.input-container {
    max-width: 48rem;
    margin: 0 auto;
    position: relative;
    background-color: var(--bg-color-input);
    border-radius: 0.75rem;
    box-shadow: 0 0 15px rgba(0,0,0,0.1);
    border: 1px solid rgba(32,33,35,0.5);
    display: flex;
    flex-direction: column;
}

#chat-input {
    background: transparent;
    border: none;
    padding: 1rem 3rem 1rem 1rem;
    color: var(--text-color-primary);
    font-family: inherit;
    font-size: 1rem;
    resize: none;
    max-height: 200px;
    outline: none;
    width: 100%;
}

.send-btn {
    position: absolute;
    right: 0.75rem;
    bottom: 0.75rem;
    background: transparent;
    border: none;
    color: var(--text-color-secondary);
    cursor: pointer;
    padding: 0.25rem;
    transition: color 0.2s;
}

.send-btn:not(:disabled) {
    color: var(--accent-color);
}

.disclaimer {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-color-secondary);
    margin-top: 0.75rem;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        height: 100%;
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .chat-header {
        display: flex;
    }

    .mobile-menu-btn {
        background: transparent;
        border: none;
        color: var(--text-color-primary);
        font-size: 1.25rem;
        cursor: pointer;
    }
}
