/* artifacts.css - Система артефактов с кодом (Mobile Responsive) */

/* ============================================
   ARTIFACT PANEL - Правая панель
   ============================================ */
.artifact-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 50%;
    height: 100vh;
    height: 100dvh;
    background: #1c1c1c;
    border-left: 1px solid rgba(255, 255, 255, 0.08);
    transform: translateX(100%);
    transition: transform 0.3s ease;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    box-shadow: -2px 0 12px rgba(0, 0, 0, 0.3);
}

.artifact-panel.open {
    transform: translateX(0);
}

/* ============================================
   ARTIFACT HEADER
   ============================================ */
.artifact-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    background: #202020;
    flex-wrap: wrap;
    gap: 12px;
}

.artifact-title {
    font-size: 14px;
    font-weight: 600;
    color: #d4d4d4;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.artifact-language {
    background: rgba(107, 136, 105, 0.2);
    color: #6b8869;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
}

.artifact-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.artifact-btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #d4d4d4;
    padding: 10px 14px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
    min-height: 44px;
    -webkit-tap-highlight-color: transparent;
}

.artifact-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.15);
}

.artifact-btn.copy-btn:hover {
    border-color: rgba(107, 136, 105, 0.5);
    color: #6b8869;
}

.artifact-btn.run-btn {
    background: rgba(107, 136, 105, 0.1);
    border-color: rgba(107, 136, 105, 0.3);
    color: #6b8869;
}

.artifact-btn.run-btn:hover {
    background: rgba(107, 136, 105, 0.2);
    border-color: rgba(107, 136, 105, 0.5);
}

.artifact-btn.run-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.artifact-btn.copied {
    background: rgba(107, 136, 105, 0.2);
    border-color: #6b8869;
    color: #6b8869;
}

.artifact-close-btn {
    background: transparent;
    border: none;
    color: #999;
    font-size: 28px;
    cursor: pointer;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.artifact-close-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

/* ============================================
   ARTIFACT CONTENT
   ============================================ */
.artifact-content {
    flex: 1;
    overflow: hidden;
    background: #1c1c1c;
    position: relative;
}

.artifact-code-wrapper {
    width: 100%;
    height: 100%;
    overflow: auto;
    padding: 20px 0;
    -webkit-overflow-scrolling: touch;
}

.artifact-code-wrapper::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

.artifact-code-wrapper::-webkit-scrollbar-track {
    background: #1c1c1c;
}

.artifact-code-wrapper::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 5px;
    border: 2px solid #1c1c1c;
}

.artifact-code-wrapper::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.25);
}

.artifact-code-wrapper::-webkit-scrollbar-corner {
    background: #1c1c1c;
}

.artifact-code-table {
    display: table;
    width: max-content;
    min-width: 100%;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.7;
    font-weight: 400;
}

.code-line {
    display: table-row;
}

.code-line-number {
    display: table-cell;
    padding: 0 16px 0 20px;
    text-align: right;
    color: #888;
    user-select: none;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    white-space: nowrap;
    vertical-align: top;
}

.code-line-content {
    display: table-cell;
    padding: 0 20px;
    color: #e8e8e8;
    white-space: pre;
    vertical-align: top;
}

/* Syntax highlighting */
.hljs-comment,
.hljs-quote {
    color: #6a9955;
    font-style: italic;
}

.hljs-keyword,
.hljs-selector-tag,
.hljs-literal,
.hljs-type {
    color: #569cd6;
}

.hljs-string,
.hljs-attr {
    color: #ce9178;
}

.hljs-number {
    color: #b5cea8;
}

.hljs-function,
.hljs-title {
    color: #dcdcaa;
}

.hljs-params {
    color: #9cdcfe;
}

.hljs-built_in,
.hljs-class .hljs-title {
    color: #4ec9b0;
}

.hljs-tag,
.hljs-name {
    color: #569cd6;
}

.hljs-attribute {
    color: #9cdcfe;
}

.hljs-variable,
.hljs-template-variable {
    color: #9cdcfe;
}

.hljs-regexp,
.hljs-link {
    color: #d16969;
}

.hljs-symbol,
.hljs-bullet {
    color: #4fc1ff;
}

.hljs-emphasis {
    font-style: italic;
}

.hljs-strong {
    font-weight: bold;
}

/* ============================================
   INLINE ARTIFACTS
   ============================================ */
.artifact-inline {
    margin: 12px 0;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    overflow: hidden;
    background: #1c1c1c;
}

.artifact-inline-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: #202020;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    flex-wrap: wrap;
    gap: 8px;
}

.artifact-inline-title {
    font-size: 13px;
    font-weight: 500;
    color: #d4d4d4;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.artifact-inline-lang {
    background: rgba(107, 136, 105, 0.2);
    color: #6b8869;
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.artifact-inline-filename {
    color: #999;
    font-weight: 400;
}

.artifact-inline-lines {
    color: #666;
    font-size: 11px;
    font-weight: 400;
}

.artifact-inline-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.artifact-inline-btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #999;
    padding: 8px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
    min-height: 40px;
    -webkit-tap-highlight-color: transparent;
}

