<div class="row">
    <!-- Dashboard Summery Card Start -->

    {{-- @foreach ($data['dashboardMenus']['today'] as $key => $item)
    @endforeach --}}

    {{-- Punch out time --}}
    <div class="col-lg-12">
        <div class="card ot-card card-with-shadow border-0 py-primary mb-primary mb-30">
            <div class="card-body p-0">
                <div class="d-flex justify-content-between pl-primary mb-20">
                    @if ($data['todayLateTime'] > 0)
                        <div>
                            <p class="text-muted mb-0">You came {{ $data['todayLateTime'] }} hours late today ! </p>
                        </div>
                        <div>
                            <span
                                class="badge radius-right-0 radius-left-4 text-size-14 text-white padding-x-14 padding-y-9  badge-danger">
                                {{ _trans('attendance.Late') }}
                            </span>
                        </div>
                    @endif
                </div>
                <div class="d-flex gap-3 flex-wrap">
                    <div class="d-flex align-items-center mr-5 gap-3">
                        <div class="icon-box width-60 height-60 mr-2"><svg xmlns="http://www.w3.org/2000/svg"
                                width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor"
                                stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
                                class="feather feather-log-in text-success">
                                <path d="M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4"></path>
                                <polyline points="10 17 15 12 10 7"></polyline>
                                <line x1="15" y1="12" x2="3" y2="12"></line>
                            </svg></div>
                        <div>
                            <h6 class="mb-1">{{ @onlyTimePlainText(@$data['todayAttendance']->check_in) }}</h6>
                            <p class="text-secondary mb-1"> {{ _trans('attendance.Punch in time') }}</p>
                        </div>
                    </div>
                    <div class="d-flex align-items-center gap-3">
                        <div class="icon-box width-60 height-60 mr-2"><svg xmlns="http://www.w3.org/2000/svg"
                                width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor"
                                stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
                                class="feather feather-log-out text-warning">
                                <path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"></path>
                                <polyline points="16 17 21 12 16 7"></polyline>
                                <line x1="21" y1="12" x2="9" y2="12"></line>
                            </svg></div>
                        <div>
                            <h6 class="mb-1">{{ @onlyTimePlainText(@$data['todayAttendance']->check_out) }}</h6>
                            <p class="text-secondary mb-1"> {{ _trans('attendance.Punch out time') }} </p>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    {{-- / Punch out time  --}}


    {{-- Today Time log --}}
    <div class="col-lg-12">
        <div class="card ot-card mb-30">
            <div class="table-summar p-0">
                <div class="summary-title">
                    <h4 class="title d-flex align-items-center flex-wrap gap-10 mb-15">
                        <i class="ri-bar-chart-line"></i>
                        <span>{{ _trans('attendance.Today Time Log') }}</span>
                    </h4>
                    <ul class="summary-listing d-flex align-items-center gap-4 flex-wrap mb-0 p-0">
                        <li class="single-summary-list">
                            <div class="text-dark rounded p-2">
                                <span class="number">{{ $data['todayTotalHours'] }} H</span>
                                <span class="text">{{ _trans('attendance.Scheduled') }}</span>
                            </div>
                        </li>
                        @php
                            $checkInTime = \Carbon\Carbon::parse(@$data['todayAttendance']->check_in);
                            $currentTime = \Carbon\Carbon::now();
                            $diffInMinutes = $currentTime->diffInMinutes($checkInTime);

                        @endphp

                        <li class="single-summary-list">
                            <div class="">
                                <span
                                    class="number">{{ isset($data['todayAttendance']->check_out) ? timeDifferenceHour(@$data['todayAttendance']->check_in, @$data['todayAttendance']->check_out) : round($diffInMinutes / 60, 2) }}
                                    H</span>
                                <span class="text text-primary">{{ _trans('attendance.Worked Time') }} </span>
                            </div>
                        </li>
                        <li class="single-summary-list">
                            <div class="">
                                <span class="number">{{ @breakTimeCalculation($data['todayAttendance']->breaks) }}
                                    H</span>
                                <span class="text text-warning">{{ _trans('attendance.Break Time') }} </span>
                            </div>
                        </li>
                        <li class="single-summary-list">
                            <div class="">
                                <span class="number"> -
                                    {{ round($data['todayTotalHours'] - @breakTimeCalculation($data['todayAttendance']->breaks)) }}
                                    H </span>
                                <span class="text text-danger">{{ _trans('attendance.Left Time') }}</span>
                            </div>
                        </li>
                    </ul>
                </div>
            </div>
        </div>
    </div>
    {{-- End Today Time log --}}

    {{-- This month --}}
    <div class="col-lg-12">
        <div class="card ot-card mb-30">
            <div class="card-title mb-20">
                <h3 class="text-capitalize">{{ _trans('attendance.This Month') }}</h3>
            </div>
            <div class="d-flex gap-5 flex-wrap">
                <div class="d-flex align-items-center mr-5 gap-3">
                    <div class="icon-box dashboard-card-icon circle-browns circle-primary width-60 height-60 mr-2">
                        <i class="las la-history"></i>
                    </div>
                    <div>
                        <h6 class="mb-1 fs-18">{{ @$data['currentMonthTotalHours'] }} H </h6>
                        <p class="text-secondary text-capitalize mb-1">{{ _trans('attendance.Schedule Time') }}</p>
                    </div>
                </div>
                <div class="d-flex align-items-center gap-3">
                    <div class="icon-box dashboard-card-icon circle-brown width-60 height-60 mr-2">
                        <i class="las la-history"></i>
                    </div>
                    <div>
                        <h6 class="mb-1 fs-18">{{ round($data['totalWorkedHours'], 2) }} H</h6>
                        <p class="text-secondary text-capitalize mb-1">{{ _trans('attendance.Worked Time') }} </p>
                    </div>
                </div>
                <div class="d-flex align-items-center gap-3">
                    <div class="icon-box dashboard-card-icon circle-lightseagreen width-60 height-60 mr-2">
                        <i class="las la-history"></i>
                    </div>
                    <div>
                        <h6 class="mb-1 fs-18">
                            {{ $data['totalWorkedHours'] - @$data['currentMonthTotalHours'] > 0 ? round($data['totalWorkedHours'] - @$data['currentMonthTotalHours'], 2) : 0 }}
                            H</h6>
                        <p class="text-secondary text-capitalize mb-1">{{ _trans('attendance.Over Time') }} </p>
                    </div>
                </div>
                <div class="d-flex align-items-center gap-3">
                    <div class="icon-box dashboard-card-icon circle-violet width-60 height-60 mr-2">
                        <i class="las la-history"></i>
                    </div>
                    <div>
                        <h6 class="mb-1 fs-18">{{ @breakTimeCalculation($data['currentMonthBreaks']) }} H</h6>
                        <p class="text-secondary text-capitalize mb-1">{{ _trans('attendance.Break time') }} </p>
                    </div>
                </div>
                <div class="d-flex align-items-center gap-3">
                    <div class="icon-box dashboard-card-icon circle-danger width-60 height-60 mr-2">
                        <i class="las la-history"></i>
                    </div>
                    <div>
                        <h6 class="mb-1 fs-18">{{ $data['totalMonthlyLateTime'] }} H</h6>
                        <p class="text-secondary text-capitalize mb-1">{{ _trans('attendance.Late time') }} </p>
                    </div>
                </div>
                <div class="d-flex align-items-center gap-3">
                    <div class="icon-box dashboard-card-icon circle-hotpink width-60 height-60 mr-2">
                        <i class="lar la-calendar"></i>
                    </div>
                    <div>
                        <h6 class="mb-1 fs-18">{{ $data['currentMonthLeave'] }} days</h6>
                        <p class="text-secondary text-capitalize mb-1">Total Leave's </p>
                    </div>
                </div>
            </div>
        </div>
    </div>
    {{-- End This month --}}


    {{-- Total Leave --}}
    <div class="col-md-6 pb-30">
        <div class="card ot-card h-100">
            <div class="card-header d-flex flex-row justify-content-between align-items-baseline">
                <div class="card-title">
                    <h3>{{ _trans('dashboard.Total Leave ') }}</h3>
                </div>
            </div>
            <div class="table-summar">
                <div class="summary-title">
                    <ul class="summary-listing mb-0 p-0 d-flex flex-wrap gap-4">
                        @foreach ($data['assignLeaves'] as $assignLeaves)
                            <li class="single-summary-list">
                                <div class="text-dark rounded p-2">
                                    <span class="number">{{ $assignLeaves->days }} {{ _trans('common.Days') }}</span>
                                    <span class="text">{{ @$assignLeaves->type->name }}</span>
                                </div>
                            </li>
                        @endforeach

                    </ul>
                </div>
            </div>

            <div class="card-body pt-0">
                <div class="custom-charst table-content table-basic">
                    <div class="card-body p-0">
                        <div class="table-responsive height-310 hide-scroll">
                            <table class="table table-bordered">
                                <thead class="thead">
                                    <tr>
                                        <th class="text-left">{{ _trans('common.SL') }}</th>
                                        <th class="text-left">{{ _trans('common.Leave Category') }}</th>
                                        <th>{{ _trans('common.Date') }}</th>
                                        <th>{{ _trans('common.Status') }}</th>
                                        <th>{{ _trans('common.Total Days') }}</th>
                                    </tr>
                                </thead>
                                <tbody class="tbody">
                                    @foreach ($data['leaveRequests'] as $index => $leave_request)
                                        <tr>
                                            <td>{{ 1 + $index }}</td>
                                            <td>
                                                <span
                                                    class="fs-14 text-capitalize">{{ @$leave_request->leaveType->name }}</span>
                                            </td>
                                            <td class="fs-18">{{ @main_date_format($leave_request->leave_from) }} -
                                                {{ @main_date_format($leave_request->leave_to) }}</td>
                                            <td>
                                                @if (@$leave_request->status_id == 1)
                                                    <small
                                                        class="badge badge-success text-capitalize">{{ _trans('common.Approved') }}</small>
                                                @elseif (@$leave_request->status_id == 2)
                                                    <small
                                                        class="badge badge-warning text-capitalize">{{ _trans('common.Pending') }}</small>
                                                @elseif (@$leave_request->status_id == 6)
                                                    <small
                                                        class="badge badge-danger text-capitalize">{{ _trans('common.Cancelled') }}</small>
                                                @endif
                                            </td>
                                            <td>{{ @$leave_request->days }}</td>
                                        </tr>
                                    @endforeach

                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    {{-- / Total Leave  --}}

    {{-- Current Month --}}
    <div class="col-md-6 pb-30">
        <div class="card ot-card">
            <div class="card-header d-flex flex-row justify-content-between align-items-baseline">
                <div class="card-title">
                    <h3>{{ _trans('dashboard.Current Month') }}</h3>
                </div>
            </div>

            <div class="table-summar">
                <div class="summary-title">
                    <ul class="summary-listing d-flex align-items-center gap-4 flex-wrap mb-2 p-0">
                        <li class="single-summary-list">
                            <div class="">
                                <span class="number">{{ $data['in_time_attendance'] }}
                                    {{ _trans('common.Days') }}</span>
                                <span class="text text-primary"> {{ _trans('attendance.In Time') }}</span>
                            </div>
                        </li>
                        <li class="single-summary-list">
                            <div class="text-dark rounded p-2">
                                <span class="number">{{ $data['late_attendance'] }}
                                    {{ _trans('common.Days') }}</span>
                                <span class="text text-danger">{{ _trans('attendance.Late Time') }} </span>
                            </div>
                        </li>
                        <li class="single-summary-list">
                            <div class="">
                                <span class="number">{{ $data['absent_days'] }} {{ _trans('common.Days') }}</span>
                                <span class="text text-warning">{{ _trans('attendance.Absence') }} </span>
                            </div>
                        </li>
                        <li class="single-summary-list">
                            <div class="">
                                <span class="number"> {{ $data['leave_days'] }} {{ _trans('common.Days') }}</span>
                                <span class="text text-danger">{{ _trans('attendance.Leave') }}</span>
                            </div>
                        </li>
                    </ul>
                </div>
            </div>

            <div class="card-body pt-0">
                <div class="custom-charst table-content table-basic">
                    <div class="card-body p-0">
                        <div class="table-responsive height-310 hide-scroll">
                            <table class="table table-bordered">
                                <thead class="thead">
                                    <tr>
                                        <th class="text-left">{{ _trans('common.SL') }}</th>
                                        <th>{{ _trans('common.Date') }}</th>
                                        <th>{{ _trans('common.In Time') }}</th>
                                        <th>{{ _trans('common.Out Time') }}</th>
                                        <th class="text-left">{{ _trans('common.Break Time') }}</th>
                                    </tr>
                                </thead>
                                <tbody class="tbody">
                                    @foreach ($data['currentMonthAttendance'] as $key => $attendance)
                                        @php
                                            $breaksCount = $attendance->breaks->count();
                                        @endphp
                                        @if ($breaksCount > 0)
                                            @foreach ($attendance->breaks as $index => $break)
                                                <tr>
                                                    @if ($index == 0)
                                                        <td rowspan="{{ $breaksCount }}">{{ $key + 1 }}</td>
                                                        <td rowspan="{{ $breaksCount }}" class="fs-18">
                                                            {{ @dateFormat($attendance->created_at) }}</td>
                                                        <td rowspan="{{ $breaksCount }}">
                                                            {{ @onlyTimePlainText(@$attendance->check_in) }}</td>
                                                        <td rowspan="{{ $breaksCount }}">
                                                            {{ @onlyTimePlainText(@$attendance->check_out) }}</td>
                                                    @endif
                                                    <td class="fs-14 text-capitalize">
                                                        {{ @onlyTimePlainText($break->start_time) }} -
                                                        {{ @onlyTimePlainText($break->end_time) }}</td>
                                                </tr>
                                            @endforeach
                                        @else
                                            <tr>
                                                <td>{{ $key + 1 }}</td>
                                                <td class="fs-18">{{ @dateFormat($attendance->created_at) }}</td>
                                                <td>{{ @onlyTimePlainText(@$attendance->check_in) }}</td>
                                                <td>{{ @onlyTimePlainText(@$attendance->check_out) }}</td>
                                                <td>{{ _trans('common.No Break') }}</td>
                                            </tr>
                                        @endif
                                    @endforeach
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    {{-- / Current Month  --}}

    <div class="col-md-6 pb-30">
        <div class="card ot-card">
            <div class="card-header d-flex flex-row justify-content-between align-items-baseline">
                <div class="card-title">
                    <h3>{{ _trans('dashboard.Appointment Schedule') }}</h3>
                </div>
            </div>
            <div class="card-body pt-0">
                <div class="custom-chart table-content table-basic">
                    <div class="card-body">
                        <div class="table-responsive  min-height-500">
                            <table class="table table-bordered">
                                <thead class="thead">
                                    <tr>
                                        <th class="text-left">{{ _trans('common.Title') }}</th>
                                        <th>{{ _trans('common.With') }}</th>
                                        <th>{{ _trans('common.Location') }}</th>
                                        <th>{{ _trans('common.Date Time') }}</th>
                                    </tr>
                                </thead>
                                <tbody class="tbody" id="appointment_schedule">
                                </tbody>
                            </table>
                        </div>
                        <!--  table end -->
                    </div>
                </div>
            </div>
        </div>
    </div>

    <div class="col-md-6 pb-30">
        <div class="card ot-card">
            <div class="card-header d-flex flex-row justify-content-between align-items-baseline">
                <div class="card-title">
                    <h3>{{ _trans('dashboard.Meeting schedule') }}</h3>
                </div>
            </div>
            <div class="card-body pt-0">
                <div class="custom-chart table-content table-basic">
                    <div class="card-body">
                        <div class="table-responsive  min-height-500">
                            <table class="table table-bordered">
                                <thead class="thead">
                                    <tr>
                                        <th class="text-left">{{ _trans('common.Title') }}</th>
                                        <th>{{ _trans('common.With') }}</th>
                                        <th>{{ _trans('common.Location') }}</th>
                                        <th>{{ _trans('common.Date Time') }}</th>
                                    </tr>
                                </thead>
                                <tbody class="tbody" id="meeting_schedule">
                                </tbody>
                            </table>
                        </div>
                        <!--  table end -->
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>