<?php
require_once __DIR__ . '/../auth.php';

$pageTitle = getenv('PROJECT_NAME') ?: 'Drillex';
$pageDescription = getenv('PROJECT_DESCRIPTION') ?: 'Create, share, and discover training drills.';
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title><?php echo htmlspecialchars($pageTitle); ?></title>
    <meta name="description" content="<?php echo htmlspecialchars($pageDescription); ?>">
    
    <!-- Open Graph / Facebook -->
    <meta property="og:type" content="website">
    <meta property="og:title" content="<?php echo htmlspecialchars($pageTitle); ?>">
    <meta property="og:description" content="<?php echo htmlspecialchars($pageDescription); ?>">
    <meta property="og:image" content="<?php echo htmlspecialchars($_SERVER['PROJECT_IMAGE_URL'] ?? ''); ?>">

    <!-- Twitter -->
    <meta property="twitter:card" content="summary_large_image">
    <meta property="twitter:title" content="<?php echo htmlspecialchars($pageTitle); ?>">
    <meta property="twitter:description" content="<?php echo htmlspecialchars($pageDescription); ?>">
    <meta property="twitter:image" content="<?php echo htmlspecialchars($_SERVER['PROJECT_IMAGE_URL'] ?? ''); ?>">

    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;600;700&family=Inter:wght@400;500&display=swap" rel="stylesheet">
    <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
    <link rel="stylesheet" href="assets/css/theme.css?v=<?php echo time(); ?>">
    <link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
    <link rel="icon" href="assets/images/favicon.svg" type="image/svg+xml">
</head>
<body >

<nav class="navbar navbar-expand-lg navbar-light sticky-top">
    <div class="container-fluid">
                <a class="navbar-brand" href="index.php">
                    <svg width="150" height="36" viewBox="0 0 250 60" xmlns="http://www.w3.org/2000/svg" class="logo">
                        <text x="10" y="45" font-family="Arial, sans-serif" font-size="40" font-weight="bold">
                            <tspan fill="var(--text-color)">Drill</tspan><tspan class="logo-text-primary">ex</tspan>
                        </text>
                    </svg>
                </a>
        
        <div class="d-flex align-items-center">
            <div class="form-check form-switch me-3">
                <input class="form-check-input" type="checkbox" id="theme-switcher">
                <label class="form-check-label" for="theme-switcher">
                    <span class="d-none d-sm-inline">Dark Mode</span>
                    <i class="material-icons vm">brightness_4</i>
                </label>
            </div>
            <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
                <span class="navbar-toggler-icon"></span>
            </button>
            <div class="collapse navbar-collapse" id="navbarNav">
                <ul class="navbar-nav ms-auto">
                    <?php if (is_logged_in()): ?>
                        <li class="nav-item">
                            <a href="create_drill.php" class="btn btn-primary me-2">Create Drill</a>
                        </li>
                        <li class="nav-item">
                            <a href="my_drills.php" class="nav-link">My Drills</a>
                        </li>
                        <li class="nav-item">
                            <a href="training_sessions.php" class="nav-link">Training Sessions</a>
                        </li>
                        <li class="nav-item">
                            <a href="teams.php" class="nav-link">Teams</a>
                        </li>
                        <?php if (is_admin()): ?>
                            <li class="nav-item">
                                <a href="admin/users.php" class="nav-link">Manage Users</a>
                            </li>
                        <?php endif; ?>
                        <li class="nav-item dropdown">
                            <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
                                <?php echo htmlspecialchars($_SESSION['user_name']); ?>
                            </a>
                            <ul class="dropdown-menu dropdown-menu-end" aria-labelledby="navbarDropdown">
                                <li><a class="dropdown-item" href="logout.php">Logout</a></li>
                            </ul>
                        </li>
                    <?php else: ?>
                        <li class="nav-item">
                            <a href="login.php" class="btn btn-outline-primary me-2">Login</a>
                        </li>
                        <li class="nav-item">
                            <a href="register.php" class="btn btn-primary">Register</a>
                        </li>
                    <?php endif; ?>
                </ul>
            </div>
        </div>
    </div>
</nav>
