<template>
  <div id="app">
    <header v-if="isLoggedIn">
      <div class="user-info">
        Logged in as: <strong>{{ role }}</strong>
      </div>
      <button @click="logout" class="logout-btn">Logout</button>
    </header>
    <main>
      <router-view />
    </main>
  </div>
</template>

<script setup>
import { computed } from 'vue';
import { useRouter } from 'vue-router';

const router = useRouter();
const isLoggedIn = computed(() => !!localStorage.getItem('token'));
const role = computed(() => localStorage.getItem('role'));

const logout = () => {
  localStorage.removeItem('token');
  localStorage.removeItem('role');
  router.push('/');
};
</script>

<style>
body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
  background-color: var(--bg-color);
  color: var(--text-primary);
}

#app {
  min-height: 100vh;
}

header {
  background: var(--card-bg);
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  border-bottom: 1px solid var(--border-color);
}

.user-info {
  color: var(--text-secondary);
}

.user-info strong {
  color: var(--accent-color);
}

.logout-btn {
  padding: 0.5rem 1rem;
  background: #252932;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  cursor: pointer;
  color: var(--text-primary);
}

.logout-btn:hover {
  background: #2e323a;
}

main {
  padding-top: 2rem;
}
</style>
