<?php
/**
 * VENDOR LAYOUT HEADER
 * File: templates/layouts/vendor/header.php
 * Header and navigation for vendor panel
 */

if (!isset($active_menu)) $active_menu = '';
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title><?= $page_title ?? 'Vendor Panel' ?> - <?= APP_NAME ?></title>

    <!-- App favicon -->
    <link rel="shortcut icon" href="../assets/images/favicon.png">
    
    <!-- CSS -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    
    <style>
        :root {
            --sidebar-width: 250px;
            --topbar-height: 60px;
            --primary-color: #27ae60;
            --sidebar-bg: #1e272e;
        }
        
        body {
            background: #f8f9fa;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
        }
        
        .sidebar {
            position: fixed;
            left: 0;
            top: 0;
            width: var(--sidebar-width);
            height: 100vh;
            background: var(--sidebar-bg);
            color: white;
            overflow-y: auto;
            z-index: 1000;
            transition: all 0.3s;
        }
        
        .sidebar-header {
            padding: 20px;
            background: #151a1e;
            text-align: center;
            border-bottom: 1px solid #2d3436;
        }
        
        .sidebar-header h3 {
            margin: 0;
            color: white;
            font-size: 1.5rem;
        }
        
        .sidebar-header .badge {
            margin-top: 5px;
        }
        
        .sidebar-menu {
            list-style: none;
            padding: 20px 0;
            margin: 0;
        }
        
        .sidebar-menu li a {
            display: block;
            padding: 12px 20px;
            color: #ecf0f1;
            text-decoration: none;
            transition: all 0.3s;
        }
        
        .sidebar-menu li a:hover,
        .sidebar-menu li a.active {
            background: #2d3436;
            color: white;
            border-left: 4px solid var(--primary-color);
        }
        
        .sidebar-menu li a i {
            width: 20px;
            margin-right: 10px;
        }
        
        .main-wrapper {
            margin-left: var(--sidebar-width);
            min-height: 100vh;
        }
        
        .topbar {
            height: var(--topbar-height);
            background: white;
            border-bottom: 1px solid #dee2e6;
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 0 30px;
            position: sticky;
            top: 0;
            z-index: 999;
        }
        
        .main-content {
            padding: 30px;
        }
        
        .page-header {
            margin-bottom: 30px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            flex-wrap: wrap;
            gap: 15px;
        }
        
        .page-header h1 {
            font-size: 2rem;
            color: #2c3e50;
            margin: 0;
        }
        
        .stats-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
            gap: 20px;
            margin-bottom: 30px;
        }
        
        .stat-card {
            background: white;
            padding: 20px;
            border-radius: 10px;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
            display: flex;
            align-items: center;
            gap: 15px;
        }
        
        .stat-icon {
            width: 60px;
            height: 60px;
            border-radius: 10px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 1.5rem;
            color: white;
        }
        
        .stat-icon.bg-primary { background: #3498db; }
        .stat-icon.bg-success { background: #27ae60; }
        .stat-icon.bg-warning { background: #f39c12; }
        .stat-icon.bg-danger { background: #e74c3c; }
        .stat-icon.bg-info { background: #17a2b8; }
        
        .stat-details h3 {
            margin: 0;
            font-size: 1.8rem;
            color: #2c3e50;
        }
        
        .stat-details p {
            margin: 0;
            color: #7f8c8d;
            font-size: 0.9rem;
        }
        
        .card {
            border: none;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
            border-radius: 10px;
        }
        
        .card-header {
            background: white;
            border-bottom: 1px solid #dee2e6;
            padding: 15px 20px;
        }
        
        .btn-primary {
            background: var(--primary-color);
            border-color: var(--primary-color);
        }
        
        .btn-primary:hover {
            background: #229954;
            border-color: #229954;
        }
        
        @media (max-width: 768px) {
            .sidebar {
                transform: translateX(-100%);
            }
            
            .sidebar.active {
                transform: translateX(0);
            }
            
            .main-wrapper {
                margin-left: 0;
            }
        }
    </style>
</head>
<body>
    <!-- Sidebar -->
    <div class="sidebar">
        <div class="sidebar-header">
            <h3><i class="fas fa-store"></i> <?= APP_NAME ?></h3>
            <small>Vendor Panel</small>
        </div>
        
        <ul class="sidebar-menu">
            <li>
                <a href="index.php" class="<?= $active_menu === 'dashboard' ? 'active' : '' ?>">
                    <i class="fas fa-tachometer-alt"></i> Dashboard
                </a>
            </li>
            <li>
                <a href="profile.php" class="<?= $active_menu === 'profile' ? 'active' : '' ?>">
                    <i class="fas fa-user"></i> My Profile
                </a>
            </li>
            <li>
                <a href="items.php" class="<?= $active_menu === 'items' ? 'active' : '' ?>">
                    <i class="fas fa-box"></i> My Items
                </a>
            </li>
            <li>
                <a href="item-form.php" class="<?= $active_menu === 'add-item' ? 'active' : '' ?>">
                    <i class="fas fa-plus-circle"></i> Add New Item
                </a>
            </li>
            <li>
                <a href="orders.php" class="<?= $active_menu === 'orders' ? 'active' : '' ?>">
                    <i class="fas fa-shopping-bag"></i> Orders
                </a>
            </li>
            <li>
                <a href="disputes.php" class="<?= $active_menu === 'disputes' ? 'active' : '' ?>">
                    <i class="fas fa-exclamation-triangle"></i> Disputes
                </a>
            </li>
            <li>
                <a href="reviews.php" class="<?= $active_menu === 'reviews' ? 'active' : '' ?>">
                    <i class="fas fa-eye"></i> Reviews
                </a>
            </li>
            <li>
                <a href="wallet.php" class="<?= $active_menu === 'wallet' ? 'active' : '' ?>">
                    <i class="fas fa-wallet"></i> Wallet
                </a>
            </li>
            <li>
                <a href="transactions.php" class="<?= $active_menu === 'transactions' ? 'active' : '' ?>">
                    <i class="fas fa-exchange-alt"></i> Transactions
                </a>
            </li>
            <li>
                <a href="withdrawals.php" class="<?= $active_menu === 'withdrawals' ? 'active' : '' ?>">
                    <i class="fas fa-exchange-alt"></i> Withdrawals
                </a>
            </li>
            <li>
                <a href="calendar.php" class="<?= $active_menu === 'calendar' ? 'active' : '' ?>">
                    <i class="fas fa-calendar"></i> Calendar
                </a>
            </li>
            <li>
                <a href="../auth/logout.php" onclick="return confirm('Are you sure you want to logout?')">
                    <i class="fas fa-sign-out-alt"></i> Logout
                </a>
            </li>
        </ul>
    </div>
    
    <!-- Main Wrapper -->
    <div class="main-wrapper">
        <!-- Topbar -->
        <div class="topbar">
            <div>
                <button class="btn btn-link d-md-none" id="sidebarToggle">
                    <i class="fas fa-bars"></i>
                </button>
            </div>
            
            <div class="d-flex align-items-center gap-3">
                <span class="text-muted">
                    <i class="fas fa-store"></i> <?= esc(Auth::email()) ?>
                </span>
                <a href="../auth/logout.php" class="btn btn-sm btn-outline-danger" 
                   onclick="return confirm('Are you sure you want to logout?')">
                    <i class="fas fa-sign-out-alt"></i> Logout
                </a>
            </div>
        </div>
        
        <!-- Flash Messages -->
        <?php if ($flash = flash('success')): ?>
            <div class="alert alert-<?= $flash['type'] ?> alert-dismissible fade show m-3" role="alert">
                <?= $flash['message'] ?>
                <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
            </div>
        <?php endif; ?>
        
        <?php if ($flash = flash('error')): ?>
            <div class="alert alert-<?= $flash['type'] ?> alert-dismissible fade show m-3" role="alert">
                <?= $flash['message'] ?>
                <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
            </div>
        <?php endif; ?>