<template>
  <div v-if="!isLoggedIn" class="login-container">
    <div class="login-card">
      <h2>Login</h2>
      <form @submit.prevent="$emit('login')">
        <div class="form-group">
          <label for="login_username">Username</label>
          <input 
            type="text" 
            id="login_username" 
            :value="loginForm.username"
            @input="$emit('update:loginForm', { ...loginForm, username: $event.target.value })"
            required 
            placeholder="Enter username"
          >
        </div>
        
        <div class="form-group">
          <label for="login_password">Password</label>
          <input 
            type="password" 
            id="login_password" 
            :value="loginForm.password"
            @input="$emit('update:loginForm', { ...loginForm, password: $event.target.value })"
            required 
            placeholder="Enter password"
          >
        </div>
        
        <button type="submit" class="btn btn-primary btn-block">Login</button>
      </form>
      
      <div v-if="loginError" class="error-message">
        {{ loginError }}
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'LoginSection',
  props: {
    isLoggedIn: {
      type: Boolean,
      required: true
    },
    loginForm: {
      type: Object,
      required: true
    },
    loginError: {
      type: String,
      default: ''
    }
  },
  emits: ['login', 'update:loginForm']
}
</script>

<style scoped>
.login-container {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 40px 0;
}

.login-card {
  background: white;
  padding: 30px;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  width: 100%;
  max-width: 400px;
}

.error-message {
  color: #e74c3c;
  margin-top: 15px;
  text-align: center;
}
</style>
