<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1" />
  <title>Iloilo National High School | Election System</title>
  <link rel="preconnect" href="https://fonts.googleapis.com">
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
  <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap" rel="stylesheet">
  <link rel="stylesheet" href="assets/css/landing.css?v=<?= time() ?>">
</head>
<body class="landing-page" style="background-image: url('assets/images/background.jpg?v=<?= filemtime('assets/images/background.jpg') ?>');">
  <div class="landing-container">
    <div class="school-header">
      <div class="school-logo">
        <img src="assets/images/logo.png?v=<?= filemtime('assets/images/logo.png') ?>" alt="Logo" style="width: 100%; height: 100%; object-fit: contain;">
      </div>
      <div class="school-info">
        <h1>Iloilo National High School</h1>
        <p>Luna St., La Paz, Iloilo City</p>
      </div>
    </div>

    <div class="info-card">
      <div class="info-card-header">
        <i>i</i> SYSTEM INFORMATION
      </div>
      <div class="info-card-body">
        <h2>Click to Vote</h2>
        <p>
          This portal is currently a <strong>PROTOTYPE MODEL</strong> under active development to 
          demonstrate the digital election process. Please be aware that all features 
          are in a testing phase and interactions are for demonstration purposes only. 
          We are continuously refining the system to ensure a seamless experience 
          for the final implementation.
        </p>
        <button class="btn-login" onclick="toggleModal()">
          <svg style="width: 18px; height: 18px; margin-right: 8px;" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11 16l-4-4m0 0l4-4m-4 4h14m-5 4v1a3 3 0 01-3 3H6a3 3 0 01-3-3V7a3 3 0 013-3h7a3 3 0 013 3v1"></path>
          </svg>
          LOGIN
        </button>
      </div>
    </div>

    <footer class="landing-footer">
      &copy; <?= date('Y') ?> Click to Vote System [PROTOTYPE]. All Rights Reserved.
    </footer>

    <div class="flatlogic-badge">
      <img src="https://flatlogic.com/favicon.ico" alt="Flatlogic">
      Built with Flatlogic
    </div>
  </div>

  <!-- Login Modal -->
  <div id="loginModal" class="modal-overlay">
    <div class="login-modal">
      <div class="modal-header">
        <div class="modal-header-content">
          <div class="header-icon">
            <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"></path><circle cx="9" cy="7" r="4"></circle><path d="M23 21v-2a4 4 0 0 0-3-3.87"></path><path d="M16 3.13a4 4 0 0 1 0 7.75"></path></svg>
          </div>
          <h2>Login</h2>
        </div>
        <button class="btn-close" onclick="toggleModal()">
          <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="6" x2="6" y2="18"></line><line x1="6" y1="6" x2="18" y2="18"></line></svg>
        </button>
      </div>
      <div class="modal-body">
        <?php if (isset($_GET['error'])): ?>
          <div style="background: #fee2e2; color: #b91c1c; padding: 0.75rem; border-radius: 10px; margin-bottom: 1.5rem; font-size: 0.85rem; border: 1px solid #fecaca; text-align: center;">
            <?= htmlspecialchars($_GET['error']) ?>
          </div>
        <?php endif; ?>
        <form action="login.php" method="POST">
          <div class="form-group">
            <label>User Type</label>
            <div class="input-container">
              <i>
                <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"></path><circle cx="12" cy="7" r="4"></circle></svg>
              </i>
              <select name="role">
                <option value="Voter">Voter</option>
                <option value="Officer">Officer</option>
                <option value="Adviser">Adviser</option>
                <option value="Admin">Admin</option>
              </select>
            </div>
          </div>

          <div class="form-group">
            <label>UID</label>
            <div class="input-container">
              <i>
                <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="4" width="18" height="16" rx="2"></rect><line x1="7" y1="8" x2="17" y2="8"></line><line x1="7" y1="12" x2="17" y2="12"></line><line x1="7" y1="16" x2="12" y2="16"></line></svg>
              </i>
              <input type="text" name="student_id" placeholder="00-0000" required pattern="\d{2}-\d{4}">
            </div>
          </div>

          <div class="form-group">
            <label>Email Account</label>
            <div class="input-container">
              <i>
                <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z"></path><polyline points="22,6 12,13 2,6"></polyline></svg>
              </i>
              <input type="email" name="email" placeholder="firstname.lastname@iloilonhs.edu.ph" required>
            </div>
          </div>

          <div class="form-group">
            <label>Password</label>
            <div class="input-container">
              <i>
                <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="11" width="18" height="11" rx="2" ry="2"></rect><path d="M7 11V7a5 5 0 0 1 10 0v4"></path></svg>
              </i>
              <input type="password" id="passwordInput" name="password" placeholder="Enter your password" required>
              <i class="password-toggle" onclick="togglePassword()">
                <svg id="eyeIcon" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"></path><circle cx="12" cy="12" r="3"></circle></svg>
              </i>
            </div>
          </div>

          <button type="submit" class="modal-btn-login">
            <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4"></path><polyline points="10 17 15 12 10 7"></polyline><line x1="15" y1="12" x2="3" y2="12"></line></svg>
            LOGIN
          </button>

          <a href="#" class="forgot-password">Forgot Password?</a>
        </form>
      </div>
    </div>
  </div>

  <script>
    function toggleModal() {
        const modal = document.getElementById('loginModal');
        modal.classList.toggle('active');
    }

    function togglePassword() {
        const input = document.getElementById('passwordInput');
        const icon = document.getElementById('eyeIcon');
        if (input.type === 'password') {
            input.type = 'text';
            icon.innerHTML = '<path d="M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19m-6.72-1.07a3 3 0 1 1-4.24-4.24"></path><line x1="1" y1="1" x2="23" y2="23"></line>';
        } else {
            input.type = 'password';
            icon.innerHTML = '<path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"></path><circle cx="12" cy="12" r="3"></circle>';
        }
    }

    // Close modal on click outside
    window.onclick = function(event) {
        const modal = document.getElementById('loginModal');
        if (event.target == modal) {
            toggleModal();
        }
    }

    // Auto-open modal if error exists
    <?php if (isset($_GET['error'])): ?>
    window.onload = function() {
        toggleModal();
    }
    <?php endif; ?>
  </script>
</body>
</html>
