/* ── Alf-E artifacts.css — rich content blocks in chat ─────────────────────── */

.artifact {
    position: relative;
    margin: 12px 0;
    background: rgba(0,0,0,0.45);
    border: 1px solid rgba(255,255,255,0.10);
    border-radius: 12px;
    overflow: hidden;
}

.artifact-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: rgba(255,255,255,0.04);
    border-bottom: 1px solid rgba(255,255,255,0.08);
    font-size: 11px;
}

.artifact-label {
    color: #a78bfa;
    font-family: 'SF Mono', monospace;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.03em;
}

.artifact-btn {
    margin-left: auto;
    background: rgba(124,58,237,0.18);
    color: #c4b5fd;
    border: 1px solid rgba(124,58,237,0.35);
    border-radius: 6px;
    padding: 3px 9px;
    font-size: 11px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    cursor: pointer;
    transition: background 0.15s;
}
.artifact-btn + .artifact-btn { margin-left: 6px; }
.artifact-btn:hover { background: rgba(124,58,237,0.32); }
.artifact-btn-flash {
    background: rgba(16,185,129,0.32) !important;
    color: #6ee7b7 !important;
    border-color: rgba(16,185,129,0.5) !important;
}

/* ── Code blocks ──────────────────────────────────────────────────────────── */

.code-artifact {
    background: #0e1320;
}
.code-artifact > .code-toolbar {
    background: rgba(255,255,255,0.03);
}
.code-artifact > pre,
.code-artifact code {
    /* keep — pre is the wrapper */
}
pre.code-artifact {
    padding-top: 0;
}
.code-artifact code {
    display: block;
    padding: 12px 14px;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 12.5px;
    line-height: 1.55;
    color: #e2e8f0;
    background: transparent !important;
    overflow-x: auto;
}

/* hljs theme override hooks (we use atom-one-dark via CDN) */
.hljs { background: transparent !important; }

/* ── Mermaid diagrams ─────────────────────────────────────────────────────── */

.mermaid-artifact {
    background: rgba(255,255,255,0.02);
    padding-bottom: 10px;
}
.mermaid-artifact .mermaid {
    padding: 20px;
    text-align: center;
    overflow-x: auto;
}
.mermaid-artifact svg { max-width: 100%; height: auto; }

/* ── SVG artifacts ────────────────────────────────────────────────────────── */

.svg-artifact .svg-content {
    padding: 20px;
    text-align: center;
    background: rgba(255,255,255,0.02);
}
.svg-artifact svg {
    max-width: 100%;
    height: auto;
    background: white;
    border-radius: 6px;
}

/* ── HTML preview ─────────────────────────────────────────────────────────── */

.html-artifact iframe.html-preview {
    width: 100%;
    height: 320px;
    border: 0;
    background: white;
    display: block;
}

.html-artifact pre.artifact-source {
    margin: 0;
    border-radius: 0;
}

/* ── Errors ───────────────────────────────────────────────────────────────── */

.artifact-error {
    padding: 12px 16px;
    color: #fca5a5;
    font-size: 12px;
    background: rgba(239,68,68,0.08);
    border-bottom: 1px solid rgba(239,68,68,0.2);
}

/* ── Artifact side panel ──────────────────────────────────────────────────── */

.artifact-panel {
    position: fixed;
    top: 0; right: 0; bottom: 0;
    width: min(520px, 100vw);
    background: rgba(8, 8, 28, 0.97);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-left: 1px solid rgba(124,58,237,0.3);
    display: flex;
    flex-direction: column;
    z-index: 200;
    transform: translateX(110%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: -8px 0 40px rgba(0,0,0,0.6);
}
.artifact-panel.open { transform: translateX(0); }

.artifact-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    gap: 10px;
    flex-shrink: 0;
}
.artifact-panel-title {
    font-size: 13px;
    font-weight: 600;
    color: #a78bfa;
    font-family: 'SF Mono', monospace;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.artifact-panel-body {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.artifact-panel-body pre {
    flex: 1;
    overflow: auto;
    margin: 0;
    border-radius: 0;
}
.artifact-panel-body iframe { flex: 1; border: 0; background: white; }

#main.panel-open {
    margin-right: min(520px, 100vw);
    transition: margin-right 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

@media (max-width: 768px) {
    .artifact-panel { width: 100vw; }
    #main.panel-open { margin-right: 0; }
}

/* ── KaTeX adjustments ────────────────────────────────────────────────────── */

.katex-display { margin: 12px 0 !important; overflow-x: auto; }
.katex { font-size: 1.05em; }

/* ── Math inline — readable contrast ──────────────────────────────────────── */
.katex-html { color: #c4b5fd; }
