/**
 * Vexla Umbric v5.1 - Fullscreen Centered Chat UI
 * Based on VEXLA AGI v12.1 Architecture
 */

:root {
    --bg-0: #000000;
    --bg-1: #0a0a0b;
    --bg-2: #111113;
    --bg-3: #18181b;
    --bg-4: #1f1f23;
    --bg-hover: rgba(255,255,255,0.04);
    --bg-active: rgba(255,255,255,0.08);
    
    --text-1: #fafafa;
    --text-2: rgba(255,255,255,0.6);
    --text-3: rgba(255,255,255,0.4);
    --text-4: rgba(255,255,255,0.2);
    
    --border: rgba(255,255,255,0.06);
    --accent: #6366f1;
    --accent-2: #818cf8;
    --accent-glow: rgba(99,102,241,0.25);
    
    --success: #22c55e;
    --warning: #f59e0b;
    --error: #ef4444;
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    
    --shadow: 0 4px 24px rgba(0,0,0,0.4);
    
    --font: 'SF Pro Display', -apple-system, BlinkMacSystemFont, sans-serif;
    --mono: 'JetBrains Mono', monospace;
    
    --dock-w: 56px;
    
    --ease: cubic-bezier(0.4, 0, 0.2, 1);
    --fast: 150ms;
    --normal: 250ms;
}

[data-theme="light"] {
    --bg-0: #ffffff;
    --bg-1: #fafafa;
    --bg-2: #f4f4f5;
    --bg-3: #e4e4e7;
    --bg-4: #d4d4d8;
    --bg-hover: rgba(0,0,0,0.04);
    --bg-active: rgba(0,0,0,0.08);
    --text-1: #09090b;
    --text-2: rgba(0,0,0,0.6);
    --text-3: rgba(0,0,0,0.4);
    --text-4: rgba(0,0,0,0.2);
    --border: rgba(0,0,0,0.08);
    --shadow: 0 4px 24px rgba(0,0,0,0.08);
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; }
body {
    font-family: var(--font);
    font-size: 14px;
    color: var(--text-1);
    background: var(--bg-0);
    -webkit-font-smoothing: antialiased;
}
input, textarea, button { font-family: inherit; border: none; outline: none; background: transparent; color: inherit; }
button { cursor: pointer; }

::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--text-4); border-radius: 4px; }

/* App - Fullscreen */
.app {
    height: 100vh;
    width: 100vw;
    display: flex;
    overflow: hidden;
    position: relative;
}
.app.fullscreen { background: var(--bg-0); }

/* Dock Toggle (Floating for mobile) */
.dock-toggle {
    position: fixed;
    top: 16px;
    left: 16px;
    width: 40px;
    height: 40px;
    display: none;
    align-items: center;
    justify-content: center;
    color: var(--text-2);
    background: var(--bg-3);
    border-radius: var(--radius-md);
    z-index: 200;
    box-shadow: var(--shadow);
    transition: all var(--fast) var(--ease);
}
.dock-toggle:hover { background: var(--bg-4); color: var(--text-1); }
.dock-toggle svg { width: 20px; height: 20px; }

/* Dock */
.dock {
    width: var(--dock-w);
    height: 100%;
    background: var(--bg-1);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 100;
    flex-shrink: 0;
    transition: transform var(--normal) var(--ease);
}

.dock-items {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 8px;
    gap: 4px;
}

.dock-spacer { flex: 1; }

.dock-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    color: var(--text-3);
    transition: all var(--fast) var(--ease);
    position: relative;
}
.dock-btn svg { width: 20px; height: 20px; }
.dock-btn:hover { color: var(--text-2); background: var(--bg-hover); }
.dock-btn.active { color: var(--accent); background: var(--bg-active); }
.dock-btn.active::before {
    content: '';
    position: absolute;
    left: -8px;
    width: 3px;
    height: 20px;
    background: var(--accent);
    border-radius: 0 4px 4px 0;
}

/* Main */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    min-width: 0;
    position: relative;
    background: var(--bg-0);
}

/* Views */
.view { display: none; flex: 1; overflow: hidden; }
.view.active { display: flex; }

/* Chat - Fullscreen Centered */
.chat-full {
    flex: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
}

