<div class="ticket-grid" style="grid-template-columns:1fr 340px">
  <div class="card">
    <div class="card-header"><h3>Business calendars</h3></div>
    <div class="table-wrap">
      <table class="table">
        <thead><tr><th>Name</th><th>Timezone</th><th>Work days</th><th>Hours</th></tr></thead>
        <tbody>
        <?php foreach ($calendars as $c) : ?>
          <tr><td><?= e($c['name']) ?><?= $c['is_default'] ? ' <span class="badge badge-outline">Default</span>' : '' ?></td><td><?= e($c['timezone']) ?></td><td class="text-sm"><?= e($c['work_days']) ?></td><td class="text-sm"><?= e(substr($c['start_time'],0,5)) ?>–<?= e(substr($c['end_time'],0,5)) ?></td></tr>
        <?php endforeach; ?>
        </tbody>
      </table>
    </div>
    <div class="card-header"><h3>Holidays</h3></div>
    <div class="table-wrap">
      <table class="table">
        <thead><tr><th>Date</th><th>Name</th><th>Calendar</th></tr></thead>
        <tbody>
        <?php foreach ($holidays as $h) : ?>
          <tr><td><?= fmt_d($h['holiday_date']) ?></td><td><?= e($h['name']) ?></td><td class="text-sm"><?= e($h['calendar_name']) ?></td></tr>
        <?php endforeach; ?>
        <?php if (empty($holidays)) : ?><tr><td colspan="3" class="text-faint">No holidays configured.</td></tr><?php endif; ?>
        </tbody>
      </table>
    </div>
  </div>
  <div class="card">
    <div class="card-header"><h3>Add holiday</h3></div>
    <div class="card-body">
      <form method="post" action="<?= url('/admin/calendar/holidays') ?>">
        <?= csrf_field() ?>
        <div class="form-group">
          <label>Calendar</label>
          <select name="calendar_id"><?php foreach ($calendars as $c) : ?><option value="<?= $c['id'] ?>"><?= e($c['name']) ?></option><?php endforeach; ?></select>
        </div>
        <div class="form-group"><label>Date <span class="req">*</span></label><input type="date" name="holiday_date" required></div>
        <div class="form-group"><label>Name <span class="req">*</span></label><input type="text" name="name" required></div>
        <button class="btn btn-primary btn-block">Add holiday</button>
        <p class="help-text mt-2">Excluded from SLA counting for tickets created after this is saved. Existing open tickets keep the due dates already computed (BRD 13.3).</p>
      </form>
    </div>
  </div>
</div>
