
<?php if (isset($component)) { $__componentOriginal9ac128a9029c0e4701924bd2d73d7f54 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54 = $attributes; } ?>
<?php $component = App\View\Components\AppLayout::resolve([] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('app-layout'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\App\View\Components\AppLayout::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['title' => 'History Absensi']); ?>

<?php $__env->startPush('styles'); ?>
<link href="https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://cdn.datatables.net/1.13.6/css/jquery.dataTables.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
<style>
/* ══════════════════════════════════════════
   RESET & ROOT
══════════════════════════════════════════ */
*, *::before, *::after {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --c-success:      #10b981;
    --c-success-l:    #d1fae5;
    --c-success-d:    #065f46;
    --c-warning:      #f59e0b;
    --c-warning-l:    #fef3c7;
    --c-warning-d:    #92400e;
    --c-danger:       #ef4444;
    --c-danger-l:     #fee2e2;
    --c-danger-d:     #991b1b;
    --c-purple:       #8b5cf6;
    --c-purple-l:     #ede9fe;
    --c-purple-d:     #5b21b6;
    --c-blue-l:       #dbeafe;
    --c-blue-d:       #1e40af;
    --c-border:       #e5e7eb;
    --c-border-l:     #f3f4f6;
    --c-bg:           #f0f4ff;
    --c-bg2:          #f8fafc;
    --c-white:        #ffffff;
    --c-text:         #0f172a;
    --c-muted:        #64748b;
    --c-muted2:       #94a3b8;
    --c-primary:      #4f46e5;
    --c-violet:       #7c3aed;
    --c-primary-l:    #eef2ff;
    --c-primary-glow: rgba(79,70,229,.14);
    --bnav-h:         64px;
    --radius-sm:      8px;
    --radius-md:      10px;
    --radius-lg:      14px;
}

/* ══════════════════════════════════════════
   PAGE SHELL
══════════════════════════════════════════ */
.ha {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 0 0 12px;
    font-family: 'Plus Jakarta Sans', sans-serif;
}

/* ══════════════════════════════════════════
   HEADER
══════════════════════════════════════════ */
.ha-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
}

.ha-title {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ha-title-ico {
    width: 30px;
    height: 30px;
    background: linear-gradient(135deg, var(--c-primary), var(--c-violet));
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 3px 10px rgba(79,70,229,.28);
    flex-shrink: 0;
}
.ha-title-ico i { color: white; font-size: 12px; }

.ha-title-text h1 {
    font-size: 15px;
    font-weight: 800;
    color: var(--c-text);
    letter-spacing: -.03em;
    line-height: 1.2;
    margin: 0;
}
.ha-title-text p {
    font-size: 10px;
    color: var(--c-muted);
    font-weight: 500;
    margin: 2px 0 0;
}

.ha-live {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: var(--c-success-l);
    color: var(--c-success-d);
    font-size: 10px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 100px;
    border: 1px solid rgba(16,185,129,.2);
    white-space: nowrap;
}
.ha-live-dot {
    width: 5px;
    height: 5px;
    background: var(--c-success);
    border-radius: 50%;
    animation: blink 2s infinite;
}
@keyframes blink {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%       { opacity: .5; transform: scale(.8); }
}

/* ══════════════════════════════════════════
   STAT CARDS — mobile: 2×2, desktop: 4×1
══════════════════════════════════════════ */
.ha-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.ha-stat {
    background: var(--c-white);
    border: 1.5px solid var(--c-border);
    border-radius: var(--radius-lg);
    padding: 10px 12px 9px;
    position: relative;
    overflow: hidden;
    transition: transform .18s, box-shadow .18s;
}
.ha-stat:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 16px rgba(0,0,0,.07);
}
.ha-stat::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    border-radius: 3px 3px 0 0;
}
.ha-stat.s1::before { background: var(--c-success); }
.ha-stat.s2::before { background: var(--c-warning); }
.ha-stat.s3::before { background: var(--c-purple); }
.ha-stat.s4::before { background: var(--c-danger); }

