<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title><?= isset($page_title) ? $page_title . ' - ' : '' ?>Admin - Auriga Portal</title>
    <link rel="icon" type="image/png" href="<?= base_url('assets/images/auriga-logo.png') ?>">
    <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap" rel="stylesheet">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.0/font/bootstrap-icons.css">
    <link rel="stylesheet" href="https://cdn.datatables.net/1.13.6/css/dataTables.bootstrap5.min.css">
    <link rel="stylesheet" href="https://cdn.datatables.net/buttons/2.4.2/css/buttons.bootstrap5.min.css">
    <style>
        :root {
            --primary-blue: #3b82f6;
            --primary-blue-light: #60a5fa;
            --sidebar-width: 280px;
            --topbar-height: 70px;
            --bg-primary: #1e3a8a;
            --bg-secondary: #1e40af;
            --text-primary: #1e293b;
            --text-secondary: #64748b;
            --border-color: #e2e8f0;
            --success-color: #10b981;
            --warning-color: #f59e0b;
            --danger-color: #ef4444;
            --info-color: #06b6d4;
        }
        
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
            background: #f1f5f9;
            color: var(--text-primary);
            font-size: 15px;
        }
        
        /* Sidebar Styles */
        .sidebar {
            position: fixed;
            top: 0;
            left: 0;
            height: 100vh;
            width: var(--sidebar-width);
            background: linear-gradient(180deg, var(--primary-blue) 0%, var(--bg-primary) 100%);
            padding: 0;
            overflow-y: auto;
            overflow-x: hidden;
            z-index: 1000;
            box-shadow: 4px 0 24px rgba(0, 0, 0, 0.1);
        }

        .sidebar::-webkit-scrollbar {
            width: 6px;
        }

        .sidebar::-webkit-scrollbar-track {
            background: rgba(255, 255, 255, 0.05);
        }

        .sidebar::-webkit-scrollbar-thumb {
            background: rgba(255, 255, 255, 0.2);
            border-radius: 3px;
        }

        .sidebar::-webkit-scrollbar-thumb:hover {
            background: rgba(255, 255, 255, 0.3);
        }
        
        .sidebar-header {
            padding: 28px 24px 24px;
            background: rgba(0, 0, 0, 0.2);
            color: white;
            border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        }

        .sidebar-header .logo-container {
            display: flex;
            align-items: center;
            gap: 14px;
            margin-bottom: 8px;
        }

        .sidebar-header .logo-icon {
            width: 48px;
            height: 48px;
            background: rgba(255, 255, 255, 0.15);
            border-radius: 12px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 24px;
            backdrop-filter: blur(10px);
            border: 1px solid rgba(255, 255, 255, 0.2);
        }

        .sidebar-header h4 {
            font-size: 20px;
            font-weight: 700;
            margin: 0;
            letter-spacing: -0.5px;
        }

        .sidebar-header small {
            font-size: 13px;
            opacity: 0.8;
            font-weight: 500;
            letter-spacing: 0.5px;
        }
        
        .sidebar-menu {
            list-style: none;
            padding: 16px 12px;
            margin: 0;
        }
        
        .sidebar-menu li {
            margin-bottom: 4px;
        }

        .sidebar-menu li a {
            display: flex;
            align-items: center;
            padding: 14px 16px;
            color: rgba(255, 255, 255, 0.8);
            text-decoration: none;
            transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
            border-radius: 10px;
            font-size: 14.5px;
            font-weight: 500;
            position: relative;
            overflow: hidden;
        }

        .sidebar-menu li a::before {
            content: '';
            position: absolute;
            left: 0;
            top: 0;
            height: 100%;
            width: 3px;
            background: white;
            transform: scaleY(0);
            transition: transform 0.3s ease;
        }
        
        .sidebar-menu li a:hover {
            background: rgba(255, 255, 255, 0.12);
            color: white;
            transform: translateX(4px);
        }

        .sidebar-menu li a:hover::before {
            transform: scaleY(1);
        }
        
        .sidebar-menu li a.active {
            background: rgba(255, 255, 255, 0.15);
            color: white;
            font-weight: 600;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
        }

        .sidebar-menu li a.active::before {
            transform: scaleY(1);
        }
        
        .sidebar-menu li a i {
            margin-right: 14px;
            width: 22px;
            font-size: 18px;
            text-align: center;
        }
        
        /* Main Content */
        .main-content {
            margin-left: var(--sidebar-width);
            min-height: 100vh;
            background: #f1f5f9;
        }
        
        /* Top Navbar */
        .top-navbar {
            background: white;
            height: var(--topbar-height);
            padding: 0 32px;
            box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
            display: flex;
            align-items: center;
            justify-content: space-between;
            position: sticky;
            top: 0;
            z-index: 999;
            border-bottom: 1px solid var(--border-color);
        }

        .top-navbar h5 {
            font-size: 20px;
            font-weight: 700;
            color: var(--text-primary);
            margin: 0;
            letter-spacing: -0.5px;
        }

        .top-navbar .user-info {
            display: flex;
            align-items: center;
            gap: 16px;
        }

        .top-navbar .user-details {
            display: flex;
            align-items: center;
            gap: 12px;
            padding: 8px 16px;
            background: #f8fafc;
            border-radius: 12px;
            border: 1px solid var(--border-color);
        }

        .top-navbar .user-details i {
            font-size: 20px;
            color: var(--primary-blue);
        }

        .top-navbar .user-details .username {
            font-weight: 600;
            color: var(--text-primary);
            font-size: 14px;
        }

        .top-navbar .badge {
            padding: 6px 12px;
            font-weight: 700;
            font-size: 11px;
            letter-spacing: 0.5px;
            border-radius: 8px;
        }

        .top-navbar .badge.bg-success {
            background: linear-gradient(135deg, var(--success-color) 0%, #059669 100%) !important;
            box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
        }
        
        /* Content Area */
        .content-area {
            padding: 32px;
        }
        
        /* Stat Cards */
        .stat-card {
            background: white;
            border-radius: 16px;
            padding: 28px;
            box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
            margin-bottom: 24px;
            transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
            border: 1px solid var(--border-color);
            position: relative;
            overflow: hidden;
        }

        .stat-card::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 4px;
            background: linear-gradient(90deg, var(--primary-blue) 0%, var(--primary-blue-light) 100%);
        }
        
        .stat-card:hover {
            transform: translateY(-4px);
            box-shadow: 0 12px 24px rgba(0, 0, 0, 0.08);
            border-color: var(--primary-blue-light);
        }
        
        .stat-card .icon {
            font-size: 2.8rem;
            opacity: 0.15;
            position: absolute;
            right: 24px;
            top: 50%;
            transform: translateY(-50%);
        }

        .stat-card h3 {
            font-size: 32px;
            font-weight: 700;
            margin-bottom: 8px;
            color: var(--text-primary);
            letter-spacing: -1px;
        }

        .stat-card p {
            font-size: 14px;
            color: var(--text-secondary);
            margin: 0;
            font-weight: 500;
            letter-spacing: 0.3px;
        }
        
        .stat-card.primary::before {
            background: linear-gradient(90deg, var(--primary-blue) 0%, var(--primary-blue-light) 100%);
        }

        .stat-card.primary .icon {
            color: var(--primary-blue-light);
        }
        
        .stat-card.success::before {
            background: linear-gradient(90deg, var(--success-color) 0%, #059669 100%);
        }

        .stat-card.success .icon {
            color: var(--success-color);
        }
        
        .stat-card.warning::before {
            background: linear-gradient(90deg, var(--warning-color) 0%, #d97706 100%);
        }

        .stat-card.warning .icon {
            color: var(--warning-color);
        }
        
        .stat-card.danger::before {
            background: linear-gradient(90deg, var(--danger-color) 0%, #dc2626 100%);
        }

        .stat-card.danger .icon {
            color: var(--danger-color);
        }
        
        .stat-card.info::before {
            background: linear-gradient(90deg, var(--info-color) 0%, #0891b2 100%);
        }

        .stat-card.info .icon {
            color: var(--info-color);
        }
        
        /* Card Styles */
        .card {
            border: 1px solid var(--border-color);
            border-radius: 16px;
            box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
            overflow: hidden;
        }
        
        .card-header {
            background: linear-gradient(135deg, var(--primary-blue) 0%, var(--primary-blue-light) 100%);
            color: white;
            border: none;
            padding: 18px 24px;
            font-weight: 600;
            font-size: 16px;
            letter-spacing: 0.3px;
        }

        .card-header i {
            margin-right: 8px;
        }

        .card-body {
            padding: 24px;
        }
        
        /* Buttons */
        .btn {
            padding: 10px 20px;
            font-weight: 600;
            border-radius: 10px;
            font-size: 14px;
            letter-spacing: 0.3px;
            transition: all 0.3s ease;
        }

        .btn-primary {
            background: linear-gradient(135deg, var(--primary-blue) 0%, var(--primary-blue-light) 100%);
            border: none;
            box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
        }
        
        .btn-primary:hover {
            transform: translateY(-2px);
            box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
        }

        .btn-success {
            background: linear-gradient(135deg, var(--success-color) 0%, #059669 100%);
            border: none;
            box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
        }

        .btn-success:hover {
            transform: translateY(-2px);
            box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
        }

        .btn-danger {
            background: linear-gradient(135deg, var(--danger-color) 0%, #dc2626 100%);
            border: none;
            box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
        }

        .btn-danger:hover {
            transform: translateY(-2px);
            box-shadow: 0 6px 20px rgba(239, 68, 68, 0.4);
        }

        .btn-warning {
            background: linear-gradient(135deg, var(--warning-color) 0%, #d97706 100%);
            border: none;
            box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
            color: white;
        }

        .btn-warning:hover {
            transform: translateY(-2px);
            box-shadow: 0 6px 20px rgba(245, 158, 11, 0.4);
            color: white;
        }

        .btn-info {
            background: linear-gradient(135deg, var(--info-color) 0%, #0891b2 100%);
            border: none;
            box-shadow: 0 4px 12px rgba(6, 182, 212, 0.3);
        }

        .btn-info:hover {
            transform: translateY(-2px);
            box-shadow: 0 6px 20px rgba(6, 182, 212, 0.4);
        }
        
        /* Table Styles */
        .table-responsive {
            background: white;
            border-radius: 16px;
            padding: 24px;
            border: 1px solid var(--border-color);
            box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
        }

        .table {
            margin: 0;
        }

        .table thead th {
            background: #f8fafc;
            color: var(--text-primary);
            font-weight: 700;
            font-size: 13px;
            text-transform: uppercase;
            letter-spacing: 0.5px;
            border-bottom: 2px solid var(--border-color);
            padding: 16px;
        }

        .table tbody td {
            padding: 16px;
            vertical-align: middle;
            color: var(--text-primary);
            font-size: 14px;
        }

        .table tbody tr {
            border-bottom: 1px solid #f1f5f9;
            transition: background 0.2s ease;
        }

        .table tbody tr:hover {
            background: #f8fafc;
        }
        
        /* Badges */
        .badge {
            padding: 6px 12px;
            font-weight: 700;
            font-size: 11px;
            letter-spacing: 0.5px;
            border-radius: 8px;
        }

        .badge-status-active {
            background: linear-gradient(135deg, var(--success-color) 0%, #059669 100%);
            color: white;
        }
        
        .badge-status-paused {
            background: linear-gradient(135deg, var(--warning-color) 0%, #d97706 100%);
            color: white;
        }
        
        .badge-status-stopped {
            background: linear-gradient(135deg, var(--danger-color) 0%, #dc2626 100%);
            color: white;
        }
        
        .badge-status-completed {
            background: linear-gradient(135deg, #64748b 0%, #475569 100%);
            color: white;
        }
        
        /* Alerts */
        .alert {
            border: none;
            border-radius: 12px;
            padding: 16px 20px;
            font-weight: 500;
            font-size: 14px;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
            display: flex;
            align-items: center;
            gap: 12px;
        }

        .alert-success {
            background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
            color: #166534;
            border-left: 4px solid var(--success-color);
        }

        .alert-danger {
            background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
            color: #991b1b;
            border-left: 4px solid var(--danger-color);
        }

        .alert-warning {
            background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
            color: #92400e;
            border-left: 4px solid var(--warning-color);
        }

        .alert-info {
            background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
            color: #075985;
            border-left: 4px solid var(--info-color);
        }
        
        /* Page Title */
        .page-title {
            margin-bottom: 28px;
        }
        
        .page-title h2 {
            font-weight: 700;
            color: var(--text-primary);
            font-size: 28px;
            letter-spacing: -0.8px;
            margin-bottom: 8px;
        }

        .page-title p {
            color: var(--text-secondary);
            font-size: 15px;
            margin: 0;
        }

        /* Form Controls */
        .form-control,
        .form-select {
            border: 2px solid var(--border-color);
            border-radius: 10px;
            padding: 10px 16px;
            font-size: 14px;
            transition: all 0.3s ease;
            background: #f8fafc;
        }

        .form-control:focus,
        .form-select:focus {
            border-color: var(--primary-blue-light);
            box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
            background: white;
        }

        .form-label {
            font-weight: 600;
            color: var(--text-primary);
            font-size: 14px;
            margin-bottom: 8px;
        }

        /* Mobile Menu Toggle */
        .mobile-menu-toggle {
            display: none;
            position: fixed;
            bottom: 24px;
            right: 24px;
            width: 56px;
            height: 56px;
            background: linear-gradient(135deg, var(--primary-blue) 0%, var(--primary-blue-light) 100%);
            border-radius: 50%;
            border: none;
            color: white;
            font-size: 24px;
            box-shadow: 0 8px 24px rgba(59, 130, 246, 0.4);
            z-index: 1001;
            cursor: pointer;
            transition: all 0.3s ease;
        }

        .mobile-menu-toggle:hover {
            transform: scale(1.1);
            box-shadow: 0 12px 32px rgba(59, 130, 246, 0.5);
        }

        .mobile-menu-toggle i {
            transition: transform 0.3s ease;
        }

        .mobile-menu-toggle.active i {
            transform: rotate(90deg);
        }

        .mobile-overlay {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(0, 0, 0, 0.5);
            z-index: 999;
            opacity: 0;
            transition: opacity 0.3s ease;
        }

        .mobile-overlay.active {
            opacity: 1;
        }

        /* Responsive */
        @media (max-width: 1200px) {
            .content-area {
                padding: 24px;
            }

            .stat-card {
                padding: 24px;
            }

            .stat-card h3 {
                font-size: 28px;
            }
        }

        @media (max-width: 992px) {
            :root {
                --sidebar-width: 260px;
            }

            .content-area {
                padding: 20px;
            }

            .top-navbar h5 {
                font-size: 18px;
            }

            .stat-card {
                padding: 20px;
            }

            .stat-card h3 {
                font-size: 26px;
            }

            .table-responsive {
                padding: 20px;
            }
        }

        @media (max-width: 768px) {
            .sidebar {
                transform: translateX(-100%);
                transition: transform 0.3s ease;
            }

            .sidebar.mobile-active {
                transform: translateX(0);
            }

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

            .mobile-menu-toggle,
            .mobile-overlay {
                display: block;
            }

            .top-navbar {
                padding: 0 20px;
                height: 60px;
            }

            .top-navbar h5 {
                font-size: 16px;
            }

            .top-navbar .user-info {
                gap: 8px;
            }

            .top-navbar .user-details {
                padding: 6px 12px;
            }

            .top-navbar .user-details .username {
                display: none;
            }

            .top-navbar .badge {
                padding: 4px 8px;
                font-size: 10px;
            }

            .content-area {
                padding: 16px;
            }

            .page-title h2 {
                font-size: 22px;
            }

            .stat-card {
                padding: 20px;
                margin-bottom: 16px;
            }

            .stat-card h3 {
                font-size: 24px;
            }

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

            .stat-card .icon {
                font-size: 2rem;
                right: 16px;
            }

            .card-header {
                padding: 14px 16px;
                font-size: 15px;
            }

            .card-body {
                padding: 16px;
            }

            .table-responsive {
                padding: 16px;
                overflow-x: auto;
            }

            .table {
                font-size: 13px;
            }

            .table thead th {
                padding: 12px 8px;
                font-size: 11px;
            }

            .table tbody td {
                padding: 12px 8px;
                font-size: 13px;
            }

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

            .form-control,
            .form-select {
                font-size: 14px;
                padding: 10px 14px;
            }

            .alert {
                padding: 12px 16px;
                font-size: 13px;
            }
        }

        @media (max-width: 576px) {
            .top-navbar {
                padding: 0 16px;
            }

            .top-navbar h5 {
                font-size: 15px;
            }

            .top-navbar .user-details {
                padding: 6px 10px;
            }

            .top-navbar .user-details i {
                font-size: 18px;
            }

            .content-area {
                padding: 12px;
            }

            .page-title {
                margin-bottom: 20px;
            }

            .page-title h2 {
                font-size: 20px;
            }

            .stat-card {
                padding: 16px;
            }

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

            .stat-card .icon {
                font-size: 1.8rem;
            }

            .card-header {
                padding: 12px 14px;
                font-size: 14px;
            }

            .card-body {
                padding: 14px;
            }

            .table-responsive {
                padding: 12px;
            }

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

            .mobile-menu-toggle {
                width: 52px;
                height: 52px;
                bottom: 20px;
                right: 20px;
                font-size: 22px;
            }

            .sidebar-header {
                padding: 20px 18px 18px;
            }

            .sidebar-header .logo-icon {
                width: 42px;
                height: 42px;
                font-size: 20px;
            }

            .sidebar-header h4 {
                font-size: 18px;
            }

            .sidebar-menu li a {
                padding: 12px 14px;
                font-size: 14px;
            }
        }

        @media (max-width: 400px) {
            .content-area {
                padding: 10px;
            }

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

            .stat-card p {
                font-size: 12px;
            }

            .table {
                font-size: 12px;
            }

            .mobile-menu-toggle {
                width: 48px;
                height: 48px;
                font-size: 20px;
            }
        }

        /* Landscape Mobile */
        @media (max-width: 768px) and (orientation: landscape) {
            .sidebar {
                width: 240px;
            }

            .sidebar-header {
                padding: 16px;
            }

            .sidebar-menu li a {
                padding: 10px 12px;
            }
        }

        /* Tablet Portrait */
        @media (min-width: 768px) and (max-width: 992px) {
            .row > [class*='col-'] {
                margin-bottom: 16px;
            }
        }

        /* Print Styles */
        @media print {
            .sidebar,
            .top-navbar,
            .mobile-menu-toggle,
            .btn,
            .alert {
                display: none !important;
            }

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

            .content-area {
                padding: 0;
            }

            .stat-card,
            .card {
                box-shadow: none;
                border: 1px solid #ddd;
                page-break-inside: avoid;
            }
        }
    </style>
</head>
<body>
    <div class="sidebar">
        <div class="sidebar-header">
            <div class="logo-container">
                <div class="logo-icon">
                    <img src="<?= base_url('assets/images/auriga-logo.png') ?>" alt="Auriga" style="width: 32px; height: 32px; object-fit: contain;">
                </div>
                <div>
                    <h4>Auriga Portal</h4>
                    <small>Admin Panel</small>
                </div>
            </div>
        </div>
        <ul class="sidebar-menu">
            <li><a href="<?= base_url('admin/dashboard') ?>" class="<?= $this->uri->segment(2) == 'dashboard' ? 'active' : '' ?>">
                <i class="bi bi-speedometer2"></i> Dashboard
            </a></li>
            <li><a href="<?= base_url('admin/users') ?>" class="<?= $this->uri->segment(2) == 'users' ? 'active' : '' ?>">
                <i class="bi bi-people"></i> User Management
            </a></li>
            <li><a href="<?= base_url('admin/campaigns') ?>" class="<?= $this->uri->segment(2) == 'campaigns' || $this->uri->segment(2) == 'campaign_view' || $this->uri->segment(2) == 'campaign_create' ? 'active' : '' ?>">
                <i class="bi bi-megaphone"></i> Campaigns
            </a></li>
            <li><a href="<?= base_url('admin/message-schedules') ?>" class="<?= in_array($this->uri->segment(2), ['message-schedules', 'message_schedules']) ? 'active' : '' ?>">
                <i class="bi bi-envelope-paper"></i> Message Scheduler
            </a></li>
            <li><a href="<?= base_url('admin/master_data') ?>" class="<?= $this->uri->segment(2) == 'master_data' ? 'active' : '' ?>">
                <i class="bi bi-database"></i> Master Data
            </a></li>
            <li><a href="<?= base_url('admin/reports') ?>" class="<?= $this->uri->segment(2) == 'reports' ? 'active' : '' ?>">
                <i class="bi bi-bar-chart"></i> Reports
            </a></li>
            <li><a href="<?= base_url('admin/login_logs') ?>" class="<?= $this->uri->segment(2) == 'login_logs' ? 'active' : '' ?>">
                <i class="bi bi-shield-lock"></i> Login Logs
            </a></li>
            <li><a href="<?= base_url('admin/activity_logs') ?>" class="<?= $this->uri->segment(2) == 'activity_logs' ? 'active' : '' ?>">
                <i class="bi bi-list-check"></i> Activity Logs
            </a></li>
            <li><a href="<?= base_url('admin/profile') ?>" class="<?= $this->uri->segment(2) == 'profile' ? 'active' : '' ?>">
                <i class="bi bi-person-circle"></i> My Profile
            </a></li>
            <li><a href="<?= base_url('logout') ?>">
                <i class="bi bi-box-arrow-right"></i> Logout
            </a></li>
        </ul>
    </div>
    
    <div class="main-content">
        <div class="top-navbar">
            <h5><?= isset($page_title) ? $page_title : 'Admin Dashboard' ?></h5>
            <div class="user-info">
                <div class="user-details">
                    <i class="bi bi-person-circle"></i>
                    <span class="username"><?= current_username() ?></span>
                </div>
                <span class="badge bg-success">ADMIN</span>
            </div>
        </div>
        
        <div class="content-area">
            <?php if (get_flash('success')): ?>
                <div class="alert alert-success alert-dismissible fade show">
                    <i class="bi bi-check-circle-fill"></i>
                    <span><?= get_flash('success') ?></span>
                    <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
                </div>
            <?php endif; ?>
            
            <?php if (get_flash('error')): ?>
                <div class="alert alert-danger alert-dismissible fade show">
                    <i class="bi bi-exclamation-triangle-fill"></i>
                    <span><?= get_flash('error') ?></span>
                    <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
                </div>
            <?php endif; ?>

    <!-- Mobile Menu Toggle -->
    <button class="mobile-menu-toggle" id="mobileMenuToggle" onclick="toggleMobileMenu()">
        <i class="bi bi-list"></i>
    </button>
    <div class="mobile-overlay" id="mobileOverlay" onclick="toggleMobileMenu()"></div>

    <script>
        function toggleMobileMenu() {
            const sidebar = document.querySelector('.sidebar');
            const overlay = document.getElementById('mobileOverlay');
            const toggle = document.getElementById('mobileMenuToggle');
            
            sidebar.classList.toggle('mobile-active');
            overlay.classList.toggle('active');
            toggle.classList.toggle('active');
            
            // Update icon
            const icon = toggle.querySelector('i');
            if (sidebar.classList.contains('mobile-active')) {
                icon.className = 'bi bi-x';
            } else {
                icon.className = 'bi bi-list';
            }
        }

        // Close menu when clicking on a menu item (mobile)
        if (window.innerWidth <= 768) {
            document.querySelectorAll('.sidebar-menu a').forEach(link => {
                link.addEventListener('click', () => {
                    if (window.innerWidth <= 768) {
                        toggleMobileMenu();
                    }
                });
            });
        }

        // Handle window resize
        window.addEventListener('resize', () => {
            const sidebar = document.querySelector('.sidebar');
            const overlay = document.getElementById('mobileOverlay');
            const toggle = document.getElementById('mobileMenuToggle');
            
            if (window.innerWidth > 768) {
                sidebar.classList.remove('mobile-active');
                overlay.classList.remove('active');
                toggle.classList.remove('active');
                toggle.querySelector('i').className = 'bi bi-list';
            }
        });
    </script>
