<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <base href="<?php echo base_url(); ?>" />
    <title><?php echo $this->config->item('company') . ' -- Powered by WAK Software Ltd.' ?></title>
    <link rel="stylesheet" href="<?php echo base_url(); ?>css/phppos.css" />
    <link rel="stylesheet" href="<?php echo base_url(); ?>css/phppos_print.css" media="print" />
    <link rel="shortcut icon" type="image/x-icon" href="<?php echo base_url(); ?>favicon.ico?v=2">
    <script src="<?php echo base_url(); ?>js/jquery-1.2.6.min.js" type="text/javascript"></script>
    <script src="<?php echo base_url(); ?>js/jquery.color.js" type="text/javascript"></script>
    <script src="<?php echo base_url(); ?>js/jquery.metadata.js" type="text/javascript"></script>
    <script src="<?php echo base_url(); ?>js/jquery.form.js" type="text/javascript"></script>
    <script src="<?php echo base_url(); ?>js/jquery.tablesorter.min.js" type="text/javascript"></script>
    <script src="<?php echo base_url(); ?>js/jquery.ajax_queue.js" type="text/javascript"></script>
    <script src="<?php echo base_url(); ?>js/jquery.bgiframe.min.js" type="text/javascript"></script>
    <script src="<?php echo base_url(); ?>js/jquery.autocomplete.js" type="text/javascript"></script>
    <script src="<?php echo base_url(); ?>js/jquery.validate.min.js" type="text/javascript"></script>
    <script src="<?php echo base_url(); ?>js/thickbox.js" type="text/javascript"></script>
    <script type="text/javascript">
        function resizeTB() {
            setTimeout(function() {
                var tbWindow = $('#TB_window');
                if (tbWindow.length) {
                    var windowHeight = $(window).height();
                    var newHeight = Math.round(windowHeight * 0.92);
                    tbWindow.css('height', newHeight + 'px');
                    $('#TB_ajaxContent').css({
                        'height': (newHeight - 60) + 'px',
                        'overflow-y': 'auto'
                    });
                }
            }, 300);
        }

        $(document).ready(function() {
            $('a.thickbox').click(function() {
                resizeTB();
            });
        });
    </script>
    <script src="<?php echo base_url(); ?>js/common.js" type="text/javascript"></script>
    <script src="<?php echo base_url(); ?>js/manage_tables.js" type="text/javascript"></script>
    <script src="<?php echo base_url(); ?>js/swfobject.js" type="text/javascript"></script>
    <style>
        * {
            box-sizing: border-box;
        }

        html {
            overflow: auto;
            height: 100%;
            margin: 0;
            padding: 0;
        }

        html {
            height: 100%;
        }

        #top_header {
            background: linear-gradient(135deg, #1a1a2e 0%, #16213e 60%, #0f3460 100%);
            padding: 0;
            box-shadow: 0 2px 15px rgba(0, 0, 0, 0.4);
            position: sticky;
            top: 0;
            z-index: 1000;
        }

        #header_main {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 10px 24px;
            border-bottom: 1px solid rgba(255, 255, 255, 0.08);
        }

        #company_info {
            display: flex;
            align-items: center;
            gap: 12px;
        }

        #company_logo_icon {
            width: 80px;
            height: 45px;
            background: none;
            border-radius: 0;
            display: flex;
            align-items: center;
            justify-content: center;
            flex-shrink: 0;
            box-shadow: none;
        }

        #company_text .company_name {
            color: #ffffff;
            font-size: 20px;
            font-weight: 700;
            letter-spacing: 0.3px;
            font-family: 'Segoe UI', Arial, sans-serif;
        }

        #company_text .company_sub {
            color: rgba(255, 255, 255, 0.45);
            font-size: 13px;
            font-family: 'Segoe UI', Arial, sans-serif;
            margin-top: 1px;
        }

        #header_right {
            display: flex;
            align-items: center;
            gap: 20px;
        }

        #user_info_bar {
            display: flex;
            align-items: center;
            gap: 10px;
            background: rgba(255, 255, 255, 0.06);
            border: 1px solid rgba(255, 255, 255, 0.1);
            border-radius: 20px;
            padding: 6px 14px;
        }

        #user_info_bar .user_name {
            color: rgba(255, 255, 255, 0.8);
            font-size: 16px;
            font-family: 'Segoe UI', Arial, sans-serif;
        }

        #user_info_bar .logout_link a {
            color: #f47f20;
            font-size: 12px;
            text-decoration: none;
            font-weight: 600;
            transition: color 0.2s;
        }

        #user_info_bar .logout_link a:hover {
            color: #ff9f40;
        }

        #date_display {
            color: rgba(255, 255, 255, 0.5);
            font-size: 15px;
            font-family: 'Segoe UI', Arial, sans-serif;
            white-space: nowrap;
        }

        #nav_bar {
            background: rgba(0, 0, 0, 0.2);
            padding: 0 16px;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 4px;
            overflow-x: auto;
            scrollbar-width: none;
        }

        #nav_bar::-webkit-scrollbar {
            display: none;
        }

        .nav_item {
            display: flex;
            flex-direction: column;
            align-items: center;
            padding: 8px 14px;
            border-radius: 8px;
            text-decoration: none;
            transition: all 0.2s ease;
            min-width: 64px;
            cursor: pointer;
        }

        .nav_item:hover {
            background: rgba(244, 127, 32, 0.2);
            text-decoration: none;
        }

        .nav_item.active {
            background: rgba(244, 127, 32, 0.25);
            border-bottom: 2px solid #f47f20;
        }

        .nav_item img {
            width: 42px;
            height: 42px;
            margin-bottom: 4px;
        }

        .nav_item span {
            color: rgba(255, 255, 255, 0.75);
            font-size: 14px;
            font-family: 'Segoe UI', Arial, sans-serif;
            white-space: nowrap;
            font-weight: 500;
        }

        .nav_item:hover span {
            color: #f47f20;
        }

        #content_area_wrapper {
            padding: 0;
        }

        #content_area {
            padding: 0;
        }

        /* Override phppos.css width restrictions */
        body {
            margin: 0 !important;
            padding: 0 !important;
            width: 100% !important;
            min-height: 100vh !important;
            display: flex !important;
            flex-direction: column !important;
        }

        #content_area_wrapper,
        #content_area {
            width: 100% !important;
            max-width: 100% !important;
            padding: 0 !important;
            margin: 0 !important;
            box-sizing: border-box !important;
            flex: 1 !important;
            display: flex !important;
            flex-direction: column !important;
        }

        #menubar_container,
        #menubar {
            display: none !important;
        }

        /* Global font override */
        body,
        input,
        select,
        textarea,
        button,
        table,
        td,
        th,
        div,
        span,
        a,
        label {
            font-family: 'Segoe UI', Arial, sans-serif !important;
        }

        /* Improve table text */
        #register tbody td {
            font-size: 14px !important;
            color: #333 !important;
        }

        #register thead th {
            font-size: 13px !important;
            font-weight: 600 !important;
            letter-spacing: 0.3px !important;
        }

        /* Improve inputs */
        input[type=text],
        input[type=password],
        select,
        textarea {
            font-family: 'Segoe UI', Arial, sans-serif !important;
            font-size: 14px !important;
            color: #333 !important;
        }

        /* Page title */
        #page_title {
            font-family: 'Segoe UI', Arial, sans-serif !important;
            font-size: 24px !important;
            font-weight: 700 !important;
            color: #1a1a2e !important;
            text-align: center !important;
            padding: 16px 0 8px !important;
        }

        /* Labels */
        label {
            font-size: 13px !important;
            color: #555 !important;
            font-weight: 500 !important;
        }

        #page_content {
            max-width: 1300px;
            margin: 0 auto;
            padding: 16px 24px 0;
            width: 100%;
            box-sizing: border-box;
        }

        /* Thickbox popup offset fix */
        #TB_overlay {
            position: fixed !important;
            top: 0 !important;
            left: 0 !important;
            width: 100% !important;
            height: 100% !important;
            z-index: 999 !important;
        }

        #TB_window {
            position: fixed !important;
            top: 50% !important;
            left: 50% !important;
            transform: translate(-50%, -50%) !important;
            margin: 0 !important;
            max-height: 80vh !important;
            height: 80vh !important;
            overflow-y: auto !important;
            z-index: 1000 !important;
        }

        #TB_title {
            position: sticky !important;
            top: 0 !important;
            z-index: 9999 !important;
            background: #f47f20 !important;
            color: #ffffff !important;
            padding: 16px 20px !important;
            border-radius: 0 !important;
            min-height: 60px !important;
            display: flex !important;
            align-items: center !important;
            position: relative !important;
        }

        #TB_title * {
            color: #ffffff !important;
        }

        #TB_ajaxWindowTitle {
            color: #ffffff !important;
            font-family: 'Segoe UI', Arial, sans-serif !important;
            font-size: 15px !important;
            font-weight: 700 !important;
            letter-spacing: 0.3px !important;
        }

        #TB_closeWindowButton {
            position: absolute !important;
            right: 12px !important;
            top: 50% !important;
            transform: translateY(-50%) !important;
            background: rgba(255, 255, 255, 0.25) !important;
            color: #ffffff !important;
            font-weight: 700 !important;
            font-size: 14px !important;
            width: 30px !important;
            height: 30px !important;
            border-radius: 50% !important;
            display: flex !important;
            align-items: center !important;
            justify-content: center !important;
            text-decoration: none !important;
            transition: all 0.2s !important;
            border: 2px solid rgba(255, 255, 255, 0.4) !important;
        }

        #TB_closeWindowButton:hover {
            background: rgba(255, 255, 255, 0.4) !important;
            border-color: white !important;
            transform: translateY(-50%) scale(1.1) !important;
        }

        #TB_ajaxContent {
            padding: 0 !important;
        }

        /* ── Responsive Header ── */
        @media (max-width: 768px) {

            #header_main {
                padding: 8px 12px;
                flex-wrap: wrap;
                gap: 8px;
            }

            #company_logo_icon img {
                width: 55px;
                height: 31px;
            }

            #company_text .company_name {
                font-size: 14px;
            }

            #company_text .company_sub {
                font-size: 10px;
            }

            #header_right {
                gap: 8px;
            }

            #user_info_bar {
                padding: 4px 10px;
            }

            #user_info_bar .user_name {
                font-size: 12px;
            }

            #date_display {
                font-size: 11px;
            }

            #nav_bar {
                padding: 0 8px;
                justify-content: flex-start;
                gap: 2px;
            }

            .nav_item {
                padding: 6px 8px;
                min-width: 50px;
            }

            .nav_item img {
                width: 28px;
                height: 28px;
            }

            .nav_item span {
                font-size: 10px;
            }
        }

        @media (max-width: 480px) {

            #header_main {
                padding: 6px 10px;
            }

            #company_logo_icon img {
                width: 45px;
                height: 25px;
            }

            #company_text .company_name {
                font-size: 12px;
            }

            #company_text .company_sub {
                display: none;
            }

            #date_display {
                display: none;
            }

            #user_info_bar .user_name {
                font-size: 11px;
            }

            #user_info_bar .logout_link a {
                font-size: 11px;
            }

            .nav_item {
                padding: 5px 6px;
                min-width: 44px;
            }

            .nav_item img {
                width: 24px;
                height: 24px;
            }

            .nav_item span {
                font-size: 9px;
            }
        }

        /* Thickbox mobile fix */
        @media (max-width: 768px) {
            #TB_window {
                width: 95% !important;
                left: 2.5% !important;
                transform: translateY(-50%) !important;
                margin: 0 !important;
            }

            #TB_ajaxContent {
                width: 100% !important;
                box-sizing: border-box !important;
            }
        }
    </style>