.ha-stat-lbl {
    font-size: 9px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .07em;
    margin-bottom: 5px;
}
.ha-stat.s1 .ha-stat-lbl { color: var(--c-success); }
.ha-stat.s2 .ha-stat-lbl { color: var(--c-warning-d); }
.ha-stat.s3 .ha-stat-lbl { color: var(--c-purple-d); }
.ha-stat.s4 .ha-stat-lbl { color: var(--c-danger); }

.ha-stat-num {
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -.04em;
    line-height: 1;
}
.ha-stat.s1 .ha-stat-num { color: var(--c-success); }
.ha-stat.s2 .ha-stat-num { color: var(--c-warning); }
.ha-stat.s3 .ha-stat-num { color: var(--c-purple); }
.ha-stat.s4 .ha-stat-num { color: var(--c-danger); }

/* ══════════════════════════════════════════
   FILTER CARD
══════════════════════════════════════════ */
.ha-filter {
    background: var(--c-white);
    border: 1.5px solid var(--c-border);
    border-radius: var(--radius-lg);
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ha-frow {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.ha-fgrp {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.ha-flbl {
    font-size: 9px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--c-muted2);
    display: flex;
    align-items: center;
    gap: 4px;
}
.ha-flbl i { font-size: 9px; }

.ha-finput {
    width: 100%;
    padding: 8px 10px;
    border: 1.5px solid var(--c-border);
    border-radius: var(--radius-sm);
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 12px;
    font-weight: 600;
    color: var(--c-text);
    background: var(--c-bg2);
    outline: none;
    transition: border-color .18s, box-shadow .18s;
}
.ha-finput:focus {
    border-color: var(--c-primary);
    background: var(--c-white);
    box-shadow: 0 0 0 3px var(--c-primary-glow);
}

.ha-btn-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 6px;
}

.ha-btn {
    padding: 9px 10px;
    border-radius: var(--radius-sm);
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    transition: all .18s;
    white-space: nowrap;
}
.ha-btn i { font-size: 10px; }

.ha-btn-primary {
    background: linear-gradient(135deg, var(--c-primary), var(--c-violet));
    color: white;
    box-shadow: 0 3px 10px rgba(79,70,229,.3);
}
.ha-btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(79,70,229,.38); }
.ha-btn-primary:active { transform: scale(.98); }

.ha-btn-export {
    background: var(--c-success-l);
    color: var(--c-success-d);
    border: 1.5px solid rgba(16,185,129,.2);
}
.ha-btn-export:hover { background: var(--c-success); color: white; }

.ha-btn-reset {
    background: var(--c-white);
    color: var(--c-muted);
    border: 1.5px solid var(--c-border);
}
.ha-btn-reset:hover { background: var(--c-primary-l); color: var(--c-primary); }

/* ══════════════════════════════════════════
   TABLE CONTAINER
══════════════════════════════════════════ */
.ha-table-box {
    background: var(--c-white);
    border: 1.5px solid var(--c-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,.05);
}

.ha-table-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px 13px;
    background: var(--c-bg2);
    border-bottom: 1px solid var(--c-border);
}

