:root {
    --bg-dark: #0f172a;
    --panel-bg: rgba(30, 41, 59, 0.7);
    --accent: #38bdf8;
    --accent-dim: rgba(56, 189, 248, 0.1);
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --border: rgba(148, 163, 184, 0.15);
    --glass-blur: blur(16px);
    --msg-user-bg: #334155;
    --msg-ai-bg: transparent;
    --sidebar-width: 400px;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(56, 189, 248, 0.08) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(99, 102, 241, 0.08) 0%, transparent 40%);
}

/* Layout */
.app-layout {
    display: flex;
    height: 100%;
    width: 100%;
}

.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    max-width: 100%;
    transition: margin-right 0.3s ease;
}

/* Header */
.chat-header {
    height: 60px;
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(8px);
}

.logo h1 { font-size: 1.25rem; font-weight: 700; font-family: 'Outfit', sans-serif; }
.logo span { color: var(--accent); }
.logo .badge { 
    font-size: 0.7rem; background: var(--accent-dim); color: var(--accent); 
    padding: 2px 6px; border-radius: 4px; margin-left: 8px; vertical-align: middle;
}

.header-controls { display: flex; align-items: center; gap: 1rem; }
.icon-btn {
    background: transparent; border: none; color: var(--text-secondary);
    cursor: pointer; padding: 4px; border-radius: 4px; transition: color 0.2s;
}
.icon-btn:hover { color: var(--text-primary); background: rgba(255,255,255,0.05); }

