

<?php $__env->startSection('title', 'Tambah Jadwal - ' . $device->name); ?>

<?php $__env->startSection('content'); ?>
<style>
    .dv-form-card {
        background: #fff;
        border-radius: 14px;
        border: 1px solid rgba(0,0,0,0.06);
        box-shadow: 0 1px 3px rgba(13,43,94,0.06);
        padding: 28px 32px;
        max-width: 640px;
    }

    .dv-form-title { font-size: 18px; font-weight: 700; color: #0D2B5E; margin: 0 0 4px 0; }
    .dv-form-sub { font-size: 12.5px; color: rgba(0,0,0,0.45); margin: 0 0 24px 0; }

    .dv-field { margin-bottom: 16px; }
    .dv-field label { display: block; font-size: 12px; font-weight: 600; color: #0D2B5E; margin-bottom: 6px; }
    .dv-field input, .dv-field select { width: 100%; padding: 9px 12px; border-radius: 8px; border: 1px solid rgba(0,0,0,0.12); font-size: 13px; font-family: inherit; }
    .dv-field input:focus, .dv-field select:focus { outline: none; border-color: #0D2B5E; box-shadow: 0 0 0 3px rgba(13,43,94,0.08); }
    .dv-field small { display: block; margin-top: 5px; font-size: 11px; color: rgba(0,0,0,0.4); }

    .dv-row { display: flex; gap: 14px; }
    .dv-row .dv-field { flex: 1; }

    .dv-alert-error { background: #fee2e2; color: #dc2626; padding: 11px 16px; border-radius: 8px; font-size: 12.5px; margin-bottom: 18px; }
    .dv-alert-error ul { margin: 0; padding-left: 18px; }

    .dv-days { display: flex; flex-wrap: wrap; gap: 8px; }
    .dv-day-chip { position: relative; }
    .dv-day-chip input { position: absolute; opacity: 0; width: 0; height: 0; }
    .dv-day-chip label {
        display: block; padding: 7px 12px; border-radius: 999px; border: 1px solid rgba(0,0,0,0.12);
        font-size: 12px; font-weight: 600; color: rgba(0,0,0,0.55); cursor: pointer; margin: 0;
    }
    .dv-day-chip input:checked + label { background: #0D2B5E; border-color: #0D2B5E; color: #fff; }

    .dv-btn-primary { background: #F5B800; color: #0D2B5E; font-weight: 700; font-size: 12.5px; padding: 10px 20px; border-radius: 8px; border: none; cursor: pointer; }
    .dv-btn-primary:hover { background: #e0a600; }
    .dv-btn-link { font-size: 12px; color: rgba(0,0,0,0.45); text-decoration: none; margin-left: 12px; }
</style>

<div class="dv-form-card">
    <h1 class="dv-form-title">Tambah / Ubah Jadwal</h1>
    <p class="dv-form-sub"><?php echo e($device->name); ?> (<?php echo e($device->ip_address); ?>)</p>

    <?php if($errors->any()): ?>
        <div class="dv-alert-error">
            <ul>
                <?php $__currentLoopData = $errors->all(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $error): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <li><?php echo e($error); ?></li>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </ul>
        </div>
    <?php endif; ?>

    <form action="<?php echo e(route('devices.schedules.store', $device)); ?>" method="POST">
        <?php echo csrf_field(); ?>

        <div class="dv-field">
            <label>Nama Jadwal</label>
            <input type="text" name="name" value="<?php echo e(old('name')); ?>" placeholder="Misal: Pagi" required maxlength="50">
        </div>

        <div class="dv-field">
            <label>Nomor Template</label>
            <input type="number" name="plan_template_no" value="<?php echo e(old('plan_template_no', 1)); ?>" min="1" max="16" required>
            <small>
                Isi nomor template yang sama kalau mau MENGGANTI jadwal yang sudah ada di nomor itu.
                Cek dulu berapa slot yang device ini benar-benar dukung (biasanya 1-16).
            </small>
        </div>

        <div class="dv-row">
            <div class="dv-field">
                <label>Jam Mulai Bisa Absen</label>
                <input type="time" name="begin_time" value="<?php echo e(old('begin_time', '06:00')); ?>" required>
            </div>
            <div class="dv-field">
                <label>Jam Terakhir Bisa Absen</label>
                <input type="time" name="end_time" value="<?php echo e(old('end_time', '08:00')); ?>" required>
            </div>
        </div>

        <div class="dv-field">
            <label>Hari Aktif</label>
            <div class="dv-days">
                <?php $oldDays = old('days', \App\Models\DeviceSchedule::ALL_DAYS); ?>
                <?php $__currentLoopData = \App\Models\DeviceSchedule::ALL_DAYS; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $day): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <div class="dv-day-chip">
                        <input type="checkbox" name="days[]" id="day-<?php echo e($day); ?>" value="<?php echo e($day); ?>"
                               <?php echo e(in_array($day, $oldDays) ? 'checked' : ''); ?>>
                        <label for="day-<?php echo e($day); ?>"><?php echo e(substr($day, 0, 3)); ?></label>
                    </div>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </div>
        </div>

        <button type="submit" class="dv-btn-primary">Simpan &amp; Terapkan ke Device</button>
        <a href="<?php echo e(route('devices.schedules.index', $device)); ?>" class="dv-btn-link">Batal</a>
    </form>
</div>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH E:\laragon\www\maiadminweb\resources\views/devices/schedules/create.blade.php ENDPATH**/ ?>