:root {
    --bg-color: #0f172a;
    --sidebar-bg: rgba(30, 41, 59, 0.7);
    --panel-bg: rgba(30, 41, 59, 0.5);
    --border-color: rgba(255, 255, 255, 0.1);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --accent: #3b82f6;
    --accent-hover: #60a5fa;
    --msg-in-bg: rgba(59, 130, 246, 0.15);
    --msg-in-border: rgba(59, 130, 246, 0.3);
    --msg-out-bg: rgba(16, 185, 129, 0.15);
    --msg-out-border: rgba(16, 185, 129, 0.3);
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    background-image: 
        radial-gradient(at 0% 0%, rgba(59, 130, 246, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(16, 185, 129, 0.15) 0px, transparent 50%);
    background-attachment: fixed;
    min-height: 100vh;
}

.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background-color: var(--sidebar-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.logo-container {
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border-color);
}

.logo-icon {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    border-radius: 8px;
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.4);
}

.logo-container h1 {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.nav-menu {
    padding: 24px 16px;
    flex: 1;
    overflow-y: auto;
}

.nav-section {
    margin-bottom: 24px;
}

.nav-section h3 {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.05em;
    margin-bottom: 12px;
    padding-left: 8px;
}

.nav-section ul {
    list-style: none;
}

.nav-section li {
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.nav-section li a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    width: 100%;
    text-decoration: none;
    color: inherit;
    border-radius: 8px;
}

.nav-section li:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
}

.nav-section li.active {
    background-color: rgba(59, 130, 246, 0.1);
    color: var(--text-main);
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #10b981;
    box-shadow: 0 0 10px #10b981;
}

.badge {
    background-color: rgba(255, 255, 255, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.75rem;
    margin-left: auto;
}

/* Settings Form */
.settings-form {
    padding: 0 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.settings-form label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.settings-form input {
    width: 100%;
    padding: 8px 10px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: rgba(0,0,0,0.2);
    color: white;
    font-family: inherit;
    font-size: 0.85rem;
}

.settings-form input:focus {
    outline: none;
    border-color: var(--accent);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.topbar {
    height: 73px;
    padding: 0 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
    background-color: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(8px);
}

.btn {
    padding: 8px 16px;
    border-radius: 8px;
    border: none;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    font-size: 0.9rem;
}

.btn.primary {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: white;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.btn.primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.4);
}

.content-area {
    padding: 32px;
    flex: 1;
    overflow-y: auto;
}

.glass-panel {
    background-color: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    height: 100%;
}

.glass-panel h3 {
    margin-bottom: 24px;
    font-weight: 600;
}

/* Messages */
.message-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
    flex: 1;
    overflow-y: auto;
    padding-right: 8px;
}

.message-item {
    padding: 12px 16px;
    border-radius: 12px;
    border: 1px solid;
    animation: slideIn 0.3s ease-out forwards;
    max-width: 80%;
    width: fit-content;
}

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

.message-item.in {
    background-color: var(--msg-in-bg);
    border-color: var(--msg-in-border);
    align-self: flex-start;
}

.message-item.out {
    background-color: var(--msg-out-bg);
    border-color: var(--msg-out-border);
    align-self: flex-end;
}

.msg-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 0.8rem;
    color: var(--text-muted);
    gap: 16px;
}

.msg-type {
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.message-item.in .msg-type { color: #60a5fa; }
.message-item.out .msg-type { color: #34d399; }

.msg-content {
    font-size: 0.95rem;
    line-height: 1.5;
    margin-bottom: 4px;
}

.msg-footer {
    font-size: 0.75rem;
    color: rgba(255,255,255,0.3);
}

.empty-state {
    text-align: center;
    padding: 48px;
    color: var(--text-muted);
    border: 1px dashed var(--border-color);
    border-radius: 12px;
}

/* Markdown rendered content */
.markdown-text p {
    margin: 0 0 8px 0;
}
.markdown-text p:last-child {
    margin-bottom: 0;
}
.markdown-text strong {
    font-weight: 700;
    color: var(--text-main);
}
.markdown-text em {
    font-style: italic;
}
.markdown-text h1,
.markdown-text h2,
.markdown-text h3,
.markdown-text h4 {
    margin: 12px 0 6px 0;
    font-weight: 600;
}
.markdown-text h1 { font-size: 1.3rem; }
.markdown-text h2 { font-size: 1.15rem; }
.markdown-text h3 { font-size: 1.05rem; }
.markdown-text ul,
.markdown-text ol {
    margin: 6px 0;
    padding-left: 20px;
}
.markdown-text li {
    margin-bottom: 4px;
}
.markdown-text code {
    background: rgba(0, 0, 0, 0.3);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.88em;
}
.markdown-text pre {
    background: rgba(0, 0, 0, 0.4);
    padding: 12px 16px;
    border-radius: 8px;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: break-word;
    margin: 8px 0;
}
.markdown-text pre code {
    background: none;
    padding: 0;
    font-size: 0.85em;
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
}
.markdown-text blockquote {
    border-left: 3px solid var(--accent);
    margin: 8px 0;
    padding: 4px 12px;
    color: var(--text-muted);
}
.markdown-text a {
    color: var(--accent-hover);
    text-decoration: underline;
}
.markdown-text hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 12px 0;
}
.markdown-text table {
    width: 100%;
    border-collapse: collapse;
    margin: 8px 0;
}
.markdown-text th,
.markdown-text td {
    border: 1px solid var(--border-color);
    padding: 6px 10px;
    text-align: left;
    font-size: 0.9em;
}
.markdown-text th {
    background: rgba(0, 0, 0, 0.2);
    font-weight: 600;
}

/* Toast Styling */
.toast {
    background-color: var(--sidebar-bg);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    backdrop-filter: blur(12px);
}

.toast-header {
    background-color: rgba(0, 0, 0, 0.2);
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
}

.btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
}

/* Typing indicator animation */
.typing-dots {
    display: inline-flex;
    gap: 4px;
    align-items: center;
}

.typing-dots span {
    font-size: 1.2rem;
    color: #34d399;
    animation: typingPulse 1.4s infinite ease-in-out;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingPulse {
    0%, 80%, 100% { opacity: 0.2; transform: scale(0.8); }
    40% { opacity: 1; transform: scale(1.1); }
}
