/* Artifact System Styles */

/* Toolbar Container */
.artifact-toolbar-container {
    position: fixed;
    top: 0;
    right: -400px;
    width: 380px;
    height: 100vh;
    z-index: 1000;
    transition: right 0.3s ease;
    background: var(--card-bg, #ffffff);
    border-left: 1px solid var(--border-color, #e2e2e2);
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
}

.artifact-toolbar-container.visible {
    right: 0;
}

/* Artifact Toolbar */
.artifact-toolbar {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: var(--card-bg, #ffffff);
    color: var(--text-color, #333333);
}

.toolbar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid var(--border-color, #e2e2e2);
    background: var(--header-bg, #f8f9fa);
}

.toolbar-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-color, #333333);
}

.close-toolbar {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    color: var(--text-color-secondary, #666666);
    transition: all 0.2s ease;
}

.close-toolbar:hover {
    background: var(--hover-bg, #f0f0f0);
    color: var(--text-color, #333333);
}

/* Toolbar Content */
.toolbar-content {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}

/* File Type Grid */
.file-type-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

.file-type-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 16px 12px;
    border: 2px solid var(--border-color, #e2e2e2);
    border-radius: 8px;
    background: var(--card-bg, #ffffff);
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 80px;
}

.file-type-btn:hover {
    border-color: var(--primary-color, #007bff);
    background: var(--hover-bg, #f8f9ff);
    transform: translateY(-1px);
}

.file-type-btn.selected {
    border-color: var(--primary-color, #007bff);
    background: var(--primary-bg, #e3f2fd);
    color: var(--primary-color, #007bff);
}

.file-icon {
    font-size: 24px;
    margin-bottom: 8px;
    display: block;
}

.file-label {
    font-size: 14px;
    font-weight: 500;
    text-align: center;
}

/* Toolbar Actions */
.toolbar-actions {
    border-top: 1px solid var(--border-color, #e2e2e2);
    padding-top: 20px;
}

.file-name-input {
    position: relative;
    margin-bottom: 16px;
}

.file-name-input input {
    width: 100%;
    padding: 12px 16px;
    padding-right: 60px;
    border: 2px solid var(--border-color, #e2e2e2);
    border-radius: 8px;
    font-size: 14px;
    background: var(--input-bg, #ffffff);
    color: var(--text-color, #333333);
    transition: border-color 0.2s ease;
}

.file-name-input input:focus {
    outline: none;
    border-color: var(--primary-color, #007bff);
}

.file-name-input input.error {
    border-color: var(--error-color, #dc3545);
}

.file-extension {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 14px;
    color: var(--text-color-secondary, #666666);
    font-weight: 500;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 12px;
}

.btn {
    flex: 1;
    padding: 12px 16px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

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

.btn-primary {
    background: var(--primary-color, #007bff);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover, #0056b3);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--secondary-bg, #f8f9fa);
    color: var(--text-color, #333333);
    border: 1px solid var(--border-color, #e2e2e2);
}

.btn-secondary:hover {
    background: var(--hover-bg, #e9ecef);
    transform: translateY(-1px);
}

/* File Explorer */
.file-explorer-container {
    position: fixed;
    left: -320px;
    top: 0;
    width: 300px;
    height: 100vh;
    z-index: 999;
    transition: left 0.3s ease;
}

.file-explorer {
    width: 100%;
    height: 100%;
    background: var(--card-bg, #ffffff);
    border-right: 1px solid var(--border-color, #e2e2e2);
    display: flex;
    flex-direction: column;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
}

.file-explorer.visible {
    left: 0;
}

.file-explorer-container .file-explorer.visible {
    transform: translateX(320px);
}

/* Explorer Header */
.explorer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid var(--border-color, #e2e2e2);
    background: var(--header-bg, #f8f9fa);
}

.explorer-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-color, #333333);
}

.explorer-actions {
    display: flex;
    gap: 4px;
}

.explorer-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    border-radius: 4px;
    color: var(--text-color-secondary, #666666);
    transition: all 0.2s ease;
}

.explorer-btn:hover {
    background: var(--hover-bg, #f0f0f0);
    color: var(--text-color, #333333);
}

/* Explorer Content */
.explorer-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.explorer-toolbar {
    padding: 12px;
    border-bottom: 1px solid var(--border-color, #e2e2e2);
}

.file-search-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color, #e2e2e2);
    border-radius: 6px;
    font-size: 14px;
    background: var(--input-bg, #ffffff);
    color: var(--text-color, #333333);
}

.file-search-input:focus {
    outline: none;
    border-color: var(--primary-color, #007bff);
}

/* File Tree Container */
.file-tree-container {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.file-tree {
    list-style: none;
    padding: 0;
    margin: 0;
}

.file-tree-item {
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    font-size: 14px;
    position: relative;
}

.file-tree-item:hover {
    background: var(--hover-bg, #f0f0f0);
}

.file-tree-item.selected {
    background: var(--primary-bg, #e3f2fd);
    color: var(--primary-color, #007bff);
}

.item-content {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    min-height: 28px;
}

.folder-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    transition: transform 0.2s ease;
}

.folder-toggle svg {
    width: 12px;
    height: 12px;
    color: var(--text-color-secondary, #666666);
}

.item-spacer {
    width: 16px;
    height: 16px;
}

.item-icon {
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
}

.item-name {
    flex: 1;
    font-weight: 500;
    color: var(--text-color, #333333);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.item-path {
    font-size: 12px;
    color: var(--text-color-secondary, #666666);
    opacity: 0.7;
}

.item-actions {
    display: flex;
    gap: 2px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.file-tree-item:hover .item-actions {
    opacity: 1;
}

.item-action {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: 3px;
    color: var(--text-color-secondary, #666666);
    transition: all 0.2s ease;
}

.item-action:hover {
    background: var(--hover-bg, #f0f0f0);
    color: var(--text-color, #333333);
}

.item-action.delete-file:hover {
    background: var(--error-bg, #ffe6e6);
    color: var(--error-color, #dc3545);
}

.folder-children {
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.folder-children.hidden {
    max-height: 0;
}

/* Explorer Footer */
.explorer-footer {
    padding: 12px;
    border-top: 1px solid var(--border-color, #e2e2e2);
    background: var(--footer-bg, #f8f9fa);
}

.storage-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: var(--text-color-secondary, #666666);
}

/* Loading and Error States */
.loading-files, .error-message, .empty-state {
    text-align: center;
    padding: 20px;
    color: var(--text-color-secondary, #666666);
    font-style: italic;
}

.error-message {
    color: var(--error-color, #dc3545);
}

/* Search Results */
.search-results {
    padding: 8px;
}

.search-header {
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-color-secondary, #666666);
    border-bottom: 1px solid var(--border-color, #e2e2e2);
    margin-bottom: 8px;
}

.search-result-item {
    margin-bottom: 4px;
}

.search-result-item .item-name mark {
    background: var(--highlight-bg, #ffeb3b);
    color: var(--text-color, #333333);
    padding: 1px 2px;
    border-radius: 2px;
}

/* Header Buttons */
.artifacts-toggle,
.files-toggle,
.preview-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    color: var(--text-color-secondary, #666666);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.artifacts-toggle:hover,
.files-toggle:hover,
.preview-toggle:hover {
    background: var(--hover-bg, #f0f0f0);
    color: var(--text-color, #333333);
}

/* Quick Action Button */
.quick-artifact-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--primary-color, #007bff);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.3);
    transition: all 0.3s ease;
    z-index: 998;
}

.quick-artifact-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 123, 255, 0.4);
}

/* Responsive Design */
@media (max-width: 768px) {
    .artifact-toolbar-container {
        width: 100vw;
        right: -100vw;
    }
    
    .file-type-grid {
        grid-template-columns: 1fr;
    }
    
    .action-buttons {
        flex-direction: column;
    }
    
    .file-explorer {
        width: 100vw;
        left: -100vw;
    }
}

/* Dark Theme Support */
.dark-theme .artifact-toolbar-container,
.dark-theme .artifact-toolbar,
.dark-theme .file-explorer {
    --card-bg: #1a1a1a;
    --header-bg: #2d2d2d;
    --text-color: #ffffff;
    --text-color-secondary: #b0b0b0;
    --border-color: #404040;
    --hover-bg: #2d2d2d;
    --input-bg: #2d2d2d;
    --primary-bg: #1e3a8a20;
    --secondary-bg: #2d2d2d;
}

/* Loading States */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1001;
}

.dark-theme .loading-overlay {
    background: rgba(26, 26, 26, 0.9);
}

.loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border-color, #e2e2e2);
    border-top: 3px solid var(--primary-color, #007bff);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Success/Error Messages */
.message-toast {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 12px 16px;
    border-radius: 8px;
    color: white;
    font-size: 14px;
    font-weight: 500;
    z-index: 1002;
    animation: slideInRight 0.3s ease;
}

.message-toast.success {
    background: var(--success-color, #28a745);
}

.message-toast.error {
    background: var(--error-color, #dc3545);
}

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