/* Messages Stream */
.messages-stream {
    flex: 1;
    overflow-y: auto;
    padding: 2rem 0;
    scroll-behavior: smooth;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.message {
    width: 100%;
    display: flex;
    justify-content: center;
    padding: 0 1.5rem;
}

.message-content {
    max-width: 800px;
    width: 100%;
    line-height: 1.6;
    font-size: 1rem;
}

/* User Message */
.user-message {
    background: transparent; 
}

.user-message .message-content {
    background: var(--msg-user-bg);
    padding: 0.75rem 1rem;
    border-radius: 12px;
    width: auto;
    max-width: 70%;
    margin-left: auto; /* Push to right contextually */
    display: inline-block; /* Wrap tightly */
    border-bottom-right-radius: 2px;
}

/* Assistant Message */
.assistant-message .message-content {
    color: var(--text-primary);
}

.assistant-message strong { color: var(--accent); font-weight: 600; }
.assistant-message ul { margin-left: 1.5rem; margin-bottom: 1rem; }
.assistant-message p { margin-bottom: 1rem; }
.assistant-message h1, .assistant-message h2, .assistant-message h3 {
    margin-top: 1.5rem; margin-bottom: 0.75rem; color: #fff; font-family: 'Outfit', sans-serif;
}
.assistant-message a { color: var(--accent); text-decoration: none; border-bottom: 1px dotted var(--accent); }
.assistant-message a:hover { border-bottom-style: solid; }

/* Input Area */
.input-area {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    background: linear-gradient(to top, var(--bg-dark) 80%, transparent);
}

.input-wrapper {
    position: relative;
    width: 100%;
    max-width: 800px;
    background: var(--panel-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.75rem 1rem;
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    /* Glass effect */
    backdrop-filter: var(--glass-blur);
}

.input-wrapper:focus-within { border-color: var(--accent); }

textarea {
    flex: 1;
    background: transparent;
    border: none;
    color: white;
    resize: none;
    max-height: 200px;
    outline: none;
    line-height: 1.5;
    padding: 4px 0;
}

.send-btn {
    background: var(--accent);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #0f172a;
    cursor: pointer;
    transition: opacity 0.2s;
}
.send-btn:hover { opacity: 0.9; }
.send-btn:disabled { background: var(--text-secondary); cursor: not-allowed; }

.status-indicator {
    font-size: 0.75rem;
    color: var(--text-secondary);
    height: 1rem;
}

/* Sidebar (Evidence) */
.evidence-sidebar {
    width: var(--sidebar-width);
    border-left: 1px solid var(--border);
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(20px);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
    flex-shrink: 0;
}

.evidence-sidebar.collapsed {
    display: none; /* Simple toggle for now, usually prefer transform translate */
}

.sidebar-header {
    height: 60px;
    padding: 0 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
}

.sidebar-header h3 { font-size: 0.9rem; font-weight: 600; text-transform: uppercase; letter-spacing: 1px; }

.small-btn {
    font-size: 0.75rem; padding: 4px 8px;
}

.stats-bar {
    padding: 0.5rem 1rem;
    display: flex;
    gap: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.stat-pill {
    background: rgba(255,255,255,0.05); padding: 2px 8px; border-radius: 12px; font-size: 0.7rem; color: var(--text-secondary);
}

.evidence-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.empty-state { text-align: center; color: var(--text-secondary); margin-top: 3rem; font-size: 0.9rem; font-style: italic; }

/* Collapsible Cards */
.act-card {
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 0.75rem;
    overflow: hidden;
    background: rgba(255,255,255,0.02);
}

.act-header {
    padding: 0.6rem 0.8rem;
    background: rgba(255,255,255,0.03);
    cursor: pointer;
    display: flex; justify-content: space-between; align-items: center;
    font-size: 0.85rem; font-weight: 600;
}
.act-header:hover { background: rgba(255,255,255,0.06); }

.section-group { border-top: 1px solid var(--border); }
.sec-card { }
.sec-header {
    padding: 0.5rem 0.8rem;
    cursor: pointer;
    font-size: 0.8rem;
    color: var(--accent);
    display: flex; justify-content: space-between;
    border-bottom: 1px solid rgba(255,255,255,0.03);
}

.chunk-list { padding: 0.5rem; display: flex; flex-direction: column; gap: 0.5rem; }

.chunk-item {
    background: rgba(0,0,0,0.2);
    padding: 0.6rem; border-radius: 6px; font-size: 0.8rem;
}

.chunk-meta { display: flex; gap: 4px; margin-bottom: 4px; flex-wrap: wrap; }
.badge { background: rgba(255,255,255,0.1); padding: 1px 4px; border-radius: 3px; font-size: 0.65rem; color: #ccc; text-decoration: none; }
.badge-score { color: var(--accent); background: var(--accent-dim); }

.chunk-text { color: #e2e8f0; font-family: 'Inter', sans-serif; }

.toggle-meta { font-size: 0.7rem; color: var(--text-secondary); cursor: pointer; margin-top: 0.4rem; display: inline-block; text-decoration: underline; }
.meta-json { background: #000; padding: 0.5rem; font-family: monospace; font-size: 0.7rem; color: #aaa; margin-top: 0.3rem; border-radius: 4px; display: none; }
.meta-json.show { display: block; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255, 0.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255, 0.2); }

/* Typing Indicator */
.typing-indicator span {
    display: inline-block; width: 6px; height: 6px; background-color: var(--text-secondary); border-radius: 50%;
    animation: typing 1s infinite;
    margin: 0 2px;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing {
    0%, 100% { transform: translateY(0); opacity: 0.5; }
    50% { transform: translateY(-4px); opacity: 1; }
}

.hidden { display: none !important; }

/* Cost Tracker */
.cost-tracker {
    position: fixed;
    bottom: 20px;
    left: 20px;
    padding: 12px 16px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: var(--glass-blur);
    font-size: 0.75rem;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    gap: 4px;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    transition: transform 0.3s ease;
}

.cost-tracker:hover {
    transform: translateY(-5px);
    background: rgba(15, 23, 42, 0.6);
}

.cost-item {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.cost-label {
    font-weight: 500;
}

.cost-total {
    margin-top: 4px;
    padding-top: 4px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    color: var(--accent);
    font-weight: 600;
}

.pulse {
    animation: pulse 0.5s ease-out;
}

@keyframes pulse {
    0% { transform: scale(1); opacity: 1; text-shadow: none; }
    50% { transform: scale(1.1); opacity: 0.8; text-shadow: 0 0 8px var(--accent); }
    100% { transform: scale(1); opacity: 1; text-shadow: none; }
}