.artifact-inline-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(107, 136, 105, 0.5);
    color: #d4d4d4;
}

.artifact-inline-btn svg {
    width: 14px;
    height: 14px;
}

.artifact-inline-content {
    position: relative;
    max-height: 500px;
    overflow: hidden;
}

.artifact-inline-content.collapsed {
    max-height: 300px;
}

.artifact-inline-content pre {
    margin: 0;
    padding: 16px;
    background: #1c1c1c;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.artifact-inline-content code {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.6;
}

.artifact-inline-content::-webkit-scrollbar {
    width: 8px;
}

.artifact-inline-content::-webkit-scrollbar-track {
    background: #1c1c1c;
}

.artifact-inline-content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}

.artifact-inline-content::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Fade effect */
.artifact-inline-fade {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 80px;
    background: linear-gradient(to bottom, rgba(28, 28, 28, 0), #1c1c1c);
    pointer-events: none;
}

/* Expand button */
.artifact-inline-expand {
    width: 100%;
    background: #202020;
    border: none;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    color: #999;
    padding: 12px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 44px;
    -webkit-tap-highlight-color: transparent;
}

.artifact-inline-expand:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #d4d4d4;
}

/* ============================================
   LOADING STATE
   ============================================ */
.artifact-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: #888;
}

.artifact-loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(107, 136, 105, 0.2);
    border-top-color: #6b8869;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

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

/* ============================================
   RESIZER
   ============================================ */
.artifact-resizer {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 6px;
    cursor: col-resize;
    background: transparent;
    transition: background 0.2s;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
}

.artifact-resizer::before {
    content: '';
    width: 3px;
    height: 40px;
    background: rgba(107, 136, 105, 0.3);
    border-radius: 2px;
    opacity: 0;
    transition: opacity 0.2s;
}

.artifact-resizer:hover::before {
    opacity: 1;
}

.artifact-resizer:hover {
    background: rgba(107, 136, 105, 0.1);
}

.artifact-resizer:active {
    background: rgba(107, 136, 105, 0.15);
}

.artifact-resizer:active::before {
    background: rgba(107, 136, 105, 0.6);
}

/* ============================================
   OVERLAY
   ============================================ */
.artifact-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.15);
    z-index: 9998;
    display: none;
}

.artifact-overlay.active {
    display: block;
}

/* ============================================
   CHAT AREA ADJUSTMENT
   ============================================ */
body.artifact-open .chat-area {
    transition: margin-right 0.1s ease;
}

/* ============================================
   NOTIFICATIONS
   ============================================ */
.artifact-notification {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: #202020;
    border: 1px solid rgba(107, 136, 105, 0.5);
    border-radius: 8px;
    padding: 14px 18px;
    color: #d4d4d4;
    font-size: 14px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    z-index: 10000;
    animation: slideUp 0.3s ease;
    cursor: pointer;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.artifact-notification:hover {
    background: #2a2a2a;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.artifact-notification-icon {
    display: inline-block;
    margin-right: 8px;
    color: #6b8869;
}

/* ============================================
   TABS (hidden)
   ============================================ */
.artifact-tabs {
    display: none !important;
}

/* ============================================
   EMPTY STATE
   ============================================ */
.artifact-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #888;
    text-align: center;
    padding: 40px;
}

.artifact-empty-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.4;
}

.artifact-empty-text {
    font-size: 14px;
    margin-bottom: 8px;
    color: #999;
}

.artifact-empty-hint {
    font-size: 12px;
    opacity: 0.6;
    color: #888;
}

/* ============================================
   CONSOLE
   ============================================ */
.artifact-console {
    display: none;
    flex-direction: column;
    background: #0f0f0f;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    max-height: 300px;
    min-height: 150px;
}

.console-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    background: #1a1a1a;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.console-header span {
    font-size: 12px;
    font-weight: 600;
    color: #999;
    text-transform: uppercase;
}

.console-clear-btn {
    background: transparent;
    border: none;
    color: #666;
    font-size: 20px;
    cursor: pointer;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.console-clear-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #999;
}

.console-output {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.6;
    -webkit-overflow-scrolling: touch;
}

.console-output::-webkit-scrollbar {
    width: 8px;
}

.console-output::-webkit-scrollbar-track {
    background: #0f0f0f;
}

.console-output::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}

.console-line {
    margin-bottom: 4px;
    word-wrap: break-word;
}

.console-log {
    color: #d4d4d4;
}

.console-user-input {
    color: #6b8869;
    font-weight: 500;
}

.console-error {
    color: #ff6b6b;
}

.console-warn {
    color: #ffa500;
}

.console-output iframe {
    margin-top: 12px;
}

/* Console input */
.console-input-container {
    display: none;
    align-items: center;
    padding: 10px 16px;
    background: #1a1a1a;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    gap: 8px;
}

.console-input-prompt {
    color: #6b8869;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 13px;
    font-weight: 600;
}

.console-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: #d4d4d4;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 13px;
    padding: 4px 0;
}

.console-input::placeholder {
    color: #666;
}