/* Welcome - Centered */
.welcome {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 32px 16px;
    animation: fadeUp 0.5s var(--ease);
}
@keyframes fadeUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

.welcome-icon svg { width: 64px; height: 64px; }
.welcome h1 { font-size: 32px; font-weight: 600; margin: 20px 0 8px; background: linear-gradient(135deg, var(--text-1), var(--text-2)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.welcome p { color: var(--text-3); font-size: 15px; margin-bottom: 32px; }

.quick-prompts { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.qp {
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-lg);
    background: var(--bg-3);
    color: var(--text-2);
    transition: all var(--fast) var(--ease);
}
.qp svg { width: 24px; height: 24px; }
.qp:hover { background: var(--bg-4); color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow); }

/* Messages */
.message {
    display: flex;
    gap: 12px;
    padding: 16px 0;
    max-width: 720px;
    margin: 0 auto;
    width: 100%;
    animation: slideIn var(--normal) var(--ease);
}
@keyframes slideIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.msg-avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.msg-avatar svg { width: 18px; height: 18px; }
.message.user .msg-avatar { background: var(--bg-3); color: var(--text-2); }
.message.assistant .msg-avatar { background: linear-gradient(135deg, #6366f1, #a855f7); color: #fff; }

.msg-body { flex: 1; min-width: 0; }
.msg-text { font-size: 15px; line-height: 1.7; color: var(--text-1); word-wrap: break-word; }
.msg-text code { font-family: var(--mono); font-size: 13px; padding: 2px 6px; background: var(--bg-3); border-radius: 4px; }
.msg-text pre { margin: 12px 0; padding: 16px; background: var(--bg-3); border-radius: var(--radius-md); overflow-x: auto; }
.msg-text pre code { padding: 0; background: transparent; }

/* Inline Artifact */
.msg-artifact {
    margin: 12px 0;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--border);
    background: var(--bg-2);
}
.artifact-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--bg-3);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-2);
}
.artifact-actions { display: flex; gap: 4px; }
.artifact-actions button {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    color: var(--text-3);
}
.artifact-actions button:hover { background: var(--bg-hover); color: var(--text-1); }
.artifact-actions button svg { width: 14px; height: 14px; }

.artifact-preview { height: 320px; background: #fff; }
.artifact-preview iframe { width: 100%; height: 100%; border: none; }

.artifact-code { max-height: 320px; overflow: auto; background: var(--bg-2); }
.artifact-code pre { margin: 0; padding: 14px; font-size: 12px; line-height: 1.6; }

/* Thinking */
.thinking { display: flex; align-items: center; gap: 8px; color: var(--text-3); font-size: 13px; }
.thinking-dots { display: flex; gap: 4px; }
.thinking-dots span { width: 6px; height: 6px; background: var(--accent); border-radius: 50%; animation: pulse 1.4s infinite ease-in-out; }
.thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes pulse { 0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); } 40% { opacity: 1; transform: scale(1); } }

/* Input Area - Centered */
.chat-input-area {
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: linear-gradient(to top, var(--bg-0) 85%, transparent);
}
.input-container {
    max-width: 720px;
    width: 100%;
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 14px 18px;
    background: var(--bg-3);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    transition: all var(--fast) var(--ease);
}
.input-container:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.input-container textarea { flex: 1; resize: none; max-height: 150px; font-size: 15px; line-height: 1.5; padding: 4px 0; }
.input-container textarea::placeholder { color: var(--text-4); }

.input-btns { display: flex; gap: 4px; }
.input-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    color: var(--text-3);
    transition: all var(--fast) var(--ease);
}
.input-btn svg { width: 18px; height: 18px; }
.input-btn:hover { color: var(--text-2); background: var(--bg-hover); }
.input-btn.primary { background: var(--accent); color: #fff; }
.input-btn.primary:hover { background: var(--accent-2); }

/* Status Mini (inside input area) */
.status-mini {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    font-size: 11px;
    color: var(--text-4);
}
.status-mini .status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--success);
}
.status-mini .status-dot.error { background: var(--error); }
.status-mini .status-dot.warning { background: var(--warning); }

