{% load static %}
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>{% block title %}Your Site Name{% endblock %}</title>

  <!-- Bootstrap 5 CSS -->
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">

  <!-- SweetAlert2 CSS -->
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/sweetalert2@11/dist/sweetalert2.min.css">

  <!-- Font Awesome Icons -->
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">

  <!-- Google Fonts (Poppins) -->
  <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap" rel="stylesheet">

  <!-- Custom CSS File -->
  <link rel="stylesheet" href="{% static 'css/style.css' %}">

  <!-- Inline CSS for quick overrides and dark mode support -->
  <style>
    :root {
      --primary-color: #2c3e50;
      --secondary-color: #3498db;
      --hover-color: rgb(233, 41, 121);
    }
    body {
      font-family: 'Poppins', sans-serif;
      background-color: #f8f9fa;
      transition: background-color 0.3s ease, color 0.3s ease;
    }
    .navbar-brand {
      font-weight: 700;
      letter-spacing: 1px;
      transition: transform 0.3s ease;
    }
    .navbar-brand:hover {
      transform: scale(1.05);
    }
    .nav-link {
      font-weight: 500;
      transition: color 0.3s ease;
    }
    .nav-link:hover {
      color: var(--hover-color) !important;
    }
    .dropdown-menu {
      border: none;
      box-shadow: 0 0 15px rgba(0, 0, 0, 0.1);
    }
    .footer {
      background-color: var(--primary-color);
      color: white;
      padding: 1.5rem 0;
      margin-top: auto;
    }
    /* Dark Mode Styles */
    body.dark-mode {
      background-color: #121212;
      color: #e0e0e0;
    }
    body.dark-mode .navbar,
    body.dark-mode .footer {
      background-color: #1e1e1e;
    }
    body.dark-mode .dropdown-menu {
      background-color: #2a2a2a;
      color: #e0e0e0;
    }
    body.dark-mode .nav-link,
    body.dark-mode .navbar-brand {
      color: #e0e0e0;
    }
    body.dark-mode .nav-link:hover {
      color: var(--hover-color) !important;
    }
    /* Toggle Button Styles */
    #themeToggleBtn {
      border: none;
      background: transparent;
      color: #fff;
      font-size: 1.2rem;
    }
  </style>

  {% block extra_css %}{% endblock %}
</head>
<body class="d-flex flex-column min-vh-100">
  {% include 'navbar.html' %}
  <main class="flex-grow-1">
    <div class="container mt-4">
      {% block content %}
      {% endblock %}
    </div>
  </main>
  <footer class="footer mt-5">
    <div class="container text-center">
      <p class="mb-0">&copy; {% now "Y" %} Your Company Name. All rights reserved.</p>
    </div>
  </footer>

  <!-- Scripts (placed at end for performance) -->
  <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11/dist/sweetalert2.all.min.js"></script>
  {% if messages %}
  <script>
    {% for message in messages %}
      Swal.fire({
        icon: '{{ message.tags }}',
        title: '{{ message }}',
        timer: 3000,
        showConfirmButton: false
      });
    {% endfor %}
  </script>
  {% endif %}
  {% block extra_js %}{% endblock %}
  <!-- Custom JS File -->
  <script src="{% static 'js/script.js' %}"></script>
  <!-- Dark/Light Mode Toggle Script -->
  <script>
    if (localStorage.getItem('theme') === 'dark') {
      document.body.classList.add('dark-mode');
      document.addEventListener('DOMContentLoaded', function() {
        var toggleBtn = document.getElementById('themeToggleBtn');
        if (toggleBtn) {
          toggleBtn.innerHTML = '<i class="fas fa-sun"></i>';
        }
      });
    }
    function toggleTheme() {
      document.body.classList.toggle('dark-mode');
      var toggleBtn = document.getElementById('themeToggleBtn');
      if (document.body.classList.contains('dark-mode')) {
        localStorage.setItem('theme', 'dark');
        toggleBtn.innerHTML = '<i class="fas fa-sun"></i>';
      } else {
        localStorage.setItem('theme', 'light');
        toggleBtn.innerHTML = '<i class="fas fa-moon"></i>';
      }
    }
  </script>
</body>
</html>
