/* Modern, Premium Dark Mode and Glassmorphic Theme */
:root {
    --bg-primary: #0b0f19;
    --bg-secondary: #111827;
    --card-bg: rgba(31, 41, 55, 0.65);
    --border-color: rgba(255, 255, 255, 0.08);
    --accent-color: #6366f1; /* Indigo */
    --accent-glow: rgba(99, 102, 241, 0.4);
    --accent-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --color-thought: #fbbf24; /* Golden */
    --color-action: #3b82f6; /* Blue */
    --color-observation: #10b981; /* Green */
    --color-system: #a855f7; /* Purple */
}

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

body {
    font-family: 'Outfit', 'Inter', system-ui, -apple-system, sans-serif;
    background: radial-gradient(circle at top right, #1e1b4b 0%, var(--bg-primary) 70%);
    color: var(--text-primary);
    min-height: 100vh;
    padding: 2rem 1rem;
    line-height: 1.5;
}

h1 {
    font-size: 2.25rem;
    font-weight: 800;
    text-align: center;
    background: linear-gradient(to right, #818cf8, #a78bfa, #f472b6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 2rem;
    letter-spacing: -0.025em;
    filter: drop-shadow(0 2px 8px rgba(99, 102, 241, 0.3));
}

/* App Layout Grid */
.app-container {
    max-width: 1200px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 2rem;
    align-items: start;
}

@media (max-width: 768px) {
    .app-container {
        grid-template-columns: 1fr;
    }
}

/* Sidebar and Cards */
.sidebar {
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.4);
}

.sidebar-title {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: #e5e7eb;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.skill-card {
    background: rgba(17, 24, 39, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 1rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.skill-card:hover {
    border-color: var(--accent-color);
    box-shadow: 0 0 15px var(--accent-glow);
    transform: translateY(-2px);
}

.skill-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.skill-name {
    font-weight: 700;
    color: #f3f4f6;
}

.skill-badge {
    background: rgba(168, 85, 247, 0.2);
    border: 1px solid rgba(168, 85, 247, 0.4);
    color: #d8b4fe;
    font-size: 0.7rem;
    padding: 0.15rem 0.5rem;
    border-radius: 9999px;
    text-transform: uppercase;
    font-weight: 700;
}

.skill-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    line-height: 1.4;
}

.skill-manifest-toggle {
    font-size: 0.8rem;
    color: var(--accent-color);
    cursor: pointer;
    background: none;
    border: none;
    text-decoration: underline;
    outline: none;
}

.skill-manifest-toggle:hover {
    color: #8b5cf6;
}

.skill-manifest-body {
    display: none;
    font-family: monospace;
    background: #090d16;
    border-radius: 8px;
    padding: 0.75rem;
    margin-top: 0.75rem;
    font-size: 0.75rem;
    color: #d1d5db;
    overflow-x: auto;
    white-space: pre-wrap;
    max-height: 200px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

/* Chat/Main Panel */
.main-panel {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.chat-card {
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Controls & Suggestions */
.controls {
    display: flex;
    gap: 0.75rem;
}

#prompt-input {
    flex: 1;
    background: rgba(17, 24, 39, 0.8);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 0.75rem 1rem;
    color: var(--text-primary);
    font-size: 0.95rem;
    outline: none;
    transition: all 0.3s;
}

#prompt-input:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 10px var(--accent-glow);
}

#run-btn {
    background: var(--accent-gradient);
    border: none;
    border-radius: 10px;
    padding: 0.75rem 1.5rem;
    color: white;
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.3s;
    outline: none;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

#run-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5);
}

#run-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.suggestion-chip {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-secondary);
}

.suggestion-chip:hover {
    background: rgba(99, 102, 241, 0.15);
    border-color: var(--accent-color);
    color: var(--text-primary);
}

/* Reasoning Logs Section */
.panel-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #e5e7eb;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

#logs {
    background: #090d16;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.25rem;
    height: 380px;
    overflow-y: auto;
    font-family: 'Fira Code', 'Courier New', Courier, monospace;
    font-size: 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    scroll-behavior: smooth;
}

/* Custom Scrollbar for Logs */
#logs::-webkit-scrollbar {
    width: 6px;
}
#logs::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
}
#logs::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}
#logs::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.25);
}

