<div id="importModal" class="modal">
    <div class="modal-content">
        <div class="modal-header">
            <button class="close" onclick="modalManager.closeModal('importModal')">&times;</button>
            <h2>{{ t('recipes.controls.import.action') }}</h2>
        </div>
        
        <!-- Step 1: Provide Image (URL first, or drop zone below) -->
        <div class="import-step" id="uploadStep">
            <p class="import-description">{{ t('recipes.controls.import.title') }}</p>

            <!-- Input URL/Path Section (primary mode) -->
            <div class="import-section" id="urlSection">
                <div class="input-group">
                    <label for="imageUrlInput">{{ t('recipes.controls.import.imageUrlOrPath') }}</label>
                    <div class="input-with-button">
                        <input type="text" id="imageUrlInput" placeholder="{{ t('recipes.controls.import.urlPlaceholder') }}">
                        <button class="primary-btn" id="fetchImageBtn" onclick="importManager.handleUrlInput()">
                            <i class="fas fa-download"></i> {{ t('recipes.controls.import.fetchImage') }}
                        </button>
                    </div>
                    <div class="error-message" id="importUrlError"></div>
                </div>
            </div>

            <div class="import-divider"><span>{{ t('recipes.controls.import.orDivider') }}</span></div>

            <!-- Unified drop zone: click to browse, drag & drop, or paste an image -->
            <div class="import-drop-zone" id="importDropZone" tabindex="0" role="button"
                 aria-label="{{ t('recipes.controls.import.dropZoneLabel') }}">
                <input type="file" id="recipeImageUpload" accept="image/*" hidden
                       onchange="importManager.handleImageUpload(event)">
                <i class="fas fa-cloud-upload-alt drop-zone-icon"></i>
                <p class="drop-zone-primary" id="dropZonePrimaryText">{{ t('recipes.controls.import.dropZoneHint') }}</p>
                <p class="drop-zone-filename" id="selectedFileName" style="display: none;"></p>
            </div>
            <div class="error-message" id="uploadError"></div>

            <div class="modal-actions">
                <button class="secondary-btn" onclick="modalManager.closeModal('importModal')">{{ t('common.actions.cancel') }}</button>
            </div>
        </div>
        
        <!-- Step 2: Recipe Details -->
        <div class="import-step" id="detailsStep" style="display: none;">
            <div class="recipe-details-layout">
                <div class="recipe-image-container">
                    <div id="recipeImagePreview" class="recipe-image"></div>
                </div>
                
                <div class="recipe-form-container">
                    <div class="input-group">
                        <label for="recipeName">{{ t('recipes.controls.import.recipeName') }}</label>
                        <input type="text" id="recipeName" placeholder="{{ t('recipes.controls.import.recipeNamePlaceholder') }}" 
                               onchange="importManager.handleRecipeNameChange(event)">
                    </div>
                    
                    <div class="input-group">
                        <label>{{ t('recipes.controls.import.tagsOptional') }}</label>
                        <div class="tag-input-container">
                            <input type="text" id="tagInput" placeholder="{{ t('recipes.controls.import.addTagPlaceholder') }}">
                            <button class="secondary-btn" onclick="importManager.addTag()">
                                <i class="fas fa-plus"></i> {{ t('recipes.controls.import.addTag') }}
                            </button>
                        </div>
                        <div id="tagsContainer" class="tags-container">
                            <div class="empty-tags">{{ t('recipes.controls.import.noTagsAdded') }}</div>
                        </div>
                    </div>
                </div>
            </div>
            
            <div class="input-group">
                <label>{{ t('recipes.controls.import.lorasInRecipe') }} <span id="loraCountInfo" class="lora-count-info">(0/0 in library)</span></label>
                <div id="lorasList" class="loras-list">
                    <!-- LoRAs will be populated here -->
                </div>
            </div>

            <!-- Container for duplicate recipes warning -->
            <div id="duplicateRecipesContainer" class="duplicate-recipes-container" style="display: none;">
                <!-- Duplicate recipes will be populated here -->
            </div>
            
            <div class="modal-actions" id="detailsStepActions">
                <button class="secondary-btn" onclick="importManager.backToUpload()">{{ t('common.actions.back') }}</button>
                <button class="secondary-btn" id="importOnlyBtn" onclick="importManager.saveRecipeOnlyFromDetails()" style="display: none;">{{ t('recipes.controls.import.importRecipeOnly') }}</button>
                <button class="primary-btn" id="nextBtn" onclick="importManager.proceedFromDetails()">{{ t('common.actions.next') }}</button>
            </div>
        </div>
        
        <!-- Step 3: Download Location (if needed) -->
        <div class="import-step" id="locationStep" style="display: none;">
            <div class="location-selection">
                <!-- Path preview with inline toggle -->
                <div class="path-preview">
                    <div class="path-preview-header">
                        <label>{{ t('recipes.controls.import.downloadLocationPreview') }}</label>
                        <div class="inline-toggle-container" title="{{ t('recipes.controls.import.useDefaultPathTooltip') }}">
                            <span class="inline-toggle-label">{{ t('recipes.controls.import.useDefaultPath') }}</span>
                            <div class="toggle-switch">
                                <input type="checkbox" id="importUseDefaultPath">
                                <label for="importUseDefaultPath" class="toggle-slider"></label>
                            </div>
                        </div>
                    </div>
                    <div class="path-display" id="importTargetPathDisplay">
                        <span class="path-text">{{ t('recipes.controls.import.selectLoraRoot') }}</span>
                    </div>
                </div>

                <!-- Model Root Selection -->
                <div class="input-group">
                    <label for="importLoraRoot">{{ t('recipes.controls.import.selectLoraRoot') }}</label>
                    <select id="importLoraRoot"></select>
                </div>

                <!-- Manual Path Selection -->
                <div class="manual-path-selection" id="importManualPathSelection">
                    <!-- Path input with autocomplete -->
                    <div class="input-group">
                        <label for="importFolderPath">{{ t('recipes.controls.import.targetFolderPath') }}</label>
                        <div class="path-input-container">
                            <input type="text" id="importFolderPath" placeholder="{{ t('recipes.controls.import.folderPathPlaceholder') }}" autocomplete="off" />
                            <button type="button" id="importCreateFolderBtn" class="create-folder-btn" title="{{ t('recipes.controls.import.createNewFolder') }}">
                                <i class="fas fa-plus"></i>
                            </button>
                        </div>
                        <div class="path-suggestions" id="importPathSuggestions" style="display: none;"></div>
                    </div>
                    
                    <!-- Breadcrumb navigation -->
                    <div class="breadcrumb-nav" id="importBreadcrumbNav">
                        <span class="breadcrumb-item root" data-path="">
                            <i class="fas fa-home"></i> {{ t('recipes.controls.import.root') }}
                        </span>
                    </div>
                    
                    <!-- Hierarchical folder tree -->
                    <div class="input-group">
                        <label>{{ t('recipes.controls.import.browseFolders') }}</label>
                        <div class="folder-tree-container">
                            <div class="folder-tree" id="importFolderTree">
                                <!-- Tree will be loaded dynamically -->
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            
            <div class="modal-actions">
                <button class="secondary-btn" onclick="importManager.backToDetails()">{{ t('common.actions.back') }}</button>
                <button class="primary-btn" onclick="importManager.saveRecipe()">{{ t('recipes.controls.import.importAndDownload') }} <span id="downloadLoraCount"></span></button>
            </div>
        </div>
    </div>
</div>
