<!DOCTYPE html>
<html lang="sr">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title><?php echo isset($page_title) ? $page_title . ' - ' : ''; ?>Admin Panel | Hugong Aparati</title>
    
    <!-- Google Font -->
    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700&display=fallback">
    <!-- Font Awesome -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
    <!-- AdminLTE -->
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/admin-lte@3.2.0/dist/css/adminlte.min.css">
    <!-- Custom Admin CSS -->
    <link rel="stylesheet" href="/admin/assets/css/admin-custom.css">
    
    <!-- Dropzone ako je potrebno -->
    <?php if (strpos($_SERVER['PHP_SELF'], '/products/') !== false): ?>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/dropzone/5.9.3/min/dropzone.min.css">
    <script src="https://cdnjs.cloudflare.com/ajax/libs/dropzone/5.9.3/min/dropzone.min.js"></script>
    <?php endif; ?>
    
        <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" />
    
    <!-- jQuery -->
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
</head>
<body class="hold-transition sidebar-mini">
    <div class="wrapper">
        <!-- Navbar -->
        <nav class="main-header navbar navbar-expand navbar-white navbar-light">
            <!-- Left navbar links -->
            <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="/admin/" class="nav-link">Dashboard</a>
                </li>
                <li class="nav-item d-none d-sm-inline-block">
                    <a href="/" class="nav-link" target="_blank">Pogledaj sajt</a>
                </li>
            </ul>
            
            <!-- Right navbar links -->
            <ul class="navbar-nav ml-auto">
                <li class="nav-item dropdown">
                    <a class="nav-link" data-toggle="dropdown" href="#">
                        <i class="fas fa-user-circle"></i>
                        <span class="d-none d-md-inline-block ml-1"><?php echo $_SESSION['user_name']; ?></span>
                    </a>
                    <div class="dropdown-menu dropdown-menu-right">
                        <a href="/admin/profile.php" class="dropdown-item">
                            <i class="fas fa-user-cog mr-2"></i> Profil
                        </a>
                        <div class="dropdown-divider"></div>
                        <a href="/admin/logout.php" class="dropdown-item">
                            <i class="fas fa-sign-out-alt mr-2"></i> Odjava
                        </a>
                    </div>
                </li>
            </ul>
        </nav>
        