.ha-table-title {
    display: flex;
    align-items: center;
    gap: 6px;
}
.ha-table-ico {
    width: 24px;
    height: 24px;
    background: var(--c-primary-l);
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.ha-table-ico i { color: var(--c-primary); font-size: 10px; }
.ha-table-title h3 { font-size: 12px; font-weight: 700; color: var(--c-text); margin: 0; }

.ha-badge {
    background: var(--c-primary-l);
    color: var(--c-primary);
    font-size: 10px;
    font-weight: 700;
    padding: 2px 10px;
    border-radius: 100px;
    border: 1px solid rgba(79,70,229,.15);
}

.ha-table-inner {
    padding: 0 12px 14px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* ══════════════════════════════════════════
   DATATABLE OVERRIDES
══════════════════════════════════════════ */
.dataTables_wrapper .dataTables_filter {
    padding: 10px 0 6px;
}
.dataTables_wrapper .dataTables_filter label {
    font-size: 11px;
    font-weight: 600;
    color: var(--c-muted);
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 5px;
    width: 100%;
}
.dataTables_wrapper .dataTables_filter input {
    background: var(--c-bg2);
    border: 1.5px solid var(--c-border);
    border-radius: 100px;
    padding: 6px 12px;
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 11px;
    color: var(--c-text);
    outline: none;
    transition: all .18s;
    margin-left: 0 !important;
    width: 100%;
    display: block;
    margin-top: 3px;
}
.dataTables_wrapper .dataTables_filter input:focus {
    border-color: var(--c-primary);
    box-shadow: 0 0 0 3px var(--c-primary-glow);
    background: white;
}
.dataTables_wrapper .dataTables_length { margin-bottom: 4px; }
.dataTables_wrapper .dataTables_length label {
    font-size: 11px;
    font-weight: 600;
    color: var(--c-muted);
    display: flex;
    align-items: center;
    gap: 5px;
    flex-wrap: wrap;
}
.dataTables_wrapper .dataTables_length select {
    border: 1.5px solid var(--c-border);
    border-radius: 7px;
    padding: 4px 7px;
    font-family: inherit;
    font-size: 11px;
    outline: none;
}
.dataTables_wrapper .dataTables_info {
    font-size: 10px;
    color: var(--c-muted2);
    font-weight: 600;
    padding-top: 8px;
}
.dataTables_wrapper .dataTables_paginate {
    padding-top: 8px;
    display: flex;
    justify-content: center;
}
.dataTables_wrapper .dataTables_paginate .paginate_button {
    padding: 5px 10px;
    border-radius: 7px;
    font-family: inherit;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
}
.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: var(--c-primary) !important;
    color: white !important;
    border: none !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button:hover:not(.current) {
    background: var(--c-primary-l) !important;
    color: var(--c-primary) !important;
    border: none !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button.disabled { opacity: .4 !important; }

/* ══════════════════════════════════════════
   TABLE ITSELF
══════════════════════════════════════════ */
table.dataTable {
    width: 100% !important;
    margin: 0 !important;
    border-collapse: collapse !important;
    min-width: 480px;
}
table.dataTable thead th {
    background: var(--c-bg2) !important;
    color: var(--c-muted2) !important;
    font-weight: 800 !important;
    font-size: 9px !important;
    text-transform: uppercase !important;
    letter-spacing: .07em !important;
    padding: 9px 10px !important;
    border-bottom: 1.5px solid var(--c-border) !important;
    border-top: none !important;
    white-space: nowrap;
}
table.dataTable thead th.sorting::after,
table.dataTable thead th.sorting_asc::after,
table.dataTable thead th.sorting_desc::after { opacity: .3; }

table.dataTable tbody td {
    padding: 9px 10px !important;
    font-size: 11px;
    font-weight: 500;
    color: var(--c-text);
    border-bottom: 1px solid var(--c-border-l) !important;
    vertical-align: middle;
}
table.dataTable tbody tr:last-child td { border-bottom: none !important; }
table.dataTable tbody tr { transition: background .12s; }
table.dataTable tbody tr:hover td { background-color: #fafbff !important; }

/* ── Cell helpers ── */
.c-no {
    color: var(--c-muted2);
    font-weight: 700;
    font-size: 11px;
}

.c-date .c-day {
    display: block;
    font-size: 9px;
    font-weight: 700;
    color: var(--c-muted2);
    text-transform: uppercase;
    letter-spacing: .04em;
}
.c-date .c-d {
    font-size: 11px;
    font-weight: 700;
    color: var(--c-text);
}

.tc {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 7px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
}
.tc i { font-size: 8px; }
.tc-in    { background: var(--c-primary-l); color: var(--c-primary); }
.tc-out   { background: var(--c-success-l); color: var(--c-success-d); }
.tc-empty { background: var(--c-bg2);       color: var(--c-muted2); }

.sp {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 100px;
    font-size: 10px;
    font-weight: 700;
}
.sp i { font-size: 8px; }
.sp-hadir     { background: var(--c-success-l); color: var(--c-success-d); border: 1px solid rgba(16,185,129,.2); }
.sp-terlambat { background: var(--c-warning-l); color: var(--c-warning-d); border: 1px solid rgba(245,158,11,.2); }
.sp-izin      { background: var(--c-blue-l);    color: var(--c-blue-d);    border: 1px solid rgba(59,130,246,.2); }
.sp-sakit     { background: var(--c-purple-l);  color: var(--c-purple-d);  border: 1px solid rgba(139,92,246,.2); }
.sp-alpha     { background: var(--c-danger-l);  color: var(--c-danger-d);  border: 1px solid rgba(239,68,68,.2); }

.a-btn {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    border: 1.5px solid var(--c-border);
    background: transparent;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--c-muted);
    transition: all .15s;
    font-size: 10px;
}
.a-btn:hover {
    background: var(--c-primary-l);
    border-color: rgba(79,70,229,.3);
    color: var(--c-primary);
}

/* Empty state */
.es td { text-align: center; padding: 40px 20px !important; }
.es-inner { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.es-ico {
    width: 46px;
    height: 46px;
    background: var(--c-bg2);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px dashed var(--c-border);
}
.es-ico i { font-size: 18px; color: var(--c-muted2); }
.es-inner h4 { font-size: 13px; font-weight: 700; color: var(--c-text); margin: 0; }
.es-inner p  { font-size: 11px; color: var(--c-muted); margin: 0; }

/* ══════════════════════════════════════════
   TOAST
══════════════════════════════════════════ */
.ha-toast {
    position: fixed;
    right: 12px;
    bottom: calc(var(--bnav-h, 64px) + 12px);
    padding: 8px 14px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 12px;
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 7px;
    box-shadow: 0 6px 22px rgba(0,0,0,.13);
    animation: toastIn .28s cubic-bezier(.4,0,.2,1);
    max-width: calc(100vw - 24px);
    font-family: 'Plus Jakarta Sans', sans-serif;
}
@keyframes toastIn {
    from { transform: translateX(110%); opacity: 0; }
    to   { transform: none; opacity: 1; }
}
.ha-toast-ico {
    width: 20px;
    height: 20px;
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 10px;
}
.ha-toast.ok   { background: #fff; border-left: 3px solid var(--c-success); color: var(--c-text); }
.ha-toast.ok   .ha-toast-ico { background: var(--c-success-l); color: var(--c-success); }
.ha-toast.warn { background: #fff; border-left: 3px solid var(--c-warning); color: var(--c-text); }
.ha-toast.warn .ha-toast-ico { background: var(--c-warning-l); color: var(--c-warning); }
.ha-toast.inf  { background: #fff; border-left: 3px solid var(--c-primary); color: var(--c-text); }
.ha-toast.inf  .ha-toast-ico { background: var(--c-primary-l); color: var(--c-primary); }

/* ══════════════════════════════════════════
   RESPONSIVE — TABLET (≥ 560px)
   Masih mobile-ish tapi sedikit lebih lebar
══════════════════════════════════════════ */
@media (min-width: 560px) {
    .ha { gap: 12px; }
    .ha-stats { grid-template-columns: repeat(4, 1fr); }
    .ha-stat-num { font-size: 26px; }
    .ha-filter { flex-direction: row; flex-wrap: wrap; align-items: flex-end; gap: 10px; }
    .ha-frow { flex: 1; min-width: 260px; }
    .ha-btn-row { flex-direction: row; align-self: flex-end; gap: 6px; }
    .ha-btn { padding: 9px 14px; }
    .dataTables_wrapper .dataTables_filter input { width: auto; margin-top: 0; }
    .dataTables_wrapper .dataTables_filter label { flex-wrap: nowrap; }
}

/* ══════════════════════════════════════════
   RESPONSIVE — DESKTOP (≥ 769px)
   Sidebar layout, lebih luas
══════════════════════════════════════════ */
@media (min-width: 769px) {
    .ha { gap: 14px; }

    /* Header */
    .ha-title-ico { width: 34px; height: 34px; border-radius: 10px; }
    .ha-title-ico i { font-size: 14px; }
    .ha-title-text h1 { font-size: 17px; }
    .ha-title-text p  { font-size: 11px; }
    .ha-live { font-size: 11px; padding: 4px 11px; }

    /* Stats */
    .ha-stats { grid-template-columns: repeat(4, 1fr); gap: 12px; }
    .ha-stat { padding: 12px 14px 10px; }
    .ha-stat-num { font-size: 28px; }
    .ha-stat-lbl { font-size: 10px; }

    /* Filter */
    .ha-filter {
        flex-direction: row;
        flex-wrap: nowrap;
        align-items: flex-end;
        padding: 14px 16px;
        gap: 12px;
        border-radius: var(--radius-lg);
    }
    .ha-frow {
        flex: 1;
        min-width: 0;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }
    .ha-btn-row {
        display: flex;
        flex-direction: row;
        gap: 8px;
        align-self: flex-end;
        flex-shrink: 0;
    }
    .ha-btn { padding: 9px 16px; font-size: 12px; }

    /* Table */
    .ha-table-head { padding: 12px 18px; }
    .ha-table-inner { padding: 0 18px 18px; }
    .ha-table-title h3 { font-size: 13px; }

    table.dataTable thead th { font-size: 10px !important; padding: 10px 12px !important; }
    table.dataTable tbody td { font-size: 12px; padding: 10px 12px !important; }
    .c-date .c-day { font-size: 9px; }
    .c-date .c-d   { font-size: 12px; }
    .tc { font-size: 11px; padding: 3px 8px; }
    .sp { font-size: 10px; padding: 3px 9px; }
    .a-btn { width: 26px; height: 26px; }

    /* Toast */
    .ha-toast { bottom: 22px; right: 22px; }
}

/* ══════════════════════════════════════════
   RESPONSIVE — LARGE DESKTOP (≥ 1200px)
══════════════════════════════════════════ */
@media (min-width: 1200px) {
    .ha-title-ico { width: 38px; height: 38px; }
    .ha-title-text h1 { font-size: 19px; }
    .ha-stat-num { font-size: 30px; }
    .ha-btn { font-size: 13px; }
}
</style>
<?php $__env->stopPush(); ?>

<?php
    $karyawan = auth()->user()->karyawan;

    $riwayat = \App\Models\Absensi::where('karyawan_id', $karyawan->id)
                ->latest('tanggal')->get();

    $bulanIni = now()->month;
    $tahunIni = now()->year;
    $riwayatBulanIni = $riwayat->filter(fn($a) =>
        \Carbon\Carbon::parse($a->tanggal)->month == $bulanIni &&
        \Carbon\Carbon::parse($a->tanggal)->year  == $tahunIni
    );

    $totalHadir     = $riwayatBulanIni->whereIn('status_waktu', ['tepat_waktu', 'hadir'])->count();
    $totalTerlambat = $riwayatBulanIni->where('status_waktu', 'terlambat')->count();
    $totalIzin      = \App\Models\IzinSakit::where('karyawan_id', $karyawan->id)
                        ->whereMonth('created_at', $bulanIni)
                        ->whereYear('created_at', $tahunIni)
                        ->count();
    $totalAlpha     = $riwayatBulanIni->where('status_waktu', 'alpha')->count();

    $days = ['Minggu','Senin','Selasa','Rabu','Kamis','Jumat','Sabtu'];
    $statusMap = [
        'tepat_waktu' => ['cls' => 'sp-hadir',    'ico' => 'fa-check-circle',  'txt' => 'Hadir'],
        'hadir'       => ['cls' => 'sp-hadir',    'ico' => 'fa-check-circle',  'txt' => 'Hadir'],
        'terlambat'   => ['cls' => 'sp-terlambat','ico' => 'fa-clock',         'txt' => 'Terlambat'],
        'izin'        => ['cls' => 'sp-izin',     'ico' => 'fa-calendar-alt',  'txt' => 'Izin'],
        'sakit'       => ['cls' => 'sp-sakit',    'ico' => 'fa-notes-medical', 'txt' => 'Sakit'],
        'alpha'       => ['cls' => 'sp-alpha',    'ico' => 'fa-times-circle',  'txt' => 'Alpha'],
    ];
?>

<div class="ha">

    
    <div class="ha-header">
        <div class="ha-title">
            <div class="ha-title-ico"><i class="fas fa-calendar-check"></i></div>
            <div class="ha-title-text">
                <h1>History Absensi</h1>
                <p>Pantau performa kehadiran Anda</p>
            </div>
        </div>
        <div class="ha-live"><span class="ha-live-dot"></span> Live Update</div>
    </div>

    
    <div class="ha-stats">
        <div class="ha-stat s1">
            <div class="ha-stat-lbl">Total Hadir</div>
            <div class="ha-stat-num"><?php echo e($totalHadir); ?></div>
        </div>
        <div class="ha-stat s2">
            <div class="ha-stat-lbl">Terlambat</div>
            <div class="ha-stat-num"><?php echo e($totalTerlambat); ?></div>
        </div>
        <div class="ha-stat s3">
            <div class="ha-stat-lbl">Sakit / Izin</div>
            <div class="ha-stat-num"><?php echo e($totalIzin); ?></div>
        </div>
        <div class="ha-stat s4">
            <div class="ha-stat-lbl">Alpha</div>
            <div class="ha-stat-num"><?php echo e($totalAlpha); ?></div>
        </div>
    </div>

    
    <div class="ha-filter">
        <div class="ha-frow">
            <div class="ha-fgrp">
                <label class="ha-flbl"><i class="far fa-calendar-alt"></i> Dari Tanggal</label>
                <input type="date" id="filterDari" class="ha-finput"
                       value="<?php echo e(now()->startOfMonth()->format('Y-m-d')); ?>">
            </div>
            <div class="ha-fgrp">
                <label class="ha-flbl"><i class="far fa-calendar-check"></i> Sampai Tanggal</label>
                <input type="date" id="filterSampai" class="ha-finput"
                       value="<?php echo e(now()->endOfMonth()->format('Y-m-d')); ?>">
            </div>
        </div>
        <div class="ha-btn-row">
            <button class="ha-btn ha-btn-primary" id="btnFilter">
                <i class="fas fa-sliders-h"></i> Tampilkan
            </button>
            <button class="ha-btn ha-btn-export" id="btnExport">
                <i class="fas fa-print"></i> Export
            </button>
            <button class="ha-btn ha-btn-reset" id="btnReset">
                <i class="fas fa-undo-alt"></i> Reset
            </button>
        </div>
    </div>

    
    <div class="ha-table-box">
        <div class="ha-table-head">
            <div class="ha-table-title">
                <div class="ha-table-ico"><i class="fas fa-history"></i></div>
                <h3>Riwayat Absensi</h3>
            </div>
            <span class="ha-badge" id="haBadge"><?php echo e($riwayat->count()); ?> Records</span>
        </div>
        <div class="ha-table-inner">
            <table id="haTable" class="display" style="width:100%">
                <thead>
                    <tr>
                        <th>No</th>
                        <th>Tanggal</th>
                        <th>Jam Masuk</th>
                        <th>Jam Pulang</th>
                        <th>Status</th>
                        <th></th>
                    </tr>
                </thead>
                <tbody>
                <?php $__empty_1 = true; $__currentLoopData = $riwayat; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $i => $ab): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                    <?php
                        $tgl = \Carbon\Carbon::parse($ab->tanggal);
                        $s   = $statusMap[$ab->status_waktu ?? 'alpha'] ?? $statusMap['alpha'];
                    ?>
                    <tr data-tanggal="<?php echo e($ab->tanggal); ?>">
                        <td><span class="c-no"><?php echo e($i + 1); ?></span></td>
                        <td>
                            <div class="c-date">
                                <span class="c-day"><?php echo e($days[$tgl->dayOfWeek]); ?></span>
                                <span class="c-d"><?php echo e($tgl->format('d M Y')); ?></span>
                            </div>
                        </td>
                        <td>
                            <?php if($ab->jam_masuk): ?>
                                <span class="tc tc-in">
                                    <i class="fas fa-sign-in-alt"></i>
                                    <?php echo e(\Carbon\Carbon::parse($ab->jam_masuk)->format('H:i')); ?>

                                </span>
                            <?php else: ?>
                                <span class="tc tc-empty"><i class="far fa-clock"></i> —</span>
                            <?php endif; ?>
                        </td>
                        <td>
                            <?php if($ab->jam_pulang): ?>
                                <span class="tc tc-out">
                                    <i class="fas fa-sign-out-alt"></i>
                                    <?php echo e(\Carbon\Carbon::parse($ab->jam_pulang)->format('H:i')); ?>

                                </span>
                            <?php else: ?>
                                <span class="tc tc-empty"><i class="far fa-clock"></i> —</span>
                            <?php endif; ?>
                        </td>
                        <td>
                            <span class="sp <?php echo e($s['cls']); ?>">
                                <i class="fas <?php echo e($s['ico']); ?>"></i> <?php echo e($s['txt']); ?>

                            </span>
                        </td>
                        <td>
                            <button class="a-btn" onclick="showDetail(<?php echo e($ab->id); ?>)" title="Detail">
                                <i class="fas fa-eye"></i>
                            </button>
                        </td>
                    </tr>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                    <tr class="es">
                        <td colspan="6">
                            <div class="es-inner">
                                <div class="es-ico"><i class="fas fa-calendar-times"></i></div>
                                <h4>Belum ada data absensi</h4>
                                <p>Data absensi Anda akan muncul di sini</p>
                            </div>
                        </td>
                    </tr>
                <?php endif; ?>
                </tbody>
            </table>
        </div>
    </div>

</div>

<?php $__env->startPush('scripts'); ?>
<script src="https://code.jquery.com/jquery-3.7.0.min.js"></script>
<script src="https://cdn.datatables.net/1.13.6/js/jquery.dataTables.min.js"></script>
<script>
var dt;

$(function () {

    /* ── Init DataTable ── */
    if ($('#haTable tbody tr.es').length === 0) {
        dt = $('#haTable').DataTable({
            responsive: false,
            language: {
                search: '',
                searchPlaceholder: '🔍  Cari data...',
                lengthMenu: 'Tampilkan _MENU_',
                info: 'Menampilkan _START_–_END_ dari _TOTAL_ data',
                infoEmpty: 'Tidak ada data',
                paginate: { next: '›', previous: '‹' }
            },
            pageLength: 10,
            order: [[1, 'desc']],
            dom: '<"top"fl>rt<"bottom"ip><"clear">'
        });
    }

    /* ── Filter by date range ── */
    $('#btnFilter').on('click', function () {
        var dari   = $('#filterDari').val();
        var sampai = $('#filterSampai').val();

        if (!dari || !sampai) {
            showToast('Pilih rentang tanggal!', 'warn'); return;
        }
        if (new Date(dari) > new Date(sampai)) {
            showToast('Tanggal awal tidak boleh lebih dari akhir!', 'warn'); return;
        }

        var from = new Date(dari   + 'T00:00:00');
        var to   = new Date(sampai + 'T23:59:59');
        var n    = 0;

        if (dt) {
            dt.rows().every(function () {
                var tgl = $(this.node()).data('tanggal');
                var vis = tgl
                    && new Date(tgl + 'T00:00:00') >= from
                    && new Date(tgl + 'T00:00:00') <= to;
                $(this.node()).toggleClass('ha-hidden-row', !vis);
                if (vis) n++;
            });

            $.fn.dataTable.ext.search.pop();
            $.fn.dataTable.ext.search.push(function (settings, data, idx) {
                return !$(dt.row(idx).node()).hasClass('ha-hidden-row');
            });
            dt.draw();
            $('#haBadge').text(n + ' Records');
            showToast('Menampilkan ' + n + ' data', 'ok');
        }
    });

    /* ── Reset filter ── */
    $('#btnReset').on('click', function () {
        $('#filterDari').val('<?php echo e(now()->startOfMonth()->format("Y-m-d")); ?>');
        $('#filterSampai').val('<?php echo e(now()->endOfMonth()->format("Y-m-d")); ?>');

        if (dt) {
            $.fn.dataTable.ext.search.pop();
            dt.rows().nodes().to$().removeClass('ha-hidden-row');
            dt.draw();
            $('#haBadge').text('<?php echo e($riwayat->count()); ?> Records');
        }
        showToast('Filter direset', 'inf');
    });

    /* ── Export / Print ── */
    $('#btnExport').on('click', function () {
        var dari   = $('#filterDari').val();
        var sampai = $('#filterSampai').val();
        var win    = window.open();

        win.document.write(
            '<html><head><title>Export Absensi</title>' +
            '<link href="https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;600;700&display=swap" rel="stylesheet">' +
            '<style>' +
            'body{font-family:\'Plus Jakarta Sans\',sans-serif;padding:32px;color:#0f172a}' +
            'h2{color:#4f46e5;font-size:16px;margin-bottom:4px}' +
            'p{color:#64748b;font-size:11px;margin-bottom:14px}' +
            'table{border-collapse:collapse;width:100%}' +
            'th{background:#f8faff;color:#94a3b8;font-size:9px;text-transform:uppercase;' +
            '   padding:8px 10px;border-bottom:2px solid #e5e7eb;text-align:left}' +
            'td{padding:8px 10px;border-bottom:1px solid #f3f4f6;font-size:11px}' +
            '.dataTables_filter,.dataTables_length,.dataTables_info,' +
            '.dataTables_paginate,.a-btn{display:none}' +
            '</style>' +
            '</head><body>' +
            '<h2>History Absensi — <?php echo e(auth()->user()->name); ?></h2>' +
            '<p>Periode: ' + dari + ' s/d ' + sampai +
            '&nbsp;&nbsp;·&nbsp;&nbsp;Dicetak: ' + new Date().toLocaleString('id-ID') + '</p>' +
            document.querySelector('.ha-table-inner').innerHTML +
            '</body></html>'
        );
        win.document.close();
        setTimeout(function () { win.print(); }, 500);
        showToast('Membuka dialog print…', 'ok');
    });
});

/* ── Detail ── */
function showDetail(id) {
    showToast('Detail absensi #' + id, 'inf');
    /* TODO: buka modal/drawer detail */
}

/* ── Toast helper ── */
var _tIco = { ok: 'fa-check', warn: 'fa-exclamation', inf: 'fa-info' };
function showToast(msg, type) {
    type = type || 'inf';
    $('.ha-toast').remove();
    var t = $(
        '<div class="ha-toast ' + type + '">' +
        '<div class="ha-toast-ico"><i class="fas ' + (_tIco[type] || 'fa-info') + '"></i></div>' +
        '<span>' + msg + '</span>' +
        '</div>'
    );
    $('body').append(t);
    setTimeout(function () {
        t.css({ opacity: 0, transform: 'translateX(110%)' });
        setTimeout(function () { t.remove(); }, 350);
    }, 2600);
}
</script>
<?php $__env->stopPush(); ?>

 <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54)): ?>
<?php $attributes = $__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54; ?>
<?php unset($__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal9ac128a9029c0e4701924bd2d73d7f54)): ?>
<?php $component = $__componentOriginal9ac128a9029c0e4701924bd2d73d7f54; ?>
<?php unset($__componentOriginal9ac128a9029c0e4701924bd2d73d7f54); ?>
<?php endif; ?><?php /**PATH C:\laragon\www\absen_gw\resources\views/karyawan/history.blade.php ENDPATH**/ ?>