<template>
  <div class="default-layout">
    <header class="app-header" v-if="user">
      <div class="stats">
        <span>SmurfCoins: {{ user.coins }}</span>
        <span>EXP: {{ user.exp }}</span>
      </div>
      <div class="user-info">
        <!-- Level can be calculated later -->
        <span>{{ user.nickname }}</span>
      </div>
    </header>

    <main class="app-content">
      <slot />
    </main>

    <footer class="app-footer">
      <nav class="bottom-nav">
        <NuxtLink to="/" class="nav-item">Главная</NuxtLink>
        <NuxtLink to="/habits" class="nav-item">Привычки</NuxtLink>
        <NuxtLink to="/village" class="nav-item">Деревня</NuxtLink>
        <NuxtLink to="/leaderboard" class="nav-item">Лидеры</NuxtLink>
      </nav>
    </footer>
  </div>
</template>

<script setup lang="ts">
const { user } = useAuth();
</script>

<style scoped>
.default-layout {
  display: flex;
  flex-direction: column;
  min-height: 100vh; /* Use min-height to allow content to push height */
  background-color: #eef5ff;
  color: #333;
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 15px;
  background-color: #4a90e2;
  color: white;
  flex-shrink: 0;
}

.stats, .user-info {
  display: flex;
  gap: 15px;
}

.app-content {
  flex-grow: 1;
  overflow-y: auto; /* Allow content to scroll */
  padding: 15px;
  /* Add padding-bottom to prevent content from being overlapped by fixed footer */
  padding-bottom: 60px; /* Adjust based on footer height */
}

.app-footer {
  flex-shrink: 0;
  position: fixed; /* Changed to fixed as per request */
  bottom: 0;
  width: 100%;
  background-color: #ffffff;
  border-top: 1px solid #dcdcdc;
  padding: 10px 0;
  box-sizing: border-box; /* Include padding in width */
  z-index: 1000; /* Ensure footer is on top */
}

.bottom-nav {
  display: flex;
  justify-content: space-around;
  width: 100%;
}

.nav-item {
  text-decoration: none;
  color: #4a90e2;
  padding: 5px 10px;
  border-radius: 5px;
  text-align: center;
  flex: 1; /* Distribute space evenly */
}

.nav-item.router-link-exact-active {
  background-color: #eef5ff;
  font-weight: bold;
}
</style>