@php
  $quotes = [
      [
          'text' => 'Success is the result of hard work, determination, and the courage to pursue greatness.',
      ],
      [
          'text' => 'Teamwork divides the task and multiplies the success.',
      ],
      [
          'text' => 'You don’t have to be perfect to make an impact; every small effort counts.',
      ],
      [
          'text' => 'Productivity is not about doing more; it’s about focusing on what truly matters.',
      ],
      [
          'text' => 'Your attitude, not your aptitude, will determine your altitude.',
      ],
      [
          'text' => 'The secret to great teamwork is trust, communication, and a shared goal.',
      ],
      [
          'text' => 'Every accomplishment starts with the decision to try.',
      ],
      [
          'text' => 'When we work together, the impossible becomes possible.',
      ],
      [
          'text' => 'Productivity is never an accident. It is always the result of commitment to excellence.',
      ],
      [
          'text' => 'Believe in your ability to shape the future with the work you do today.',
      ],
      [
          'text' => 'Collaboration allows us to achieve the extraordinary.',
      ],
      [
          'text' => 'Set your goals high, and don’t stop until you get there.',
      ],
      [
          'text' => 'Stay focused on the journey, and success will find you.',
      ],
      [
          'text' => 'Teamwork is the fuel that allows common people to attain uncommon results.',
      ],
      [
          'text' => 'Take small steps every day; big things happen when you keep moving forward.',
      ],
      [
          'text' => 'Hard work beats talent when talent doesn’t work hard.',
      ],
      [
          'text' => 'Growth comes from challenging yourself each day.',
      ],
      [
          'text' => 'Your potential is endless; push beyond the limits you set for yourself.',
      ],
      [
          'text' => 'Innovation thrives in an environment of collaboration and open minds.',
      ],
      [
          'text' => 'Dedicate yourself to continuous improvement, one day at a time.',
      ],
      [
          'text' => 'The strength of the team is each individual member, and the strength of each member is the team.',
      ],
      [
          'text' => 'When we strive to become better than we are, everything around us becomes better too.',
      ],
      [
          'text' => 'Small steps in the right direction lead to big results.',
      ],
      [
          'text' => 'Success comes to those who focus on what’s important, not just what’s urgent.',
      ],
      [
          'text' => 'Perseverance is the hard work you do after you get tired of doing the hard work you already did.',
      ],
      [
          'text' => 'You don’t need a new year to make a change; all you need is a Monday.',
      ],
      [
          'text' => 'Dream big, work hard, stay focused, and surround yourself with good people.',
      ],
      [
          'text' => 'Efficiency is doing things right; effectiveness is doing the right things.',
      ],
      [
          'text' => 'The journey of a thousand miles begins with a single step.',
      ],
      [
          'text' => 'No one can whistle a symphony. It takes a whole orchestra to play it.',
      ],
      [
          'text' => 'Be so good they can’t ignore you.',
      ],
      [
          'text' => 'Teamwork makes the dream work.',
      ],
      [
          'text' => 'Growth and comfort do not coexist.',
      ],
      [
          'text' => 'Success is no accident. It is hard work, perseverance, learning, and sacrifice.',
      ],
      [
          'text' => 'Work hard in silence, let your success be your noise.',
      ],
      [
          'text' => 'You don’t get what you wish for; you get what you work for.',
      ],
      [
          'text' => 'The only way to achieve the impossible is to believe it is possible.',
      ],
      [
          'text' => 'Quality is not an act, it is a habit.',
      ],
      [
          'text' => 'The best way to predict the future is to create it.',
      ],
      [
          'text' => 'Believe you can, and you’re halfway there.',
      ],
      [
          'text' => 'Alone, we can do so little; together, we can do so much.',
      ],
      [
          'text' => 'Great things are never done by one person. They’re done by a team of people.',
      ],
      [
          'text' => 'Strive for progress, not perfection.',
      ],
      [
          'text' => 'Don’t watch the clock; do what it does. Keep going.',
      ],
      [
          'text' => 'Success is not final, failure is not fatal: it is the courage to continue that counts.',
      ],
      [
          'text' => 'You don’t have to be great to start, but you have to start to be great.',
      ],
      [
          'text' => 'The only limit to our realization of tomorrow is our doubts of today.',
      ],
      [
          'text' => 'Success is not how high you have climbed, but how you make a positive difference to the world.',
      ],
      [
          'text' => 'Productivity is being able to do things that you were never able to do before.',
      ],
      [
          'text' => 'Each new day is a chance to improve yourself.',
      ],
      [
          'text' => 'The best way to accomplish great work is to love what you do.',
      ],
      [
          'text' => 'The only way to do great work is to focus and persevere.',
      ],
      [
          'text' => 'A goal without a plan is just a wish.',
      ],
      [
          'text' => 'Create a vision that makes you want to jump out of bed in the morning.',
      ],
      [
          'text' => 'Success is a journey, not a destination.',
      ],
      [
          'text' => 'Don’t wait for the right opportunity; create it.',
      ],
      [
          'text' => 'Don’t count the days; make the days count.',
      ],
      [
          'text' => 'Work hard, be kind, and amazing things will happen.',
      ],
      [
          'text' => 'Excellence is not being the best; it is doing your best.',
      ],
      [
          'text' => 'Find your passion, and let it fuel your work.',
      ],
      [
          'text' => 'Start where you are. Use what you have. Do what you can.',
      ],
      [
          'text' => 'Motivation gets you going, but discipline keeps you growing.',
      ],
      [
          'text' => 'Nothing worthwhile comes easy; put in the work, and see the rewards.',
      ],
      [
          'text' => 'Ambition is the first step to success. The second step is action.',
      ],
      [
          'text' => 'Stay humble, work hard, and never give up.',
      ],
      [
          'text' => 'Don’t be afraid to give up the good to go for the great.',
      ],
      [
          'text' => 'Dream it, believe it, achieve it.',
      ],
      [
          'text' => 'Strength lies in differences, not in similarities.',
      ],
      [
          'text' => 'In teamwork, silence isn’t golden. It’s deadly.',
      ],
      [
          'text' => 'No one of us is as smart as all of us.',
      ],
      [
          'text' => 'Goals are dreams with deadlines.',
      ],
      [
          'text' => 'To win big, you sometimes have to take big risks.',
      ],
      [
          'text' => 'The harder you work for something, the greater you’ll feel when you achieve it.',
      ],
      [
          'text' => 'Don’t stop when you’re tired; stop when you’re done.',
      ],
      [
          'text' => 'Success is the sum of small efforts, repeated day in and day out.',
      ],
      [
          'text' => 'Start each day with a positive thought and a grateful heart.',
      ],
      [
          'text' => 'Together, we can accomplish anything.',
      ],
      [
          'text' => 'Make each day your masterpiece.',
      ],
      [
          'text' => 'If you want to go fast, go alone. If you want to go far, go together.',
      ],
      [
          'text' => 'The way to get started is to quit talking and begin doing.',
      ],
      [
          'text' => 'Small progress is still progress.',
      ],
      [
          'text' => 'Push yourself, because no one else is going to do it for you.',
      ],
      [
          'text' => 'Be yourself; everyone else is already taken.',
      ],
      [
          'text' => 'Success is the best revenge.',
      ],
      [
          'text' => 'The dream is free, but the hustle is sold separately.',
      ],
      [
          'text' => 'Act as if what you do makes a difference. It does.',
      ],
      [
          'text' => 'The best time to plant a tree was 20 years ago. The second best time is now.',
      ],
      [
          'text' => 'Do what you can with all you have, wherever you are.',
      ],
      [
          'text' => 'We can’t help everyone, but everyone can help someone.',
      ],
      [
          'text' => 'The difference between ordinary and extraordinary is that little extra.',
      ],
      [
          'text' => 'Success usually comes to those who are too busy to be looking for it.',
      ],
      [
          'text' => 'Work as if you were to live forever, and live as if you were to die tomorrow.',
      ],
      [
          'text' => 'Stay positive, work hard, make it happen.',
      ],
      [
          'text' => 'In the middle of every difficulty lies opportunity.',
      ],
      [
          'text' => 'Don’t be pushed around by the fears in your mind. Be led by the dreams in your heart.',
      ],
      [
          'text' => 'You miss 100% of the shots you don’t take.',
      ],
      [
          'text' => 'Doubt kills more dreams than failure ever will.',
      ],
      [
          'text' => 'Success is not about the destination; it’s about the journey.',
      ],
      [
          'text' => 'Keep going because you did not come this far just to come this far.',
      ],
      [
          'text' => 'Our greatest glory is not in never falling, but in rising every time we fall.',
      ],
      [
          'text' => 'There is no substitute for hard work.',
      ],
      [
          'text' => 'What you do today can improve all your tomorrows.',
      ],
  ];

  $quote = $quotes[array_rand($quotes)];
  $quoteText = $quote['text'];

