
<?php
/* ============================================================
   INTERNATIONAL ADVENTURES
   PREMIUM ADMIN TOPBAR
   File: admin/top.php
============================================================ */

if (session_status() === PHP_SESSION_NONE) {
    session_start();
}

$adminName = $_SESSION['ADMIN_NAME'] ?? 'Administrator';
$adminEmail = $_SESSION['ADMIN_EMAIL'] ?? '';

$initial = strtoupper(substr(trim($adminName), 0, 1));

if ($initial === '') {
    $initial = 'A';
}

if (!function_exists('ia_top_escape')) {
    function ia_top_escape($value) {
        return htmlspecialchars((string)$value, ENT_QUOTES, 'UTF-8');
    }
}
?>

<!DOCTYPE html>
<html lang="en">
<head>

<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>International Adventures | Admin Panel</title>

<!-- Bootstrap -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">

<!-- Font Awesome -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.6.0/css/all.min.css">

<!-- Google Fonts -->
<link href="https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700;800&family=Playfair+Display:wght@600;700;800&display=swap" rel="stylesheet">

<style>

.admin-top-space {
    height: 76px;
    margin-left: 275px;
}

@media(max-width:991px) {
    .admin-top-space {
        margin-left: 0;
    }
}

/* ============================================================
   GLOBAL
============================================================ */

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
}

body {
    background: #f4f7f5;
    color: #26352d;
    font-family: 'DM Sans', sans-serif;
    overflow-x: hidden;
}

/* ============================================================
   TOPBAR
============================================================ */

.admin-navbar {
    position: fixed;
    top: 0;
    left: 275px;
    width: calc(100% - 275px);
    height: 76px;
    z-index: 1000;

    background: rgba(255,255,255,.97);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);

    border-bottom: 1px solid #e1ebe3;
    box-shadow: 0 5px 25px rgba(7,59,44,.07);
}

@media(max-width:991px) {
    .admin-navbar {
        left: 0;
        width: 100%;
    }
}


/* ============================================================
   MOBILE MENU
============================================================ */

#menu-btn {
    width: 43px;
    height: 43px;

    display: none;
    align-items: center;
    justify-content: center;

    border: 1px solid #dce8df;
    border-radius: 12px;

    background: #f0f7f2;
    color: #073b2c;

    font-size: 18px;
    margin-right: 14px;

    transition: .25s;
    cursor: pointer;
}

#menu-btn:hover {
    background: #073b2c;
    color: #fff;
    border-color: #073b2c;
}

/* ============================================================
   BRAND
============================================================ */

.admin-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
}

.admin-logo {
    width: 47px;
    height: 47px;

    display: flex;
    align-items: center;
    justify-content: center;

    overflow: hidden;

    border-radius: 14px;
    background: #ffffff;
    border: 1px solid #e0e9e1;

    box-shadow: 0 5px 15px rgba(7,59,44,.09);
}

.admin-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 4px;
}

.admin-logo-fallback {
    display: flex;
    align-items: center;
    justify-content: center;

    width: 100%;
    height: 100%;

    color: #073b2c;
    background: linear-gradient(135deg,#d9f99d,#86efac);
    font-size: 22px;
}

.admin-brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}

.admin-brand-title {
    font-family: 'Playfair Display', serif;
    font-size: 19px;
    font-weight: 800;
    color: #073b2c;
    letter-spacing: .2px;
}

.admin-brand-subtitle {
    margin-top: 6px;
    color: #8b9d91;
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 1.8px;
}

/* ============================================================
   RIGHT SIDE
============================================================ */

.admin-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* ============================================================
   WEBSITE BUTTON
============================================================ */

.website-btn {
    display: inline-flex;
    align-items: center;
    gap: 9px;

    padding: 11px 16px;

    border: 1px solid #dce8df;
    border-radius: 11px;

    background: #ffffff;
    color: #174c36;

    text-decoration: none;
    font-size: 12px;
    font-weight: 800;

    transition: .25s;
}

.website-btn i {
    font-size: 14px;
}

.website-btn:hover {
    background: #073b2c;
    color: #ffffff;
    border-color: #073b2c;
    transform: translateY(-2px);
}

/* ============================================================
   PROFILE
============================================================ */

.admin-profile {
    display: flex;
    align-items: center;
    gap: 10px;

    padding: 5px 13px 5px 5px;

    background: #f4f8f4;
    border: 1px solid #e0e9e0;
    border-radius: 13px;
}

