<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title><?= $title ?? 'Employee Dashboard' ?> | Saanvi Infratech</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.1/font/bootstrap-icons.css">
    <link rel="stylesheet" href="<?= base_url('assets/css/style.css') ?>">
    <style>
        :root {
            --primary: #e52d27;
            --secondary: #b31217;
            --bg-body: #f8f9fa;
            --bg-card: #ffffff;
            --text-main: #2d3436;
            --text-muted: #636e72;
            --border: #dfe6e9;
        }

        body {
            background-color: var(--bg-body);
            color: var(--text-main);
            font-family: 'Inter', sans-serif;
            margin: 0;
            padding: 0;
        }

        .employee-layout {
            display: flex;
            min-height: 100vh;
        }

        .sidebar {
            width: 280px;
            background: #1e1e2d;
            color: #fff;
            padding: 30px 20px;
            display: flex;
            flex-direction: column;
            gap: 40px;
            position: fixed;
            height: 100vh;
            z-index: 1000;
        }

        .logo {
            font-size: 1.6rem;
            font-weight: 800;
            color: #fff;
            text-decoration: none;
            display: flex;
            align-items: center;
            gap: 12px;
            padding-left: 10px;
        }

        .logo i {
            color: var(--primary);
        }

        .menu {
            display: flex;
            flex-direction: column;
            gap: 8px;
        }

        .menu-item {
            display: flex;
            align-items: center;
            gap: 15px;
            padding: 12px 20px;
            text-decoration: none;
            color: #a2a3b7;
            border-radius: 12px;
            transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
            font-weight: 500;
        }

        .menu-item i {
            font-size: 1.2rem;
        }

        .menu-item:hover, .menu-item.active {
            color: #fff;
            background: rgba(255, 255, 255, 0.05);
        }

        .menu-item.active {
            background: var(--primary);
            box-shadow: 0 4px 15px rgba(229, 45, 39, 0.3);
        }

        .main-content {
            flex: 1;
            margin-left: 280px;
            padding: 0;
            background: #f5f7f9;
        }

        .header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 20px 40px;
            background: #fff;
            box-shadow: 0 2px 15px rgba(0,0,0,0.03);
            position: sticky;
            top: 0;
            z-index: 900;
        }

        .page-content {
            padding: 40px;
        }

        .user-profile {
            display: flex;
            align-items: center;
            gap: 12px;
            cursor: pointer;
            padding: 5px 15px;
            border-radius: 12px;
            transition: background 0.3s;
        }

        .user-profile:hover {
            background: #f8f9fa;
        }

        .user-avatar {
            width: 40px;
            height: 40px;
            border-radius: 10px;
            object-fit: cover;
            border: 2px solid #fff;
            box-shadow: 0 2px 8px rgba(0,0,0,0.1);
        }

        .card {
            background: #fff;
            border-radius: 20px;
            padding: 30px;
            border: none;
            box-shadow: 0 10px 30px rgba(0,0,0,0.04);
            transition: transform 0.3s;
        }

        .btn-logout {
            margin-top: auto;
            color: #ff5e5e;
            text-decoration: none;
            display: flex;
            align-items: center;
            gap: 15px;
            padding: 15px 20px;
            font-weight: 600;
            border-radius: 12px;
            transition: background 0.3s;
        }

        .btn-logout:hover {
            background: rgba(255, 94, 94, 0.1);
        }

        .mobile-toggle {
            display: none;
            font-size: 1.8rem;
            color: var(--text-main);
            background: none;
            border: none;
            cursor: pointer;
        }

        @media (max-width: 992px) {
            .employee-layout {
                flex-direction: column;
            }

            .sidebar {
                position: fixed;
                left: -280px;
                top: 0;
                bottom: 0;
                width: 280px;
                z-index: 2000;
                transition: left 0.3s;
                box-shadow: 10px 0 30px rgba(0,0,0,0.1);
            }

            .sidebar.active {
                left: 0;
            }

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

            .header {
                padding: 15px 20px;
            }

            .page-content {
                padding: 20px;
            }

            .mobile-toggle {
                display: block;
            }

            .user-profile span {
                display: none;
            }
        }

        @media (max-width: 576px) {
            .header {
                padding: 10px 15px;
            }
            .header h1 {
                font-size: 1.1rem !important;
            }
            .user-avatar {
                width: 32px;
                height: 32px;
            }
            .page-content {
                padding: 15px;
            }
        }
    </style>
