<?php
require_once __DIR__ . '/auth_check.php';
require_once __DIR__ . '/../config/db.php';
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>MARTLUX | Administrative Panel</title>
    <!-- Bootstrap 5 CSS -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <!-- Font Awesome -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <!-- Fonts -->
    <link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@300;400;500;600;700&family=Playfair+Display:ital,wght@0,400;0,600;0,700;1,400&display=swap" rel="stylesheet">
    <style>
        :root {
            --bg-black: #0A111E;
            --bg-dark: #131C2D;
            --bg-card: #2A1E14;
            --border-gray: #202D3F;
            --accent-gold: #866a42;
            --accent-gold-rgb: 134, 106, 66;
            --text-white: #FFFFFF;
            --text-gray: #4a779e;
            --font-heading: 'Playfair Display', serif;
            --font-body: 'Montserrat', sans-serif;
        }

        body {
            background-color: var(--bg-black);
            color: var(--text-white);
            font-family: var(--font-body);
            margin: 0;
            display: flex;
            flex-direction: column;
            min-height: 100vh;
        }

        .navbar {
            background-color: rgba(10, 10, 10, 0.95) !important;
            backdrop-filter: blur(15px);
            -webkit-backdrop-filter: blur(15px);
            border-bottom: 1px solid var(--border-gray);
            padding: 0.8rem 0;
            z-index: 1050;
        }

        .navbar-logo {
            height: 32px;
            width: 82px;
            object-fit: cover;
            object-position: top;
            border-radius: 4px;
            transition: transform 0.3s cubic-bezier(0.165, 0.84, 0.44, 1), filter 0.3s ease;
        }

        .navbar-logo:hover {
            transform: scale(1.05);
            filter: brightness(1.15);
        }

        .nav-link {
            color: var(--text-gray) !important;
            font-size: 0.75rem;
            text-transform: uppercase;
            letter-spacing: 2px;
            font-weight: 600;
            margin: 0 10px;
            padding-bottom: 4px !important;
            border-bottom: 2px solid transparent;
            transition: all 0.3s ease;
        }

        .nav-link:hover, .nav-link.active {
            color: var(--text-white) !important;
            border-bottom-color: var(--accent-gold);
        }

        .btn-luxury {
            background-color: var(--accent-gold);
            border-color: var(--accent-gold);
            color: #000 !important;
            font-weight: 700;
            text-transform: uppercase;
            letter-spacing: 1.5px;
            font-size: 0.7rem;
            border-radius: 50px;
            padding: 0.6rem 1.4rem;
            transition: all 0.3s cubic-bezier(0.165, 0.84, 0.44, 1);
            text-decoration: none;
            display: inline-flex;
            align-items: center;
        }

        .btn-luxury:hover {
            background-color: var(--text-white);
            border-color: var(--text-white);
            transform: translateY(-2px);
        }

        .btn-outline-luxury {
            border: 1px solid var(--accent-gold);
            color: var(--accent-gold) !important;
            background: transparent;
            font-weight: 700;
            text-transform: uppercase;
            letter-spacing: 1.5px;
            font-size: 0.7rem;
            border-radius: 50px;
            padding: 0.6rem 1.4rem;
            transition: all 0.3s ease;
            text-decoration: none;
            display: inline-flex;
            align-items: center;
        }

        .btn-outline-luxury:hover {
            background-color: var(--accent-gold);
            color: #000 !important;
        }

        .admin-card {
            background-color: var(--bg-card);
            border: 1px solid var(--border-gray);
            border-radius: 16px;
            padding: 1.8rem;
            transition: border-color 0.3s;
        }

        .admin-card:hover {
            border-color: rgba(var(--accent-gold-rgb), 0.2);
        }

        .form-control, .form-select {
            background-color: var(--bg-dark) !important;
            border: 1px solid var(--border-gray) !important;
            color: var(--text-white) !important;
            border-radius: 8px;
            padding: 0.6rem 0.8rem;
            font-size: 0.85rem;
            transition: all 0.3s;
        }

        .form-control:focus, .form-select:focus {
            border-color: var(--accent-gold) !important;
            box-shadow: 0 0 10px rgba(var(--accent-gold-rgb), 0.15) !important;
        }

        .table-luxury {
            border-color: var(--border-gray) !important;
            color: var(--text-white) !important;
            font-size: 0.85rem;
        }

        .table-luxury th {
            font-family: var(--font-heading);
            color: var(--accent-gold);
            font-weight: 600;
            letter-spacing: 1px;
            border-bottom: 2px solid var(--border-gray) !important;
            padding: 1rem 0.75rem;
        }

        .table-luxury td {
            vertical-align: middle;
            border-bottom: 1px solid var(--border-gray) !important;
            padding: 0.8rem 0.75rem;
        }

        .text-warning {
            color: var(--accent-gold) !important;
        }

        h1, h2, h3, h4, h5, .heading-font {
            font-family: var(--font-heading);
        }

        .breadcrumb-item a {
            color: var(--accent-gold);
            text-decoration: none;
            font-size: 0.8rem;
        }
        .breadcrumb-item.active {
            color: var(--text-gray);
            font-size: 0.8rem;
        }
        .text-muted {
            color: var(--text-white) !important;
        }
    </style>
