<!DOCTYPE html>
<html
  lang="en"
  class="light-style layout-menu-fixed"
  dir="ltr"
  data-theme="theme-default"
  data-assets-path="../assets/"
  data-template="vertical-menu-template-free"
>
  <head>
    <meta charset="utf-8" />
    <meta
      name="viewport"
      content="width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0"
    />

    <title>Materi Pembelajaran - AMetative HLE</title>

    <meta name="description" content="" />

    <!-- Favicon -->
    <link rel="icon" type="image/x-icon" href="{{ asset('publicc/backend/assets/img/logo/logo_ametative.png') }}" />
    <!-- Tambahkan ini di <head> -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.0/css/all.min.css" integrity="sha512-..." crossorigin="anonymous" referrerpolicy="no-referrer" />

    <!-- Fonts -->
    <link rel="preconnect" href="https://fonts.googleapis.com" />
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
    <link
      href="https://fonts.googleapis.com/css2?family=Public+Sans:ital,wght@0,300;0,400;0,500;0,600;0,700;1,300;1,400;1,500;1,600;1,700&display=swap"
      rel="stylesheet"
    />

    <!-- Icons. Uncomment required icon fonts -->
    <link rel="stylesheet" href="{{ asset('publicc/backend/assets/vendor/fonts/boxicons.css') }}" />
    <link href="https://cdn.jsdelivr.net/npm/bootstrap-icons/font/bootstrap-icons.css" rel="stylesheet">

    <!-- Core CSS -->
    <link rel="stylesheet" href="{{ asset('publicc/backend/assets/vendor/css/core.css') }}" class="template-customizer-core-css" />
    <link rel="stylesheet" href="{{ asset('publicc/backend/assets/vendor/css/theme-default.css') }}" class="template-customizer-theme-css" />
    <link rel="stylesheet" href="{{ asset('publicc/backend/assets/css/demo.css') }}" />

    <!-- Vendors CSS -->
    <link rel="stylesheet" href="{{ asset('publicc/backend/assets/vendor/libs/perfect-scrollbar/perfect-scrollbar.css') }}" />

    <link rel="stylesheet" href="{{ asset('publicc/backend/assets/vendor/libs/apex-charts/apex-charts.css') }}" />

    <!-- Page CSS -->

    <!-- Helpers -->
    <script src="{{ asset('publicc/backend/assets/vendor/js/helpers.js') }}"></script>

    <!--! Template customizer & Theme config files MUST be included after core stylesheets and helpers.js in the <head> section -->
    <!--? Config:  Mandatory theme config file contain global vars & default theme options, Set your preferred theme option in this file.  -->
    <script src="{{ asset('publicc/backend/assets/js/config.js') }}"></script>
  </head>

  <body>
    <div class="learning-style-sidebar-container position-fixed end-0 d-flex flex-column align-items-end"
     style="top: 50%; transform: translateY(-50%); z-index: 1050;">
            <!-- Show/Hide Button -->
            {{-- Tombol Toggle Sidebar --}}
            <button id="toggleLearningStyleSidebar" 
                    class="btn btn-secondary btn-sm position-fixed end-0 top-50 translate-middle-y me-1"
                    type="button"
                    style="z-index: 1060; border-radius: 50%; width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;">
                <span id="sidebarToggleIcon" class="fas fa-chevron-left"></span>
            </button>

            <!-- Sidebar -->
           <div id="learningStyleSidebar" class="card shadow-lg p-3 bg-white rounded">
                <div class="d-flex flex-column gap-3 mt-3">
                    @php
                        $learningStyles = [
                            [
                                'url' => url('materi/visual/1'),
                                'icon' => 'fa-eye',
                                'label' => 'Visual',
                                'btnClass' => 'btn-primary'
                            ],
                            [
                                'url' => url('materi/readwrite/1'),
                                'icon' => 'fa-book-open',
                                'label' => 'Read/Write',
                                'btnClass' => 'btn-secondary'
                            ],
                            [
                                'url' => url('materi/kinesthetic/1'),
                                'icon' => 'fa-running',
                                'label' => 'Kinesthetic',
                                'btnClass' => 'btn-warning'
                            ],
                        ];
                    @endphp

                    @foreach ($learningStyles as $style)
                        <div class="card shadow-sm text-center px-3 py-2">
                            <div class="fs-3 text-dark mb-1">
                                <i class="fas {{ $style['icon'] }}"></i>
                            </div>
                            <h6 class="mb-1 text-{{ str_replace('btn-', '', $style['btnClass']) }}">{{ $style['label'] }}</h6>
                            <a href="{{ $style['url'] }}" class="btn {{ $style['btnClass'] }} btn-sm">
                                Coba Belajar
                            </a>
                        </div>
                    @endforeach
                </div>
            </div>
        </div>

        <!-- Layout wrapper -->
        <div class="layout-wrapper layout-content-navbar">
        <div class="layout-container">
            <!-- Sidebar Menu -->
            <aside id="layout-menu" class="layout-menu menu-vertical menu bg-menu-theme">
            <div class="app-brand demo">
                <a href="dashboard" class="app-brand-link">
                <span class="app-brand-logo demo">
                    <img src="{{ asset('publicc/backend/assets/img/logo/logo_ametative.png') }}" alt="AMetative HLE"
                    style="width: 65px; height: auto;">
                </span>
                <span class="app-brand-text demo menu-text fw-bolder ms-2"
                    style="text-transform: none; font-size: 20px;">AMetative HLE</span>
                </a>
                <a href="javascript:void(0);" class="layout-menu-toggle menu-link text-large ms-auto d-block d-xl-none">
                <i class="bx bx-chevron-left bx-sm align-middle"></i>
                </a>
            </div>

            <!-- Profil -->
            <div class="text-center p-3">
            <div style="width: 100px; height: 100px; background: #D9D9D9; display: flex; justify-content: center; align-items: center; border-radius: 50%; margin: auto;">
            <img src="{{ asset('storage/' . Auth::user()->foto)}}" alt="Profile" class="rounded-circle" style="width: 100px; height: 100px;">
            </div>
            <div class="mt-2" style="color: #666; font-size: 16px; font-weight: 500;">
                {{ Auth::user()->nama_lengkap }}
            </div>
            <div style="color: #666; font-size: 14px;">
                {{ Auth::user()->nim }}
            </div>
            </div>

            <!-- Menu Navigasi -->
            <ul class="menu-inner py-1">
                <li class="menu-item">
                <a href="/dashboard" class="menu-link">
                    <i class="menu-icon tf-icons bx bx-home-circle"></i>
                    <div data-i18n="Analytics">Dashboard</div>
                </a>
                </li>

                <li class="menu-item">
                <a href="{{ route('user.questionnaire.check')}}" class="menu-link">
                    <i class="menu-icon tf-icons bx bx-pencil"></i>
                    <div data-i18n="Analytics">Kuesioner</div>
                </a>
                </li>

                <li class="menu-item active">
                <a href="javascript:void(0)" class="menu-link menu-toggle">
                    <i class="menu-icon tf-icons bx bx-copy"></i>
                    <div data-i18n="Extended UI">Materi Pembelajaran</div>
                </a>
                <ul class="menu-sub">
                    <li class="menu-item active">
                    <a href="/materi" class="menu-link">
                        <div data-i18n="Perfect Scrollbar">Enkapsulasi</div>
                    </a>
                    </li>
                </ul>
                </li>

                <li class="menu-item">
                <a href="/history_quis" class="menu-link">
                    <i class="menu-icon tf-icons bx bx-history"></i>
                    <div data-i18n="Analytics">History Kuisioner</div>
                </a>
                </li>
                <li class="menu-item">
                <a href="" class="menu-link">
                    <i class="menu-icon tf-icons bx bx-task"></i>
                    <div data-i18n="Analytics">Resume Pembelajaran</div>
                </a>
                </li>
            </ul>
            </aside>

            <!-- Layout Page Start -->
            <div class="layout-page">

            <nav
                class="layout-navbar container-xxl navbar navbar-expand-xl navbar-detached align-items-center bg-navbar-theme"
                id="layout-navbar"
            >
                <div class="layout-menu-toggle navbar-nav align-items-xl-center me-3 me-xl-0 d-xl-none">
                <a class="nav-item nav-link px-0 me-xl-4" href="javascript:void(0)">
                    <i class="bx bx-menu bx-sm"></i>
                </a>
                </div>
                <div class="d-flex align-items-center">
                    <button 
                    onclick="toggleSidebar()" 
                    class="btn btn-sm btn-outline-secondary me-3 d-flex align-items-center"
                    title="Sembunyikan/Munculkan Menu"
                    >
                    <i id="sidebar-toggle-icon" class="bx bx-chevrons-left fs-5"></i>
                    </button>
                </div>

                <div class="navbar-nav-right d-flex align-items-center" id="navbar-collapse">
                <ul class="navbar-nav flex-row align-items-center ms-auto">
                    <!-- Notifikasi -->
                
                    <!-- User -->
                    <li class="nav-item navbar-dropdown dropdown-user dropdown">
                    <a class="nav-link dropdown-toggle hide-arrow" href="javascript:void(0);" data-bs-toggle="dropdown">
                    <div class="avatar avatar-online">
                        <img src="{{ asset('storage/' . Auth::user()->foto) }}" 
                            alt="Profile" 
                            class="rounded-circle" 
                            style="width: 40px; height: 40px; object-fit: cover;" />
                    </div>
                    </a>

                    <ul class="dropdown-menu dropdown-menu-end">
                        <li>
                        <a class="dropdown-item" href="">
                        <div class="d-flex">
                            <div class="flex-shrink-0 me-3">
                            <div class="avatar avatar-online">
                                <img src="{{ asset('storage/' . Auth::user()->foto) }}" alt="Profile Picture" class="rounded-circle" style="width: 40px; height: 40px; object-fit: cover;" />
                            </div>
                            </div>
                            <div class="flex-grow-1">
                            <span class="fw-semibold d-block">{{ Auth::user()->nama_lengkap }}</span>
                            <small class="text-muted">{{ Auth::user()->nim }}</small>
                            </div>
                        </div>
                        </a>

                        </li>
                        <li>
                        <div class="dropdown-divider"></div>
                        </li>
                        <li>
                        <a class="dropdown-item" href="/profile">
                            <i class="bx bx-user me-2"></i>
                            <span class="align-middle">My Profile</span>
                        </a>
                        </li>
                        <li>
                        <!-- <a class="dropdown-item" href="#">
                            <i class="bx bx-cog me-2"></i>
                            <span class="align-middle">Settings</span>
                        </a> -->
                        </li>
                        <li>
                        <div class="dropdown-divider"></div>
                        </li>
                        <li>
                        <a class="dropdown-item" href="#" data-bs-toggle="modal" data-bs-target="#confirmlogout">
                            <i class="bx bx-power-off me-2"></i>
                            <span class="align-middle">Log Out</span>
                        </a>
                    </li>
                    </ul>
                    </li>
                    <!--/ User -->
                </ul>
                </div>
            </nav>

            <!-- Modal Konfirmasi -->
            <div class="modal fade" id="confirmlogout" tabindex="-1" aria-labelledby="confirmlogoutLabel" aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="confirmlogoutLabel">Konfirmasi Logout</h5>
                    <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                </div>
                <div class="modal-body">
                    Apakah Anda yakin ingin logout?
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Tidak</button>
                    <!-- Form logout yang di-submit ketika user klik "Ya" -->
                    <form id="logout-form" action="{{ route('logout') }}" method="POST" class="d-none">
                    @csrf
                    </form>
                    <button type="button" class="btn btn-primary" onclick="document.getElementById('logout-form').submit();">Ya, Logout</button>
                </div>
                </div>
            </div>
            </div>

           @section('content')
            <div class="row">
                <div class="col-12">
                    <h4 class="fw-bold mb-4">Materi Auditory</h4>

                    <div class="card mb-4">
                        <div class="card-header">
                            <strong>Materi #{{ $materi->id_materi }}</strong>
                        </div>
                        <div class="card-body">
                            {{-- Konten --}}

                            {{-- Audio --}}
                            @php
                                $audioPath = 'storage/' . trim($materi->audio);
                            @endphp

                            @if ($materi->audio)
                                <div class="mb-3 text-center">
                                    <strong>Audio:</strong><br>
                                    <audio controls class="d-block mx-auto mt-2">
                                        <source src="{{ asset('storage/' . ltrim($materi->audio, '/')) }}" type="audio/mpeg">
                                        Browser kamu tidak mendukung elemen audio.
                                    </audio>
                                </div>
                            @else
                                <p class="text-muted">Tidak ada audio tersedia.</p>
                            @endif
                        </div>
                    </div>

                    {{-- Navigasi --}}
                    <div class="d-flex justify-content-between">
                        @if ($prev)
                            <a href="{{ route('materi.auditory', $prev->id_materi) }}" class="btn btn-secondary">⬅ Sebelumnya</a>
                        @else
                            <div></div>
                        @endif

                        @if ($next)
                            <a href="{{ route('materi.auditory', $next->id_materi) }}" class="btn btn-primary">Selanjutnya ➡</a>
                        @endif
                    </div>
                </div>
            </div>
            @endsection

            {{-- Tombol bantuan --}}
                <div class="bantuan">
                    <img id="helpButton"
                        src="https://raw.githubusercontent.com/Sangga123/asset/refs/heads/main/3f11c161-28c5-4cc7-be53-61f6e90d9230.jfif-removebg-preview%203.png"
                        alt="Pusat Bantuan"
                        style="width: 80px; height: auto; position: fixed; bottom: 20px; right: 20px; z-index: 999; cursor: pointer;">
                </div>

                <!-- Kotak Instruksi -->
                <div id="instructionPopup" style="
                    display: none;
                    position: fixed;
                    bottom: 90px;
                    right: 20px;
                    width: 400px;
                    background: white;
                    border-radius: 10px;
                    padding: 15px;
                    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
                    z-index: 1000;">
                    <div id="instructionContent" style="font-size:15px; margin-bottom:12px;"></div>
                    <div style="display: flex; justify-content: space-between; align-items: center;">
                        <button id="nextBtn" style="padding:6px 12px; font-size:13px; background-color:#4CAF50; color:white; border:none; border-radius:6px;">Next</button>
                        <button id="closeModal" style="background:none; border:none; font-size:18px; color:#888;">&times;</button>
                    </div>
                </div>

                <script>
                    const steps = [
                        @foreach($instruksi as $i)
                            `{!! addslashes($i) !!}`,
                        @endforeach
                    ];

                    let currentStep = 0;
                    const helpButton = document.getElementById("helpButton");
                    const popup = document.getElementById("instructionPopup");
                    const contentDiv = document.getElementById("instructionContent");
                    const nextBtn = document.getElementById("nextBtn");
                    const closeModal = document.getElementById("closeModal");

                    helpButton.addEventListener("click", () => {
                        currentStep = 0;
                        showStep(currentStep);
                        popup.style.display = "block";
                        nextBtn.textContent = steps.length > 1 ? "Next" : "Selesai";
                    });

                    nextBtn.addEventListener("click", () => {
                        currentStep++;
                        if (currentStep < steps.length) {
                            showStep(currentStep);
                            if (currentStep === steps.length - 1) {
                                nextBtn.textContent = "Selesai";
                            }
                        } else {
                            popup.style.display = "none";
                        }
                    });

                    closeModal.addEventListener("click", () => {
                        popup.style.display = "none";
                    });

                    function showStep(index) {
                        contentDiv.innerHTML = steps[index];
                    }
                </script>

            <script>
            function toggleSidebar() {
                const sidebar = document.getElementById('layout-menu');
                const icon = document.getElementById('sidebar-toggle-icon');
                const layoutPage = document.querySelector('.layout-page');
                const layoutContainer = document.querySelector('.layout-container');

                // Toggle sidebar
                sidebar.classList.toggle('d-none');

                // Toggle icon direction
                if (sidebar.classList.contains('d-none')) {
                    icon.classList.remove('bx-chevrons-left');
                    icon.classList.add('bx-chevrons-right');

                    // Tambahkan class full width ke layout-page atau layout-container
                    layoutPage.classList.add('w-100');
                    layoutContainer.classList.add('sidebar-hidden');
                } else {
                    icon.classList.remove('bx-chevrons-right');
                    icon.classList.add('bx-chevrons-left');

                    // Hapus class full width
                    layoutPage.classList.remove('w-100');
                    layoutContainer.classList.remove('sidebar-hidden');
                }
            }
            </script>

            <script>
                document.addEventListener('DOMContentLoaded', function () {
                    const sidebar = document.getElementById('learningStyleSidebar');
                    const toggleBtn = document.getElementById('toggleLearningStyleSidebar');
                    const icon = document.getElementById('sidebarToggleIcon');
                    let sidebarVisible = true;

                    toggleBtn.addEventListener('click', function () {
                        sidebarVisible = !sidebarVisible;
                        if (sidebarVisible) {
                            sidebar.style.transform = 'translateX(0)';
                            sidebar.style.pointerEvents = 'auto'; // bisa diklik
                            icon.classList.remove('fa-chevron-right');
                            icon.classList.add('fa-chevron-left');
                        } else {
                            sidebar.style.transform = 'translateX(100%)';
                            sidebar.style.pointerEvents = 'none'; // tidak menangkap klik
                            icon.classList.remove('fa-chevron-left');
                            icon.classList.add('fa-chevron-right');
                        }
                    });
                });
                sidebar.classList.toggle('hidden-sidebar');
            </script>

            <!-- Content wrapper -->
            <div class="content-wrapper">
                <div class="container-xxl flex-grow-1 container-p-y">
                    @yield('content')
                </div>
            </div>
            <!-- / Content wrapper -->

    <!-- / Layout wrapper -->

    <!-- Core JS -->
    <!-- build:js assets/vendor/js/core.js -->
    <script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.11.6/dist/umd/popper.min.js"></script>
    <script src="{{ asset('publicc/backend/assets/vendor/libs/jquery/jquery.js') }}"></script>
    <script src="{{ asset('publicc/backend/assets/vendor/libs/popper/popper.js') }}"></script>
    <script src="{{ asset('publicc/backend/assets/vendor/js/bootstrap.js') }}"></script>
    <script src="{{ asset('publicc/backend/assets/vendor/libs/perfect-scrollbar/perfect-scrollbar.js') }}"></script>

    <script src="{{ asset('publicc/backend/assets/vendor/js/menu.js') }}"></script>
    <!-- endbuild -->

    <!-- Vendors JS -->
    <script src="{{ asset('publicc/backend/assets/vendor/libs/apex-charts/apexcharts.js') }}"></script>

    <!-- Main JS -->
    <script src="{{ asset('publicc/backend/assets/js/main.js') }}"></script>

    <!-- Page JS -->
    <script src="{{ asset('publicc/backend/assets/js/dashboards-analytics.js') }}"></script>

    <!-- Place this tag in your head or just before your close body tag. -->
    <script async defer src="https://buttons.github.io/buttons.js"></script>
  </body>
</html>