<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>@yield('title', 'SIA Warkop Cak Imin')</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/admin-lte@3.2/dist/css/adminlte.min.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@5.15.4/css/all.min.css">
    <style>
        .main-sidebar { background-color: #2c3e50 !important; }
        .brand-link { background: linear-gradient(90deg, #ff8a00 0%, #ff5e00 100%) !important; color: white !important; border-bottom: none !important; }
        .nav-pills .nav-link.active, .nav-pills .show > .nav-link { background-color: #ff5e00 !important; color: #fff !important; }
        .sidebar-dark-primary .nav-sidebar > .nav-item > .nav-link.active { background-color: #ff5e00 !important; }
        [class*="sidebar-dark-"] .nav-treeview > .nav-item > .nav-link.active { background-color: rgba(255, 94, 0, 0.2) !important; color: #ff5e00 !important; }
    </style>
</head>
<body class="hold-transition sidebar-mini">
<div class="wrapper">
    <!-- Navbar -->
    <nav class="main-header navbar navbar-expand navbar-white navbar-light">
        <ul class="navbar-nav">
            <li class="nav-item">
                <a class="nav-link" data-widget="pushmenu" href="#" role="button"><i class="fas fa-bars"></i></a>
            </li>
            <li class="nav-item d-none d-sm-inline-block">
                <a href="/dashboard" class="nav-link">Home</a>
            </li>
        </ul>
        @if(!Request::is('dashboard'))
        <form class="form-inline ml-3" action="{{ url()->current() }}" method="GET">
            @foreach(request()->except('search') as $key => $value)
                <input type="hidden" name="{{ $key }}" value="{{ $value }}">
            @endforeach
            <div class="input-group input-group-sm">
                <input class="form-control form-control-navbar" type="search" name="search" value="{{ request('search') }}" placeholder="Search" aria-label="Search">
                <div class="input-group-append">
                    <button class="btn btn-navbar" type="submit">
                        <i class="fas fa-search"></i>
                    </button>
                </div>
            </div>
        </form>
        @endif
        <ul class="navbar-nav ml-auto">
            <li class="nav-item dropdown">
                <a class="nav-link" data-toggle="dropdown" href="#">
                    <i class="far fa-user"></i>
                </a>
                <div class="dropdown-menu dropdown-menu-lg dropdown-menu-right">
                    <span class="dropdown-header">Profil Pengguna</span>
                    <div class="dropdown-divider"></div>
                    <a href="#" class="dropdown-item" onclick="event.preventDefault(); document.getElementById('logout-form').submit();">
                        <i class="fas fa-sign-out-alt mr-2"></i> Logout
                    </a>
                    <form id="logout-form" action="{{ route('logout') }}" method="POST" style="display: none;">
                        @csrf
                    </form>
                </div>
            </li>
        </ul>
    </nav>
    <!-- Sidebar -->
    <aside class="main-sidebar sidebar-dark-primary elevation-4">
        <a href="#" class="brand-link">
            <span class="brand-text font-weight-light">SIA - {{ auth()->user()->branch }}</span>
        </a>
        <div class="sidebar">
            <nav class="mt-2">
                <ul class="nav nav-pills nav-sidebar flex-column" data-widget="treeview" role="menu">
                    <li class="nav-item">
                        <a href="/dashboard" class="nav-link {{ Request::is('dashboard') ? 'active' : '' }}">
                            <i class="nav-icon fas fa-tachometer-alt"></i>
                            <p>Dashboard</p>
                        </a>
                    </li>
                    <li class="nav-item">
                        <a href="/produk" class="nav-link {{ Request::is('produk') || Request::is('produk-karyawan') ? 'active' : '' }}">
                            <i class="nav-icon fas fa-utensils"></i>
                            <p>Produk</p>
                        </a>
                    </li>
                    <li class="nav-item has-treeview {{ Request::is('laporan/*') || Request::is('transaksi/*') ? 'menu-open' : '' }}">
                        <a href="#" class="nav-link {{ Request::is('laporan/*') || Request::is('transaksi/*') ? 'active' : '' }}">
                            <i class="nav-icon fas fa-file-invoice-dollar"></i>
                            <p>
                                Laporan
                                <i class="right fas fa-angle-left"></i>
                            </p>
                        </a>
                        <ul class="nav nav-treeview" style="{{ Request::is('laporan/*') || Request::is('transaksi/*') ? 'display: block;' : 'display: none;' }}">

                            <li class="nav-item"><a href="/laporan/pembelian" class="nav-link {{ Request::is('laporan/pembelian') ? 'active' : '' }}"><i class="far fa-circle nav-icon"></i> <p>Laporan Pembelian</p></a></li>
                            <li class="nav-item"><a href="/laporan/penjualan" class="nav-link {{ Request::is('laporan/penjualan') ? 'active' : '' }}"><i class="far fa-circle nav-icon"></i> <p>Laporan Penjualan</p></a></li>
                            <li class="nav-item"><a href="/transaksi/pembelian/create" class="nav-link {{ Request::is('transaksi/pembelian/create') ? 'active' : '' }}"><i class="far fa-circle nav-icon"></i> <p>Tambah Pembelian</p></a></li>
                            <li class="nav-item"><a href="/transaksi/penjualan/create" class="nav-link {{ Request::is('transaksi/penjualan/create') ? 'active' : '' }}"><i class="far fa-circle nav-icon"></i> <p>Tambah Penjualan</p></a></li>

                        </ul>
                    </li>

                </ul>
            </nav>
        </div>
    </aside>
    <!-- Content Wrapper -->
    <div class="content-wrapper">
        @yield('content')
    </div>
</div>
<script src="https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/js/bootstrap.bundle.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/admin-lte@3.2/dist/js/adminlte.min.js"></script>
@stack('scripts')
</body>
</html>
