/* === DevAI Dark Theme === */
:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-tertiary: #1a1a25;
    --bg-hover: #22222f;
    --bg-input: #16161f;
    
    --text-primary: #f0f0f5;
    --text-secondary: #9090a0;
    --text-muted: #606070;
    
    --accent-primary: #6366f1;
    --accent-secondary: #8b5cf6;
    --accent-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    
    --success: #22c55e;
    --warning: #f59e0b;
    --error: #ef4444;
    
    --border: #2a2a35;
    --border-light: #3a3a45;
    
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 20px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 40px rgba(0,0,0,0.5);
    
    --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    
    --sidebar-width: 260px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* === Layout === */
.app {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* === Sidebar === */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 20px 12px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    margin-bottom: 24px;
}

.logo-icon {
    flex-shrink: 0;
}

.logo-text {
    font-size: 22px;
    font-weight: 600;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.2s ease;
    font-weight: 500;
}

.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    width: 3px;
    height: 24px;
    background: var(--accent-gradient);
    border-radius: 0 3px 3px 0;
}

/* === Status Panel === */
.status-panel {
    margin-top: auto;
    padding: 16px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
}

.status-title {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.status-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.status-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: all 0.3s ease;
}

.status-item.healthy .status-dot {
    background: var(--success);
    box-shadow: 0 0 8px var(--success);
}

.status-item.unhealthy .status-dot {
    background: var(--error);
    box-shadow: 0 0 8px var(--error);
}

.status-item.unknown .status-dot {
    background: var(--warning);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.status-label {
    font-size: 12px;
    color: var(--text-secondary);
    font-family: var(--font-mono);
}

.sidebar-footer {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    text-align: center;
}

.version {
    font-size: 11px;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

/* === Main Content === */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-primary);
}

.view {
    display: none;
    flex: 1;
    overflow: hidden;
}

.view.active {
    display: flex;
}

/* === Chat View === */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
    padding: 20px;
}

/* === Welcome State === */
.welcome {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 40px;
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.welcome-icon {
    margin-bottom: 24px;
    opacity: 0.8;
}

.welcome-title {
    font-size: 32px;
    font-weight: 600;
    margin-bottom: 12px;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.welcome-subtitle {
    font-size: 16px;
    color: var(--text-secondary);
    max-width: 500px;
    margin-bottom: 40px;
}

/* === Agent Selector === */
.agent-selector {
    display: flex;
    gap: 16px;
}

.agent-btn {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 24px;
    background: var(--bg-secondary);
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
}

.agent-btn:hover {
    background: var(--bg-tertiary);
    border-color: var(--border-light);
    transform: translateY(-2px);
}

.agent-btn.active {
    border-color: var(--accent-primary);
    background: rgba(99, 102, 241, 0.1);
}

.agent-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-gradient);
    border-radius: var(--radius-md);
    font-weight: 700;
    font-size: 14px;
    color: white;
}

.agent-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.agent-name {
    font-weight: 600;
    color: var(--text-primary);
}

.agent-desc {
    font-size: 13px;
    color: var(--text-secondary);
}

/* === Messages === */
.messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 0;
    display: none;
}

.messages.active {
    display: block;
}

.message {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 13px;
    flex-shrink: 0;
}

.message.human .message-avatar {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

.message.agent .message-avatar {
    background: var(--accent-gradient);
    color: white;
}

.message-content {
    flex: 1;
    padding-top: 6px;
}

.message-text {
    font-size: 15px;
    line-height: 1.7;
    color: var(--text-primary);
}

.message-text p {
    margin-bottom: 12px;
}

.message-text p:last-child {
    margin-bottom: 0;
}

.message-text code {
    font-family: var(--font-mono);
    font-size: 13px;
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: 4px;
}

.message-text pre {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px;
    overflow-x: auto;
    margin: 12px 0;
}

.message-text pre code {
    background: none;
    padding: 0;
}

/* === Input Area === */
.input-area {
    padding: 20px 0;
    border-top: 1px solid var(--border);
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 12px 16px;
    transition: all 0.2s ease;
}

.input-wrapper:focus-within {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

#message-input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    font-family: var(--font-sans);
    font-size: 15px;
    color: var(--text-primary);
    resize: none;
    max-height: 200px;
    line-height: 1.5;
}

#message-input::placeholder {
    color: var(--text-muted);
}

