/* ============================================
   INSTANT MODE ARTIFACT STYLES
   Styles for live streaming and static artifact panels
   CSS follows JS - class names match what app.js creates
   ============================================ */

/* ============================================
   LIVE STREAMING ARTIFACTS (streamMessage)
   Used during real-time code streaming
   ============================================ */

/* Main container - live streaming */
.live-streaming-artifact {
    background: #1e1e1e;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 12px;
    overflow: hidden;
    margin: 10px 0;
    max-width: 680px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

/* Header */
.live-artifact-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: rgba(255,255,255,0.03);
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.live-artifact-icon {
    width: 16px;
    height: 16px;
    color: #777;
    flex-shrink: 0;
}

.live-artifact-icon svg {
    width: 100%;
    height: 100%;
}

.live-artifact-info {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.live-artifact-title {
    font-size: 13px;
    font-weight: 500;
    color: #e0e0e0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.live-artifact-lang {
    font-size: 10px;
    color: #777;
    background: rgba(255,255,255,0.08);
    padding: 2px 6px;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    flex-shrink: 0;
}

.live-artifact-status {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #888;
    font-size: 12px;
    flex-shrink: 0;
}

.live-artifact-spinner {
    width: 12px;
    height: 12px;
    border: 1.5px solid #444;
    border-top-color: #888;
    border-radius: 50%;
    animation: artifact-spin 0.8s linear infinite;
}

@keyframes artifact-spin {
    to { transform: rotate(360deg); }
}

/* Code area - live streaming */
.live-artifact-code {
    display: flex;
    max-height: 600px;
    overflow: auto;
    background: #111;
    -webkit-overflow-scrolling: touch;
    contain: content;
}

.live-artifact-lines {
    padding: 10px 8px;
    background: rgba(255,255,255,0.02);
    color: #444;
    text-align: right;
    user-select: none;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 13px;
    line-height: 1.5;
    min-width: 36px;
    border-right: 1px solid rgba(255,255,255,0.05);
    position: sticky;
    left: 0;
    z-index: 1;
    flex-shrink: 0;
}

.live-artifact-lines div {
    height: 1.5em;
}

.live-artifact-content {
    flex: 1;
    padding: 10px 12px !important;
    margin: 0 !important;
    border: none !important;
    border-radius: 0 !important;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 13px;
    line-height: 1.5;
    color: #d4d4d4;
    background: transparent !important;
    overflow-x: auto;
    white-space: pre;
    tab-size: 4;
    min-width: 0;
}

/* Line-by-line code rendering for perfect alignment with line numbers */
.live-artifact-content .code-line {
    height: 1.5em;
    line-height: 1.5;
    white-space: pre;
}

/* Scrollbar styling for code areas */
.live-artifact-code::-webkit-scrollbar,
.streaming-artifact-code::-webkit-scrollbar { width: 6px; height: 6px; }
.live-artifact-code::-webkit-scrollbar-track,
.streaming-artifact-code::-webkit-scrollbar-track { background: transparent; }
.live-artifact-code::-webkit-scrollbar-thumb,
.streaming-artifact-code::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 3px; }
.live-artifact-code::-webkit-scrollbar-thumb:hover,
.streaming-artifact-code::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.25); }

/* Completed state - live streaming */
.live-streaming-artifact.completed .live-artifact-spinner {
    display: none;
}

.live-streaming-artifact.completed .live-artifact-status {
    color: #6b6;
}

/* Footer added to live artifact on completion */
.live-artifact-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 12px;
    background: rgba(255,255,255,0.02);
    border-top: 1px solid rgba(255,255,255,0.06);
}