<!-- Main Sidebar Container -->
<aside class="main-sidebar sidebar-dark-primary elevation-4">
    <!-- Brand Logo -->
    <a href="/admin/" class="brand-link">
        <img src="/assets/images/logo.png" alt="<?php echo get_setting('site_name', 'Hugong Aparati'); ?>" class="brand-image img-circle elevation-3" style="opacity: .8">
        <span class="brand-text font-weight-light">Admin Panel</span>
    </a>
    
    <!-- Sidebar -->
    <div class="sidebar">
        <!-- Sidebar Menu -->
        <nav class="mt-2">
            <ul class="nav nav-pills nav-sidebar flex-column">
                <li class="nav-item">
                    <a href="/admin/" class="nav-link <?php echo basename($_SERVER['PHP_SELF']) === 'index.php' && dirname($_SERVER['PHP_SELF']) === '/admin' ? 'active' : ''; ?>">
                        <i class="nav-icon fas fa-tachometer-alt"></i>
                        <p>Dashboard</p>
                    </a>
                </li>
                
                <!-- Proizvodi grupa - uvek otvorena -->
                <li class="nav-item nav-header">
                    <div class="nav-link">
                        <i class="nav-icon fas fa-box"></i>
                        <p>Proizvodi</p>
                    </div>
                </li>
                
                <li class="nav-item">
                    <a href="/admin/products/" class="nav-link <?php echo basename($_SERVER['PHP_SELF']) === 'index.php' && dirname($_SERVER['PHP_SELF']) === '/admin/products' ? 'active' : ''; ?>">
                        <i class="far fa-circle nav-icon"></i>
                        <p>Svi proizvodi</p>
                    </a>
                </li>
                <li class="nav-item">
                    <a href="/admin/products/add.php" class="nav-link <?php echo basename($_SERVER['PHP_SELF']) === 'add.php' && dirname($_SERVER['PHP_SELF']) === '/admin/products' ? 'active' : ''; ?>">
                        <i class="far fa-circle nav-icon"></i>
                        <p>Dodaj novi</p>
                    </a>
                </li>
                <li class="nav-item">
                    <a href="/admin/categories/" class="nav-link <?php echo strpos($_SERVER['PHP_SELF'], '/admin/categories/') !== false ? 'active' : ''; ?>">
                        <i class="far fa-circle nav-icon"></i>
                        <p>Kategorije</p>
                    </a>
                </li>
                
                <!-- Porudžbine grupa - uvek otvorena -->
                <li class="nav-item nav-header">
                    <div class="nav-link">
                        <i class="nav-icon fas fa-shopping-cart"></i>
                        <p>Porudžbine</p>
                    </div>
                </li>
                
                <li class="nav-item">
                    <a href="/admin/orders/" class="nav-link <?php echo basename($_SERVER['PHP_SELF']) === 'index.php' && dirname($_SERVER['PHP_SELF']) === '/admin/orders' ? 'active' : ''; ?>">
                        <i class="far fa-circle nav-icon"></i>
                        <p>Sve porudžbine</p>
                    </a>
                </li>
                <li class="nav-item">
                    <a href="/admin/orders/index.php?status=pending" class="nav-link <?php echo isset($_GET['status']) && $_GET['status'] === 'pending' && basename($_SERVER['PHP_SELF']) === 'index.php' && dirname($_SERVER['PHP_SELF']) === '/admin/orders' ? 'active' : ''; ?>">
                        <i class="far fa-circle nav-icon"></i>
                        <p>Na čekanju</p>
                    </a>
                </li>
                <li class="nav-item">
                    <a href="/admin/orders/index.php?status=processing" class="nav-link <?php echo isset($_GET['status']) && $_GET['status'] === 'processing' && basename($_SERVER['PHP_SELF']) === 'index.php' && dirname($_SERVER['PHP_SELF']) === '/admin/orders' ? 'active' : ''; ?>">
                        <i class="far fa-circle nav-icon"></i>
                        <p>U obradi</p>
                    </a>
                </li>
                
                <!-- Ostale sekcije -->
                <li class="nav-item">
                    <a href="/admin/users/" class="nav-link <?php echo strpos($_SERVER['PHP_SELF'], '/admin/users/') !== false ? 'active' : ''; ?>">
                        <i class="nav-icon fas fa-users"></i>
                        <p>Korisnici</p>
                    </a>
                </li>
                
                <li class="nav-item">
                    <a href="/admin/reviews/" class="nav-link <?php echo strpos($_SERVER['PHP_SELF'], '/admin/reviews/') !== false ? 'active' : ''; ?>">
                        <i class="nav-icon fas fa-star"></i>
                        <p>Recenzije</p>
                    </a>
                </li>
                
                <li class="nav-item">
                    <a href="/admin/settings/" class="nav-link <?php echo strpos($_SERVER['PHP_SELF'], '/admin/settings/') !== false ? 'active' : ''; ?>">
                        <i class="nav-icon fas fa-cog"></i>
                        <p>Podešavanja</p>
                    </a>
                </li>
            </ul>
        </nav>
    </div>
</aside>
        
        <!-- Content Wrapper. Contains page content -->
        <div class="content-wrapper">
            <?php if (isset($_SESSION['success_message'])): ?>
            <div class="alert alert-success alert-dismissible fade show m-3">
                <?php echo $_SESSION['success_message']; ?>
                <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <?php unset($_SESSION['success_message']); ?>
            <?php endif; ?>
            
            <?php if (isset($_SESSION['error_message'])): ?>
            <div class="alert alert-danger alert-dismissible fade show m-3">
                <?php echo $_SESSION['error_message']; ?>
                <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <?php unset($_SESSION['error_message']); ?>
            <?php endif; ?>
            
            
                <script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>
