{% extends 'base.html' %}

{% block body %}

<!-- ===== Custom CSS ===== -->
<style>
  body {
    background: linear-gradient(135deg, #e8f5e9, #ffffff);
  }

  .signup-section {
    min-height: 100vh;
    display: flex;
    align-items: center;
    padding: 2rem 0;
  }

  .signup-card {
    background: #ffffff;
    border-radius: 25px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    transition: all 0.3s ease-in-out;
  }

  .signup-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.15);
  }

  .form-control {
    border-radius: 12px;
    border: 1px solid #cfcfcf;
    box-shadow: none;
    padding: 0.9rem;
  }

  .form-control:focus {
    border-color: #28a745;
    box-shadow: 0 0 0 0.2rem rgba(25, 135, 84, 0.25);
  }

  label {
    color: #555;
    font-weight: 500;
  }

  .btn-success {
    background-color: #28a745;
    border: none;
    border-radius: 10px;
    font-weight: 600;
    font-size: 1.1rem;
    padding: 0.7rem 2rem;
    transition: all 0.3s ease;
  }

  .btn-success:hover {
    background-color: #218838;
    transform: translateY(-2px);
  }

  .illustration {
    max-width: 100%;
    border-radius: 15px;
  }

  .alert {
    border-radius: 12px;
  }

  .link-success {
    text-decoration: none;
  }

  .link-success:hover {
    text-decoration: underline;
  }

  @media (max-width: 768px) {
    .signup-card {
      margin: 0 10px;
    }
    .illustration {
      margin-bottom: 2rem;
    }
  }
</style>

<!-- ===== Sign-Up Section ===== -->
<section class="signup-section">
  <div class="container">
    <div class="card signup-card border-0">
      <div class="row align-items-center">
        
        <!-- Left Side (Image) -->
        <div class="col-md-6 text-center bg-light py-4">
          <img src="static/logo_2.jpg" alt="GreenField Logo" class="illustration shadow-sm">
        </div>

        <!-- Right Side (Form) -->
        <div class="col-md-6 p-5">
          <h2 class="text-center text-success fw-bold mb-4">
            <i class="bi bi-person-plus"></i> Create Your Account
          </h2>

          <!-- Django Messages -->
          {% for message in messages %}
          <div class="alert alert-danger alert-dismissible fade show shadow-sm" role="alert">
            <strong>{{ message }}</strong>
            <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
          </div>
          {% endfor %}

          <!-- Sign-Up Form -->
          <form method="POST" action="/SignUp" class="row g-3">
            {% csrf_token %}

            <!-- First Name -->
            <div class="form-floating col-md-6">
              <input type="text" name="fname" id="fname" class="form-control" placeholder="Enter Your First Name" required>
              <label for="fname">First Name</label>
            </div>

            <!-- Last Name -->
            <div class="form-floating col-md-6">
              <input type="text" name="lname" id="lname" class="form-control" placeholder="Enter Your Last Name" required>
              <label for="lname">Last Name</label>
            </div>

            <!-- Mobile Number -->
            <div class="form-floating col-12">
              <input type="text" name="number" id="phone" class="form-control" maxlength="10" placeholder="Enter Mobile Number" required>
              <label for="phone">Mobile Number</label>
            </div>

            <!-- Password -->
            <div class="form-floating col-12">
              <input type="password" name="password" id="password" class="form-control" minlength="8" placeholder="Enter Password" required>
              <label for="password">Password</label>
              <div class="alert alert-warning alert-dismissible fade show mt-2 py-2" role="alert">
                <small>* Minimum length of password must be 8 characters</small>
                <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
              </div>
            </div>

            <!-- Confirm Password -->
            <div class="form-floating col-12">
              <input type="password" name="cpassword" id="cpassword" class="form-control" minlength="8" placeholder="Confirm Password" required>
              <label for="cpassword">Confirm Password</label>
            </div>

            <!-- Submit Button -->
            <div class="text-center mt-3">
              <button type="submit" class="btn btn-success w-100 shadow-sm">
                <i class="bi bi-check-circle"></i> Sign Up
              </button>
              <p class="small mt-3 mb-0">
                Already have an account?
                <a href="/Login" class="link-success fw-semibold">Login Here</a>
              </p>
            </div>
          </form>
        </div>

      </div>
    </div>
  </div>
</section>

{% endblock body %}
