<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Betting Tips Admin</title>
    <link rel="icon" type="image/svg+xml" href="<?= base_url('favicon.svg') ?>">
    <link rel="icon" type="image/x-icon" href="<?= base_url('favicon.ico') ?>">
    <link rel="apple-touch-icon" href="<?= base_url('favicon.svg') ?>">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.1/font/bootstrap-icons.css" rel="stylesheet">
    <link href="<?= base_url('assets/css/admin.css') ?>" rel="stylesheet">
    <style>
        :root {
            --primary-color: #2563eb;
            --primary-dark: #1d4ed8;
            --secondary-color: #64748b;
            --success-color: #059669;
            --warning-color: #d97706;
            --danger-color: #dc2626;
            --info-color: #0891b2;
            --light-bg: #f8fafc;
            --border-color: #e2e8f0;
            --text-muted: #64748b;
            --sidebar-bg: #ffffff;
            --card-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
            --card-shadow-hover: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
        }

        html,
        body {
            height: 100%;
            font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
        }

        body {
            display: flex;
            flex-direction: column;
            min-height: 100vh;
            background-color: var(--light-bg);
        }

        .main-wrapper {
            flex: 1;
        }

        .sidebar {
            min-height: calc(100vh - 56px);
            background-color: var(--sidebar-bg);
            border-right: 1px solid var(--border-color);
            box-shadow: 2px 0 4px rgba(0, 0, 0, 0.05);
        }

        .nav-link {
            color: var(--text-muted);
            border-radius: 8px;
            margin: 2px 8px;
            padding: 12px 16px;
            transition: all 0.2s ease;
            border: none;
            position: relative;
        }

        .nav-link:hover {
            color: var(--primary-color);
            background-color: rgba(37, 99, 235, 0.05);
            transform: translateX(2px);
        }

        .nav-link.active {
            color: var(--primary-color);
            background-color: rgba(37, 99, 235, 0.1);
            font-weight: 600;
            box-shadow: 0 2px 4px rgba(37, 99, 235, 0.1);
        }

        .nav-link.active::before {
            content: '';
            position: absolute;
            left: 0;
            top: 50%;
            transform: translateY(-50%);
            width: 3px;
            height: 20px;
            background-color: var(--primary-color);
            border-radius: 0 2px 2px 0;
        }

        .navbar {
            background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%) !important;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
        }

        .navbar-brand {
            font-weight: 700;
            font-size: 1.25rem;
        }

        .card {
            border: none;
            border-radius: 12px;
            box-shadow: var(--card-shadow);
            transition: all 0.3s ease;
        }

        .card:hover {
            box-shadow: var(--card-shadow-hover);
            transform: translateY(-2px);
        }

        .card-header {
            background-color: transparent;
            border-bottom: 1px solid var(--border-color);
            padding: 1.25rem 1.5rem;
        }

        .btn {
            border-radius: 8px;
            font-weight: 500;
            padding: 0.5rem 1rem;
            transition: all 0.2s ease;
        }

        .btn-primary {
            background-color: var(--primary-color);
            border-color: var(--primary-color);
        }

        .btn-primary:hover {
            background-color: var(--primary-dark);
            border-color: var(--primary-dark);
            transform: translateY(-1px);
            box-shadow: 0 4px 8px rgba(37, 99, 235, 0.3);
        }

        .form-control,
        .form-select {
            border-radius: 8px;
            border: 1px solid var(--border-color);
            padding: 0.75rem 1rem;
            transition: all 0.2s ease;
        }

        .form-control:focus,
        .form-select:focus {
            border-color: var(--primary-color);
            box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
        }

        .alert {
            border-radius: 8px;
            border: none;
            padding: 1rem 1.25rem;
        }

        .table {
            border-radius: 8px;
            overflow: hidden;
        }

        .table thead th {
            background-color: var(--light-bg);
            border-bottom: 2px solid var(--border-color);
            font-weight: 600;
            color: var(--text-muted);
        }

        .badge {
            border-radius: 6px;
            font-weight: 500;
        }

        /* Custom scrollbar */
        ::-webkit-scrollbar {
            width: 6px;
        }

        ::-webkit-scrollbar-track {
            background: var(--light-bg);
        }

        ::-webkit-scrollbar-thumb {
            background: var(--border-color);
            border-radius: 3px;
        }

        ::-webkit-scrollbar-thumb:hover {
            background: var(--secondary-color);
        }

        /* Loading states */
        .loading {
            opacity: 0.6;
            pointer-events: none;
        }

        /* Animations */
        @keyframes fadeIn {
            from {
                opacity: 0;
                transform: translateY(10px);
            }

            to {
                opacity: 1;
                transform: translateY(0);
            }
        }

        .fade-in {
            animation: fadeIn 0.3s ease-out;
        }

        main {
            padding-bottom: 20px;
        }

        /* Responsive improvements */
        @media (max-width: 768px) {
            .sidebar {
                position: fixed;
                top: 56px;
                left: -100%;
                width: 280px;
                z-index: 1000;
                transition: left 0.3s ease;
            }

            .sidebar.show {
                left: 0;
            }
        }
    </style>
