<!DOCTYPE html>
<html lang="<?php echo \App\Services\LanguageService::getLang(); ?>">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title><?php echo __('admin_dashboard'); ?> - <?php echo htmlspecialchars(get_setting('site_name', 'APK ADMIN')); ?></title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
    <link rel="icon" type="image/x-icon" href="/<?php echo get_setting('site_favicon'); ?>">
    <style>
        :root {
            --primary-color: #4e73df;
            --success-color: #1cc88a;
        }
        body {
            background-color: #f8f9fc;
            font-family: 'Nunito', sans-serif;
        }
        .navbar-admin {
            background-color: #fff;
            box-shadow: 0 .15rem 1.75rem 0 rgba(58,59,69,.15);
        }
        .nav-link {
            color: #4e73df;
            padding: 0.5rem 1rem;
            border-radius: 0.35rem;
            transition: all 0.2s;
            font-weight: 600;
        }
        .nav-link:hover {
            background-color: rgba(78, 115, 223, 0.1);
            color: #224abe;
        }
        .nav-link.active {
            background-color: #4e73df;
            color: #fff !important;
        }
    </style>
</head>
<body>
    <nav class="navbar navbar-expand-lg navbar-admin sticky-top py-3">
        <div class="container-fluid px-4">
            <a class="navbar-brand fw-bold text-primary d-flex align-items-center" href="/admin/dashboard">
                <?php if (get_setting('site_icon')): ?>
                    <img src="/<?php echo get_setting('site_icon'); ?>" alt="Logo" class="me-2" style="height: 30px;">
                <?php else: ?>
                    <i class="fas fa-shield-halved me-2"></i>
                <?php endif; ?>
                <?php echo htmlspecialchars(get_setting('site_name', 'APK ADMIN')); ?>
            </a>
            <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
                <span class="navbar-toggler-icon"></span>
            </button>
            <div class="collapse navbar-collapse" id="navbarNav">
                <ul class="navbar-nav me-auto">
                    <li class="nav-item">
                        <a class="nav-link px-3" href="/admin/dashboard"><i class="fas fa-tachometer-alt me-1"></i> Dashboard</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link px-3" href="/admin/users"><i class="fas fa-users me-1"></i> Members</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link px-3" href="/admin/apks"><i class="fas fa-mobile-alt me-1"></i> APKs</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link px-3" href="/admin/apks/mass-upload"><i class="fas fa-cloud-upload-alt me-1"></i> Mass Upload</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link px-3" href="/admin/categories"><i class="fas fa-list me-1"></i> <?php echo __('categories'); ?></a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link px-3" href="/admin/withdrawals"><i class="fas fa-wallet me-1"></i> <?php echo __('manage_withdrawals'); ?></a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link px-3" href="/admin/settings"><i class="fas fa-cog me-1"></i> <?php echo __('settings'); ?></a>
                    </li>
                </ul>
                
                <!-- Admin Search Bar -->
                <form action="/admin/apks" method="GET" class="d-none d-sm-inline-block form-inline me-auto ms-md-3 my-2 my-md-0 mw-100 navbar-search">
                    <div class="input-group">
                        <input type="text" name="search" class="form-control bg-light border-0 small" placeholder="Search APKs..." aria-label="Search" value="<?php echo htmlspecialchars($_GET['search'] ?? ''); ?>">
                        <button class="btn btn-primary" type="submit">
                            <i class="fas fa-search fa-sm"></i>
                        </button>
                    </div>
                </form>

                <div class="d-flex align-items-center ms-auto">
                    <div class="dropdown me-3">
                        <button class="btn btn-outline-primary btn-sm dropdown-toggle fw-bold" type="button" data-bs-toggle="dropdown">
                            <i class="fas fa-globe me-1"></i> <?php echo \App\Services\LanguageService::getLang() == 'id' ? 'ID' : 'EN'; ?>
                        </button>
                        <ul class="dropdown-menu dropdown-menu-end shadow border-0">
                            <li><a class="dropdown-item" href="/lang/id">🇮🇩 Indonesia</a></li>
                            <li><a class="dropdown-item" href="/lang/en">🇺🇸 English</a></li>
                        </ul>
                    </div>
                    <span class="text-muted me-3 d-none d-md-inline"><b><?php echo $_SESSION['username'] ?? 'Admin'; ?></b></span>
                    <a href="/" class="btn btn-outline-secondary btn-sm me-2" target="_blank"><i class="fas fa-external-link-alt"></i></a>
                    <a href="/admin/logout" class="btn btn-danger btn-sm"><i class="fas fa-sign-out-alt"></i></a>
                </div>
            </div>
        </div>
    </nav>