.console-input:focus {
    outline: none;
}

/* ============================================
   UPDATE NOTIFICATIONS
   ============================================ */
.update-notification {
    margin: 12px 0;
    animation: slideInFromLeft 0.3s ease-out;
}

.update-notification-content {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: linear-gradient(135deg, rgba(107, 136, 105, 0.1) 0%, rgba(107, 136, 105, 0.05) 100%);
    border-left: 3px solid #6b8869;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.update-notification-content:hover {
    background: linear-gradient(135deg, rgba(107, 136, 105, 0.15) 0%, rgba(107, 136, 105, 0.08) 100%);
    transform: translateX(2px);
}

.update-icon {
    font-size: 24px;
    flex-shrink: 0;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

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

.update-title {
    font-weight: 600;
    color: #6b8869;
    font-size: 14px;
}

.update-details {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    flex-wrap: wrap;
}

.update-file {
    color: #d4d4d4;
    font-family: 'Fira Code', 'Consolas', monospace;
    background: rgba(107, 136, 105, 0.1);
    padding: 2px 8px;
    border-radius: 4px;
}

.update-meta {
    color: #888;
    font-size: 12px;
}

.update-hint {
    font-size: 11px;
    color: #666;
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}

@keyframes slideInFromLeft {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Artifact highlight on update */
.artifact-panel.open.file-updated {
    animation: highlightArtifact 1s ease-out;
}

@keyframes highlightArtifact {
    0% {
        box-shadow: 0 0 0 0 rgba(107, 136, 105, 0.7);
    }
    50% {
        box-shadow: 0 0 20px 10px rgba(107, 136, 105, 0.3);
    }
    100% {
        box-shadow: none;
    }
}

/* ============================================
   SAFE AREA INSETS
   ============================================ */
@supports (padding: max(0px)) {
    .artifact-notification {
        bottom: max(24px, env(safe-area-inset-bottom));
        right: max(24px, env(safe-area-inset-right));
    }
}

/* ============================================
   TABLET RESPONSIVE (1024px)
   ============================================ */
@media (max-width: 1024px) {
    .artifact-panel {
        width: 60%;
    }
}

/* ============================================
   MOBILE RESPONSIVE (768px)
   ============================================ */
@media (max-width: 768px) {
    .artifact-panel {
        width: 100% !important;
    }
    
    body.artifact-open .chat-area {
        margin-right: 0 !important;
    }
    
    .artifact-overlay.active {
        display: none;
    }
    
    /* Hide resizer on mobile */
    .artifact-resizer {
        display: none;
    }
    
    /* Header */
    .artifact-header {
        padding: 14px 16px;
    }
    
    .artifact-title {
        font-size: 13px;
    }
    
    .artifact-btn {
        padding: 8px 12px;
        font-size: 12px;
    }
    
    .artifact-close-btn {
        width: 40px;
        height: 40px;
        font-size: 24px;
    }
    
    /* Code wrapper */
    .artifact-code-wrapper {
        padding: 16px 0;
    }
    
    .artifact-code-table {
        font-size: 12px;
        line-height: 1.6;
    }
    
    .code-line-number {
        padding: 0 12px 0 16px;
    }
    
    .code-line-content {
        padding: 0 16px;
    }
    
    /* Inline artifacts */
    .artifact-inline-header {
        padding: 10px 14px;
    }
    
    .artifact-inline-btn {
        padding: 6px 10px;
        font-size: 11px;
    }
    
    .artifact-inline-content pre {
        padding: 12px;
    }
    
    .artifact-inline-content code {
        font-size: 12px;
    }
    
    /* Update notifications */
    .update-notification-content {
        padding: 10px 12px;
        gap: 10px;
    }

    .update-icon {
        font-size: 20px;
    }

    .update-title {
        font-size: 13px;
    }

    .update-details {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    .update-hint {
        font-size: 10px;
    }
    
    /* Notifications */
    .artifact-notification {
        bottom: 16px;
        right: 16px;
        left: 16px;
        padding: 12px 14px;
        font-size: 13px;
    }
}

/* ============================================
   SMALL PHONES (480px)
   ============================================ */
@media (max-width: 480px) {
    .artifact-header {
        padding: 12px;
    }
    
    .artifact-actions {
        width: 100%;
        justify-content: flex-end;
    }
    
    .artifact-btn {
        flex: 1;
        justify-content: center;
    }
    
    .artifact-code-table {
        font-size: 11px;
    }
    
    .code-line-number {
        padding: 0 8px 0 12px;
    }
    
    .code-line-content {
        padding: 0 12px;
    }
    
    .artifact-inline-content code {
        font-size: 11px;
    }
}

/* ============================================
   TOUCH DEVICE ADJUSTMENTS
   ============================================ */
@media (hover: none) and (pointer: coarse) {
    .artifact-btn,
    .artifact-inline-btn,
    .artifact-close-btn,
    .artifact-inline-expand,
    .console-clear-btn {
        min-height: 48px;
    }
    
    .artifact-inline-btn {
        padding: 10px 14px;
    }
}
