<?php
if (session_status() === PHP_SESSION_NONE) {
    session_start();
}
date_default_timezone_set('Asia/Vientiane');

// Check if logged in and is superadmin
if (!isset($_SESSION['user_id']) || $_SESSION['role'] !== 'superadmin') {
    header('Location: ../login.php');
    exit;
}

require_once dirname(__DIR__, 2) . '/include/con_data.php';

$current_page = basename($_SERVER['PHP_SELF'], '.php');
?>
<!DOCTYPE html>
<html lang="lo" data-theme="dark">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>
        <?= $page_title ?? 'Superadmin' ?> - MUANJAI
    </title>
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=Noto+Sans+Lao:wght@300;400;500;600;700&display=swap"
        rel="stylesheet">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">
    <!-- SweetAlert2 -->
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/sweetalert2@11/dist/sweetalert2.min.css">
    <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
    <link rel="icon" type="image/png" href="../img/logo/muanjai_logo.png">
    <script>
        (function () {
            if (localStorage.getItem('muanjai_sidebar_collapsed') === 'true') {
                document.documentElement.classList.add('sidebar-preload-collapsed');
                document.documentElement.classList.add('no-transitions');
            }
            if (localStorage.getItem('muanjai_theme') === 'light') {
                document.documentElement.setAttribute('data-theme', 'light');
            }
        })();
    </script>
    <style>
        .sidebar-preload-collapsed .sidebar {
            width: 70px !important;
            overflow: visible !important;
        }

        .sidebar-preload-collapsed .main-content {
            margin-left: 70px !important;
        }

        .sidebar-preload-collapsed .sidebar-brand,
        .sidebar-preload-collapsed .menu-label,
        .sidebar-preload-collapsed .menu-item a span,
        .sidebar-preload-collapsed .menu-arrow {
            opacity: 0 !important;
            width: 0 !important;
            pointer-events: none !important;
            transform: translateX(-10px) !important;
        }

        .sidebar-preload-collapsed .sidebar-header {
            justify-content: center !important;
            padding: 15px !important;
            gap: 0 !important;
        }

        .sidebar-preload-collapsed .sidebar-logo {
            width: 40px !important;
            height: 40px !important;
        }

        .sidebar-preload-collapsed .menu-item>a {
            justify-content: flex-start !important;
            padding: 12px 15px !important;
        }

        .sidebar-preload-collapsed .menu-item a i {
            margin-right: 0 !important;
            text-align: center !important;
            width: 30px !important;
        }

        .sidebar-preload-collapsed .sidebar-menu {
            overflow: visible !important;
            height: auto !important;
        }

        .sidebar-preload-collapsed .sidebar-toggle {
            top: 32px !important;
        }

        .sidebar-preload-collapsed .sidebar-toggle i {
            transform: rotate(180deg) !important;
        }

        @media (max-width: 991px) {
            .sidebar-preload-collapsed .main-content {
                margin-left: 0 !important;
            }
        }

        .no-transitions * {
            transition: none !important;
        }

        .swal2-container,
        .swal2-popup {
            z-index: 99999 !important;
        }
    </style>
    <style>
        /* ===== MUANJAI Gold Theme ===== */
        :root {
            /* Gold Theme Colors */
            --primary: #c1992a;
            --primary-light: #d4ac4a;
            --primary-dark: #a67f1f;
            --accent: #c1992a;
            --accent-light: #d4ac4a;
            --accent-soft: #8b6914;

            /* Light Mode */
            --light-bg: #F5F7FA;
            --light-card: #FFFFFF;
            --light-text: #1A1A2E;
            --light-text-secondary: #5A6370;
            --light-border: #E1E5EB;

            /* Dark Mode */
            --dark-bg: #1a1a2e;
            --dark-bg-secondary: #0f0f23;
            --dark-card: rgba(255, 255, 255, 0.05);
            --dark-text: #FFFFFF;
            --dark-text-secondary: rgba(255, 255, 255, 0.7);
            --dark-border: rgba(193, 153, 42, 0.2);

            /* Status Colors */
            --success: #28A745;
            --warning: #FFC107;
            --danger: #DC3545;
            --info: #17A2B8;
        }

        [data-theme="dark"] {
            --bg-primary: var(--dark-bg);
            --bg-secondary: var(--dark-bg-secondary);
            --card-bg: var(--dark-card);
            --text-primary: var(--dark-text);
            --text-secondary: var(--dark-text-secondary);
            --border-color: var(--dark-border);
            --sidebar-bg: var(--dark-bg-secondary);
        }

        [data-theme="light"] {
            --bg-primary: var(--light-bg);
            --bg-secondary: #E8ECF1;
            --card-bg: var(--light-card);
            --text-primary: var(--light-text);
            --text-secondary: var(--light-text-secondary);
            --border-color: var(--light-border);
            --sidebar-bg: var(--primary);
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Noto Sans Lao', sans-serif;
            background: var(--bg-primary);
            color: var(--text-primary);
            min-height: 100vh;
            transition: all 0.3s ease;
        }

        /* Sidebar */
        .sidebar {
            position: fixed;
            left: 0;
            top: 0;
            width: 260px;
            height: 100vh;
            background: var(--sidebar-bg);
            border-right: 1px solid var(--border-color);
            z-index: 100;
            transition: width 0.35s cubic-bezier(0.4, 0, 0.2, 1);
        }

        .sidebar.collapsed {
            width: 70px;
            overflow: visible;
        }

        .sidebar .sidebar-brand,
        .sidebar .menu-label,
        .sidebar .menu-item a span,
        .sidebar .menu-arrow {
            opacity: 1;
            transform: translateX(0);
            transition: opacity 0.25s ease, transform 0.25s ease;
            white-space: nowrap;
            overflow: hidden;
        }

        .sidebar.collapsed .sidebar-brand,
        .sidebar.collapsed .menu-label,
        .sidebar.collapsed .menu-item a span,
        .sidebar.collapsed .menu-arrow {
            opacity: 0;
            transform: translateX(-10px);
            width: 0;
            pointer-events: none;
        }

        .sidebar-header {
            padding: 20px;
            border-bottom: 1px solid var(--border-color);
            display: flex;
            align-items: center;
            gap: 12px;
            transition: padding 0.35s, gap 0.35s;
        }

        .sidebar.collapsed .sidebar-header {
            justify-content: center;
            padding: 15px;
            gap: 0;
        }

        .sidebar-logo {
            width: 45px;
            height: 45px;
            
            /* SOLID COLOR AS REQUESTED */
            border-radius: 12px;
            display: flex;
            align-items: center;
            justify-content: center;
            color: white;
            font-size: 20px;
            flex-shrink: 0;
            transition: width 0.35s, height 0.35s;
        }

        .sidebar-logo img {
            width: 100%;
            height: 100%;
            object-fit: contain;
            border-radius: 12px;
        }

        .sidebar.collapsed .sidebar-logo {
            width: 40px;
            height: 40px;
        }

        .menu-item>a {
            transition: padding 0.35s, justify-content 0.35s;
        }

        .sidebar.collapsed .menu-item>a {
            justify-content: flex-start;
            padding: 12px 15px;
        }

        .sidebar.collapsed .menu-item a i {
            font-size: 20px;
            margin-right: 0;
            text-align: center;
            width: 30px;
        }

        .sidebar.collapsed .menu-item {
            position: static;
        }

        .sidebar.collapsed .menu-item>a {
            position: relative;
        }

        .sidebar.collapsed .submenu {
            display: none;
            position: fixed;
            left: 60px;
            min-width: 220px;
            background: var(--bg-secondary);
            border: 1px solid var(--border-color);
            border-radius: 12px;
            padding: 10px 0;
            padding-left: 15px;
            margin-left: 0;
            box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
            z-index: 9999;
            max-height: none;
            overflow: visible;
            opacity: 1;
            transition: none;
        }

        .sidebar.collapsed .submenu::before {
            content: '';
            position: absolute;
            left: -15px;
            top: 0;
            width: 20px;
            height: 100%;
            background: transparent;
        }

        .sidebar.collapsed .menu-item:hover .submenu {
            display: block;
        }

        .sidebar.collapsed .submenu::after {
            content: '';
            position: absolute;
            left: 5px;
            top: 15px;
            width: 0;
            height: 0;
            border-top: 8px solid transparent;
            border-bottom: 8px solid transparent;
            border-right: 8px solid var(--bg-secondary);
        }

        .sidebar.collapsed .submenu li a {
            padding: 12px 18px;
            justify-content: flex-start;
            gap: 10px;
        }

        .sidebar.collapsed .submenu li a span {
            display: inline;
        }

        [data-theme="light"] .sidebar.collapsed .submenu {
            background: var(--primary);
            border-color: var(--primary-light);
        }

        [data-theme="light"] .sidebar.collapsed .submenu li a {
            color: rgba(255, 255, 255, 0.85);
        }

        [data-theme="light"] .sidebar.collapsed .submenu li a:hover {
            background: rgba(255, 255, 255, 0.1);
            color: white;
        }

        [data-theme="light"] .sidebar.collapsed .submenu::after {
            border-right-color: var(--primary);
        }

        .sidebar.collapsed .sidebar-menu {
            overflow: visible;
            height: auto;
        }

        .sidebar-toggle {
            position: absolute;
            right: -14px;
            top: 35px;
            width: 28px;
            height: 28px;
            border-radius: 50%;
            background: var(--accent);
            border: 3px solid var(--bg-primary);
            color: white;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 11px;
            transition: all 0.3s ease;
            z-index: 101;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
        }

        .sidebar-toggle:hover {
            background: var(--accent-light);
            transform: scale(1.15);
        }

        .sidebar.collapsed .sidebar-toggle {
            top: 32px;
        }

        .sidebar.collapsed .sidebar-toggle i {
            transform: rotate(180deg);
        }

        .sidebar-brand {
            color: white;
        }

        .sidebar-brand h2 {
            font-size: 20px;
            font-weight: 700;
            color: var(--accent);
        }

        [data-theme="light"] .sidebar-brand h2 {
            color: white;
        }

        .sidebar-brand span {
            font-size: 13px;
            color: rgba(255, 255, 255, 0.6);
        }

        [data-theme="dark"] .sidebar-brand span {
            color: var(--text-secondary);
        }

        .sidebar-menu {
            padding: 15px 0;
            list-style: none;
            overflow-y: auto;
            height: calc(100vh - 85px);
        }

        .menu-label {
            padding: 10px 20px;
            font-size: 13px;
            text-transform: uppercase;
            color: rgba(255, 255, 255, 0.4);
            font-weight: 600;
            letter-spacing: 0.5px;
        }

        [data-theme="dark"] .menu-label {
            color: var(--accent);
        }

        .menu-item {
            margin: 2px 10px;
        }

        .menu-item>a {
            display: flex;
            align-items: center;
            gap: 12px;
            padding: 12px 15px;
            color: rgba(255, 255, 255, 0.7);
            text-decoration: none;
            border-radius: 10px;
            transition: all 0.3s ease;
            font-size: 16px;
        }

        [data-theme="dark"] .menu-item>a {
            color: var(--text-secondary);
        }

        .menu-item>a:hover {
            background: rgba(255, 255, 255, 0.1);
            color: white;
        }

        [data-theme="dark"] .menu-item>a:hover {
            background: rgba(193, 153, 42, 0.15);
            color: var(--accent);
        }

        .menu-item>a.active {
            background: var(--accent);
            color: white;
        }

        .menu-item a i {
            width: 20px;
            text-align: center;
        }

        .menu-arrow {
            margin-left: auto;
            transition: transform 0.3s ease;
        }

        .menu-item.open .menu-arrow {
            transform: rotate(90deg);
        }

        .submenu {
            list-style: none;
            padding-left: 15px;
            margin-top: 5px;
            max-height: 0;
            overflow: hidden;
            transition: max-height 0.3s ease-out, opacity 0.3s ease-out;
            opacity: 0;
        }

        .menu-item.open .submenu {
            max-height: 500px;
            opacity: 1;
            transition: max-height 0.4s ease-in, opacity 0.3s ease-in;
        }

        .submenu li a {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 10px 15px;
            color: rgba(255, 255, 255, 0.6);
            text-decoration: none;
            font-size: 15px;
            border-radius: 8px;
            transition: all 0.3s ease;
        }

        [data-theme="dark"] .submenu li a {
            color: var(--text-secondary);
        }

        .submenu li a:hover {
            color: white;
            background: rgba(255, 255, 255, 0.05);
        }

        [data-theme="dark"] .submenu li a:hover {
            color: var(--accent);
            background: rgba(193, 153, 42, 0.1);
        }

        .submenu li a.active {
            color: var(--accent);
        }

        .main-content {
            margin-left: 260px;
            min-height: 100vh;
            transition: margin-left 0.35s cubic-bezier(0.4, 0, 0.2, 1);
        }

        body.sidebar-collapsed .main-content {
            margin-left: 70px;
        }

        .top-header {
            position: sticky;
            top: 0;
            background: var(--bg-primary);
            border-bottom: 1px solid var(--border-color);
            padding: 15px 25px;
            display: flex;
            align-items: center;
            justify-content: space-between;
            z-index: 50;
        }

        .page-title {
            font-size: 24px;
            font-weight: 600;
        }

        .header-actions {
            display: flex;
            align-items: center;
            gap: 15px;
        }

        .theme-toggle {
            width: 40px;
            height: 40px;
            border-radius: 10px;
            background: var(--card-bg);
            border: 1px solid var(--border-color);
            color: var(--text-primary);
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all 0.3s ease;
        }

        .theme-toggle:hover {
            background: var(--accent);
            color: white;
        }

        .user-dropdown {
            position: relative;
        }

        .user-btn {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 8px 15px;
            background: var(--card-bg);
            border: 1px solid var(--border-color);
            border-radius: 10px;
            color: var(--text-primary);
            cursor: pointer;
            transition: all 0.3s ease;
        }

        .user-btn:hover {
            border-color: var(--accent);
        }

        .user-avatar {
            width: 32px;
            height: 32px;
            border-radius: 8px;
            background: var(--accent);
            display: flex;
            align-items: center;
            justify-content: center;
            color: white;
            font-size: 14px;
        }

        .user-info {
            text-align: left;
        }

        .user-info .name {
            font-size: 15px;
            font-weight: 600;
        }

        .user-info .role {
            font-size: 13px;
            color: var(--text-secondary);
        }

        .dropdown-menu {
            position: absolute;
            top: 100%;
            right: 0;
            margin-top: 8px;
            background: var(--bg-secondary);
            border: 1px solid var(--border-color);
            border-radius: 10px;
            min-width: 180px;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
            display: none;
            overflow: hidden;
        }

        .dropdown-menu.show {
            display: block;
        }

        .dropdown-menu a {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 12px 15px;
            color: var(--text-primary);
            text-decoration: none;
            font-size: 15px;
            transition: all 0.3s ease;
        }

        .dropdown-menu a:hover {
            background: var(--accent);
            color: white;
        }

        .dropdown-menu a.danger {
            color: var(--danger);
        }

        .dropdown-menu a.danger:hover {
            background: var(--danger);
            color: white;
        }

        .content {
            padding: 25px;
        }

        .card {
            background: var(--card-bg);
            border: 1px solid var(--border-color);
            border-radius: 15px;
            overflow: hidden;
        }

        .card-header {
            padding: 18px 20px;
            border-bottom: 1px solid var(--border-color);
            display: flex;
            align-items: center;
            justify-content: space-between;
        }

        .card-title {
            font-size: 18px;
            font-weight: 600;
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .card-body {
            padding: 20px;
        }

        .btn {
            display: inline-flex;
            align-items: center;
            gap: 8px;
            padding: 10px 18px;
            border: none;
            border-radius: 8px;
            font-size: 15px;
            font-weight: 500;
            font-family: inherit;
            cursor: pointer;
            transition: all 0.3s ease;
        }

        .btn-primary {
            background: #c1992a;
            /* SOLID COLOR */
            color: white;
        }

        .btn-primary:hover {
            transform: translateY(-2px);
            box-shadow: 0 5px 20px rgba(193, 153, 42, 0.3);
        }

        .btn-secondary {
            background: var(--card-bg);
            border: 1px solid var(--border-color);
            color: var(--text-primary);
        }

        .btn-secondary:hover {
            border-color: var(--accent);
            color: var(--accent);
        }

        .stats-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
            gap: 20px;
            margin-bottom: 25px;
        }

        .stat-card {
            background: var(--card-bg);
            border: 1px solid var(--border-color);
            border-radius: 15px;
            padding: 20px;
            display: flex;
            align-items: center;
            gap: 15px;
        }

        .stat-icon {
            width: 55px;
            height: 55px;
            border-radius: 12px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 22px;
            color: white;
        }

        .stat-icon.gold {
            background: #c1992a;
            /* SOLID COLOR */
        }

        .stat-icon.green {
            background: linear-gradient(135deg, #28A745, #1E7B33);
        }

        .stat-icon.orange {
            background: linear-gradient(135deg, #FD7E14, #E06B10);
        }

        .stat-icon.purple {
            background: linear-gradient(135deg, #6C7AE0, #4A5BC7);
        }

        .stat-info h3 {
            font-size: 28px;
            font-weight: 700;
        }

        .stat-info p {
            font-size: 15px;
            color: var(--text-secondary);
        }

        .menu-item>a.danger {
            color: var(--danger) !important;
        }

        .menu-item>a.danger:hover {
            background: var(--danger);
            color: white !important;
        }

        .modal-overlay {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(0, 0, 0, 0.6);
            display: none;
            align-items: center;
            justify-content: center;
            z-index: 1000;
        }

        .modal-overlay.show {
            display: flex;
        }

        .modal {
            background: var(--bg-primary);
            border: 1px solid var(--border-color);
            border-radius: 15px;
            width: 100%;
            max-width: 550px;
            max-height: 90vh;
            overflow-y: auto;
        }

        .modal-header {
            padding: 18px 20px;
            border-bottom: 1px solid var(--border-color);
            display: flex;
            align-items: center;
            justify-content: space-between;
        }

        .modal-title {
            font-size: 20px;
            font-weight: 600;
        }

        .modal-close {
            width: 35px;
            height: 35px;
            border: none;
            background: var(--card-bg);
            border-radius: 8px;
            color: var(--text-primary);
            cursor: pointer;
            transition: all 0.3s ease;
        }

        .modal-close:hover {
            background: var(--danger);
            color: white;
        }

        .modal-body {
            padding: 20px;
        }

        .modal-footer {
            padding: 15px 20px;
            border-top: 1px solid var(--border-color);
            display: flex;
            justify-content: flex-end;
            gap: 10px;
        }

        .form-group {
            margin-bottom: 18px;
        }

        .form-label {
            display: block;
            font-size: 15px;
            font-weight: 500;
            color: var(--text-secondary);
            margin-bottom: 8px;
        }

        .form-control {
            width: 100%;
            padding: 12px 15px;
            background: var(--bg-secondary);
            border: 1px solid var(--border-color);
            border-radius: 8px;
            color: var(--text-primary);
            font-size: 16px;
            font-family: inherit;
            transition: all 0.3s ease;
        }

        .form-control:focus {
            outline: none;
            border-color: var(--accent);
            box-shadow: 0 0 0 3px rgba(193, 153, 42, 0.15);
        }

        /* Welcome Section */
        .welcome-section {
            background: #c1992a;
            /* SOLID COLOR */
            border-radius: 15px;
            padding: 30px;
            margin-bottom: 25px;
            color: white;
        }

        .welcome-section h2 {
            font-size: 28px;
            margin-bottom: 10px;
        }

        .welcome-section p {
            font-size: 16px;
            opacity: 0.9;
        }

        @media (max-width: 991px) {
            .sidebar {
                transform: translateX(-100%);
                z-index: 1000;
            }

            .sidebar.show {
                transform: translateX(0);
            }

            .sidebar-toggle {
                display: none;
            }

            .main-content {
                margin-left: 0;
            }

            body.sidebar-collapsed .main-content {
                margin-left: 0;
            }

            .mobile-menu-toggle {
                display: flex;
            }

            .sidebar-overlay {
                display: none;
                position: fixed;
                top: 0;
                left: 0;
                right: 0;
                bottom: 0;
                background: rgba(0, 0, 0, 0.5);
                z-index: 999;
            }

            .sidebar-overlay.show {
                display: block;
            }

            .top-header {
                padding: 12px 15px;
            }

            .page-title {
                font-size: 18px;
            }

            .content {
                padding: 15px;
            }

            .stats-grid {
                grid-template-columns: 1fr;
                gap: 12px;
            }

            .stat-card {
                padding: 15px;
            }

            .stat-icon {
                width: 45px;
                height: 45px;
                font-size: 18px;
            }

            .stat-info h3 {
                font-size: 22px;
            }

            .stat-info p {
                font-size: 13px;
            }

            .card {
                border-radius: 12px;
            }

            .card-header {
                padding: 14px 15px;
                flex-wrap: wrap;
                gap: 10px;
            }

            .card-title {
                font-size: 16px;
            }

            .card-body {
                padding: 15px;
            }

            .btn {
                padding: 8px 14px;
                font-size: 14px;
            }

            .user-info {
                display: none;
            }

            .user-btn {
                padding: 8px 10px;
            }

            .header-actions {
                gap: 10px;
            }

            .theme-toggle {
                width: 36px;
                height: 36px;
            }

            .modal {
                margin: 15px;
                max-width: calc(100% - 30px);
            }

            .modal-header {
                padding: 14px 15px;
            }

            .modal-body {
                padding: 15px;
            }

            .modal-footer {
                padding: 12px 15px;
                flex-wrap: wrap;
            }

            .form-control {
                padding: 10px 12px;
                font-size: 15px;
            }
        }

        @media (max-width: 576px) {
            .page-title {
                font-size: 16px;
            }

            .stat-card {
                padding: 12px;
            }

            .stat-icon {
                width: 40px;
                height: 40px;
                font-size: 16px;
            }

            .stat-info h3 {
                font-size: 20px;
            }

            .btn {
                padding: 8px 12px;
                font-size: 13px;
            }

            .card-header {
                padding: 12px;
            }

            .card-body {
                padding: 12px;
            }

            .dropdown-menu {
                min-width: 150px;
            }

            .dropdown-menu a {
                padding: 10px 12px;
                font-size: 14px;
            }
        }

        .mobile-menu-toggle {
            display: none;
            width: 40px;
            height: 40px;
            border-radius: 10px;
            background: var(--card-bg);
            border: 1px solid var(--border-color);
            color: var(--text-primary);
            cursor: pointer;
            align-items: center;
            justify-content: center;
            font-size: 18px;
            transition: all 0.3s ease;
            flex-shrink: 0;
        }

        .mobile-menu-toggle:hover {
            background: var(--accent);
            color: white;
        }

        @media (max-width: 991px) {
            .mobile-menu-toggle {
                display: flex !important;
            }
        }
    </style>
</head>

<body>
    <!-- Sidebar -->
    <aside class="sidebar" id="sidebar">
        <button class="sidebar-toggle" onclick="toggleSidebar()" title="ພັບ/ຂະຫຍາຍເມນູ">
            <i class="fas fa-chevron-left"></i>
        </button>
        <div class="sidebar-header">
            <div class="sidebar-logo">
                <img src="../img/logo/muanjai_logo_white.png" alt="Muanjai Logo">
            </div>
            <div class="sidebar-brand">
                <h2>MUANJAI</h2>
                <span>Superadmin</span>
            </div>
        </div>

        <ul class="sidebar-menu">
            <!-- ໜ້າຫຼັກ -->
            <li class="menu-item">
                <a href="index.php" class="<?= $current_page === 'index' ? 'active' : '' ?>">
                    <i class="fas fa-home"></i>
                    <span>ໜ້າຫຼັກ</span>
                </a>
            </li>

            <!-- ຈັດການຜູ້ໃຊ້ -->
            <li class="menu-item">
                <a href="users.php" class="<?= $current_page === 'users' ? 'active' : '' ?>">
                    <i class="fas fa-users"></i>
                    <span>ຈັດການຜູ້ໃຊ້</span>
                </a>
            </li>

            <!-- ຈັດການຮ້ານຄ້າ -->
            <li class="menu-item">
                <a href="shops.php" class="<?= $current_page === 'shops' ? 'active' : '' ?>">
                    <i class="fas fa-store"></i>
                    <span>ຈັດການຮ້ານຄ້າ</span>
                </a>
            </li>

            <!-- ອອກຈາກລະບົບ -->
            <li class="menu-item">
                <a href="../logout.php" class="danger">
                    <i class="fas fa-sign-out-alt"></i>
                    <span>ອອກຈາກລະບົບ</span>
                </a>
            </li>
        </ul>
    </aside>

    <!-- Sidebar Overlay for Mobile -->
    <div class="sidebar-overlay" id="sidebarOverlay" onclick="closeMobileSidebar()"></div>

    <!-- Main Content -->
    <main class="main-content">
        <!-- Top Header -->
        <header class="top-header">
            <!-- Mobile Menu Toggle -->
            <button class="mobile-menu-toggle" onclick="toggleMobileSidebar()" title="ເມນູ">
                <i class="fas fa-bars"></i>
            </button>

            <h1 class="page-title">
                <?= $page_title ?? 'Superadmin Dashboard' ?>
            </h1>

            <div class="header-actions">
                <button class="theme-toggle" onclick="toggleTheme()" title="ສະຫຼັບໂໝດສີ">
                    <i class="fas fa-moon" id="theme-icon"></i>
                </button>

                <div class="user-dropdown">
                    <button class="user-btn" onclick="toggleDropdown()">
                        <div class="user-avatar">
                            <i class="fas fa-user-shield"></i>
                        </div>
                        <div class="user-info">
                            <div class="name">
                                <?= htmlspecialchars($_SESSION['username'] ?? 'Superadmin') ?>
                            </div>
                            <div class="role">
                                <?= htmlspecialchars($_SESSION['role'] ?? 'Superadmin') ?>
                            </div>
                        </div>
                        <i class="fas fa-chevron-down"></i>
                    </button>
                    <div class="dropdown-menu" id="userDropdown">
                        <a href="../logout.php" class="danger"><i class="fas fa-sign-out-alt"></i> ອອກຈາກລະບົບ</a>
                    </div>
                </div>
            </div>
        </header>

        <!-- Page Content -->
        <div class="content">