:root {
    --bg-color: #0f172a;
    --sidebar-bg: #1e293b;
    --panel-bg: rgba(30, 41, 59, 0.7);
    --border-color: #334155;
    --primary-color: #8b5cf6;
    --primary-hover: #7c3aed;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --input-bg: #334155;
    --user-msg-bg: #8b5cf6;
    --bot-msg-bg: #334155;
    --danger-color: #ef4444;
}

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

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

/* App Layout */
.app-container {
    display: flex;
    height: 100dvh;
}

.sidebar {
    width: 280px;
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 1rem;
}

.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    background: radial-gradient(circle at top right, #1e1b4b, #0f172a);
}

/* Sidebar Components */
.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.bot-list {
    flex: 1;
    overflow-y: auto;
    margin-bottom: 1rem;
}

.bot-item {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: background-color 0.2s;
    margin-bottom: 0.5rem;
}

.bot-item:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.bot-item.active {
    background-color: var(--primary-color);
}

.bot-avatar {
    width: 40px;
    height: 40px;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.2rem;
    margin-right: 0.75rem;
}

.bot-info h4 {
    font-size: 0.95rem;
    font-weight: 500;
}

.bot-info p {
    font-size: 0.8rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 150px;
}

.bot-item.active .bot-info p {
    color: rgba(255, 255, 255, 0.8);
}

/* Buttons */
.primary-btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    cursor: pointer;
    font-weight: 500;
    transition: background-color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

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

.full-width {
    width: 100%;
}

#dh-connect-btn {
    width: 80px;
    white-space: nowrap;
}

.icon-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.1rem;
    padding: 0.5rem;
    border-radius: 50%;
    transition: color 0.2s, background-color 0.2s;
}

.icon-btn:hover {
    color: var(--text-primary);
    background-color: rgba(255, 255, 255, 0.1);
}

.icon-btn.danger:hover {
    color: var(--danger-color);
    background-color: rgba(239, 68, 68, 0.1);
}

.danger-btn {
    background-color: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--danger-color);
    color: var(--danger-color);
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.danger-btn:hover {
    background-color: var(--danger-color);
    color: white;
}

/* Chat Area */
.empty-state {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100%;
    color: var(--text-secondary);
    text-align: center;
}

.empty-state i {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.chat-interface {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.chat-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(10px);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chat-bot-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.bot-avatar.large {
    width: 48px;
    height: 48px;
    font-size: 1.5rem;
}

.status {
    font-size: 0.8rem;
    color: #4ade80;
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.message {
    display: flex;
    gap: 1rem;
    max-width: 80%;
}

.message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message-content {
    background-color: var(--bot-msg-bg);
    padding: 1rem;
    border-radius: 1rem;
    border-top-left-radius: 0;
    line-height: 1.5;
    font-size: 0.95rem;
}

.message.user .message-content {
    background-color: var(--user-msg-bg);
    border-radius: 1rem;
    border-top-right-radius: 0;
}

.input-area {
    padding: 1.5rem;
    background-color: rgba(15, 23, 42, 0.9);
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 1rem;
    align-items: flex-end;
}

#message-input {
    flex: 1;
    background-color: var(--input-bg);
    border: none;
    border-radius: 0.75rem;
    padding: 1rem;
    color: white;
    font-family: inherit;
    resize: none;
    max-height: 120px;
    outline: none;
}

.send-btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    width: 50px;
    height: 50px;
    border-radius: 0.75rem;
    cursor: pointer;
    font-size: 1.2rem;
    transition: transform 0.1s;
}

.send-btn:active {
    transform: scale(0.95);
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.modal {
    background-color: var(--sidebar-bg);
    border-radius: 1rem;
    width: 90%;
    max-width: 500px;
    border: 1px solid var(--border-color);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
}

.modal-header {
    padding: 1.25rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-body {
    padding: 1.5rem;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.form-group input,
.form-group textarea {
    width: 100%;
    background-color: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 0.75rem;
    color: white;
    font-family: inherit;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

.modal-footer {
    padding: 1.25rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

.secondary-btn {
    background-color: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.secondary-btn:hover {
    background-color: var(--border-color);
}

.hidden {
    display: none !important;
}

/* Markdown Styles within Message */
.message-content p {
    margin-bottom: 0.5em;
}

.message-content pre {
    background-color: rgba(0, 0, 0, 0.3);
    padding: 0.5rem;
    border-radius: 0.5rem;
    overflow-x: auto;
    margin: 0.5rem 0;
}

.message-content code {
    font-family: 'Consolas', monospace;
    font-size: 0.9em;
}