/* Browser */
.browser-full { flex: 1; display: flex; flex-direction: column; }
.browser-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: var(--bg-2);
    border-bottom: 1px solid var(--border);
}
.browser-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-3);
    padding: 4px 8px;
    background: var(--bg-active);
    border-radius: 4px;
}
.browser-nav { display: flex; gap: 4px; }
.browser-nav button, .browser-url-box button {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    color: var(--text-3);
}
.browser-nav button:hover, .browser-url-box button:hover { background: var(--bg-hover); color: var(--text-1); }
.browser-nav button svg, .browser-url-box button svg { width: 16px; height: 16px; }

.browser-url-box {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 12px;
    height: 38px;
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}
.browser-url-box svg { width: 14px; height: 14px; color: var(--text-4); flex-shrink: 0; }
.browser-url-box input { flex: 1; font-size: 13px; }
.browser-url-box input::placeholder { color: var(--text-4); }

.browser-view { flex: 1; position: relative; background: #fff; }
.browser-view iframe { width: 100%; height: 100%; border: none; }
.browser-empty {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: var(--bg-1);
    color: var(--text-4);
}
.browser-empty svg { width: 48px; height: 48px; opacity: 0.3; }
.browser-empty span { font-size: 13px; }
.browser-empty.hidden { display: none; }

/* Sandbox */
.sandbox-full { flex: 1; display: flex; flex-direction: column; }
.sandbox-split { flex: 1; display: flex; min-height: 0; }
.sandbox-editor-pane { flex: 1; display: flex; flex-direction: column; min-width: 200px; background: var(--bg-1); }
.sandbox-tabs {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px;
    border-bottom: 1px solid var(--border);
}
.sandbox-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-3);
    padding: 4px 8px;
    background: var(--bg-active);
    border-radius: 4px;
    margin-right: 8px;
}
.sandbox-tab {
    padding: 8px 14px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-3);
    border-radius: 6px;
    transition: all var(--fast) var(--ease);
}
.sandbox-tab:hover { color: var(--text-2); background: var(--bg-hover); }
.sandbox-tab.active { color: var(--text-1); background: var(--bg-active); }
.sandbox-code-wrap { flex: 1; overflow: hidden; }
.sandbox-code-wrap .CodeMirror { height: 100%; font-family: var(--mono); font-size: 13px; }

.sandbox-resize {
    width: 4px;
    background: var(--border);
    cursor: col-resize;
    transition: background var(--fast) var(--ease);
}
.sandbox-resize:hover { background: var(--accent); }

.sandbox-preview-pane { flex: 1; min-width: 200px; background: #fff; }
.sandbox-preview-pane iframe { width: 100%; height: 100%; border: none; }

/* Files */
.files-full { flex: 1; display: flex; }
.files-sidebar { width: 280px; display: flex; flex-direction: column; border-right: 1px solid var(--border); background: var(--bg-1); }
.files-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-3);
}
.files-header button { width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; color: var(--text-3); border-radius: 4px; }
.files-header button:hover { background: var(--bg-hover); color: var(--text-1); }
.files-header button svg { width: 14px; height: 14px; }

.files-list { flex: 1; overflow-y: auto; padding: 8px; }
.files-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; color: var(--text-4); padding: 40px; }
.files-empty svg { width: 40px; height: 40px; opacity: 0.3; }
.files-empty span { font-size: 12px; }

