/* ═══════════════════════════════════════════════
   Jimmy AI — app.css
   ═══════════════════════════════════════════════ */

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

:root {
    --bg-base:        #0d1117;
    --bg-surface:     #161b22;
    --bg-elevated:    #1c2128;
    --bg-input:       #21262d;
    --border:         #30363d;
    --border-focus:   #58a6ff;
    --text-primary:   #e6edf3;
    --text-secondary: #8b949e;
    --text-muted:     #6e7681;
    --accent:         #58a6ff;
    --accent-hover:   #79c0ff;
    --success:        #3fb950;
    --warning:        #d29922;
    --error:          #f85149;
    --error-bg:       #1f1117;
    --success-bg:     #0f1f14;
    --radius:         6px;
    --radius-lg:      10px;
    --font:           -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    --font-mono:      'JetBrains Mono', 'Fira Code', 'Cascadia Code', Consolas, monospace;
    --sidebar-w:      260px;
    --artifact-w:     480px;
    --topbar-h:       48px;
}

html, body {
    height: 100%;
    font-family: var(--font);
    font-size: 14px;
    color: var(--text-primary);
    background: var(--bg-base);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ── Auth layout ─────────────────────────────────────────────── */
.auth-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
}

.auth-container { width: 100%; max-width: 400px; }

.auth-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 40px;
}

.auth-logo            { text-align: center; margin-bottom: 28px; }
.auth-logo .logo-icon { display: block; font-size: 36px; margin-bottom: 8px; }
.auth-logo h1         { font-size: 22px; font-weight: 600; }

.auth-subtitle {
    text-align: center;
    color: var(--text-secondary);
    font-size: 13px;
    margin-bottom: 20px;
    line-height: 1.5;
}

.auth-links         { text-align: center; margin-top: 16px; }
.auth-links a       { color: var(--accent); font-size: 13px; text-decoration: none; }
.auth-links a:hover { color: var(--accent-hover); text-decoration: underline; }

/* ── Forms ───────────────────────────────────────────────────── */
.auth-form   { display: flex; flex-direction: column; gap: 16px; }
.form-group  { display: flex; flex-direction: column; gap: 6px; }

.form-group label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-group input,
.form-group select,
.form-group textarea {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 14px;
    padding: 9px 12px;
    outline: none;
    width: 100%;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.12);
}

.form-group input::placeholder { color: var(--text-muted); }

/* 2FA code input */
input#code {
    font-family: var(--font-mono);
    font-size: 28px;
    text-align: center;
    letter-spacing: 10px;
    padding: 12px;
}

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-family: var(--font);
    font-size: 14px;
    font-weight: 500;
    padding: 9px 16px;
    border-radius: var(--radius);
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    white-space: nowrap;
    line-height: 1;
    -webkit-user-select: none;
    user-select: none;
}

