

<?php $__env->startSection('title', 'Özel Alanlar — '.$customer->full_name); ?>
<?php $__env->startSection('page_title', 'Özel Alan Değerleri'); ?>

<?php $__env->startPush('styles'); ?>
<style>
:root { --cp:#6366f1; --border:#f1f5f9; }
.cfv-page { max-width:800px; margin:0 auto; }
.cfv-customer-bar {
    background:linear-gradient(135deg,#6366f1,#8b5cf6);
    border-radius:16px; padding:1.25rem 1.5rem;
    display:flex; align-items:center; gap:1rem;
    margin-bottom:1rem; color:#fff;
}
.cfv-avatar {
    width:48px;height:48px;border-radius:12px;background:rgba(255,255,255,.2);
    display:flex;align-items:center;justify-content:center;
    font-size:1.2rem;font-weight:800;flex-shrink:0;
}
.cfv-name { font-size:1.05rem;font-weight:800; }
.cfv-sub  { font-size:.78rem;color:rgba(255,255,255,.7);margin-top:2px; }

.cfv-card {
    background:#fff;border-radius:16px;border:1px solid var(--border);
    box-shadow:0 1px 4px rgba(0,0,0,.04);margin-bottom:1rem;overflow:hidden;
}
.cfv-card-header {
    display:flex;align-items:center;gap:.75rem;
    padding:1rem 1.25rem;border-bottom:1px solid var(--border);background:#fafbff;
}
.cfv-card-icon { width:34px;height:34px;border-radius:8px;display:flex;align-items:center;justify-content:center;font-size:14px;flex-shrink:0; }
.cfv-card-title { font-size:.88rem;font-weight:700;color:#0f172a; }
.cfv-card-count  { margin-left:auto;font-size:.75rem;color:#94a3b8; }

.cfv-body { padding:1.25rem; }
.cfv-fields { display:grid;grid-template-columns:repeat(auto-fill,minmax(280px,1fr));gap:1.25rem; }

.cf-field-item {}
.cf-field-label {
    display:flex;align-items:center;justify-content:space-between;
    margin-bottom:.4rem;
}
.cf-field-name { font-size:.78rem;font-weight:700;color:#64748b;text-transform:uppercase;letter-spacing:.4px; }
.cf-field-type { font-size:.65rem;background:#eef2ff;color:#6366f1;padding:2px 7px;border-radius:20px;font-weight:600; }
.cf-field-req  { color:#ef4444;margin-left:3px; }
.cf-help { font-size:.72rem;color:#94a3b8;margin-top:.25rem; }

/* Inputs */
.cf-input {
    width:100%;border:1.5px solid #e2e8f0;border-radius:10px;
    padding:.65rem .9rem;font-size:.875rem;color:#0f172a;
    background:#f8fafc;transition:all .2s;
}
.cf-input:focus { outline:none;border-color:#6366f1;box-shadow:0 0 0 3px rgba(99,102,241,.1);background:#fff; }
select.cf-input { cursor:pointer; }
textarea.cf-input { resize:vertical;height:80px; }
.cf-bool { display:flex;gap:.75rem; }
.cf-bool label { display:flex;align-items:center;gap:.5rem;cursor:pointer;font-size:.875rem;font-weight:500; }
.cf-bool input[type=radio] { accent-color:#6366f1;width:16px;height:16px; }

/* Multiselect checkboxes */
.cf-multi { display:flex;flex-wrap:wrap;gap:.5rem;margin-top:.25rem; }
.cf-multi-check {
    display:flex;align-items:center;gap:.5rem;
    background:#f8fafc;border:1.5px solid #e2e8f0;border-radius:8px;
    padding:.4rem .75rem;cursor:pointer;transition:all .15s;
}
.cf-multi-check:has(input:checked) { border-color:#6366f1;background:#eef2ff; }
.cf-multi-check input { accent-color:#6366f1;width:14px;height:14px; }
.cf-multi-check span { font-size:.82rem;font-weight:500; }

/* Empty fields notice */
.cfv-empty { text-align:center;padding:2.5rem;color:#94a3b8; }
.cfv-empty i { font-size:2.5rem;color:#cbd5e1;margin-bottom:.75rem; }

/* Footer */
.cfv-footer {
    background:#fff;border-top:1px solid var(--border);
    padding:1rem 1.25rem;display:flex;justify-content:space-between;align-items:center;
    border-radius:0 0 16px 16px;box-shadow:0 -4px 20px rgba(0,0,0,.05);
    position:sticky;bottom:0;z-index:10;
}
</style>
<?php $__env->stopPush(); ?>

<?php $__env->startSection('content'); ?>
<div class="container-fluid">
<div class="cfv-page">


<div class="cfv-customer-bar">
    <div class="cfv-avatar"><?php echo e($customer->initials); ?></div>
    <div>
        <div class="cfv-name"><?php echo e($customer->full_name); ?></div>
        <div class="cfv-sub">
            <?php echo e($customer->customer_type === 'corporate' ? '🏢 Kurumsal' : '👤 Bireysel'); ?>

            <?php if($customer->email): ?> · <?php echo e($customer->email); ?> <?php endif; ?>
        </div>
    </div>
    <a href="<?php echo e(route('agency.customers.show', $customer)); ?>" class="ms-auto btn btn-sm" style="background:rgba(255,255,255,.15);color:#fff;border-radius:8px;border:1px solid rgba(255,255,255,.2)">
        <i class="fas fa-arrow-left me-1"></i>Müşteri Kartına Dön
    </a>
</div>

<?php if($definitions->isEmpty()): ?>
<div class="cfv-card">
    <div class="cfv-empty">
        <i class="fas fa-puzzle-piece d-block"></i>
        <p>Henüz özel alan tanımlanmamış.</p>
        <a href="<?php echo e(route('agency.customers.fields.index')); ?>" class="btn btn-sm" style="background:#eef2ff;color:#6366f1;border-radius:8px">
            <i class="fas fa-plus me-1"></i>Alan Tanımla
        </a>
    </div>
</div>
<?php else: ?>

<form method="POST" action="<?php echo e(route('agency.customers.field-values.update', $customer)); ?>" id="cfvForm">
<?php echo csrf_field(); ?> <?php echo method_field('POST'); ?>

<div class="cfv-card">
    <div class="cfv-card-header">
        <div class="cfv-card-icon" style="background:#eef2ff;color:#6366f1"><i class="fas fa-puzzle-piece"></i></div>
        <div>
            <div class="cfv-card-title">Özel Alan Değerleri</div>
        </div>
        <div class="cfv-card-count"><?php echo e($definitions->count()); ?> alan</div>
    </div>
    <div class="cfv-body">
        <div class="cfv-fields">
            <?php $__currentLoopData = $definitions; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $def): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
            <?php $current = $existingValues[$def->id] ?? null; ?>
            <div class="cf-field-item">
                <div class="cf-field-label">
                    <span class="cf-field-name">
                        <?php echo e($def->label); ?>

                        <?php if($def->is_required): ?><span class="cf-field-req">*</span><?php endif; ?>
                    </span>
                    <span class="cf-field-type"><?php echo e($def->field_type_label); ?></span>
                </div>

                <?php if($def->field_type === 'boolean'): ?>
                    <div class="cf-bool">
                        <label>
                            <input type="radio" name="custom_fields[<?php echo e($def->id); ?>]" value="1" <?php echo e($current == '1' ? 'checked' : ''); ?>>
                            <span>Evet</span>
                        </label>
                        <label>
                            <input type="radio" name="custom_fields[<?php echo e($def->id); ?>]" value="0" <?php echo e($current == '0' ? 'checked' : ''); ?>>
                            <span>Hayır</span>
                        </label>
                        <label>
                            <input type="radio" name="custom_fields[<?php echo e($def->id); ?>]" value="" <?php echo e(is_null($current) ? 'checked' : ''); ?>>
                            <span style="color:#94a3b8">Belirtilmedi</span>
                        </label>
                    </div>

                <?php elseif($def->field_type === 'textarea'): ?>
                    <textarea name="custom_fields[<?php echo e($def->id); ?>]" class="cf-input"
                              placeholder="<?php echo e($def->default_value ?: ''); ?>"
                              <?php echo e($def->is_required ? 'required' : ''); ?>><?php echo e($current); ?></textarea>

                <?php elseif($def->field_type === 'select'): ?>
                    <select name="custom_fields[<?php echo e($def->id); ?>]" class="cf-input" <?php echo e($def->is_required ? 'required' : ''); ?>>
                        <option value="">Seçiniz</option>
                        <?php if($def->options): ?>
                            <?php $__currentLoopData = $def->options; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $opt): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <option value="<?php echo e($opt['value']); ?>" <?php echo e($current == $opt['value'] ? 'selected' : ''); ?>>
                                    <?php echo e($opt['label'] ?? $opt['value']); ?>

                                </option>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        <?php endif; ?>
                    </select>

                <?php elseif($def->field_type === 'multiselect'): ?>
                    <?php $selectedMulti = $current ? (json_decode($current, true) ?? []) : []; ?>
                    <div class="cf-multi">
                        <?php if($def->options): ?>
                            <?php $__currentLoopData = $def->options; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $opt): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <label class="cf-multi-check">
                                    <input type="checkbox" name="custom_fields[<?php echo e($def->id); ?>][]"
                                           value="<?php echo e($opt['value']); ?>"
                                           <?php echo e(in_array($opt['value'], $selectedMulti) ? 'checked' : ''); ?>>
                                    <span><?php echo e($opt['label'] ?? $opt['value']); ?></span>
                                </label>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        <?php endif; ?>
                    </div>

                <?php elseif($def->field_type === 'date'): ?>
                    <input type="date" name="custom_fields[<?php echo e($def->id); ?>]" class="cf-input"
                           value="<?php echo e($current); ?>" <?php echo e($def->is_required ? 'required' : ''); ?>>

                <?php elseif(in_array($def->field_type, ['number','decimal'])): ?>
                    <input type="number" name="custom_fields[<?php echo e($def->id); ?>]" class="cf-input"
                           value="<?php echo e($current); ?>"
                           step="<?php echo e($def->field_type === 'decimal' ? '0.01' : '1'); ?>"
                           placeholder="<?php echo e($def->default_value ?: '0'); ?>"
                           <?php echo e($def->is_required ? 'required' : ''); ?>>

                <?php elseif($def->field_type === 'email'): ?>
                    <input type="email" name="custom_fields[<?php echo e($def->id); ?>]" class="cf-input"
                           value="<?php echo e($current); ?>" placeholder="ornek@mail.com"
                           <?php echo e($def->is_required ? 'required' : ''); ?>>

                <?php elseif($def->field_type === 'phone'): ?>
                    <input type="tel" name="custom_fields[<?php echo e($def->id); ?>]" class="cf-input"
                           value="<?php echo e($current); ?>" placeholder="+90 5xx..."
                           <?php echo e($def->is_required ? 'required' : ''); ?>>

                <?php elseif($def->field_type === 'url'): ?>
                    <input type="url" name="custom_fields[<?php echo e($def->id); ?>]" class="cf-input"
                           value="<?php echo e($current); ?>" placeholder="https://"
                           <?php echo e($def->is_required ? 'required' : ''); ?>>

                <?php else: ?>
                    <input type="text" name="custom_fields[<?php echo e($def->id); ?>]" class="cf-input"
                           value="<?php echo e($current); ?>" placeholder="<?php echo e($def->default_value ?: ''); ?>"
                           <?php echo e($def->is_required ? 'required' : ''); ?>>
                <?php endif; ?>

                <?php if($def->help_text): ?>
                    <div class="cf-help"><i class="fas fa-info-circle me-1"></i><?php echo e($def->help_text); ?></div>
                <?php endif; ?>
            </div>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
        </div>
    </div>

    <div class="cfv-footer">
        <a href="<?php echo e(route('agency.customers.show', $customer)); ?>" class="btn btn-outline-secondary" style="border-radius:10px">
            <i class="fas fa-times me-1"></i>Vazgeç
        </a>
        <button type="submit" class="btn text-white" style="background:linear-gradient(135deg,#6366f1,#8b5cf6);border-radius:10px;padding:.65rem 2rem;font-weight:600">
            <i class="fas fa-save me-1"></i>Değerleri Kaydet
        </button>
    </div>
</div>

</form>
<?php endif; ?>

</div>
</div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('agency.layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\xampp\htdocs\acente\resources\views/agency/customers/fields/values.blade.php ENDPATH**/ ?>