</head>

<body>

    <div id="top_header">
        <!-- Main header bar -->
        <div id="header_main">
            <div id="company_info">
                <div id="company_logo_icon">
                    <img src="<?php echo base_url(); ?>images/menubar/logo.png" alt="Logo" style="width:80px;height:45px;object-fit:contain;">
                </div>
                <div id="company_text">
                    <div class="company_name"><?php echo $this->config->item('company'); ?></div>
                    <div class="company_sub">Powered by WAK Software Ltd. | Hotline: 0595637362</div>
                </div>
            </div>
            <div id="header_right">
                <div id="user_info_bar">
                    <span class="user_name">👤 <?php echo $user_info->first_name . ' ' . $user_info->last_name; ?></span>
                    <span style="color:rgba(255,255,255,0.2);">|</span>
                    <span class="logout_link"><?php echo anchor("home/logout", "Logout"); ?></span>
                </div>
                <div id="date_display">
                    📅 <?php echo date('M d, Y h:i a'); ?>
                </div>
            </div>
        </div>

        <!-- Navigation bar -->
        <div id="nav_bar">
            <?php
            $current = $this->uri->segment(1);
            ?>
            <a href="<?php echo site_url('home'); ?>" class="nav_item <?php echo ($current == 'home' ? 'active' : ''); ?>">
                <img src="<?php echo base_url() . 'images/menubar/home.png'; ?>" alt="Home" />
                <span><?php echo $this->lang->line('module_home'); ?></span>
            </a>

            <?php foreach ($allowed_modules->result() as $module): ?>
                <a href="<?php echo site_url($module->module_id); ?>" class="nav_item <?php echo ($current == $module->module_id ? 'active' : ''); ?>">
                    <img src="<?php echo base_url() . 'images/menubar/' . $module->module_id . '.png'; ?>" alt="<?php echo $module->module_id; ?>" />
                    <span><?php echo $this->lang->line('module_' . $module->module_id); ?></span>
                </a>
            <?php endforeach; ?>
        </div>
    </div>

    <div id="content_area_wrapper">
        <div id="content_area">
            <div id="page_content">