:root {
    --bg-color: #f8f9fa;
    --sidebar-bg: #ffffff;
    --chat-bg: #ffffff;
    --primary: #2563eb;
    --user-msg-bg: #eff6ff;
    --bot-msg-bg: #f3f4f6;
    --border-color: #e5e7eb;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
}

/* Dark Theme Variables */
[data-theme="dark"] {
    --bg-color: #111827;
    --sidebar-bg: #1f2937;
    --chat-bg: #111827;
    --primary: #3b82f6;
    --user-msg-bg: #1e3a8a;
    --bot-msg-bg: #374151;
    --border-color: #374151;
    --text-primary: #f9fafb;
    --text-secondary: #9ca3af;
}

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

/* Layout */
.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* Sidebar (History) */
.sidebar {
    width: 280px;
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
    z-index: 100;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.new-chat-btn {
    width: 100%;
    padding: 10px;
    background-color: transparent;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    transition: all 0.2s;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 10px;
}

.new-chat-btn:hover {
    background-color: var(--bot-msg-bg);
    border-color: var(--primary);
}

.history-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.history-item {
    padding: 12px;
    margin-bottom: 4px;
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: background 0.2s;
}

.history-item:hover, .history-item.active {
    background-color: var(--bot-msg-bg);
    color: var(--text-primary);
}

.sidebar-footer {
    padding: 15px;
    border-top: 1px solid var(--border-color);
}

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

.top-bar {
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--sidebar-bg); /* Opaque for scrolling */
    border-bottom: 1px solid var(--border-color);
}

/* Added class for the Model Display that holds the tooltip */
.model-display-container {
    cursor: help;
}

/* Custom Tooltip Styling for multi-line content */
.tooltip-inner {
    white-space: pre-wrap;
    max-width: 300px;
    text-align:left;
}
/* End Custom Tooltip Styling */

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

.chat-scroll-area {
    flex: 1;
    overflow-y: auto;
    padding: 20px 0;
    display: flex;
    flex-direction: column;
    align-items: center;

}

.message-container {
    width: 100%;
    max-width: 800px;
    padding: 0 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.message {
    display: flex;
    gap: 15px;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1.2rem;
}

.avatar.bot { background-color: #10a37f; color: white; }
.avatar.user { background-color: var(--primary); color: white; }

.message-content {
    padding-top: 6px;
    line-height: 1.6;
    color: var(--text-primary);
    flex: 1;
    min-width: 0; /* Ensures code blocks don't overflow */
}

/* Markdown Styling */
.message-content pre {
    background-color: #0d1117;
    padding: 15px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 10px 0;
}
.message-content code {
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.9em;
}
.message-content p { margin-bottom: 10px; }
.message-content p:last-child { margin-bottom: 0; }

/* Input Area */
.input-wrapper {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    background-color: var(--chat-bg);
}

.input-box {
    position: relative;
    background-color: var(--sidebar-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px 15px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: flex-end;
    gap: 10px;
}

.input-box:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

textarea {
    width: 100%;
    background: transparent;
    border: none;
    resize: none;
    height: 24px;
    max-height: 200px;
    outline: none;
    color: var(--text-primary);
    font-family: inherit;
    padding: 0;
    line-height: 1.5;
}

#sendBtn {
    background-color: var(--primary);
    color: white;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: opacity 0.2s;
}

#sendBtn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Settings Modal */
.modal-content {
    background-color: var(--sidebar-bg);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.form-control, .form-select {
    background-color: var(--bg-color);
    border-color: var(--border-color);
    color: var(--text-primary);
}

.form-control:focus {
    background-color: var(--bg-color);
    color: var(--text-primary);
}

/* Typing Indicator */
.typing-indicator span {
    display: inline-block;
    width: 6px;
    height: 6px;
    background-color: var(--text-secondary);
    border-radius: 50%;
    animation: typing 1s infinite;
    margin: 0 2px;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }
.text-muted {
    color: var(--text-secondary)!important;;
}
@keyframes typing {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .sidebar {
        position: absolute;
        height: 100%;
        transform: translateX(-100%);
    }
    .sidebar.show {
        transform: translateX(0);
        box-shadow: 10px 0 20px rgba(0,0,0,0.2);
    }
    .mobile-menu-btn { display: block; }
    .overlay {
        position: fixed; top: 0; left: 0; width: 100%; height: 100%;
        background: rgba(0,0,0,0.5); z-index: 90; display: none;
    }
    .overlay.show { display: block; }
    .chat-scroll-area {
        max-width: 26rem;
        text-wrap-style: pretty;
        overflow-wrap: anywhere;
    }
}
.code-block-wrapper {
    position: relative;
    margin: -1.5rem 0 1.5rem;
}

.copy-btn {
    position: absolute;
    left: 0;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    border-radius: 4px;
    padding: 0.25rem 0.5rem;
    cursor: pointer;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    transition: all 0.2s;
}

.copy-btn:hover {
    background: rgba(0, 0, 0, 0.9);
}

.copy-btn i {
    margin-left: 0.25rem;
}

.message-content {
    position: relative;
}