/**
 * Modal Styles - Shared styles for all modal dialogs
 * Extracted from inline JavaScript styles for maintainability
 */

/* ============================================
   BASE MODAL STYLES
   ============================================ */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-overlay.hidden {
    display: none;
}

.modal-container {
    background: var(--panel-bg, #1e1e2e);
    border: 1px solid var(--border, #3a3a4a);
    border-radius: 12px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border, #3a3a4a);
    flex-shrink: 0;
}

.modal-title {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-main, #fff);
}

.modal-close-btn {
    background: none;
    border: none;
    color: var(--text-dim, #888);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color 0.2s;
}

.modal-close-btn:hover {
    color: var(--text-main, #fff);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 20px;
    border-top: 1px solid var(--border, #3a3a4a);
    flex-shrink: 0;
}

/* ============================================
   FORM ELEMENTS IN MODALS
   ============================================ */

.form-group {
    margin-bottom: 16px;
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    color: var(--text-dim, #888);
    font-size: 0.875rem;
}

.form-group .required {
    color: #ff4444;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border, #3a3a4a);
    border-radius: 6px;
    padding: 10px 12px;
    color: var(--text-main, #fff);
    font-family: inherit;
    font-size: 0.875rem;
    box-sizing: border-box;
    transition: border-color 0.2s;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--accent, #7c5cff);
}

.form-input.error,
.form-textarea.error {
    border-color: #ff4444;
}

.form-textarea {
    resize: vertical;
    min-height: 80px;
}

.form-select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23888' d='M6 8L2 4h8z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

.input-with-button {
    display: flex;
    gap: 8px;
}

.input-with-button .form-select,
.input-with-button .form-input {
    flex: 1;
}

.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--border, #3a3a4a);
    border-radius: 6px;
    color: var(--text-main, #fff);
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.btn-icon:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--accent, #7c5cff);
}

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

.btn-add {
    font-size: 1.25rem;
    font-weight: bold;
}

.error-message {
    color: #ff4444;
    font-size: 0.875rem;
    margin-top: 4px;
}

/* ============================================
   BUTTON STYLES
   ============================================ */

.btn-primary,
.btn-secondary {
    padding: 10px 20px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--accent, #7c5cff);
    color: #000;
}

.btn-primary:hover:not(:disabled) {
    background: var(--accent-hover, #9178ff);
}

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

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main, #fff);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
}

.btn-small {
    padding: 6px 12px;
    font-size: 0.8125rem;
}

/* ============================================
   ASSET BROWSER MODAL
   ============================================ */

.asset-browser-modal {
    width: 90%;
    max-width: 1000px;
    height: 80vh;
    display: flex;
    flex-direction: column;
}

.asset-browser-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border, #3a3a4a);
    gap: 16px;
    flex-wrap: nowrap;
}

.toolbar-filters {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: nowrap;
    flex: 1;
    min-width: 0;
}

.filter-select {
    min-width: 100px;
    max-width: 200px;
    flex-shrink: 1;
}

.search-input-wrapper {
    position: relative;
    flex: 1;
    min-width: 120px;
}

.search-input {
    padding-right: 36px;
    width: 100%;
}

.search-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.875rem;
    pointer-events: none;
}

.toolbar-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.asset-browser-content {
    flex: 1;
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.asset-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    grid-auto-rows: min-content;
    gap: 16px;
    padding: 20px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.asset-grid-empty,
.asset-grid-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: var(--text-dim, #888);
}

.asset-grid-loading-more {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    color: var(--text-dim, #888);
    gap: 12px;
}

.asset-grid-loading-more.hidden {
    display: none;
}

.loading-spinner-small {
    width: 24px;
    height: 24px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--accent, #7c5cff);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-text {
    font-size: 0.875rem;
    color: var(--text-dim, #888);
}

.empty-icon,
.loading-spinner {
    font-size: 3rem;
    margin-bottom: 16px;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--accent, #7c5cff);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

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

.asset-grid-item {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border, #3a3a4a);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    padding: 0;
    margin: 0;
    box-sizing: border-box;
}

.asset-thumbnail {
    position: relative;
    height: 120px;
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    overflow: hidden;
    border-radius: 6px 6px 0 0;
}

.asset-item-info {
    padding: 10px 12px;
    box-sizing: border-box;
}

.asset-item-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px 12px;
    box-sizing: border-box;
}

.asset-item-actions .version-select {
    flex: 1;
    min-width: 0;
    padding: 4px 8px;
    font-size: 0.75rem;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border, #3a3a4a);
    border-radius: 4px;
    color: var(--text-main, #fff);
    cursor: pointer;
    outline: none;
    transition: all 0.2s;
    height: 28px;
    box-sizing: border-box;
}

.asset-detail-btn {
    width: 28px;
    height: 28px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 4px;
    color: var(--text-dim, #888);
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
    box-sizing: border-box;
}

.asset-detail-btn:hover {
    color: var(--text-main, #fff);
    background: rgba(255, 255, 255, 0.1);
}

.asset-grid-item:hover {
    border-color: var(--accent, #7c5cff);
    transform: translateY(-2px);
}

.asset-grid-item.selected {
    border-color: var(--accent, #7c5cff);
    background: rgba(124, 92, 255, 0.1);
}

.asset-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.asset-thumbnail img.loaded {
    opacity: 1;
}

.asset-thumbnail-skeleton {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0.05) 0%,
        rgba(255, 255, 255, 0.1) 50%,
        rgba(255, 255, 255, 0.05) 100%
    );
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
}

.asset-thumbnail-skeleton.hidden {
    display: none;
}

@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

.asset-select-overlay {
    position: absolute;
    top: 8px;
    right: 8px;
}

.select-checkbox {
    width: 24px;
    height: 24px;
    background: rgba(0, 0, 0, 0.6);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: transparent;
    font-size: 14px;
    transition: all 0.2s;
}

.select-checkbox.checked {
    background: var(--accent, #7c5cff);
    border-color: var(--accent, #7c5cff);
    color: #fff;
}

.asset-item-name {
    font-weight: 500;
    color: var(--text-main, #fff);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.asset-item-meta {
    font-size: 0.75rem;
    color: var(--text-dim, #888);
}

.asset-item-actions .version-select:hover {
    border-color: var(--text-dim, #888);
    background: rgba(0, 0, 0, 0.4);
}

.asset-item-actions .version-select:focus {
    border-color: var(--accent, #7c5cff);
}

.asset-browser-footer {
    justify-content: space-between;
}

.selection-info {
    color: var(--text-dim, #888);
    font-size: 0.875rem;
}

/* Asset Detail Overlay */
.asset-detail-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.asset-detail-overlay.hidden {
    display: none;
}

.asset-detail-modal {
    background: var(--panel-bg, #1e1e2e);
    border: 1px solid var(--border, #3a3a4a);
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
    max-height: 80%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.asset-detail-content {
    padding: 20px;
    overflow-y: auto;
}

.detail-preview {
    aspect-ratio: 16 / 9;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 16px;
}

.detail-preview img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.detail-info {
    margin-bottom: 16px;
}

.detail-row {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.detail-label {
    color: var(--text-dim, #888);
    font-size: 0.875rem;
    min-width: 80px;
}

.detail-value {
    color: var(--text-main, #fff);
    font-size: 0.875rem;
}

.detail-versions h4 {
    margin: 0 0 12px;
    font-size: 0.875rem;
    color: var(--text-dim, #888);
}

.version-list {
    max-height: 150px;
    overflow-y: auto;
}

.version-item {
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 6px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: background 0.2s;
}

.version-item:hover {
    background: rgba(255, 255, 255, 0.06);
}

.version-item.latest {
    border-left: 3px solid var(--accent, #7c5cff);
}

.version-item.selected {
    background: rgba(124, 92, 255, 0.15);
}

.version-info {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 4px;
}

.version-number {
    font-weight: 600;
    color: var(--text-main, #fff);
}

.version-badge {
    background: var(--accent, #7c5cff);
    color: #000;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.625rem;
    font-weight: 600;
    text-transform: uppercase;
}

.version-date {
    color: var(--text-dim, #888);
    font-size: 0.75rem;
}

.version-comment {
    color: var(--text-dim, #888);
    font-size: 0.8125rem;
}

/* ============================================
   ASSET IMPORT MODAL
   ============================================ */

.asset-import-modal {
    width: 90%;
    max-width: 900px;
}

.asset-import-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    padding: 20px;
}

@media (max-width: 768px) {
    .asset-import-body {
        grid-template-columns: 1fr;
    }
}

.asset-preview-panel {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.asset-preview-viewport {
    aspect-ratio: 4 / 3;
    background: #1a1a2e;
    border-radius: 8px;
    overflow: hidden;
}

.asset-preview-controls {
    display: flex;
    gap: 8px;
}

.asset-preview-info {
    text-align: center;
    color: var(--text-dim, #888);
    font-size: 0.875rem;
}

.asset-form-panel {
    display: flex;
    flex-direction: column;
}

.file-upload-area {
    border: 2px dashed var(--border, #3a3a4a);
    border-radius: 8px;
    padding: 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.file-upload-area:hover {
    border-color: var(--accent, #7c5cff);
    background: rgba(124, 92, 255, 0.05);
}

.file-upload-area.has-file {
    border-style: solid;
    border-color: var(--accent, #7c5cff);
}

.file-upload-area.drag-over {
    border-color: var(--accent, #7c5cff);
    background: rgba(124, 92, 255, 0.1);
}

.hidden-input {
    display: none;
}

.file-upload-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.file-upload-icon {
    font-size: 2rem;
}

.file-upload-text {
    color: var(--text-dim, #888);
    font-size: 0.875rem;
}

.version-section {
    background: rgba(255, 165, 0, 0.1);
    border: 1px solid rgba(255, 165, 0, 0.3);
    border-radius: 8px;
    padding: 16px;
    margin-top: 8px;
}

.version-info {
    font-size: 0.8125rem;
    color: var(--text-dim, #888);
    line-height: 1.5;
}

/* ============================================
   INLINE DIALOG STYLES
   ============================================ */

.inline-dialog {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--panel-bg, #1e1e2e);
    border: 1px solid var(--border, #3a3a4a);
    border-radius: 8px;
    padding: 20px;
    z-index: 100;
    min-width: 280px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.inline-dialog.hidden {
    display: none;
}

.inline-dialog-content h4 {
    margin: 0 0 16px;
    font-size: 1rem;
}

.inline-dialog-content .form-input {
    margin-bottom: 16px;
}

.inline-dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* ============================================
   SAVE/PUBLISH DIALOG STYLES
   ============================================ */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
    width: auto;
    max-width: none;
    background: none;
    border: none;
    border-radius: 0;
    display: none;
}

.modal:not(.hidden) {
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
}

.modal .modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 10000;
}

.modal .modal-content {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--panel-bg, #1e1e2e);
    border: 1px solid var(--border, #3a3a4a);
    border-radius: 8px;
    width: 90%;
    max-width: 400px;
    z-index: 10001;
}

.modal .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border, #3a3a4a);
}

.modal .modal-header h3 {
    margin: 0;
    font-size: 1rem;
}

.modal .modal-close {
    background: none;
    border: none;
    color: var(--text-dim, #888);
    font-size: 1.5rem;
    cursor: pointer;
}

.modal .modal-body {
    padding: 20px;
}

.modal .modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 20px;
    border-top: 1px solid var(--border, #3a3a4a);
}

.modal .modal-input,
.modal textarea {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border, #3a3a4a);
    border-radius: 4px;
    padding: 10px 12px;
    color: var(--text-main, #fff);
    font-family: inherit;
    resize: vertical;
    box-sizing: border-box;
}

.modal textarea.error {
    border-color: #ff4444;
}

.modal textarea:focus {
    outline: none;
    border-color: var(--accent, #7c5cff);
}

.modal .btn {
    padding: 8px 16px;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    font-family: inherit;
}

.modal .btn-primary {
    background: var(--accent, #7c5cff);
    color: #000;
}

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

.modal .btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main, #fff);
}

/* ============================================
   MATERIAL BROWSER MODAL
   ============================================ */

.material-browser-modal {
    width: 90%;
    max-width: 900px;
    height: 80vh;
}

.material-browser-tabs {
    display: flex;
    padding: 0 20px;
    border-bottom: 1px solid var(--border, #3a3a4a);
}

.tab-btn {
    padding: 12px 24px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-dim, #888);
    font-family: inherit;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
}

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

.tab-btn.active {
    color: var(--accent, #7c5cff);
    border-bottom-color: var(--accent, #7c5cff);
}

.material-browser-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    gap: 16px;
}

.material-browser-content {
    flex: 1;
    overflow: hidden;
    position: relative;
}

.material-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 16px;
    padding: 20px;
    overflow-y: auto;
    max-height: 100%;
}

.material-grid-empty {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: var(--text-dim, #888);
}

.material-grid-item {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border, #3a3a4a);
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s;
}

.material-grid-item:hover {
    border-color: var(--accent, #7c5cff);
    transform: translateY(-2px);
}

.material-grid-item.selected {
    border-color: var(--accent, #7c5cff);
    background: rgba(124, 92, 255, 0.1);
}

.material-thumbnail {
    aspect-ratio: 1;
    background: rgba(0, 0, 0, 0.3);
    background-size: cover;
    background-position: center;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.material-placeholder {
    font-size: 2rem;
    opacity: 0.5;
}

.material-select-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
}

.material-grid-item:hover .material-select-overlay {
    opacity: 1;
}

.material-grid-item.selected .material-select-overlay {
    opacity: 1;
    background: rgba(124, 92, 255, 0.5);
}

.select-checkbox {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    color: transparent;
    transition: all 0.2s;
}

.select-checkbox.checked {
    background: var(--accent, #7c5cff);
    border-color: var(--accent, #7c5cff);
    color: white;
}

.material-item-info {
    padding: 10px;
}

.material-item-name {
    font-weight: 500;
    color: var(--text-main, #fff);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
    font-size: 0.875rem;
}

.material-item-type {
    font-size: 0.75rem;
    color: var(--text-dim, #888);
    text-transform: capitalize;
}

.material-item-actions {
    display: flex;
    gap: 4px;
    padding: 0 10px 10px;
    flex-wrap: wrap;
}

.material-item-actions .btn-icon {
    width: 28px;
    height: 28px;
    font-size: 0.75rem;
    padding: 0;
}

.material-browser-footer {
    justify-content: space-between;
}

.presets-dropdown {
    position: relative;
}

.presets-dropdown .dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    min-width: 150px;
    background: var(--panel-bg, #1e1e2e);
    border: 1px solid var(--border, #3a3a4a);
    border-radius: 6px;
    padding: 4px 0;
    z-index: 100;
}

/* ============================================
   MATERIAL EDITOR MODAL
   ============================================ */

.material-editor-modal {
    width: 90%;
    max-width: 1000px;
    max-height: 90vh;
}

.material-editor-content {
    display: grid;
    grid-template-columns: 1fr 1.2fr;
    gap: 20px;
    padding: 20px;
    max-height: calc(90vh - 140px);
    overflow-y: auto;
    align-items: start; /* Align items to top */
}

@media (max-width: 768px) {
    .material-editor-content {
        grid-template-columns: 1fr;
    }
}

.material-preview-panel {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 0; /* Prevent flex item from overflowing */
}

.preview-viewport {
    aspect-ratio: 1;
    background: #1a1a2e;
    border-radius: 8px;
    overflow: hidden;
    width: 100%;
    max-width: 100%;
    min-height: 0;
    position: relative;
}

.preview-viewport canvas {
    width: 100% !important;
    height: 100% !important;
    display: block;
    object-fit: contain;
}

.preview-controls {
    position: absolute;
    bottom: 12px;
    right: 12px;
    display: flex;
    gap: 8px;
    z-index: 10;
}

.preview-shape-btn {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border, #3a3a4a);
    color: var(--text-dim, #888);
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
}

.preview-shape-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main, #fff);
}

.preview-shape-btn.active {
    background: rgba(124, 92, 255, 0.2);
    border-color: var(--accent, #7c5cff);
    color: var(--accent, #7c5cff);
}

.material-properties-panel {
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow-y: auto;
    min-width: 0; /* Prevent flex item from overflowing */
    max-height: calc(90vh - 140px);
}

.property-section {
    background: rgba(255, 255, 255, 0.02);
    border-radius: 8px;
    padding: 12px;
}

.property-section .section-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-dim, #888);
    margin-bottom: 12px;
}

.property-group {
    margin-bottom: 12px;
}

.property-group:last-child {
    margin-bottom: 0;
}

.property-group > label {
    display: block;
    font-size: 0.8125rem;
    color: var(--text-dim, #888);
    margin-bottom: 6px;
}

.property-group.inline > label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    color: var(--text-main, #fff);
}

.property-group.inline input[type="checkbox"] {
    width: 16px;
    height: 16px;
}

.color-input-wrapper {
    display: flex;
    gap: 8px;
    align-items: center;
}

.color-picker {
    width: 40px;
    height: 32px;
    padding: 2px;
    border: 1px solid var(--border, #3a3a4a);
    border-radius: 4px;
    cursor: pointer;
}

.color-hex {
    flex: 1;
    max-width: 100px;
}

.slider-input-wrapper {
    display: flex;
    gap: 12px;
    align-items: center;
}

.slider-input-wrapper input[type="range"] {
    flex: 1;
    height: 4px;
    background: var(--border, #3a3a4a);
    border-radius: 2px;
    appearance: none;
    cursor: pointer;
}

.slider-input-wrapper input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 16px;
    height: 16px;
    background: var(--accent, #7c5cff);
    border-radius: 50%;
    cursor: pointer;
}

.slider-value {
    width: 60px;
    text-align: right;
}

/* ============================================
   MATERIAL SLOT (Inspector)
   ============================================ */

.material-section {
    margin-top: 8px;
}

.material-slot {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 8px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border, #3a3a4a);
    border-radius: 6px;
}

.material-slot-preview {
    width: 48px;
    height: 48px;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.3);
    background-size: cover;
    background-position: center;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: border-color 0.2s;
    border: 2px solid transparent;
}

.material-slot-preview:hover {
    border-color: var(--accent, #7c5cff);
}

.material-slot-preview.has-material {
    background-color: transparent;
}

.material-slot-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    font-size: 0.625rem;
    color: var(--text-dim, #888);
}

.material-slot-placeholder .placeholder-icon {
    font-size: 1rem;
}

.material-slot-info {
    flex: 1;
    min-width: 0;
}

.material-slot-name {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-main, #fff);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.material-slot-type {
    font-size: 0.6875rem;
    color: var(--text-dim, #888);
    text-transform: capitalize;
}

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

.material-slot-actions .btn-icon {
    width: 28px;
    height: 28px;
}

.material-slot-recent {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--panel-bg, #1e1e2e);
    border: 1px solid var(--border, #3a3a4a);
    border-radius: 6px;
    margin-top: 4px;
    padding: 8px;
    z-index: 10;
    max-height: 200px;
    overflow-y: auto;
}

.material-slot-recent.hidden {
    display: none;
}

.recent-title {
    font-size: 0.6875rem;
    text-transform: uppercase;
    color: var(--text-dim, #888);
    margin-bottom: 8px;
}

.recent-item {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 6px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s;
}

.recent-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.recent-item.active {
    background: rgba(124, 92, 255, 0.15);
}

.recent-item-thumb {
    width: 24px;
    height: 24px;
    background: rgba(0, 0, 0, 0.3);
    background-size: cover;
    background-position: center;
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.625rem;
}

.recent-item-name {
    font-size: 0.8125rem;
    color: var(--text-main, #fff);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ============================================
   MULTI-MATERIAL SLOTS PANEL
   ============================================ */

.material-slots-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.material-slot-wrapper {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.material-slot-label {
    font-size: 0.6875rem;
    font-weight: 500;
    color: var(--text-dim, #888);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.material-slot-container {
    position: relative;
}

.material-slot-preview.embedded-material {
    position: relative;
}

.embedded-material-lock {
    position: absolute;
    top: 4px;
    right: 4px;
    font-size: 0.75rem;
    background: rgba(0, 0, 0, 0.6);
    padding: 2px 4px;
    border-radius: 3px;
    pointer-events: none;
}

.material-extract-btn {
    width: 28px;
    height: 28px;
}

/* ============================================
   TEXTURE UPLOAD UI
   ============================================ */

.property-with-map {
    display: flex;
    gap: 8px;
    align-items: center;
}

.map-toggle-btn {
    width: 32px;
    height: 32px;
    padding: 0;
    border: 1px solid var(--border, #3a3a4a);
    background: rgba(255, 255, 255, 0.03);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.map-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--accent, #7c5cff);
}

.map-toggle-btn.active {
    background: rgba(124, 92, 255, 0.2);
    border-color: var(--accent, #7c5cff);
}

.map-upload-section {
    margin-top: 8px;
    padding: 8px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border, #3a3a4a);
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.map-upload-section.hidden {
    display: none;
}

.map-file-input {
    width: 100%;
    padding: 6px 8px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border, #3a3a4a);
    border-radius: 4px;
    color: var(--text-main, #fff);
    font-size: 0.8125rem;
    cursor: pointer;
}

.map-file-input:hover {
    background: rgba(255, 255, 255, 0.08);
}

.map-preview {
    width: 100%;
    height: 80px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border, #3a3a4a);
    border-radius: 4px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.map-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.map-loading {
    color: var(--text-dim, #888);
    font-size: 0.75rem;
    padding: 8px;
}

.map-error {
    color: var(--error, #ff4444);
    font-size: 0.75rem;
    padding: 8px;
}

.map-controls {
    display: flex;
    gap: 8px;
    align-items: center;
}

.map-controls label {
    font-size: 0.75rem;
    color: var(--text-dim, #888);
    white-space: nowrap;
}

.map-controls .form-input {
    flex: 1;
    min-width: 60px;
}

.clear-map-btn {
    padding: 4px 8px;
    font-size: 0.75rem;
    color: var(--text-dim, #888);
    background: transparent;
    border: none;
    cursor: pointer;
    transition: color 0.2s;
}

.clear-map-btn:hover {
    color: var(--text-main, #fff);
}

/* ============================================
   VIEW MODE BANNER
   ============================================ */

.view-mode-banner {
    margin-top: 12px;
    padding: 12px;
    background: rgba(124, 92, 255, 0.1);
    border: 1px solid rgba(124, 92, 255, 0.3);
    border-radius: 6px;
}

.banner-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.banner-icon {
    font-size: 1.25rem;
}

.banner-text {
    flex: 1;
    font-size: 0.875rem;
    color: var(--text-main, #fff);
}

.extract-material-btn {
    padding: 6px 12px;
    font-size: 0.8125rem;
}

/* ============================================
   STANDARDIZED PREVIEW VIEWPORT STYLES
   ============================================ */

/* Preview Viewport Container */
.preview-viewport-container {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 300px;
    background: var(--bg-dark, #1a1a2e);
    border-radius: 8px;
    overflow: hidden;
}

/* Preview Viewport Canvas Container */
.preview-viewport {
    width: 100%;
    height: 100%;
    display: block;
    cursor: grab;
}

.preview-viewport:active {
    cursor: grabbing;
}

/* Preview Info Overlay */
.preview-info {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.7);
    color: var(--text-main, #ffffff);
    font-size: 0.875rem;
    z-index: 10;
    pointer-events: none;
}

.preview-info:not([style*="display: none"]) {
    display: flex;
}

/* Preview Controls Container */
.preview-controls {
    position: absolute;
    bottom: 12px;
    right: 12px;
    display: flex;
    gap: 4px;
    z-index: 20;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    padding: 4px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Preview Control Button */
.preview-control-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    color: var(--text-main, #ffffff);
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    padding: 0;
}

.preview-control-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

.preview-control-btn.active {
    background: var(--accent, #00f2ff);
    border-color: var(--accent, #00f2ff);
    color: var(--bg-dark, #1a1a2e);
}

.preview-control-btn:active {
    transform: scale(0.95);
}

/* Material Detail Modal Styles */
.material-detail-dialog {
    max-width: 900px;
    width: 90vw;
}

.material-detail-body {
    display: flex;
    gap: 20px;
    padding: 20px;
    min-height: 500px;
}

.detail-preview-panel {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.detail-properties-panel {
    flex: 0 0 300px;
    min-width: 250px;
    padding: 16px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    border: 1px solid var(--border, #3a3a4a);
    overflow-y: auto;
    max-height: 500px;
}

.detail-properties-panel h4 {
    margin: 0 0 16px 0;
    font-size: 1rem;
    color: var(--text-main, #fff);
    border-bottom: 1px solid var(--border, #3a3a4a);
    padding-bottom: 8px;
}

.property-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.property-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.property-label {
    font-size: 0.75rem;
    color: var(--text-dim, #888);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.property-value {
    font-size: 0.875rem;
    color: var(--text-main, #fff);
    word-break: break-word;
}

/* ============================================
   OUTDATED ASSETS WARNING DIALOG
   ============================================ */

#outdated-assets-dialog .modal-body {
    max-height: 60vh;
    overflow-y: auto;
}

#outdated-assets-dialog .modal-body ul {
    background: rgba(255, 165, 0, 0.1);
    border: 1px solid rgba(255, 165, 0, 0.3);
    border-radius: 6px;
    padding: 12px 16px;
    margin: 12px 0;
}

#outdated-assets-dialog .modal-body li {
    padding: 4px 0;
    color: var(--text-main);
}

#outdated-assets-dialog .form-group label {
    display: flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

#outdated-assets-dialog .form-group input[type="checkbox"] {
    margin-right: 8px;
    cursor: pointer;
    width: 16px;
    height: 16px;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .material-detail-body {
        flex-direction: column;
        gap: 16px;
    }
    
    .detail-properties-panel {
        flex: 1;
        max-height: 300px;
    }
    
    .preview-controls {
        bottom: 8px;
        right: 8px;
        gap: 2px;
        padding: 2px;
    }
    
    .preview-control-btn {
        width: 28px;
        height: 28px;
        font-size: 0.875rem;
    }
}

/* ============================================
   CONNECTION MODAL
   ============================================ */

.connection-modal {
    width: 350px;
    min-width: 300px;
}

.connection-modal .modal-header {
    padding: 20px;
}

.connection-modal .modal-title {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1rem;
    width: 100%;
}

.connection-modal .modal-title i {
    color: var(--accent, #7c5cff);
    font-size: 1.125rem;
}

.connection-status {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 20px 0;
}

.connection-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--accent, #7c5cff);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.connection-status-text {
    color: var(--text-main, #fff);
    font-size: 0.875rem;
    text-align: center;
    margin: 0;
}

.connection-modal .modal-footer {
    justify-content: center;
    padding: 16px 20px;
}

.connection-modal .btn-secondary {
    min-width: 100px;
}

/* Connection Progress Bar */
.connection-progress {
    width: 100%;
    padding: 0 20px;
    margin-top: 8px;
}

.connection-progress.hidden {
    display: none;
}

.connection-progress-track {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 8px;
}

.connection-progress-bar {
    height: 100%;
    width: 0%;
    background: var(--accent, #7c5cff);
    border-radius: 3px;
    transition: width 0.2s ease-out;
}

.connection-progress-text {
    display: block;
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-dim, #888);
}

/* ============================================
   VERSION EXPLORER MODAL
   ============================================ */

.version-explorer-modal {
    width: 90%;
    max-width: 800px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
}

.version-explorer-body {
    padding: 0 !important;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 300px;
}

.version-explorer-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    gap: 16px;
}

.version-explorer-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: var(--text-dim, #888);
}

.version-explorer-table {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex: 1;
    min-height: 0;
}

.version-explorer-table-header {
    display: grid;
    grid-template-columns: 120px 150px 170px 130px 1fr;
    gap: 12px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border, #3a3a4a);
    color: var(--text-dim, #888);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.02);
}

.version-explorer-list {
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.version-row {
    display: grid;
    grid-template-columns: 120px 150px 170px 130px 1fr;
    gap: 12px;
    align-items: center;
    padding: 10px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    cursor: pointer;
    transition: all 0.15s ease;
}

.version-row:hover:not(.current) {
    background: rgba(255, 255, 255, 0.04);
}

.version-row.selected {
    background: rgba(0, 242, 255, 0.08);
    box-shadow: inset 2px 0 0 var(--accent, #00f2ff);
}

.version-row.current {
    opacity: 0.65;
    cursor: default;
}

.version-row-thumb {
    width: 110px;
    height: 62px;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid var(--border, #3a3a4a);
    background: rgba(0, 0, 0, 0.3);
}

.version-row-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.version-row-header {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.version-row-label {
    font-weight: 600;
    font-size: 0.9375rem;
    color: var(--text-main, #fff);
    font-family: monospace;
}

.version-badge {
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 0.625rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.version-badge.current-badge {
    background: rgba(255, 255, 255, 0.15);
    color: var(--text-dim, #888);
}

.version-badge.published-badge {
    background: var(--accent, #00f2ff);
    color: #000;
}

.version-row-comment {
    font-size: 0.8125rem;
    color: var(--text-dim, #888);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
}

.version-row-comment .no-comment {
    font-style: italic;
    opacity: 0.5;
}

.version-row-date,
.version-row-author {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.3);
}

@media (max-width: 640px) {
    .version-explorer-table-header {
        display: none;
    }

    .version-row {
        grid-template-columns: 1fr;
        gap: 8px;
        padding: 12px;
    }

    .version-row-thumb {
        width: 100%;
        height: 120px;
    }

    .version-row-date::before {
        content: 'Date: ';
        color: var(--text-dim, #888);
    }

    .version-row-author::before {
        content: 'Author: ';
        color: var(--text-dim, #888);
    }
}