.send-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-gradient);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    opacity: 0.5;
}

.send-btn:not(:disabled) {
    opacity: 1;
}

.send-btn:not(:disabled):hover {
    transform: scale(1.05);
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
}

.send-btn svg {
    color: white;
}

.input-footer {
    display: flex;
    justify-content: center;
    margin-top: 10px;
}

.input-hint {
    font-size: 12px;
    color: var(--text-muted);
}

/* === Runs View === */
.runs-container {
    flex: 1;
    padding: 32px;
    overflow-y: auto;
}

.runs-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.runs-header h2 {
    font-size: 24px;
    font-weight: 600;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-weight: 500;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
}

.btn-primary {
    background: var(--accent-gradient);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
}

.runs-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.run-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.run-card:hover {
    background: var(--bg-tertiary);
    border-color: var(--border-light);
}

.run-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.run-id {
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--accent-primary);
}

.run-state {
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 20px;
    font-weight: 500;
}

.run-state.active {
    background: rgba(34, 197, 94, 0.15);
    color: var(--success);
}

.run-state.pending {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
}

.run-title {
    font-weight: 500;
    margin-bottom: 4px;
}

.run-meta {
    font-size: 13px;
    color: var(--text-secondary);
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

/* === Status View === */
.status-container {
    flex: 1;
    padding: 32px;
    overflow-y: auto;
}

.status-container h2 {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 24px;
}

.status-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.status-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
}

.status-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.status-card-title {
    font-weight: 600;
    font-size: 16px;
}

.status-card-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 20px;
    font-weight: 500;
}

.status-card-badge.healthy {
    background: rgba(34, 197, 94, 0.15);
    color: var(--success);
}

.status-card-badge.unhealthy {
    background: rgba(239, 68, 68, 0.15);
    color: var(--error);
}

.status-card-details {
    font-size: 13px;
    color: var(--text-secondary);
    font-family: var(--font-mono);
}

/* === Scrollbar === */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-light);
}

/* === Typing Indicator === */
.typing-dots {
    display: flex;
    align-items: center;
    gap: 4px;
    height: 24px;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-primary);
    animation: typing 1.4s infinite ease-in-out;
}

.typing-dots span:nth-child(1) { animation-delay: 0s; }
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 60%, 100% { 
        transform: translateY(0); 
        opacity: 0.6;
    }
    30% { 
        transform: translateY(-6px); 
        opacity: 1;
    }
}

/* === Memory View === */
.memory-container {
    flex: 1;
    padding: 32px;
    overflow-y: auto;
}

.memory-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.memory-header h2 {
    font-size: 24px;
    font-weight: 600;
}

.memory-search {
    display: flex;
    gap: 12px;
}

.memory-search input {
    padding: 10px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 14px;
    width: 300px;
}

.memory-search input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.memory-stats {
    display: flex;
    gap: 24px;
    margin-bottom: 24px;
}

.memory-stat {
    font-size: 14px;
    color: var(--text-secondary);
}

.memory-stat strong {
    color: var(--accent-primary);
    font-size: 18px;
}

.memory-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.memory-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
}

.memory-card.pinned {
    border-left: 3px solid var(--accent-primary);
}

.memory-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.memory-type {
    font-size: 11px;
    padding: 4px 8px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    text-transform: uppercase;
    color: var(--text-secondary);
    font-weight: 600;
}

.memory-key {
    font-family: var(--font-mono);
    font-size: 14px;
    color: var(--accent-primary);
}

.memory-value {
    font-size: 14px;
    color: var(--text-primary);
    line-height: 1.6;
}

.memory-meta {
    display: flex;
    gap: 16px;
    margin-top: 12px;
    font-size: 12px;
    color: var(--text-muted);
}

.memory-badge {
    background: var(--accent-primary);
    color: white;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: 8px;
    font-weight: 600;
}

/* === Responsive === */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -100%;
        z-index: 100;
        transition: left 0.3s ease;
    }
    
    .sidebar.open {
        left: 0;
    }
    
    .agent-selector {
        flex-direction: column;
    }
}