.admin-avatar {
    width: 40px;
    height: 40px;
    min-width: 40px;

    display: flex;
    align-items: center;
    justify-content: center;

    border-radius: 11px;

    background: linear-gradient(135deg,#073b2c,#39835b);
    color: #ffffff;

    font-size: 16px;
    font-weight: 800;

    box-shadow: 0 5px 13px rgba(7,59,44,.18);
}

.admin-details {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.admin-name {
    color: #253b2e;
    font-size: 12px;
    font-weight: 800;
}

.admin-role {
    margin-top: 5px;
    color: #91a096;
    font-size: 10px;
    font-weight: 600;
}

/* ============================================================
   LOGOUT
============================================================ */

.logout-btn {
    min-width: 96px;

    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;

    padding: 11px 15px;

    border-radius: 11px;

    background: linear-gradient(135deg,#a83d31,#c95142);
    color: #ffffff !important;

    text-decoration: none;
    font-size: 12px;
    font-weight: 800;

    box-shadow: 0 6px 16px rgba(168,61,49,.17);

    transition: .25s;
}

.logout-btn:hover {
    color: #ffffff !important;
    transform: translateY(-2px);
    box-shadow: 0 9px 22px rgba(168,61,49,.25);
}

/* ============================================================
   TOP SPACE
============================================================ */

.admin-top-space {
    height: 76px;
}

/* ============================================================
   RESPONSIVE
============================================================ */

@media(max-width:991px) {

    #menu-btn {
        display: flex;
    }

    .admin-navbar .container-fluid {
        padding: 0 14px;
    }

    .admin-brand-subtitle {
        display: none;
    }

    .admin-brand-title {
        font-size: 16px;
    }

    .admin-logo {
        width: 41px;
        height: 41px;
    }

    .website-btn {
        display: none;
    }

    .admin-details {
        display: none;
    }

    .admin-profile {
        padding: 3px;
        border: none;
        background: transparent;
    }

    .logout-btn {
        min-width: 40px;
        width: 40px;
        height: 40px;
        padding: 0;
    }

    .logout-btn span {
        display: none;
    }
}

@media(max-width:480px) {

    .admin-navbar,
    .admin-navbar .container-fluid {
        height: 68px;
    }

    .admin-top-space {
        height: 68px;
    }

    #menu-btn {
        width: 38px;
        height: 38px;
        margin-right: 9px;
    }

    .admin-logo {
        width: 36px;
        height: 36px;
    }

    .admin-brand {
        gap: 8px;
    }

    .admin-brand-title {
        font-size: 13px;
    }

    .admin-avatar {
        width: 35px;
        height: 35px;
        min-width: 35px;
    }

    .logout-btn {
        width: 36px;
        min-width: 36px;
        height: 36px;
    }

    .admin-right {
        gap: 7px;
    }
}

</style>

</head>

<body>

<!-- ============================================================
     PREMIUM ADMIN TOPBAR
============================================================ -->

<nav class="admin-navbar">

    <div class="container-fluid d-flex align-items-center">

        <!-- MOBILE MENU BUTTON -->
        <button
            type="button"
            id="menu-btn"
            aria-label="Open Sidebar">

            <i class="fa-solid fa-bars"></i>

        </button>

        <!-- BRAND -->
        <a href="index.php" class="admin-brand">

            <div class="admin-logo">

                <img
                    src="../assets/images/logo.png"
                    alt="International Adventures Logo"
                    onerror="this.style.display='none';this.nextElementSibling.style.display='flex';"
                >

                <div class="admin-logo-fallback" style="display:none;">
                    <i class="fa-solid fa-earth-asia"></i>
                </div>

            </div>

            <div class="admin-brand-text">

                <div class="admin-brand-title">
                    INTERNATIONAL ADVENTURES
                </div>

                <div class="admin-brand-subtitle">
                    OVERSEAS SERVICES • ADMIN PANEL
                </div>

            </div>

        </a>

        <!-- RIGHT SIDE -->
        <div class="admin-right ms-auto">

            <!-- WEBSITE -->
            <a
                href="../index.php"
                target="_blank"
                rel="noopener noreferrer"
                class="website-btn">

                <i class="fa-solid fa-globe"></i>

                <span>View Website</span>

            </a>

            <!-- ADMIN PROFILE -->
            <div class="admin-profile">

                <div class="admin-avatar">
                    <?php echo ia_top_escape($initial); ?>
                </div>

                <div class="admin-details">

                    <div class="admin-name">
                        <?php echo ia_top_escape($adminName); ?>
                    </div>

                    <div class="admin-role">
                        <i class="fa-solid fa-circle"
                           style="font-size:7px;color:#22a06b;"></i>
                        Administrator
                    </div>

                </div>

            </div>

            <!-- LOGOUT -->
            <a
                href="logout.php"
                class="logout-btn"
                onclick="return confirm('Are you sure you want to logout?');">

                <i class="fa-solid fa-right-from-bracket"></i>

                <span>Logout</span>

            </a>

        </div>

    </div>

</nav>

<!-- TOP SPACE -->
<div class="admin-top-space"></div>

</body>
</html>