.file-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background var(--fast) var(--ease);
}
.file-item:hover { background: var(--bg-hover); }
.file-item.active { background: var(--bg-active); }
.file-item svg { width: 18px; height: 18px; color: var(--text-3); flex-shrink: 0; }
.file-item span { flex: 1; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.files-preview { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.files-preview-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
}
.preview-tabs { display: flex; gap: 4px; }
.preview-tab { padding: 8px 14px; font-size: 12px; color: var(--text-3); border-radius: 6px; }
.preview-tab:hover { color: var(--text-2); }
.preview-tab.active { color: var(--text-1); background: var(--bg-active); }
.preview-actions { display: flex; gap: 4px; }
.preview-actions button { width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; color: var(--text-3); border-radius: 6px; }
.preview-actions button:hover { background: var(--bg-hover); color: var(--text-1); }
.preview-actions button svg { width: 15px; height: 15px; }

.preview-content { flex: 1; position: relative; overflow: hidden; }
.preview-content iframe { width: 100%; height: 100%; border: none; background: #fff; }
.preview-code { position: absolute; inset: 0; margin: 0; padding: 16px; overflow: auto; background: var(--bg-2); font-family: var(--mono); font-size: 13px; }
.preview-code.hidden { display: none; }

/* Console (Floating) */
.console {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 440px;
    max-width: calc(100vw - 40px);
    height: 300px;
    background: var(--bg-3);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    z-index: 150;
    animation: slideUp var(--normal) var(--ease);
}
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
.console.hidden { display: none; }

.console-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
}
.console-tabs { display: flex; gap: 4px; }
.console-tab { padding: 6px 12px; font-size: 12px; color: var(--text-3); border-radius: 6px; }
.console-tab:hover { color: var(--text-2); }
.console-tab.active { color: var(--text-1); background: var(--bg-active); }
.console-actions { display: flex; gap: 4px; }
.console-actions button { width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; color: var(--text-3); border-radius: 6px; }
.console-actions button:hover { background: var(--bg-hover); color: var(--text-1); }
.console-actions button svg { width: 14px; height: 14px; }

.console-body { flex: 1; overflow: hidden; position: relative; }
.console-pane { position: absolute; inset: 0; overflow-y: auto; padding: 12px; font-family: var(--mono); font-size: 12px; display: none; }
.console-pane.active { display: block; }

.console-line { display: flex; gap: 8px; padding: 4px 0; color: var(--text-2); }
.console-line .time { color: var(--text-4); min-width: 40px; }
.console-line.success { color: var(--success); }
.console-line.error { color: var(--error); }
.console-line.warning { color: var(--warning); }

/* Toasts */
.toasts { position: fixed; top: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 200; pointer-events: none; }
.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    background: var(--bg-3);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow);
    font-size: 13px;
    pointer-events: auto;
    animation: toastIn var(--normal) var(--ease);
}
@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
.toast svg { width: 16px; height: 16px; flex-shrink: 0; }
.toast.success svg { color: var(--success); }
.toast.error svg { color: var(--error); }
.toast.info svg { color: var(--accent); }

/* Mobile Responsive */
@media (max-width: 768px) {
    .dock {
        position: fixed;
        left: 0;
        top: 0;
        height: 100%;
        transform: translateX(-100%);
        z-index: 200;
        box-shadow: var(--shadow);
    }
    .dock.open { transform: translateX(0); }
    .dock-toggle { display: flex; }
    
    .main { height: 100vh; }
    
    .welcome-icon svg { width: 56px; height: 56px; }
    .welcome h1 { font-size: 26px; }
    .welcome p { font-size: 14px; margin-bottom: 24px; }
    .qp { width: 48px; height: 48px; }
    .qp svg { width: 22px; height: 22px; }
    
    .chat-messages { padding: 70px 12px 12px; }
    .chat-input-area { padding: 16px 12px; }
    .input-container { padding: 12px 14px; border-radius: var(--radius-lg); }
    
    .message { gap: 10px; padding: 12px 0; max-width: 100%; }
    .msg-avatar { width: 28px; height: 28px; }
    .msg-avatar svg { width: 16px; height: 16px; }
    .msg-text { font-size: 14px; }
    
    .msg-artifact { margin: 8px 0; }
    .artifact-preview { height: 220px; }
    .artifact-code { max-height: 220px; }
    
    .console { left: 12px; right: 12px; width: auto; bottom: 12px; height: 260px; }
    
    .sandbox-split { flex-direction: column; }
    .sandbox-resize { width: 100%; height: 4px; cursor: row-resize; }
    .sandbox-editor-pane, .sandbox-preview-pane { min-width: 0; min-height: 200px; }
    
    .files-full { flex-direction: column; }
    .files-sidebar { width: 100%; height: 40%; border-right: none; border-bottom: 1px solid var(--border); }
}

@media (max-width: 480px) {
    .welcome-icon svg { width: 48px; height: 48px; }
    .welcome h1 { font-size: 22px; }
    .quick-prompts { gap: 8px; }
    .qp { width: 44px; height: 44px; }
    .qp svg { width: 20px; height: 20px; }
    
    .input-btn { width: 32px; height: 32px; }
    .input-btn svg { width: 16px; height: 16px; }
}

.hidden { display: none !important; }