</head>
<body>
    <div class="employee-layout">
        <aside class="sidebar">
            <a href="<?= base_url('employee') ?>" class="logo">
                <?php 
                    $logo_url = $settings['site_logo'] ?? 'assets/images/logo.png';
                    if (strpos($logo_url, 'http') === false) {
                        $logo_url = base_url($logo_url);
                    }
                ?>
                <img src="<?= $logo_url ?>" style="height: 35px; width: auto; border-radius: 4px;">
                SAANVI
            </a>

            <nav class="menu">
                <a href="<?= base_url('employee') ?>" class="menu-item <?= (current_url() == base_url('employee')) ? 'active' : '' ?>">
                    <i class="bi bi-grid-1x2-fill"></i> My Dashboard
                </a>
                <a href="<?= base_url('employee/my_expenses') ?>" class="menu-item <?= (strpos(current_url(), 'expenses') !== false) ? 'active' : '' ?>">
                    <i class="bi bi-receipt"></i> My Expenses
                </a>
                <a href="<?= base_url('employee/my_attendance') ?>" class="menu-item <?= (strpos(current_url(), 'attendance') !== false) ? 'active' : '' ?>">
                    <i class="bi bi-calendar-check"></i> My Attendance
                </a>
                <a href="<?= base_url('employee/my_projects') ?>" class="menu-item <?= (strpos(current_url(), 'projects') !== false) ? 'active' : '' ?>">
                    <i class="bi bi-kanban"></i> My Projects
                </a>
                <a href="<?= base_url('employee/profile') ?>" class="menu-item <?= (strpos(current_url(), 'profile') !== false) ? 'active' : '' ?>">
                    <i class="bi bi-person-circle"></i> My Profile
                </a>
                <a href="<?= base_url('employee/settings') ?>" class="menu-item <?= (strpos(current_url(), 'settings') !== false) ? 'active' : '' ?>">
                    <i class="bi bi-gear-fill"></i> Settings
                </a>
            </nav>

            <a href="<?= base_url('logout') ?>" class="btn-logout">
                <i class="bi bi-box-arrow-left"></i> Logout
            </a>
        </aside>

        <main class="main-content">
            <header class="header">
                <div style="display: flex; align-items: center; gap: 20px;">
                    <button class="mobile-toggle" onclick="document.querySelector('.sidebar').classList.toggle('active')">
                        <i class="bi bi-list"></i>
                    </button>
                    <div style="display: flex; align-items: center; gap: 15px;">
                        <h1 style="margin: 0; font-size: 1.4rem; font-weight: 800; color: var(--text-main);"><?= $title ?></h1>
                    </div>
                </div>
                <div class="user-profile">
                    <?php 
                        $user_pic = session()->get('profile_pic') ?? '';
                        if ($user_pic) {
                            if (strpos($user_pic, 'http') === false) {
                                $user_pic = base_url($user_pic);
                            }
                        } else {
                            $user_pic = base_url('assets/images/placeholder-user.jpg');
                        }
                    ?>
                    <img src="<?= $user_pic ?>" class="user-avatar">
                    <div style="display: flex; flex-direction: column;">
                        <span style="font-weight: 700; font-size: 0.9rem; line-height: 1.2;"><?= session()->get('name') ?></span>
                        <span style="font-size: 0.7rem; color: var(--text-muted);">Employee</span>
                    </div>
                </div>
            </header>

            <div class="page-content">
                <?= $this->renderSection('content') ?>
            </div>
        </main>
    </div>
</body>
</html>