</head>
<body>

<!-- Navigation Header -->
<nav class="navbar navbar-expand-lg navbar-dark sticky-top">
    <div class="container">
        <!-- Logo -->
        <a class="navbar-brand d-flex align-items-center" href="index.php">
            <img src="../assets/images/logo.png" alt="MARTLUX Logo" class="navbar-logo">
            <span class="ms-3 text-uppercase text-white small fw-bold tracking-widest d-none d-sm-inline" style="font-size: 0.65rem; letter-spacing: 2px;">Admin Desk</span>
        </a>
        
        <!-- Mobile Toggler -->
        <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#adminNavbarContent" aria-controls="adminNavbarContent" aria-expanded="false" aria-label="Toggle navigation">
            <span class="navbar-toggler-icon"></span>
        </button>

        <!-- Navbar Links -->
        <div class="collapse navbar-collapse" id="adminNavbarContent">
            <ul class="navbar-nav mx-auto mb-2 mb-lg-0">
                <li class="nav-item">
                    <a class="nav-link <?php echo (basename($_SERVER['PHP_SELF']) == 'index.php') ? 'active' : ''; ?>" href="index.php">Dashboard</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link <?php echo (strpos(basename($_SERVER['PHP_SELF']), 'categories') !== false || strpos(basename($_SERVER['PHP_SELF']), 'category') !== false) ? 'active' : ''; ?>" href="categories.php">Categories</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link <?php echo (strpos(basename($_SERVER['PHP_SELF']), 'products') !== false || strpos(basename($_SERVER['PHP_SELF']), 'product') !== false) ? 'active' : ''; ?>" href="products.php">Products</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link <?php echo (basename($_SERVER['PHP_SELF']) == 'colors.php') ? 'active' : ''; ?>" href="colors.php">Colors</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link <?php echo (basename($_SERVER['PHP_SELF']) == 'sizes.php') ? 'active' : ''; ?>" href="sizes.php">Sizes</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link <?php echo (basename($_SERVER['PHP_SELF']) == 'change_logo.php') ? 'active' : ''; ?>" href="change_logo.php">Logo Settings</a>
                </li>
            </ul>

            <div class="d-flex align-items-center gap-3">
                <a href="../shop.php" class="btn-outline-luxury" target="_blank">
                    <i class="fa-solid fa-store me-1"></i> View Store
                </a>
                <a href="logout.php" class="btn-luxury">
                    <i class="fa-solid fa-sign-out-alt me-1"></i> Logout
                </a>
            </div>
        </div>
    </div>
</nav>

<div class="container py-4 flex-grow-1">
