{% extends "base.html" %}
{% block content %}
<div class="max-w-md mx-auto my-8">
  <div class="bg-white p-8 rounded-lg shadow-md">
    <h1 class="text-2xl font-bold text-irish-green mb-6 text-center">Log In</h1>
    
    <!-- Messages/Alerts -->
    {% if error %}
      <div class="mb-4 p-3 rounded bg-red-100 text-red-700">
        {{ error }}
      </div>
    {% endif %}
    
    {% if message %}
      <div class="mb-4 p-3 rounded bg-green-100 text-green-700">
        {{ message }}
      </div>
    {% endif %}
    
    <form action="/auth/login" method="post" class="space-y-4">      
      <div>
        <label for="username" class="block text-sm font-medium text-gray-700 mb-1">Username</label>
        <input
          type="text"
          id="username"
          name="username"
          required
          class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-irish-green focus:border-irish-green"
        >
      </div>
      
      <div>
        <label for="password" class="block text-sm font-medium text-gray-700 mb-1">Password</label>
        <input
          type="password"
          id="password"
          name="password"
          required
          class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-irish-green focus:border-irish-green"
        >
      </div>
      
      <!-- Debug info -->
      <div class="text-xs text-gray-500">
        <p>Having trouble logging in? Make sure your browser accepts cookies.</p>
      </div>
      
      <div class="flex items-center">
        <input
          type="checkbox"
          id="remember"
          name="remember"
          class="h-4 w-4 text-irish-green focus:ring-irish-green border-gray-300 rounded"
        >
        <label for="remember" class="ml-2 block text-sm text-gray-700">Remember me</label>
      </div>
      
      <div>
        <button
          type="submit"
          class="w-full bg-irish-green text-white py-2 px-4 rounded-md hover:bg-opacity-90 transition focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-irish-green"
        >
          Log In
        </button>
      </div>
    </form>
    
    <div class="mt-6 pt-6 border-t border-gray-200 text-center">
      <p class="text-gray-600">Don't have an account?</p>
      <a href="/auth/register" class="block mt-2 bg-cream-white text-irish-green border border-irish-green py-2 px-4 rounded-md hover:bg-irish-green hover:text-white transition">
        Create an account
      </a>
    </div>
    
    <!-- OAuth login options -->
    {% if show_oauth %}
    <div class="mt-6 pt-6 border-t border-gray-200">
      <p class="text-center text-gray-600 mb-4">Or sign in with</p>
      <div class="flex justify-center">
        <a href="/auth/oauth-login" class="bg-blue-600 text-white py-2 px-4 rounded-md hover:bg-opacity-90 transition w-full flex items-center justify-center">
          <i class="fas fa-sign-in-alt mr-2"></i> {{ oauth_provider_name }}
        </a>
      </div>
    </div>
    {% else %}
    <div class="mt-6 pt-6 border-t border-gray-200">
      <p class="text-center text-gray-600 mb-4">Or sign in with</p>
      <div class="flex justify-center space-x-4">
        <button class="bg-blue-600 text-white py-2 px-4 rounded-md hover:bg-opacity-90 transition w-full disabled:opacity-50" disabled>
          <i class="fab fa-google mr-2"></i> Google
        </button>
        <button class="bg-gray-800 text-white py-2 px-4 rounded-md hover:bg-opacity-90 transition w-full disabled:opacity-50" disabled>
          <i class="fab fa-github mr-2"></i> GitHub
        </button>
      </div>
      <p class="text-center text-gray-500 text-xs mt-2">OAuth login currently disabled</p>
    </div>
    {% endif %}
  </div>
</div>
{% endblock %}