.btn-primary  { background: var(--accent);      color: #0d1117;            border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-secondary { background: var(--bg-elevated); color: var(--text-primary); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg-input); border-color: var(--text-muted); }

.btn-ghost    { background: transparent; color: var(--text-secondary); border-color: transparent; }
.btn-ghost:hover { background: var(--bg-elevated); color: var(--text-primary); }

.btn-danger   { background: transparent; color: var(--error); border-color: var(--error); }
.btn-danger:hover { background: var(--error); color: #fff; }

.btn-full     { width: 100%; }
.btn-sm       { font-size: 12px; padding: 5px 10px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

/* ── Alerts ──────────────────────────────────────────────────── */
.alert {
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 13px;
    line-height: 1.5;
    border: 1px solid transparent;
}
.alert-error   { background: var(--error-bg);   border-color: rgba(248,81,73,0.4);  color: var(--error);   }
.alert-success { background: var(--success-bg); border-color: rgba(63,185,80,0.4);  color: var(--success); }
.alert-warning { background: #1f1a0e;           border-color: rgba(210,153,34,0.4); color: var(--warning); }

/* ── App shell ───────────────────────────────────────────────── */
.app-shell {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
    flex-shrink: 0;
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-header {
    height: var(--topbar-h);
    padding: 0 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.sidebar-header .logo-icon { font-size: 20px; }
.sidebar-header .logo-text { font-size: 16px; font-weight: 600; }

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.sidebar-section-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-muted);
    padding: 8px 8px 4px;
}

.sidebar-footer {
    padding: 10px 16px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    font-size: 13px;
    color: var(--text-secondary);
}

/* Main content */
.main-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.top-bar {
    height: var(--topbar-h);
    flex-shrink: 0;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 12px;
}

/* ── Artifact panel ──────────────────────────────────────────── */
.artifact-panel {
    flex-shrink: 0;
    width: 0;
    overflow: hidden;
    background: var(--bg-surface);
    border-left: 1px solid transparent;
    display: flex;
    flex-direction: column;
    transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.artifact-panel.open {
    width: var(--artifact-w);
    border-left-color: var(--border);
}

.artifact-panel-header {
    height: var(--topbar-h);
    flex-shrink: 0;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 8px 0 12px;
    gap: 8px;
    min-width: var(--artifact-w); /* keeps layout stable during open animation */
}

.artifact-lang-badge {
    flex-shrink: 0;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 20px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.artifact-panel-title {
    flex: 1;
    font-size: 13px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.artifact-btn-close {
    flex-shrink: 0;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    width: 28px;
    height: 28px;
    border-radius: var(--radius);
    font-size: 16px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s, background 0.15s;
}
.artifact-btn-close:hover { color: var(--text-primary); background: var(--bg-elevated); }

.artifact-panel-body {
    flex: 1;
    overflow: auto;
    padding: 16px;
    min-width: var(--artifact-w);
}

.artifact-panel-body pre {
    margin: 0;
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.65;
    color: var(--text-primary);
    white-space: pre;
    tab-size: 4;
}

/* ── Artifact pill (inline in chat messages) ─────────────────── */
.artifact-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font);
    font-size: 12px;
    font-weight: 500;
    padding: 4px 12px;
    margin: 4px 0;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: var(--bg-elevated);
    color: var(--accent);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}
.artifact-pill:hover { background: var(--bg-input); border-color: var(--accent); }

/* ── Chat message text ───────────────────────────────────────── */
.msg-text {
    color: var(--text-primary);
    line-height: 1.65;
    margin: 0 0 8px 0;
    white-space: pre-wrap;
    word-break: break-word;
}
.msg-text:last-child { margin-bottom: 0; }

/* ── Nav items (used in sidebar) ─────────────────────────────── */
.nav-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    border-radius: var(--radius);
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    text-decoration: none;
    transition: background 0.12s, color 0.12s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.nav-item:hover  { background: var(--bg-elevated); color: var(--text-primary); }
.nav-item.active { background: var(--bg-input);    color: var(--text-primary); font-weight: 500; }

/* ── Utility ─────────────────────────────────────────────────── */
a        { color: var(--accent); text-decoration: none; }
a:hover  { color: var(--accent-hover); text-decoration: underline; }

code, kbd {
    font-family: var(--font-mono);
    font-size: 12px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 1px 5px;
    color: var(--text-primary);
}

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

.visually-hidden {
    position: absolute; width: 1px; height: 1px;
    padding: 0; margin: -1px; overflow: hidden;
    clip: rect(0,0,0,0); border: 0;
}

/* ── Chat layer additions ────────────────────────────────────── */
.welcome-screen {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}

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

.message {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: var(--radius-lg);
    line-height: 1.6;
}

.message-user {
    align-self: flex-end;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
}

.message-assistant {
    align-self: flex-start;
    background: var(--bg-surface);
    border: 1px solid var(--border);
}

.message-role {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.message-body {
    color: var(--text-primary);
    font-size: 14px;
}

.typing-indicator .msg-text {
    color: var(--text-muted);
    font-style: italic;
}

/* Input area */
.input-area {
    flex-shrink: 0;
    padding: 12px 24px 16px;
    border-top: 1px solid var(--border);
    display: flex;
    background: var(--bg-surface);
}

.input-wrapper {
    flex: 1;
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.message-input {
    flex: 1;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 14px;
    padding: 10px 14px;
    resize: none;
    outline: none;
    min-height: 40px;
    max-height: 200px;
    line-height: 1.5;
    transition: border-color 0.15s;
}

.message-input:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.12);
}

.message-input::placeholder { color: var(--text-muted); }

.send-btn {
    height: 40px;
    width: 40px;
    padding: 0;
    flex-shrink: 0;
}

/* Model select */
.model-select {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 12px;
    padding: 4px 8px;
    outline: none;
    cursor: pointer;
}

.model-select:focus { border-color: var(--border-focus); }

.chat-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-left: 8px;
}

/* Universe label active state */
.universe-label.active {
    color: var(--accent);
}