/* Syntax highlighting for live streaming */
.live-artifact-content .keyword { color: #c586c0; }
.live-artifact-content .string { color: #ce9178; }
.live-artifact-content .comment { color: #6a9955; }
.live-artifact-content .function { color: #dcdcaa; }
.live-artifact-content .number { color: #b5cea8; }
.live-artifact-content .class { color: #4ec9b0; }
.live-artifact-content .decorator { color: #d7ba7d; }
.live-artifact-content .operator { color: #d4d4d4; }

/* ============================================
   STATIC/COMPLETED ARTIFACTS (renderMarkdown)
   Used for collapsible file preview panels
   ============================================ */

/* Main container - static */
.streaming-artifact {
    background: #1e1e1e;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 12px;
    overflow: hidden;
    margin: 10px 0;
    max-width: 680px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

/* Header - static */
.streaming-artifact-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: rgba(255,255,255,0.03);
    border-bottom: 1px solid rgba(255,255,255,0.06);
    cursor: pointer;
    transition: background 0.15s ease;
}

.streaming-artifact-header:hover {
    background: rgba(255,255,255,0.06);
}

/* Title section */
.streaming-artifact-title {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.streaming-artifact-icon {
    width: 16px;
    height: 16px;
    color: #777;
    flex-shrink: 0;
}

.streaming-artifact-icon svg {
    width: 100%;
    height: 100%;
}

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

.streaming-artifact-label {
    font-size: 12.5px;
    font-weight: 500;
    color: #e0e0e0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.streaming-artifact-description {
    font-size: 10.5px;
    color: #666;
}

.streaming-artifact-file-badge {
    font-size: 10px;
    color: #666;
    background: rgba(255,255,255,0.06);
    padding: 2px 6px;
    border-radius: 4px;
    flex-shrink: 0;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
}

/* Toggle arrow for collapse */
.streaming-artifact-toggle {
    width: 16px;
    height: 16px;
    color: #555;
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.streaming-artifact-toggle svg {
    width: 100%;
    height: 100%;
}

.streaming-artifact.collapsed .streaming-artifact-toggle {
    transform: rotate(-90deg);
}

/* Collapsible body */
.streaming-artifact-body {
    max-height: 600px;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.streaming-artifact.collapsed .streaming-artifact-body {
    max-height: 0;
}

/* Code area - static */
.streaming-artifact-code {
    display: flex;
    max-height: 600px;
    overflow: auto;
    background: #111;
    -webkit-overflow-scrolling: touch;
    contain: content;
}

.streaming-line-numbers {
    padding: 10px 8px;
    background: rgba(255,255,255,0.02);
    color: #444;
    text-align: right;
    user-select: none;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 13px;
    line-height: 1.5;
    min-width: 36px;
    border-right: 1px solid rgba(255,255,255,0.05);
    position: sticky;
    left: 0;
    z-index: 1;
    flex-shrink: 0;
}

.streaming-line-numbers div {
    height: 1.5em;
}

.streaming-code-content {
    flex: 1;
    padding: 10px 12px !important;
    margin: 0 !important;
    border: none !important;
    border-radius: 0 !important;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 13px;
    line-height: 1.5;
    color: #d4d4d4;
    background: transparent !important;
    overflow-x: auto;
    white-space: pre;
    tab-size: 4;
    min-width: 0;
}

/* Line-by-line code rendering for perfect alignment with line numbers */
.streaming-code-content .code-line {
    height: 1.5em;
    line-height: 1.5;
    white-space: pre;
}

/* Syntax highlighting for static */
.streaming-code-content .keyword { color: #c586c0; }
.streaming-code-content .string { color: #ce9178; }
.streaming-code-content .comment { color: #6a9955; }
.streaming-code-content .function { color: #dcdcaa; }
.streaming-code-content .number { color: #b5cea8; }
.streaming-code-content .class { color: #4ec9b0; }
.streaming-code-content .decorator { color: #d7ba7d; }
.streaming-code-content .operator { color: #d4d4d4; }

/* Footer with stats and actions */
.streaming-artifact-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 12px;
    background: rgba(255,255,255,0.02);
    border-top: 1px solid rgba(255,255,255,0.06);
}

.streaming-artifact-stats {
    display: flex;
    gap: 12px;
    font-size: 10.5px;
    color: #555;
}

.streaming-artifact-stats strong {
    color: #777;
    font-weight: 500;
}

.streaming-artifact-actions {
    display: flex;
    gap: 6px;
}

.streaming-artifact-btn {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.1);
    color: #777;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 10.5px;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    gap: 4px;
    min-height: 44px;
}

.streaming-artifact-btn:hover {
    background: rgba(255,255,255,0.06);
    color: #e0e0e0;
    border-color: rgba(255,255,255,0.2);
}

.streaming-artifact-btn svg {
    width: 11px;
    height: 11px;
}

.streaming-artifact-btn:active,
.live-artifact-btn:active { transform: scale(0.95); opacity: 0.8; }
.streaming-artifact-btn:focus-visible,
.live-artifact-btn:focus-visible { outline: 2px solid rgba(100, 210, 255, 0.5); outline-offset: 2px; }

/* ============================================
   MOBILE RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
    .live-streaming-artifact,
    .streaming-artifact {
        max-width: 100%;
        border-radius: 10px;
    }

    .live-artifact-header,
    .streaming-artifact-header {
        padding: 7px 10px;
        gap: 8px;
    }

    .live-artifact-code,
    .streaming-artifact-code {
        max-height: 500px;
    }

    .live-artifact-lines,
    .streaming-line-numbers {
        padding: 8px 6px;
        min-width: 28px;
        font-size: 13px;
    }

    .live-artifact-content,
    .streaming-code-content {
        padding: 8px 10px;
        font-size: 13px;
    }

    .live-artifact-title,
    .streaming-artifact-label {
        font-size: 11.5px;
    }
}

@media (max-width: 480px) {
    .live-artifact-lines,
    .streaming-line-numbers {
        display: none;
    }

    .live-artifact-lang,
    .streaming-artifact-file-badge {
        display: none;
    }

    .streaming-artifact-footer {
        flex-direction: column;
        gap: 8px;
        align-items: stretch;
    }

    .streaming-artifact-stats {
        justify-content: center;
    }

    .streaming-artifact-actions {
        justify-content: center;
    }

    .streaming-artifact-description {
        display: none;
    }
}
