:root {
    --bg-main: #0B0E14;
    --bg-sidebar: #131722;
    --bg-input: rgba(19, 23, 34, 0.7);
    --text-main: #F3F4F6;
    --text-muted: #94A3B8;
    --border-color: rgba(255, 255, 255, 0.08);
    --accent: #6366F1;
    --accent-hover: #4F46E5;
    --bubble-user: linear-gradient(135deg, #6366F1, #8B5CF6);
    --bubble-bot: rgba(30, 41, 59, 0.6);
    --font-family: 'Inter', -apple-system, sans-serif;
    --font-display: 'Outfit', sans-serif;
    --glass-bg: rgba(15, 20, 30, 0.6);
    --glass-border: rgba(255, 255, 255, 0.08);
    --graph-bg: #05080F;
}

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

body {
    font-family: var(--font-family);
    background-color: var(--bg-main);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
}

#app {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* Glassmorphism Utilities */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--glass-border);
}

.glass-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    padding: 6px 12px;
    border-radius: 6px;
    font-family: var(--font-family);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
}

.glass-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

/* Sidebar */
#sidebar {
    width: 260px;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 20;
}

.sidebar-header {
    padding: 24px 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-header h2 {
    font-size: 1.4rem;
    font-weight: 600;
    letter-spacing: 2px;
    background: linear-gradient(90deg, #6366F1, #D946EF);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.primary-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-main);
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
}

.primary-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-1px);
}

.session-list-wrapper {
    flex: 1;
    overflow-y: auto;
    padding: 16px 10px;
}

.session-list-wrapper::-webkit-scrollbar {
    width: 4px;
}
.session-list-wrapper::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.session-item {
    padding: 12px 14px;
    border-radius: 8px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    gap: 4px;
    border: 1px solid transparent;
}

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

.session-item.active {
    background-color: rgba(99, 102, 241, 0.1);
    border-color: rgba(99, 102, 241, 0.3);
}

.session-preview {
    font-size: 0.85rem;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.session-date {
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* Workspace (Split View) */
#workspace {
    flex: 1;
    display: flex;
    width: calc(100vw - 260px);
}

/* Main Chat */
#chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    border-right: 1px solid var(--border-color);
    min-width: 400px;
}

.chat-header {
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 10;
    position: sticky;
    top: 0;
}

.chat-header h3 {
    font-size: 1.1rem;
    font-weight: 500;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    transition: all 0.3s;
}

.dot.online {
    background-color: #10B981;
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.6);
}

.dot.offline {
    background-color: #EF4444;
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.6);
}

#chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    scroll-behavior: smooth;
}

#chat-history::-webkit-scrollbar {
    width: 6px;
}
#chat-history::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.welcome-screen {
    margin: auto;
    text-align: center;
    color: var(--text-muted);
    max-width: 400px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.glow-orb {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(99,102,241,0.4) 0%, rgba(0,0,0,0) 70%);
    box-shadow: 0 0 40px rgba(99, 102, 241, 0.3);
    animation: pulse 4s infinite alternate;
}

@keyframes pulse {
    0% { transform: scale(0.9); opacity: 0.7; }
    100% { transform: scale(1.1); opacity: 1; }
}

.welcome-screen h1 {
    font-size: 2.2rem;
    background: linear-gradient(to right, #fff, #94A3B8);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.welcome-screen p {
    line-height: 1.6;
    font-size: 0.95rem;
}

/* Messages */
.message-row {
    display: flex;
    margin-bottom: 24px;
    width: 100%;
}

.message-row.user {
    justify-content: flex-end;
}

.message-row.bot {
    justify-content: flex-start;
}

.message-bubble {
    max-width: 80%;
    padding: 14px 18px;
    border-radius: 16px;
    font-size: 0.95rem;
    line-height: 1.6;
    word-wrap: break-word;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.message-row.user .message-bubble {
    background: var(--bubble-user);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.message-row.bot .message-bubble {
    background: var(--bubble-bot);
    border: 1px solid var(--border-color);
    border-bottom-left-radius: 4px;
    backdrop-filter: blur(8px);
}

/* Input Area */
.input-area {
    padding: 24px;
    background: linear-gradient(to top, var(--bg-main) 80%, transparent);
    position: sticky;
    bottom: 0;
}

.input-wrapper {
    max-width: 100%;
    position: relative;
    background-color: var(--bg-input);
    border-radius: 16px;
    border: 1px solid var(--border-color);
    display: flex;
    align-items: flex-end;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    transition: all 0.3s ease;
    backdrop-filter: blur(12px);
}

.input-wrapper:focus-within {
    border-color: var(--accent);
    box-shadow: 0 8px 32px rgba(99, 102, 241, 0.2);
}

#chat-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-main);
    padding: 16px 20px;
    font-family: inherit;
    font-size: 0.95rem;
    resize: none;
    max-height: 200px;
    outline: none;
    line-height: 1.5;
    min-height: 56px;
}

#chat-input::placeholder {
    color: #64748B;
}

#btn-send {
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 12px;
    width: 40px;
    height: 40px;
    margin: 8px 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

#btn-send:hover {
    background: var(--accent-hover);
    transform: scale(1.05);
}

.info-text {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 12px;
}

/* Typing animation */
#loading-indicator {
    padding: 0 24px 24px;
}

.typing-indicator {
    display: flex;
    gap: 6px;
    background: var(--bubble-bot);
    padding: 14px 20px;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    border: 1px solid var(--border-color);
    width: max-content;
}

.typing-indicator span {
    width: 6px;
    height: 6px;
    background-color: var(--text-muted);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

.hidden {
    display: none !important;
}

/* Code Blocks */
.message-bubble pre {
    background: rgba(0, 0, 0, 0.4);
    padding: 16px;
    border-radius: 8px;
    overflow-x: auto;
    margin-top: 12px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.message-bubble code {
    font-family: 'Fira Code', monospace;
    font-size: 0.85em;
    color: #E2E8F0;
}

/* Graph Panel */
#graph-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    background: var(--graph-bg);
    min-width: 400px;
}

.graph-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 10;
    border-bottom: 1px solid transparent;
}

.graph-header h3 {
    font-size: 1.1rem;
    font-weight: 500;
}

#graph-container {
    flex: 1;
    width: 100%;
    height: 100%;
}

/* Graph Node Info Popup */
#node-info {
    position: absolute;
    bottom: 24px;
    right: 24px;
    width: 300px;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    z-index: 20;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.node-info-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.node-info-header h4 {
    font-size: 1.1rem;
    color: #fff;
    margin: 0;
}

#close-node-info {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
}

#close-node-info:hover {
    color: #fff;
}

.pill {
    display: inline-block;
    padding: 4px 10px;
    background: rgba(99, 102, 241, 0.2);
    color: #818CF8;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-bottom: 16px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.meta-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 200px;
    overflow-y: auto;
}

.meta-container::-webkit-scrollbar {
    width: 4px;
}
.meta-container::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.meta-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 8px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 6px;
    font-size: 0.8rem;
}

.meta-key {
    color: var(--text-muted);
    font-weight: 500;
    text-transform: capitalize;
}

.meta-value {
    color: var(--text-main);
    word-break: break-all;
}