/* ==========================================================================
   UNSLOTH-STYLE CANVAS & ARTIFACTS SYSTEM
   ========================================================================== */

/* Shimmer Animation */
@keyframes artifact-card-shimmer {
    0% { transform: translateX(-120%); }
    100% { transform: translateX(120%); }
}

@keyframes artifact-loading-line {
    0% { transform: translate3d(-125%, 0, 0) scaleX(0.78); }
    50% { transform: translate3d(0, 0, 0) scaleX(1); }
    100% { transform: translate3d(125%, 0, 0) scaleX(0.78); }
}

/* Artifact Card Row in Message Stream */
.artifact-cards-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    width: 100%;
    max-width: 640px;
    margin: 12px 0 6px 0;
}

/* Unsloth Artifact Button */
.unsloth-artifact-card {
    position: relative;
    flex: 1 1 240px;
    min-height: 56px;
    cursor: pointer;
    overflow: hidden;
    border-radius: 12px;
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
    background: var(--bg-card, rgba(255, 255, 255, 0.03));
    padding: 8px 14px;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-main, #f3f4f6);
    outline: none;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

body:not(.dark-theme) .unsloth-artifact-card {
    background: #f8fafc;
    border-color: #e2e8f0;
    color: #0f172a;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.unsloth-artifact-card:hover {
    background: var(--bg-hover, rgba(255, 255, 255, 0.08));
    border-color: var(--primary, #6366f1);
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.15);
}

body:not(.dark-theme) .unsloth-artifact-card:hover {
    background: #f1f5f9;
    border-color: var(--primary, #6366f1);
}

.unsloth-artifact-card:focus-visible {
    border-color: var(--primary, #6366f1);
    box-shadow: 0 0 0 2px var(--primary-glow, rgba(99, 102, 241, 0.3));
}

.artifact-card-icon-wrap {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    background: rgba(99, 102, 241, 0.12);
    border: 1px solid rgba(99, 102, 241, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary, #818cf8);
    flex-shrink: 0;
}

body:not(.dark-theme) .artifact-card-icon-wrap {
    background: rgba(99, 102, 241, 0.08);
    color: #4f46e5;
}

.artifact-card-icon-wrap svg {
    width: 18px;
    height: 18px;
}

.artifact-card-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    flex: 1;
}

.artifact-card-title {
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-main, #f3f4f6);
    line-height: 1.3;
}

body:not(.dark-theme) .artifact-card-title {
    color: #0f172a;
}

.artifact-card-badge {
    font-size: 11px;
    color: var(--text-muted, #94a3b8);
    line-height: 1;
}

.artifact-card-generating {
    padding: 2px 7px;
    border-radius: 9999px;
    background: rgba(99, 102, 241, 0.15);
    color: var(--primary, #818cf8);
    font-size: 10px;
    font-weight: 600;
    margin-left: auto;
    flex-shrink: 0;
}

/* Split-Screen Canvas Layout */
.app-container.split-canvas {
    display: flex;
    flex-direction: row;
    overflow: hidden;
}

.app-container.split-canvas .chat-main {
    flex: 1 1 50%;
    min-width: 380px;
    transition: flex 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.app-container.split-canvas #codex-panel {
    display: flex !important;
    flex: 1 1 50%;
    min-width: 440px;
    border-left: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
    background: var(--bg-main, #0b0b10);
    z-index: 30;
    height: 100vh;
    animation: slideInRight 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

body:not(.dark-theme) .app-container.split-canvas #codex-panel {
    background: #ffffff;
    border-left-color: #e2e8f0;
}

#codex-panel.fullscreen-canvas {
    position: fixed !important;
    inset: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 1000 !important;
    border: none !important;
}

@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Canvas Header */
.codex-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px;
    background: var(--bg-card, #12121b);
    border-bottom: 1px solid var(--border-color, rgba(255, 255, 255, 0.08));
    height: 52px;
    flex-shrink: 0;
    user-select: none;
    position: relative;
    z-index: 10;
}

body:not(.dark-theme) .codex-header {
    background: #ffffff !important;
    border-bottom: 1px solid #e2e8f0 !important;
}

/* Pill View Switcher (Preview / Code) - Exact Unsloth Pill Style */
.codex-tabs {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    background: rgba(255, 255, 255, 0.06);
    padding: 3px;
    border-radius: 9999px;
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.08));
}

body:not(.dark-theme) .codex-tabs {
    background: #f1f5f9 !important;
    border: 1px solid #e2e8f0 !important;
}

.codex-tab-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 14px;
    border-radius: 9999px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted, #94a3b8);
    background: transparent;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.15s ease;
}

body:not(.dark-theme) .codex-tab-btn {
    color: #64748b !important;
}

.codex-tab-btn:hover {
    color: var(--text-main, #f3f4f6);
}

body:not(.dark-theme) .codex-tab-btn:hover {
    color: #0f172a !important;
}

.codex-tab-btn.active {
    background: rgba(255, 255, 255, 0.14) !important;
    color: #ffffff !important;
    font-weight: 600 !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

body:not(.dark-theme) .codex-tab-btn.active {
    background: #ffffff !important;
    color: #0f172a !important;
    font-weight: 600 !important;
    border: 1px solid #cbd5e1 !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06) !important;
}

/* Hide legacy console tab - Unsloth Canvas only has [ Preview | Code ] */
#codex-tab-console,
#codex-console-badge {
    display: none !important;
}

/* Center Device Switcher */
.device-switcher {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    background: rgba(255, 255, 255, 0.04);
    padding: 3px;
    border-radius: 8px;
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.08));
}

body:not(.dark-theme) .device-switcher {
    background: #f1f5f9 !important;
    border: 1px solid #e2e8f0 !important;
}

.device-btn {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-muted, #94a3b8);
    cursor: pointer;
    font-size: 12px;
    transition: all 0.15s ease;
}

body:not(.dark-theme) .device-btn {
    color: #64748b !important;
}

.device-btn:hover {
    color: #fff;
}

body:not(.dark-theme) .device-btn:hover {
    color: #0f172a !important;
}

.device-btn.active {
    background: rgba(255, 255, 255, 0.12);
    color: var(--primary, #818cf8);
}

body:not(.dark-theme) .device-btn.active {
    background: #ffffff !important;
    color: var(--primary, #4f46e5) !important;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08) !important;
}

/* Action Icons on Right */
.codex-header-right {
    display: flex;
    align-items: center;
    gap: 4px;
}

.codex-header-right .icon-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-muted, #94a3b8);
    cursor: pointer;
    transition: all 0.15s ease;
}

.codex-header-right .icon-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-main, #f3f4f6);
}

/* Canvas Body */
.codex-body {
    flex: 1;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: var(--bg-main, #0b0b10);
}

.sandbox-frame-wrap {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #09090d;
    transition: all 0.25s ease;
    padding: 12px;
}

.sandbox-iframe {
    width: 100%;
    height: 100%;
    border: none;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
    transition: width 0.25s ease, height 0.25s ease;
}

.sandbox-frame-wrap.device-tablet .sandbox-iframe {
    width: 768px;
    max-width: 100%;
}

.sandbox-frame-wrap.device-mobile .sandbox-iframe {
    width: 375px;
    max-width: 100%;
}

/* Code View */
.codex-code-view {
    overflow: auto;
    padding: 20px;
    background: #0d0d14;
    height: 100%;
}

.codex-code-content pre {
    margin: 0;
    background: transparent !important;
    font-family: var(--font-mono, monospace);
    font-size: 13px;
    line-height: 1.65;
}

@media (max-width: 900px) {
    .app-container.split-canvas .chat-main {
        min-width: 0;
    }
    .app-container.split-canvas #codex-panel {
        position: fixed;
        inset: 0;
        width: 100vw;
        min-width: 0;
        height: 100vh;
        z-index: 100;
    }
}
