
<?php $__env->startSection('title', 'Upload Regulation Document'); ?>

<?php $__env->startSection('breadcrumbs'); ?>
    <a href="<?php echo e(route('admin.dashboard')); ?>" class="breadcrumb-item">Dashboard</a>
    <a href="<?php echo e(route('admin.regulation-documents.index')); ?>" class="breadcrumb-item">Regulation Documents</a>
    <span class="current">Upload</span>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('content'); ?>
<div style="max-width:720px;">
    <h1 class="page-title">Upload Regulation Document</h1>
    <p class="page-subtitle">Upload a PDF (scanned or digital) or Word file. GPT-4o will automatically extract zone rules.</p>

    <?php if($errors->any()): ?>
        <div class="alert alert-danger" style="margin-bottom:16px;">
            <ul style="margin:0;padding-left:20px;"><?php $__currentLoopData = $errors->all(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $e): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><li><?php echo e($e); ?></li><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?></ul>
        </div>
    <?php endif; ?>

    <div class="admin-card" style="padding:28px;">
        <form method="POST" action="<?php echo e(route('admin.regulation-documents.store')); ?>" enctype="multipart/form-data">
            <?php echo csrf_field(); ?>

            <div class="form-group">
                <label class="form-label">Document Title <span style="color:var(--vsc-red);">*</span></label>
                <input type="text" name="title" class="form-control" value="<?php echo e(old('title')); ?>"
                       placeholder="e.g. Mumbai DCR 2034, Pune Development Plan 2041"
                       required>
                <div class="form-hint">Give a clear name identifying the regulation document and its year.</div>
            </div>

            <div style="display:grid;grid-template-columns:1fr 1fr;gap:16px;margin-bottom:16px;">
                <div class="form-group" style="margin-bottom:0;">
                    <label class="form-label">State</label>
                    <select name="state_id" class="form-control">
                        <option value="">— All States —</option>
                        <?php $__currentLoopData = $states; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $s): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <option value="<?php echo e($s->id); ?>" <?php echo e(old('state_id') == $s->id ? 'selected' : ''); ?>><?php echo e($s->name); ?></option>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </select>
                </div>
                <div class="form-group" style="margin-bottom:0;">
                    <label class="form-label">City (optional)</label>
                    <select name="city_id" class="form-control">
                        <option value="">— Any City —</option>
                        <?php $__currentLoopData = $cities; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $c): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <option value="<?php echo e($c->id); ?>" <?php echo e(old('city_id') == $c->id ? 'selected' : ''); ?>><?php echo e($c->name); ?></option>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </select>
                </div>
            </div>

            <div class="form-group">
                <label class="form-label">Document File <span style="color:var(--vsc-red);">*</span></label>
                <div style="border:2px dashed var(--vsc-border);border-radius:8px;padding:32px;text-align:center;cursor:pointer;transition:border-color .2s;"
                     id="drop-zone"
                     ondragover="event.preventDefault();this.style.borderColor='var(--vsc-blue)'"
                     ondragleave="this.style.borderColor='var(--vsc-border)'"
                     ondrop="handleDrop(event)">
                    <i data-lucide="file-up" style="width:32px;height:32px;color:var(--vsc-text-muted);margin-bottom:8px;"></i>
                    <div style="font-size:13px;color:var(--vsc-text-secondary);margin-bottom:8px;">Drag &amp; drop your file here, or</div>
                    <label for="document-input" class="btn btn-secondary" style="cursor:pointer;">Browse File</label>
                    <input type="file" id="document-input" name="document" accept=".pdf,.doc,.docx"
                           style="display:none;" onchange="showFileName(this)">
                    <div id="file-name" style="margin-top:12px;font-size:12px;color:var(--vsc-text-secondary);"></div>
                </div>
                <div class="form-hint">
                    Supported: <strong>PDF</strong> (digital or scanned), <strong>DOC/DOCX</strong> (Word). Max 50 MB.<br>
                    <strong>Scanned PDFs</strong>: GPT-4o Vision will perform OCR automatically.
                </div>
            </div>

            <div style="background:var(--vsc-bg-secondary);border-radius:8px;padding:16px;margin-bottom:24px;">
                <div style="font-size:12px;font-weight:600;color:var(--vsc-yellow);margin-bottom:8px;">
                    <i data-lucide="zap" style="width:12px;height:12px;margin-right:4px;"></i> What happens after upload
                </div>
                <ol style="font-size:12px;color:var(--vsc-text-secondary);margin:0;padding-left:18px;line-height:1.8;">
                    <li>Text is extracted from the document (OCR for scanned files)</li>
                    <li>GPT-4o analyzes the text and extracts all zone rules (FAR, setbacks, floors, permitted uses, etc.)</li>
                    <li>You review the extracted rules and approve or reject them</li>
                    <li>Approved rules are pushed into the Zone Rules database</li>
                </ol>
            </div>

            <div style="display:flex;gap:12px;">
                <button type="submit" class="btn btn-primary">
                    <i data-lucide="upload" style="width:16px;height:16px;margin-right:6px;"></i> Upload &amp; Analyze
                </button>
                <a href="<?php echo e(route('admin.regulation-documents.index')); ?>" class="btn btn-ghost">Cancel</a>
            </div>
        </form>
    </div>
</div>

<script>
function showFileName(input) {
    const name = input.files[0]?.name || '';
    document.getElementById('file-name').textContent = name ? '📄 ' + name : '';
}
function handleDrop(e) {
    e.preventDefault();
    document.getElementById('drop-zone').style.borderColor = 'var(--vsc-border)';
    const files = e.dataTransfer.files;
    if (files.length > 0) {
        const input = document.getElementById('document-input');
        const dt = new DataTransfer();
        dt.items.add(files[0]);
        input.files = dt.files;
        showFileName(input);
    }
}
</script>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('admin.layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\xampp_lite_8_4\www\landfeasibility\resources\views/admin/regulation-documents/create.blade.php ENDPATH**/ ?>