.log-entry {
    background: rgba(255, 255, 255, 0.02);
    border-left: 4px solid var(--text-secondary);
    border-radius: 0 8px 8px 0;
    padding: 0.75rem 1rem;
    line-height: 1.5;
    animation: slideUp 0.3s ease-out forwards;
}

.log-entry.thought {
    border-color: var(--color-thought);
    background: rgba(251, 191, 36, 0.04);
    color: #fde047;
}

.log-entry.action {
    border-color: var(--color-action);
    background: rgba(59, 130, 246, 0.04);
    color: #60a5fa;
    font-weight: 600;
}

.log-entry.observation {
    border-color: var(--color-observation);
    background: rgba(16, 185, 129, 0.04);
    color: #34d399;
}

.log-entry.system {
    border-color: var(--color-system);
    background: rgba(168, 85, 247, 0.05);
    color: #c084fc;
    font-weight: bold;
}

/* Output Card */
.output-card {
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.4);
    position: relative;
    overflow: hidden;
}

.output-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--accent-gradient);
}

#result {
    font-size: 1.05rem;
    color: #f3f4f6;
    line-height: 1.6;
    white-space: pre-wrap;
    min-height: 2rem;
}

.empty-result {
    color: var(--text-secondary);
    font-style: italic;
}

/* Animations */
@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* HITL Approval Card */
.approval-card {
    border: 1px solid rgba(245, 158, 11, 0.4);
    box-shadow: 0 0 25px rgba(245, 158, 11, 0.15);
    background: rgba(30, 25, 15, 0.8);
    animation: slideUp 0.3s ease-out;
}

.approval-info {
    margin: 0.75rem 0;
    font-size: 0.95rem;
}

.approval-textarea {
    width: 100%;
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.75rem;
    color: #e2e8f0;
    font-family: 'Fira Code', monospace;
    font-size: 0.9rem;
    resize: vertical;
    margin-bottom: 1rem;
    transition: border-color 0.2s;
}

.approval-textarea:focus {
    outline: none;
    border-color: #f59e0b;
    box-shadow: 0 0 10px rgba(245, 158, 11, 0.2);
}

.approval-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
}

.approve-btn {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    border: none;
    padding: 0.65rem 1.25rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.approve-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(16, 185, 129, 0.4);
}

.reject-btn {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.3);
    padding: 0.65rem 1.25rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.reject-btn:hover {
    background: rgba(239, 68, 68, 0.25);
    border-color: #f87171;
}

/* Trace Explorer UI Styles */
.trace-explorer-card {
    border-top: 2px solid #3b82f6;
}

.trace-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    margin-bottom: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.trace-item:hover {
    border-color: #3b82f6;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
}

.trace-item.active {
    border-color: #3b82f6;
    background: rgba(59, 130, 246, 0.08);
}

.trace-item-title {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.trace-badge {
    font-size: 0.7rem;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-weight: bold;
    text-transform: uppercase;
}

.trace-badge.ok {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.trace-badge.error {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.trace-meta {
    font-size: 0.8rem;
    color: var(--text-secondary);
    display: flex;
    gap: 1rem;
}

.trace-action-btn:hover:not(:disabled) {
    background: #3b82f6 !important;
    color: #ffffff !important;
    border-color: #3b82f6 !important;
}

.span-row {
    margin: 0.25rem 0;
    line-height: 1.6;
}

/* Episodic Memory UI Styles */
.episodic-memory-card {
    border-top: 2px solid #a855f7;
}

.episode-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    margin-bottom: 0.6rem;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem;
    transition: all 0.2s ease;
}

.episode-item:hover {
    border-color: #a855f7;
    box-shadow: 0 2px 10px rgba(168, 85, 247, 0.15);
}

.episode-content {
    flex: 1;
    font-size: 0.88rem;
    color: var(--text-primary);
    line-height: 1.4;
}

.episode-category-badge {
    background: rgba(168, 85, 247, 0.15);
    color: #d8b4fe;
    border: 1px solid rgba(168, 85, 247, 0.3);
    font-size: 0.7rem;
    padding: 0.1rem 0.5rem;
    border-radius: 999px;
    font-weight: 700;
    text-transform: uppercase;
    display: inline-block;
    margin-bottom: 0.35rem;
}

.episode-delete-btn {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 6px;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.episode-delete-btn:hover {
    background: rgba(239, 68, 68, 0.3);
    color: #ffffff;
}


