<?php
if (session_status() === PHP_SESSION_NONE) {
    session_start();
}

include '../config/koneksi.php';

// Daftar role yang boleh akses folder kadiv
$allowed_roles = ['kadiv_ops', 'kadiv_cs', 'kadiv_kasir', 'kadiv_gudang','Human_capital','merchandiser','It','marcom','accounting','finance'];

if(!isset($_SESSION['role']) || !in_array($_SESSION['role'], $allowed_roles)){
    header('Location: ../login.php');
    exit;
}

// Label tampilan per role
$role_label = [
    'kadiv_ops'    => 'Kadiv Operasional',
    'kadiv_cs'     => 'Kadiv CS',
    'kadiv_kasir'  => 'Kadiv Kasir',
    'kadiv_gudang' => 'Kadiv Gudang',
    'Human_capital' => 'Human Capital',
    'marcom' => 'Marcom Harita',
    'merchandiser' => 'merchandiser',
    'It' => 'IT',
    'accounting' => 'ACCOUNTING',
    'finance' => 'FINANCE',
];

$label_role = $role_label[$_SESSION['role']] ?? 'Kadiv';
?>
<!DOCTYPE html>
<html lang="id">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title><?= isset($judul) ? htmlspecialchars($judul) : 'Kadiv Panel' ?></title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;600;700&family=Space+Mono:wght@400;700&display=swap" rel="stylesheet">
<style>
:root {
    --emerald-400: #34d399;
    --emerald-500: #10b981;
    --emerald-600: #059669;
    --emerald-700: #047857;
    --mint-glow:   rgba(16, 185, 129, 0.15);
    --mint-border: rgba(16, 185, 129, 0.3);
    --surface:     #0d1f18;
    --surface-1:   #142b22;
    --surface-2:   #1b3a2e;
    --surface-3:   #234a3b;
    --text-primary:   #f0fdf4;
    --text-secondary: #a7f3d0;
    --text-muted:     #6ee7b7;
    --sidebar-w: 240px;
    --topbar-h:  60px;
}
*, *::before, *::after { box-sizing: border-box; }
body {
    margin: 0; padding: 0;
    background: var(--surface) !important;
    color: var(--text-primary);
    font-family: 'DM Sans', sans-serif;
    overflow-x: hidden;
}
</style>
</head>
<body>