</head>

<body>
    <nav class="navbar navbar-expand-lg navbar-dark bg-primary">
        <div class="container-fluid">
            <a class="navbar-brand" href="<?= site_url('admin') ?>">
                <i class="bi bi-graph-up"></i> Betting Tips Admin
            </a>
            <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
                <span class="navbar-toggler-icon"></span>
            </button>
        </div>
    </nav>

    <div class="container-fluid main-wrapper">
        <div class="row">
            <!-- Sidebar -->
            <div class="col-md-3 col-lg-2 d-md-block sidebar collapse">
                <div class="position-sticky pt-3">
                    <ul class="nav flex-column">
                        <li class="nav-item">
                            <a class="nav-link <?= current_url() == site_url('admin') ? 'active' : '' ?>"
                                href="<?= site_url('admin') ?>">
                                <i class="bi bi-speedometer2"></i> Dashboard
                            </a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link <?= current_url() == site_url('admin/tips') ? 'active' : '' ?>"
                                href="<?= site_url('admin/tips') ?>">
                                <i class="bi bi-list-ul"></i> Tips
                            </a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link <?= current_url() == site_url('admin/predictions') ? 'active' : '' ?>"
                                href="<?= site_url('admin/predictions') ?>">
                                <i class="bi bi-trophy"></i> Predictions
                            </a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link <?= current_url() == site_url('admin/author-stats') ? 'active' : '' ?>"
                                href="<?= site_url('admin/author-stats') ?>">
                                <i class="bi bi-person-lines-fill"></i> Author Stats
                            </a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link <?= current_url() == site_url('admin/transactions') ? 'active' : '' ?>"
                                href="<?= site_url('admin/transactions') ?>">
                                <i class="bi bi-cash-stack"></i> Transactions
                            </a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="<?= base_url('admin/tips-unlock') ?>">
                                <i class="bi bi-unlock"></i>
                                Tips Unlock
                            </a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link <?= current_url() == site_url('admin/award-points') ? 'active' : '' ?>"
                                href="<?= site_url('admin/award-points') ?>">
                                <i class="bi bi-gift"></i>
                                Award Points
                            </a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link <?= current_url() == site_url('admin/user-points') ? 'active' : '' ?>"
                                href="<?= site_url('admin/user-points') ?>">
                                <i class="bi bi-people"></i>
                                User Points
                            </a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="<?= base_url('admin/notifications') ?>">
                                <i class="bi bi-chat-square-text"></i>
                                Notifications
                            </a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link <?= current_url() == site_url('admin/subscribers') ? 'active' : '' ?>"
                                href="<?= site_url('admin/subscribers') ?>">
                                <i class="bi bi-person-check"></i>
                                Subscribers
                            </a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link <?= current_url() == site_url('admin/plans') ? 'active' : '' ?>"
                                href="<?= site_url('admin/plans') ?>">
                                <i class="bi bi-card-list"></i>
                                Plans
                            </a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link <?= current_url() == site_url('admin/tip-sales') ? 'active' : '' ?>"
                                href="<?= site_url('admin/tip-sales') ?>">
                                <i class="bi bi-bar-chart"></i> Tip Sales
                            </a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link <?= current_url() == site_url('admin/football/settings') ? 'active' : '' ?>"
                                href="<?= site_url('admin/football/settings') ?>">
                                <i class="bi bi-globe2"></i> Football catalog
                            </a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link <?= current_url() == site_url('admin/bet-builder/matches') ? 'active' : '' ?>"
                                href="<?= site_url('admin/bet-builder/matches') ?>">
                                <i class="bi bi-grid-3x3-gap"></i> Bet Builder
                            </a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link <?= current_url() == site_url('admin/bet-builder/tickets') ? 'active' : '' ?>"
                                href="<?= site_url('admin/bet-builder/tickets') ?>">
                                <i class="bi bi-ticket-perforated"></i> Builder Tickets
                            </a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link <?= current_url() == site_url('admin/app-version') ? 'active' : '' ?>"
                                href="<?= site_url('admin/app-version') ?>">
                                <i class="bi bi-phone"></i> App Version
                            </a>
                        </li>
                    </ul>
                </div>
            </div>

            <!-- Main content -->
            <main class="col-md-9 ms-sm-auto col-lg-10 px-md-4 py-4">
                <?php if (session()->has('message')): ?>
                    <div class="alert alert-success alert-dismissible fade show" role="alert">
                        <?= session('message') ?>
                        <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
                    </div>
                <?php endif; ?>

                <?php if (session()->has('error')): ?>
                    <div class="alert alert-danger alert-dismissible fade show" role="alert">
                        <?= session('error') ?>
                        <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
                    </div>
                <?php endif; ?>

                <?= $this->renderSection('content') ?>
            </main>
        </div>
    </div>

    <footer class="py-3 bg-light mt-auto">
        <div class="container-fluid text-center">
            <p class="mb-0">&copy; <?= date('Y') ?> Betting Tips Admin</p>
        </div>
    </footer>

    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
    <?= $this->renderSection('scripts') ?>
</body>

</html>