@endphp
@extends('layouts/layoutMaster')

@section('title', 'Dashboard')

@section('vendor-style')
  @vite(['resources/assets/vendor/libs/apex-charts/apex-charts.scss'])
@endsection

@section('vendor-script')
  @vite(['resources/assets/vendor/libs/apex-charts/apexcharts.js'])
@endsection

@section('page-script')
  @vite(['resources/assets/js/app/dashboard-index.js'])
@endsection

@section('content')
  <div class="card bg-transparent shadow-none my-6 border-0">
    <div class="card-body row p-0 pb-6 g-6">
      <div class="col-12 col-lg-8 card-separator">
        <h5 class="mb-2">Welcome back,<span class="h4"> {{ auth()->user()->getFullName() }} 👋🏻</span></h5>
        <div class="col-12 col-lg-5">
          <p>{{$quoteText}}</p>
        </div>
        <div class="d-flex justify-content-between flex-wrap gap-4 me-12">
          <div class="d-flex align-items-center gap-4 me-6 me-sm-0">
            <div class="avatar avatar-lg">
              <div class="avatar-initial bg-label-primary rounded">
                <i class="bx bx-time-five"></i>
              </div>
            </div>
            <div class="content-right">
              <p class="mb-0 fw-medium">Hours Logged</p>
              <h4 class="text-primary mb-0">{{ $todayHours ?? 0 }}h</h4>
            </div>
          </div>
          <div class="d-flex align-items-center gap-4">
            <div class="avatar avatar-lg">
              <div class="avatar-initial bg-label-info rounded">
                <i class="bx bx-task"></i>
              </div>
            </div>
            <div class="content-right">
              <p class="mb-0 fw-medium">Pending Tasks</p>
              <h4 class="text-info mb-0">{{ $tasks ?? 0 }}</h4>
            </div>
          </div>
          <div class="d-flex align-items-center gap-4">
            <div class="avatar avatar-lg">
              <div class="avatar-initial bg-label-warning rounded">
                <i class="bx bx-certification"></i>
              </div>
            </div>
            <div class="content-right">
              <p class="mb-0 fw-medium">On Going Tasks</p>
              <h4 class="text-warning mb-0">{{ $onGoingTasks ?? 0 }}</h4>
            </div>
          </div>
        </div>
      </div>
      <div class="col-12 col-lg-4 ps-md-4 ps-lg-6">
        <div class="d-flex justify-content-between align-items-center">
          <div>
            <h5 class="mb-1">Time Spending</h5>
            <p class="mb-9">Weekly Overview</p>
            <div class="time-spending-chart">
              <h4 class="mb-2">{{ $thisWeekWorkingHours }}<span
                  class="text-body">h</span>
              </h4>
              <span class="badge bg-label-success"> Your weekly working hours</span>
            </div>
          </div>
          <div id="weeklyReportChart"></div>
        </div>
      </div>
    </div>
  </div>
  <div class="row">
    <!-- Overview Cards -->
    <div class="col-sm-6 col-xl-3 mb-4">
      <div class="card h-100">
        <div class="card-body">
          <h5>Total Employees</h5>
          <h2>{{ $totalUser }}</h2>
          @if($totalUser > 0)
            <small class="text-success">100% of total employees</small>
          @endif
        </div>
      </div>
    </div>
    <div class="col-sm-6 col-xl-3 mb-4">
      <div class="card h-100">
        <div class="card-body">
          <h5>On Leave</h5>
          <h2>{{ $onLeaveUsersCount  }}</h2>
          <small class="text-warning">
            @if($onLeaveUsersCount > 0)
              {{ round(($onLeaveUsersCount / $totalUser) * 100, 2) }}% of total employees
            @else
              0% of total employees
            @endif
          </small>
        </div>
      </div>
    </div>
    <div class="col-sm-6 col-xl-3 mb-4">
      <div class="card h-100">
        <div class="card-body">
          <h5>Today's Present</h5>
          <h2>{{ $todayPresentUsers }}</h2>
          <small class="text-primary">
            @if($todayPresentUsers > 0)
              {{ round(($todayPresentUsers / $totalUser) * 100, 2) }}% of total employees
            @else
              0% of total employees
            @endif
          </small>
        </div>
      </div>
    </div>
    <div class="col-sm-6 col-xl-3 mb-4">
      <div class="card h-100">
        <div class="card-body">
          <h5>Today's Absentees</h5>
          <h2>{{ $todayAbsentUsers }}</h2>
          <small class="text-danger">
            @if($todayAbsentUsers > 0)
              {{ round(($todayAbsentUsers / $totalUser) * 100, 2) }}% of total employees
            @else
              0% of total employees
            @endif
          </small>
        </div>
      </div>
    </div>
  </div>

  <div class="row">
    <!-- Top Departments by Performance -->
    <div class="col-lg-12 col-md-12 mb-4">
      <div class="card h-100">
        <div class="card-body">
          <div id="topDepartmentsChart"></div>
        </div>
      </div>
    </div>


  </div>

  <div class="row">
    <!-- Requests -->
    <div class="col-lg-4 col-md-6">
      <div class="card h-100 text-center shadow-sm">
        <div class="card-body">
          <h5 class="card-title">Pending Requests</h5>
          <div class="list-group">
            @if(\Illuminate\Support\Facades\Route::has('leaveRequests.index'))
              <a href="{{ route('leaveRequests.index') }}"
                 class="list-group-item list-group-item-action d-flex justify-content-between align-items-center">
                Leave Requests
                <span class="badge bg-primary rounded-pill">{{ $pendingLeaveRequests }}</span>
              </a>
            @endif
            @if(\Illuminate\Support\Facades\Route::has('expenseRequests.index'))
              <a href="{{ route('expenseRequests.index') }}"
                 class="list-group-item list-group-item-action d-flex justify-content-between align-items-center">
                Expense Requests
                <span class="badge bg-success rounded-pill">{{ $pendingExpenseRequests }}</span>
              </a>
            @endif
            @if(\Illuminate\Support\Facades\Route::has('documentmanagement.index'))
              <a href="{{ route('documentmanagement.index') }}"
                 class="list-group-item list-group-item-action d-flex justify-content-between align-items-center">
                Document Requests
                <span class="badge bg-warning rounded-pill">{{ $pendingDocumentRequests }}</span>
              </a>
            @endif
            @if(\Illuminate\Support\Facades\Route::has('loan.index'))
              <a href="{{ route('loan.index') }}"
                 class="list-group-item list-group-item-action d-flex justify-content-between align-items-center">
                Loan Requests
                <span class="badge bg-danger rounded-pill">{{ $pendingLoanRequests }}</span>
              </a>
            @endif
          </div>
        </div>
        <div class="card-footer text-muted">
          <small>Last updated {{ now()->diffForHumans() }}</small>
        </div>
      </div>
    </div>
    <!-- Recent Activities -->
    <div class="col-md-8 col-12">
      <div class="card">
        <div class="card-header d-flex align-items-center justify-content-between">
          <div>
            <h5 class="card-title mb-0">Recent Activities</h5>
            <p class="card-subtitle my-0">Latest activities of users</p>
          </div>
        </div>
        <div class="card-body">
          <div class="timeline">
            <!--class="list-group list-group-flush" -->
            <ul id="activityList" class="list-group list-group-flush overflow-auto" style="max-height: 400px;">
              <!-- Activities will be dynamically loaded here -->
            </ul>
          </div>
        </div>
      </div>
    </div>
  </div>
@endsection
