<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>NexCore - SuperAdmin Portal</title>
    <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
    <script src="https://unpkg.com/@phosphor-icons/web"></script>
    <link rel="stylesheet" href="/assets/css/style.css">
    <style>
        :root {
            --superadmin-color: #f59e0b;
            --superadmin-color-hover: #d97706;
            --superadmin-glow: rgba(245, 158, 11, 0.15);
        }
        .dashboard-layout {
            display: flex;
            height: 100vh;
            width: 100vw;
            position: fixed;
            top: 0;
            left: 0;
            background: var(--bg-dark);
            z-index: 1;
        }
        .sidebar {
            width: 260px;
            background: rgba(15, 23, 42, 0.85);
            backdrop-filter: blur(20px);
            border-right: 1px solid var(--glass-border);
            padding: 2rem 1.5rem;
            display: flex;
            flex-direction: column;
        }
        .sidebar-brand {
            font-size: 1.5rem;
            font-weight: 700;
            background: linear-gradient(to right, #fbbf24, #f59e0b);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            margin-bottom: 3rem;
            text-align: center;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 0.5rem;
        }
        .nav-link {
            display: flex;
            align-items: center;
            gap: 0.75rem;
            padding: 0.85rem 1rem;
            color: var(--text-muted);
            text-decoration: none;
            border-radius: 10px;
            margin-bottom: 0.5rem;
            transition: all 0.3s ease;
            font-weight: 500;
            white-space: nowrap;
        }
        .nav-link:hover, .nav-link.active {
            background: var(--superadmin-glow);
            color: white;
            border-left: 3px solid var(--superadmin-color);
        }
        .main-content {
            flex: 1;
            padding: 2rem 3rem;
            display: flex;
            flex-direction: column;
            overflow-y: auto;
            background: radial-gradient(circle at top right, rgba(245, 158, 11, 0.05), transparent 60%);
        }
        .topbar {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 2rem;
            padding-bottom: 1rem;
            border-bottom: 1px solid var(--glass-border);
        }
        .user-info {
            display: flex;
            align-items: center;
            gap: 1rem;
        }
        .logout-btn {
            background: rgba(239, 68, 68, 0.1);
            color: #ef4444;
            border: 1px solid rgba(239, 68, 68, 0.2);
            padding: 0.5rem 1rem;
            border-radius: 8px;
            text-decoration: none;
            font-size: 0.9rem;
            transition: all 0.3s ease;
        }
        .logout-btn:hover {
            background: rgba(239, 68, 68, 0.2);
        }
        .card-stat {
            background: var(--glass-bg);
            border: 1px solid var(--glass-border);
            border-radius: 16px;
            padding: 1.5rem;
            backdrop-filter: blur(10px);
            transition: all 0.3s ease;
            display: flex;
            align-items: center;
            justify-content: space-between;
        }
        .card-stat:hover {
            border-color: rgba(245, 158, 11, 0.3);
            box-shadow: 0 8px 30px rgba(245, 158, 11, 0.05);
        }
        .card-stat .icon-box {
            background: var(--superadmin-glow);
            color: var(--superadmin-color);
            padding: 1rem;
            border-radius: 12px;
            font-size: 1.5rem;
            display: flex;
            align-items: center;
            justify-content: center;
        }
        .btn-gold {
            background: var(--superadmin-color);
            color: #0f172a;
            border: none;
            padding: 0.75rem 1.5rem;
            border-radius: 8px;
            font-weight: 600;
            cursor: pointer;
            text-decoration: none;
            transition: all 0.3s ease;
            display: inline-flex;
            align-items: center;
            gap: 0.5rem;
        }
        .btn-gold:hover {
            background: var(--superadmin-color-hover);
        }
        .btn-outline-gold {
            background: transparent;
            color: var(--superadmin-color);
            border: 1px solid rgba(245, 158, 11, 0.4);
            padding: 0.5rem 1rem;
            border-radius: 8px;
            font-weight: 600;
            cursor: pointer;
            text-decoration: none;
            transition: all 0.3s ease;
        }
        .btn-outline-gold:hover {
            background: var(--superadmin-glow);
            border-color: var(--superadmin-color);
        }
        .data-table th {
            border-bottom: 2px solid rgba(245, 158, 11, 0.2);
            font-weight: 600;
            color: var(--text-light);
            text-align: left;
            padding: 1rem;
        }
        .data-table td {
            padding: 1rem;
            border-bottom: 1px solid var(--glass-border);
        }
        .action-icon {
            font-size: 1.25rem;
            margin-right: 0.5rem;
            cursor: pointer;
            transition: all 0.2s ease;
            text-decoration: none;
        }
        .action-icon.edit {
            color: #fbbf24;
        }
        .action-icon.delete {
            color: #ef4444;
        }
        .action-icon:hover {
            transform: scale(1.1);
        }
    </style>
</head>
<body>
    <div class="dashboard-layout">
        <div class="sidebar" id="sidebar">
            <div class="sidebar-brand">
                <i class="ph ph-crown" style="font-size: 1.75rem; color: #fbbf24;"></i>
                <span class="sidebar-brand-text">SuperAdmin</span>
            </div>
            
            <nav style="flex: 1;">
                <?php 
                $currentPath = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH); 
                function isSaActive($path, $current) {
                    return (strpos($current, $path) === 0) ? 'active' : '';
                }
                ?>
                <a href="/superadmin/dashboard" class="nav-link <?php echo isSaActive('/superadmin/dashboard', $currentPath); ?>">
                    <i class="ph ph-chart-pie" style="font-size: 1.25rem;"></i>
                    <span>Dashboard</span>
                </a>
                <a href="/superadmin/privileges" class="nav-link <?php echo isSaActive('/superadmin/privileges', $currentPath); ?>">
                    <i class="ph ph-shield" style="font-size: 1.25rem;"></i>
                    <span>Privileges</span>
                </a>
                <a href="/superadmin/registrations" class="nav-link <?php echo isSaActive('/superadmin/registrations', $currentPath); ?>">
                    <i class="ph ph-user-plus" style="font-size: 1.25rem;"></i>
                    <span>New Registrations</span>
                </a>
                <a href="/superadmin/uoms" class="nav-link <?php echo isSaActive('/superadmin/uoms', $currentPath); ?>">
                    <i class="ph ph-scales" style="font-size: 1.25rem;"></i>
                    <span>Units of Measure</span>
                </a>
                <a href="/superadmin/smtp" class="nav-link <?php echo isSaActive('/superadmin/smtp', $currentPath); ?>">
                    <i class="ph ph-envelope-simple" style="font-size: 1.25rem;"></i>
                    <span>SMTP Settings</span>
                </a>
                <a href="/superadmin/whatsapp" class="nav-link <?php echo isSaActive('/superadmin/whatsapp', $currentPath); ?>">
                    <i class="ph ph-whatsapp-logo" style="font-size: 1.25rem;"></i>
                    <span>WhatsApp Settings</span>
                </a>
                <a href="/superadmin/users" class="nav-link <?php echo isSaActive('/superadmin/users', $currentPath); ?>">
                    <i class="ph ph-users-three" style="font-size: 1.25rem;"></i>
                    <span>Users Control</span>
                </a>
                <a href="/superadmin/settings" class="nav-link <?php echo isSaActive('/superadmin/settings', $currentPath); ?>">
                    <i class="ph ph-gear" style="font-size: 1.25rem;"></i>
                    <span>Settings</span>
                </a>
                <a href="/superadmin/companies" class="nav-link <?php echo isSaActive('/superadmin/companies', $currentPath); ?>">
                    <i class="ph ph-buildings" style="font-size: 1.25rem;"></i>
                    <span>Company Settings</span>
                </a>
            </nav>
            
            <a href="/login/logout" class="logout-btn" style="text-align: center; margin-top: auto; display: block;">
                <i class="ph ph-sign-out" style="vertical-align: middle; margin-right: 0.5rem;"></i>Logout sa
            </a>
        </div>
        
        <div class="main-content">
            <div class="topbar">
                <div>
                    <h2 style="margin: 0; display: flex; align-items: center; gap: 0.5rem;">
                        <span style="color: var(--superadmin-color); font-weight: 700;">Superadmin</span> Portal
                    </h2>
                </div>
                
                <div id="topbarClock" style="display: flex; align-items: center; justify-content: center; gap: 0.75rem; background: rgba(30, 41, 59, 0.4); border: 1px solid var(--glass-border); padding: 0.5rem 1rem; border-radius: 12px; font-family: 'Inter', sans-serif; font-size: 0.95rem; font-weight: 500; backdrop-filter: blur(10px); color: var(--text-light);">
                    <i class="ph ph-clock" style="color: var(--superadmin-color); font-size: 1.25rem;"></i>
                    <span id="clockDate" style="color: var(--text-muted);"></span>
                    <span style="color: var(--glass-border);">|</span>
                    <span id="clockTime" style="color: white; font-weight: 600;"></span>
                </div>
                
                <div class="user-info">
                    <span style="color: var(--text-muted);">Session: <strong style="color: #fbbf24;">Super Admin</strong></span>
                </div>
            </div>

            <?php
            $flash = \App\Utils\Flash::get();
            if ($flash):
            ?>
                <div class="flash-message flash-<?php echo htmlspecialchars($flash['type']); ?>" style="margin-bottom: 2rem;">
                    <?php echo htmlspecialchars($flash['message']); ?>
                </div>
            <?php endif; ?>
            
            <!-- Views content injected below here -->
