{% extends 'base.html' %} {% load static %} {% block content %}
<div class="security-container">
  <div class="security-header">
    <h1>Security Settings</h1>
  </div>

  <div class="security-content">
    <!-- Password Change Section -->
    <div class="security-section">
      <h2>Change Password</h2>
      <form method="POST" class="password-form">
        {% csrf_token %}
        <input type="hidden" name="action" value="password_change" />

        <div class="form-group">
          <label for="current_password">Current Password</label>
          <input type="password" name="current_password" required />
        </div>

        <div class="form-group">
          <label for="new_password">New Password</label>
          <input type="password" name="new_password" required />
        </div>

        <div class="form-group">
          <label for="confirm_password">Confirm New Password</label>
          <input type="password" name="confirm_password" required />
        </div>

        <button type="submit" class="save-button">Change Password</button>
      </form>
    </div>

    <!-- Two-Factor Authentication -->
    <div class="security-section">
      <h2>Two-Factor Authentication</h2>
      <form method="POST" class="2fa-form">
        {% csrf_token %}
        <input type="hidden" name="action" value="toggle_2fa" />

        <div class="form-group checkbox">
          {{ form.two_factor_enabled }}
          <label for="{{ form.two_factor_enabled.id_for_label }}">
            Enable Two-Factor Authentication
          </label>
        </div>

        <p class="help-text">
          Two-factor authentication adds an extra layer of security to your
          account. When enabled, you'll need to enter a code sent to your email
          when logging in from a new device.
        </p>

        <button type="submit" class="save-button">Save 2FA Settings</button>
      </form>
    </div>
  </div>
</div>

<style>
  .security-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
  }

  .security-header {
    margin-bottom: 30px;
  }

  .security-content {
    background: white;
    border-radius: 8px;
    padding: 30px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  }

  .security-section {
    margin-bottom: 40px;
    padding-bottom: 30px;
    border-bottom: 1px solid #eee;
  }

  .security-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
  }

  .form-group {
    margin-bottom: 20px;
  }

  .form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
  }

  .form-group input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
  }

  .help-text {
    color: #666;
    font-size: 14px;
    margin: 10px 0;
  }

  .checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
  }

  .checkbox input {
    width: auto;
  }

  .save-button {
    background: #6366f1;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
  }

  .save-button:hover {
    background: #4f46e5;
  }

  .activity-list {
    margin-top: 20px;
  }

  .activity-item {
    display: flex;
    align-items: start;
    padding: 15px;
    border: 1px solid #eee;
    border-radius: 6px;
    margin-bottom: 10px;
  }

  .activity-item.failed {
    background-color: #fef2f2;
    border-color: #fee2e2;
  }

  .activity-icon {
    margin-right: 15px;
    font-size: 20px;
  }

  .activity-details {
    flex: 1;
  }

  .activity-main {
    font-weight: 500;
    margin-bottom: 5px;
  }

  .activity-meta {
    color: #666;
    font-size: 14px;
  }

  .device-info {
    margin-left: 10px;
    color: #888;
  }

  .error-message {
    color: #dc2626;
    font-size: 14px;
    margin-top: 5px;
  }
</style>
{% endblock %}
