/* ============================================================================
   artifacts-page.css — the in-chat Artifact Browser.

   The browser takes over the conversation column (right of the sidebar) instead
   of opening a floating window. The sidebar keeps its exact position and stays
   fully usable; only the chat list + composer are swapped out while browsing.

   It reuses the Canvas design tokens (--dc-*) so the two surfaces feel like one
   product, with graceful fallbacks when the Canvas stylesheet hasn't defined
   them.
   ========================================================================== */

/* While browsing, hide the conversation + composer but leave the sidebar be. */
body.artifacts-browsing .chat-list,
body.artifacts-browsing #chat-skeleton,
body.artifacts-browsing .typing-area,
body.artifacts-browsing .header {
    display: none !important;
}
/* The top-bar's floating action icons (delete chat, voice) belong to the chat,
   not the browser — hide them so they don't hover over the browser's own bar.
   The sidebar toggle (.nav-menu-button) stays, so the sidebar is still usable. */
body.artifacts-browsing .nav .action-buttons,
body.artifacts-browsing .nav #start-live-voice {
    display: none !important;
}

.artifacts-browser {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: var(--dc-sidebar-current-w, 56px);
    display: flex;
    flex-direction: column;
    background:
        radial-gradient(120% 80% at 100% 0%, var(--accent-soft, rgba(183, 121, 92, .10)), transparent 60%),
        var(--dc-surface, var(--chat-area-background, #0f1116));
    color: var(--dc-text, var(--text-color, #e5e7eb));
    z-index: 60;
    overflow: hidden;
    animation: ab-in .32s cubic-bezier(.22, 1, .36, 1);
    transition: left var(--sidebar-motion-duration, 320ms) var(--sidebar-motion-ease, ease);
    font-family: var(--font, system-ui, -apple-system, 'Segoe UI', sans-serif);
}
.artifacts-browser[hidden] { display: none; }
@keyframes ab-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
    .artifacts-browser { animation: none; }
}

/* ── Top bar ─────────────────────────────────────────────────────────────── */
.ab-topbar {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 22px;
    border-bottom: 1px solid var(--dc-line, rgba(255, 255, 255, .1));
    background: linear-gradient(180deg, rgba(255, 255, 255, .03), transparent);
    flex: 0 0 auto;
}
.ab-heading { display: flex; align-items: center; gap: 12px; flex: 0 0 auto; }
.ab-heading-ico {
    display: inline-flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; border-radius: 11px;
    background: var(--accent-soft, rgba(183, 121, 92, .14));
    border: 1px solid var(--accent-ring, rgba(183, 121, 92, .4));
    color: var(--dc-accent, var(--accent, #b7795c));
    font-size: 21px;
}
.ab-heading-text { display: flex; flex-direction: column; line-height: 1.2; }
.ab-heading-text strong { font-size: 18px; font-weight: 700; letter-spacing: -.02em; }
.ab-heading-sub { font-size: 11.5px; color: var(--dc-muted, #9ca3af); font-weight: 500; }
.ab-heading-sub:empty { display: none; }

.ab-search {
    display: flex; align-items: center; gap: 8px;
    flex: 1 1 auto; max-width: 420px; margin-left: auto;
    padding: 0 12px; height: 40px;
    border-radius: 12px;
    background: rgba(0, 0, 0, .22);
    border: 1px solid var(--dc-line, rgba(255, 255, 255, .1));
    transition: border-color .16s ease, box-shadow .16s ease;
}
.ab-search:focus-within {
    border-color: var(--accent-ring, rgba(183, 121, 92, .5));
    box-shadow: 0 0 0 3px var(--accent-soft, rgba(183, 121, 92, .14));
}
.ab-search .material-symbols-rounded { font-size: 19px; color: var(--dc-muted, #9ca3af); }
.ab-search-input {
    flex: 1 1 auto; border: 0; background: transparent; outline: none;
    color: var(--dc-text, #e5e7eb); font-size: 13.5px; font-family: inherit;
}
.ab-search-input::placeholder { color: var(--dc-muted, #9ca3af); }

.ab-new {
    display: inline-flex; align-items: center; gap: 7px; flex: 0 0 auto;
    height: 40px; padding: 0 16px; border: 0; border-radius: 12px;
    background: var(--dc-accent, var(--accent, #b7795c)); color: #fff;
    font-family: inherit; font-size: 13.5px; font-weight: 650; cursor: pointer;
    box-shadow: var(--dc-shadow-2, 0 4px 12px -2px rgba(0, 0, 0, .3));
    transition: transform .16s ease, filter .16s ease;
}
.ab-new .material-symbols-rounded { font-size: 19px; }
.ab-new:hover { filter: brightness(1.08); }
.ab-new:active { transform: scale(.97); }
.ab-close {
    display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
    width: 40px; height: 40px; border: 0; border-radius: 12px;
    background: rgba(255, 255, 255, .05); color: var(--dc-muted, #9ca3af); cursor: pointer;
    transition: background .16s ease, color .16s ease, transform .16s ease;
}
.ab-close:hover { background: rgba(255, 255, 255, .1); color: var(--dc-text, #fff); }
.ab-close:active { transform: scale(.92); }

/* ── Scroll region ───────────────────────────────────────────────────────── */
.ab-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 20px 22px 60px;
    scrollbar-width: thin;
    overscroll-behavior: contain;
}
.ab-scroll::-webkit-scrollbar { width: 10px; }
.ab-scroll::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, .12); border: 3px solid transparent;
    background-clip: content-box; border-radius: 8px;
}
.ab-scroll::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, .22); background-clip: content-box; }
.ab-content { max-width: 1180px; margin: 0 auto; }

/* ── Session group ───────────────────────────────────────────────────────── */
.ab-group { margin-bottom: 30px; }
.ab-group-head { display: flex; align-items: center; gap: 9px; margin-bottom: 13px; padding-left: 2px; }
.ab-group-ico { font-size: 19px; color: var(--dc-accent, var(--accent, #b7795c)); opacity: .9; }
.ab-group-title { font-size: 14.5px; font-weight: 650; letter-spacing: -.01em; color: var(--dc-text, #e5e7eb); }
.ab-group-meta { font-size: 11.5px; color: var(--dc-muted, #9ca3af); margin-left: auto; font-variant-numeric: tabular-nums; }

.ab-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 14px;
}

/* ── Artifact card ───────────────────────────────────────────────────────── */
.ab-card {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--dc-line, rgba(255, 255, 255, .1));
    border-radius: 16px;
    background:
        linear-gradient(135deg, rgba(255, 255, 255, .035), transparent 60%),
        var(--dc-surface-2, rgba(255, 255, 255, .02));
    overflow: hidden;
    box-shadow: var(--dc-shadow-1, 0 1px 3px rgba(0, 0, 0, .18));
    transition: transform .18s cubic-bezier(.22, 1, .36, 1), border-color .18s ease, box-shadow .18s ease;
}
.ab-card:hover {
    transform: translateY(-3px);
    border-color: var(--accent-ring, rgba(183, 121, 92, .45));
    box-shadow: var(--dc-shadow-3, 0 18px 44px -12px rgba(0, 0, 0, .55));
}

.ab-card-head {
    display: flex; align-items: center; gap: 11px;
    padding: 14px 15px;
    cursor: pointer;
    border-bottom: 1px solid var(--dc-line, rgba(255, 255, 255, .08));
    transition: background .16s ease;
}
.ab-card-head:hover { background: var(--accent-soft, rgba(183, 121, 92, .1)); }
.ab-card-ico {
    display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
    width: 38px; height: 38px; border-radius: 11px;
    background: var(--accent-soft, rgba(183, 121, 92, .14));
    border: 1px solid var(--accent-ring, rgba(183, 121, 92, .35));
    color: var(--dc-accent, var(--accent, #b7795c)); font-size: 20px;
}
.ab-card-titles { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1 1 auto; }
.ab-card-title {
    font-size: 14px; font-weight: 650; letter-spacing: -.01em; color: var(--dc-text, #e5e7eb);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ab-card-sub { font-size: 11.5px; color: var(--dc-muted, #9ca3af); font-variant-numeric: tabular-nums; }
.ab-card-open { flex: 0 0 auto; font-size: 18px; color: var(--dc-muted, #9ca3af); transition: color .16s ease, transform .16s ease; }
.ab-card:hover .ab-card-open { color: var(--dc-accent, var(--accent, #b7795c)); transform: translate(1px, -1px); }

.ab-card-files { display: flex; flex-direction: column; padding: 6px; gap: 1px; }
.ab-file {
    display: flex; align-items: center; gap: 10px; width: 100%;
    padding: 8px 10px; border: 0; border-radius: 9px; background: transparent;
    color: var(--dc-text, #e5e7eb); font-family: inherit; text-align: left; cursor: pointer;
    transition: background .14s ease;
}
.ab-file:hover { background: rgba(255, 255, 255, .05); }
.ab-file-ico { font-size: 17px; color: var(--dc-muted, #9ca3af); flex: 0 0 auto; }
.ab-file:hover .ab-file-ico { color: var(--dc-accent, var(--accent, #b7795c)); }
.ab-file-name {
    flex: 1 1 auto; min-width: 0; font-family: var(--dc-mono, ui-monospace, monospace); font-size: 12.5px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ab-file-size { flex: 0 0 auto; font-size: 10.5px; color: var(--dc-muted, #9ca3af); font-variant-numeric: tabular-nums; }
.ab-file-more { padding: 6px 12px; font-size: 11.5px; color: var(--dc-muted, #9ca3af); }

/* ── States: empty / error / loading skeleton ────────────────────────────── */
.ab-state { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 64px 24px; color: var(--dc-muted, #9ca3af); }
.ab-empty .ab-empty-ico {
    font-size: 46px; margin-bottom: 14px; color: var(--dc-accent, var(--accent, #b7795c)); opacity: .85;
    display: inline-flex; align-items: center; justify-content: center;
    width: 84px; height: 84px; border-radius: 24px;
    background: var(--accent-soft, rgba(183, 121, 92, .12));
    border: 1px solid var(--accent-ring, rgba(183, 121, 92, .3));
}
.ab-empty h3 { margin: 6px 0 8px; font-size: 18px; font-weight: 700; color: var(--dc-text, #e5e7eb); }
.ab-empty p { margin: 0 0 20px; max-width: 380px; font-size: 13.5px; line-height: 1.6; }
.ab-empty-cta {
    display: inline-flex; align-items: center; gap: 7px; padding: 10px 18px; border: 0; border-radius: 12px;
    background: var(--dc-accent, var(--accent, #b7795c)); color: #fff; font-family: inherit; font-size: 13.5px; font-weight: 650; cursor: pointer;
    box-shadow: var(--dc-shadow-2, 0 4px 12px -2px rgba(0, 0, 0, .3)); transition: transform .16s ease, filter .16s ease;
}
.ab-empty-cta:hover { filter: brightness(1.08); }
.ab-empty-cta:active { transform: scale(.97); }
.ab-error { color: #f85149; gap: 8px; flex-direction: row; }
.ab-error .material-symbols-rounded { font-size: 20px; }

.ab-sk-group { margin-bottom: 30px; }
.ab-sk-line { border-radius: 7px; background: linear-gradient(90deg, rgba(255,255,255,.04), rgba(255,255,255,.09), rgba(255,255,255,.04)); background-size: 200% 100%; animation: ab-sheen 1.4s linear infinite; }
.ab-sk-head { width: 180px; height: 15px; margin-bottom: 14px; }
.ab-sk-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.ab-sk-card { border: 1px solid var(--dc-line, rgba(255, 255, 255, .08)); border-radius: 16px; padding: 15px; }
.ab-sk-line--title { width: 60%; height: 14px; margin-bottom: 14px; }
.ab-sk-row { height: 11px; margin: 9px 0; }
.ab-sk-row.short { width: 55%; }
@keyframes ab-sheen { to { background-position: -200% 0; } }

/* ── New Artifact creation menu (overlay within the browser) ─────────────── */
.ab-create {
    position: absolute;
    inset: 0;
    z-index: 5;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 8vh 24px 24px;
    background: color-mix(in srgb, var(--dc-surface, #0f1116) 82%, transparent);
    backdrop-filter: blur(10px) saturate(130%);
    -webkit-backdrop-filter: blur(10px) saturate(130%);
    opacity: 0;
    transition: opacity .22s ease;
}
@supports not (background: color-mix(in srgb, red, blue)) {
    .ab-create { background: rgba(10, 11, 15, .9); }
}
.ab-create[hidden] { display: none; }
.ab-create.show { opacity: 1; }
.ab-create-inner {
    width: min(760px, 100%);
    transform: translateY(10px) scale(.99);
    transition: transform .3s cubic-bezier(.34, 1.32, .5, 1);
}
.ab-create.show .ab-create-inner { transform: none; }
.ab-create-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 22px; }
.ab-create-title { margin: 0; font-size: 24px; font-weight: 750; letter-spacing: -.025em; color: var(--dc-text, #e5e7eb); }
.ab-create-sub { margin: 5px 0 0; font-size: 13.5px; color: var(--dc-muted, #9ca3af); }
.ab-create-close {
    margin-left: auto; flex: 0 0 auto; width: 38px; height: 38px; border: 0; border-radius: 11px;
    background: rgba(255, 255, 255, .05); color: var(--dc-muted, #9ca3af); cursor: pointer; transition: background .16s ease;
}
.ab-create-close:hover { background: rgba(255, 255, 255, .1); color: var(--dc-text, #fff); }

.ab-cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 12px; margin-bottom: 20px; }
.ab-cat {
    position: relative;
    display: flex; flex-direction: column; justify-content: space-between; gap: 26px;
    min-height: 108px; padding: 15px; text-align: left;
    border: 1px solid var(--dc-line, rgba(255, 255, 255, .1)); border-radius: 15px;
    background: var(--dc-surface-2, rgba(255, 255, 255, .025)); color: var(--dc-text, #e5e7eb);
    font-family: inherit; cursor: pointer;
    transition: transform .16s cubic-bezier(.22, 1, .36, 1), border-color .16s ease, background .16s ease, box-shadow .16s ease;
}
.ab-cat:hover { transform: translateY(-2px); border-color: var(--accent-ring, rgba(183, 121, 92, .45)); box-shadow: var(--dc-shadow-2, 0 4px 12px -2px rgba(0, 0, 0, .3)); }
.ab-cat.selected {
    border-color: var(--dc-accent, var(--accent, #b7795c));
    background: var(--accent-soft, rgba(183, 121, 92, .14));
    box-shadow: inset 0 0 0 1px var(--accent-ring, rgba(183, 121, 92, .4));
}
.ab-cat-label { font-size: 14px; font-weight: 600; line-height: 1.3; letter-spacing: -.01em; max-width: 90%; }
.ab-cat-ico { align-self: flex-end; font-size: 22px; color: var(--dc-muted, #9ca3af); transition: color .16s ease; }
.ab-cat:hover .ab-cat-ico, .ab-cat.selected .ab-cat-ico { color: var(--dc-accent, var(--accent, #b7795c)); }

.ab-create-compose {
    display: flex; align-items: flex-end; gap: 10px;
    padding: 12px; border-radius: 16px;
    border: 1px solid var(--dc-line, rgba(255, 255, 255, .12));
    background: rgba(0, 0, 0, .25);
    transition: border-color .16s ease, box-shadow .16s ease;
}
.ab-create-compose:focus-within {
    border-color: var(--accent-ring, rgba(183, 121, 92, .5));
    box-shadow: 0 0 0 3px var(--accent-soft, rgba(183, 121, 92, .14));
}
.ab-create-input {
    flex: 1 1 auto; resize: none; border: 0; background: transparent; outline: none;
    color: var(--dc-text, #e5e7eb); font-family: inherit; font-size: 14.5px; line-height: 1.5; max-height: 160px;
}
.ab-create-input::placeholder { color: var(--dc-muted, #9ca3af); }
.ab-create-input.shake { animation: ab-shake .45s ease; }
@keyframes ab-shake { 0%,100%{transform:translateX(0)} 20%,60%{transform:translateX(-5px)} 40%,80%{transform:translateX(5px)} }
.ab-create-go {
    display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
    width: 40px; height: 40px; border: 0; border-radius: 12px;
    background: var(--dc-accent, var(--accent, #b7795c)); color: #fff; cursor: pointer;
    box-shadow: var(--dc-shadow-2, 0 4px 12px -2px rgba(0, 0, 0, .3));
    transition: transform .16s ease, filter .16s ease;
}
.ab-create-go:hover { filter: brightness(1.08); }
.ab-create-go:active { transform: scale(.92); }

/* ── Flash the artifact box we navigated to ──────────────────────────────── */
.sbx-artifact-flash {
    animation: sbx-flash 1.5s cubic-bezier(.22, 1, .36, 1);
}
@keyframes sbx-flash {
    0% { box-shadow: 0 0 0 0 var(--accent-ring, rgba(183, 121, 92, .5)); }
    30% { box-shadow: 0 0 0 3px var(--accent-ring, rgba(183, 121, 92, .5)); }
    100% { box-shadow: 0 0 0 0 transparent; }
}

/* ── Mobile: full-bleed over the content, sidebar is an overlay there ─────── */
@media (max-width: 1000px) {
    .artifacts-browser { left: 0; }
    .ab-topbar { flex-wrap: wrap; gap: 10px; padding: 12px 14px; }
    .ab-search { order: 3; flex-basis: 100%; max-width: none; margin-left: 0; }
    .ab-scroll { padding: 16px 14px 60px; }
    .ab-cards, .ab-sk-cards { grid-template-columns: 1fr; }
    .ab-create { padding: 5vh 14px 14px; }
    .ab-create-title { font-size: 20px; }
}
