<?php
include('dbcon.php');
$mistake = $incorrectlogin = "";

if (isset($_POST['submit']) && $_SERVER["REQUEST_METHOD"] === 'POST') {
    
    $email = mysqli_real_escape_string($connn, $_POST['email']);
    $password = trim($_POST['password']);

    if (empty($email) || empty($password)) {
        $mistake = "All Fields must be filled correctly";
    }

    // Perform query
    $result = mysqli_query($connn, "SELECT * FROM user WHERE email= '$email' AND password='$password' LIMIT 1");
    $row  = mysqli_fetch_array($result);

    if (is_array($row)) {
        session_start();
        $_SESSION["id"] = $row['id'];

        // --- NEW REDIRECT LOGIC ---
        // Check if the 'ADMIN' column equals 1
        // (Make sure the column name in your DB matches the case here: 'ADMIN' vs 'admin')
        if ($row['admin'] == '1') {
            echo "<script>window.location='user/update.php'</script>";
        } else {
            echo "<script>window.location='user/index.php'</script>";
        }
        // --------------------------
    } 
    else {
        $incorrectlogin = "Incorrect Username or Password entered";
    }
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Axiom Investment - Smart investment Growth</title>
  <link rel="stylesheet" href="css/styles.css">
    <style>
    /* Mobile Menu Styles */
    .hamburger {
      display: none;
      flex-direction: column;
      cursor: pointer;
      width: 24px;
      height: 20px;
      justify-content: space-between;
      z-index: 1001;
    }

    .hamburger span {
      display: block;
      height: 2px;
      width: 100%;
      background-color: var(--text-dark);
      transition: all 0.3s ease;
    }

    /* Mobile menu active state */
    .hamburger.active span:nth-child(1) {
      transform: rotate(45deg) translate(5px, 5px);
    }

    .hamburger.active span:nth-child(2) {
      opacity: 0;
    }

    .hamburger.active span:nth-child(3) {
      transform: rotate(-45deg) translate(7px, -6px);
    }

    /* Nav Container */
    nav {
      background: white;
      box-shadow: 0 2px 10px rgba(0,0,0,0.1);
      position: sticky;
      top: 0;
      z-index: 100;
    }

    .nav-container {
      display: flex;
      justify-content: space-between;
      align-items: center;
      max-width: 1200px;
      margin: 0 auto;
      padding: 15px 20px;
      position: relative;
    }

    .logo {
      display: flex;
      align-items: center;
      font-size: 1.5rem;
      font-weight: bold;
      color: var(--text-dark);
      text-decoration: none;
    }

    .logo-icon {
      font-size: 1.8rem;
      margin-right: 8px;
      color: #ffffff;
    }

    /* Desktop Navigation */
    .nav-links {
      display: flex;
      align-items: center;
      gap: 25px;
      list-style: none;
      margin: 0;
      padding: 0;
    }

    .nav-links a {
      color: var(--text-light);
      text-decoration: none;
      font-weight: 500;
      transition: color 0.3s;
      padding: 8px 0;
    }

    .nav-links a:hover,
    .nav-links a.active {
      color: var(--primary-color);
    }

    .nav-links .btn {
      padding: 10px 20px;
      border-radius: 6px;
      text-decoration: none;
      font-weight: 600;
      font-size: 0.9rem;
      transition: all 0.3s;
    }

    .nav-links .btn-secondary {
      background: #f1f5f9;
      color: #475569 !important;
      border: 1px solid #cbd5e1;
    }

    .nav-links .btn-primary {
      background: var(--primary-color);
      color: white !important;
      border: 1px solid var(--primary-color);
    }

    .nav-links .btn-secondary:hover {
      background: #e2e8f0;
    }

    .nav-links .btn-primary:hover {
      background: var(--primary-dark);
      border-color: var(--primary-dark);
    }

    /* Overlay when menu is open */
    .nav-overlay {
      display: none;
      position: fixed;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      background: rgba(0,0,0,0.5);
      z-index: 999;
    }

    .nav-overlay.active {
      display: block;
    }

    /* Responsive Nav Links */
    @media (max-width: 992px) {
      .hamburger {
        display: flex;
        position: absolute;
        right: 20px;
        top: 50%;
        transform: translateY(-50%);
      }
      
      .nav-links {
        position: fixed;
        top: 0;
        right: -100%;
        width: 80%;
        max-width: 400px;
        height: 100vh;
        background: white;
        flex-direction: column;
        padding: 80px 30px 30px;
        box-shadow: -5px 0 15px rgba(0,0,0,0.1);
        transition: right 0.3s ease;
        z-index: 1000;
        overflow-y: auto;
        gap: 0;
      }
      
      .nav-links.active {
        right: 0;
      }
      
      .nav-links li {
        margin: 0;
        margin-bottom: 20px;
        width: 100%;
      }
      
      .nav-links a {
        padding: 12px 0;
        font-size: 1.1rem;
        display: block;
        width: 100%;
      }
      
      .nav-links .btn {
        width: 100%;
        text-align: center;
        margin-bottom: 10px;
        padding: 12px;
      }
      
      /* Hide regular nav links on mobile initially */
      .nav-links:not(.active) {
        display: none;
      }
    }

    /* Hide hamburger on desktop */
    @media (min-width: 993px) {
      .hamburger {
        display: none !important;
      }
      
      .nav-overlay {
        display: none !important;
      }
    }

    /* Hero Section */
    .hero {
      background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
      color: white;
      text-align: center;
      padding: 80px 20px;
    }

    /* CTA Section */
    .cta-section {
      background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
      color: white;
      padding: 80px 20px;
      text-align: center;
    }

    .cta-container {
      max-width: 800px;
      margin: 0 auto;
    }

    .cta-content h2 {
      font-size: 2.5rem;
      margin-bottom: 20px;
    }

    /* Buttons */
    .btn {
      display: inline-block;
      padding: 12px 28px;
      border-radius: 6px;
      text-decoration: none;
      font-weight: 600;
      transition: all 0.3s;
      border: none;
      cursor: pointer;
    }

    .btn-primary {
      background: var(--primary-color);
      color: white;
      border: 1px solid var(--primary-color);
    }

    .btn-outline {
      background: transparent;
      color: white;
      border: 2px solid white;
    }

    .btn-outline:hover {
      background: white;
      color: var(--primary-color);
    }

    /* Section Header */
    .section-header {
      text-align: center;
      margin-bottom: 40px;
    }

    .section-header h2 {
      font-size: 2rem;
      color: var(--text-dark);
      margin-bottom: 10px;
    }

    .section-header p {
      color: var(--text-light);
      font-size: 1.1rem;
    }

    /* CSS Variables */
    :root {
      --primary-color: #6366f1;
      --primary-dark: #4f46e5;
      --text-dark: #1f2937;
      --text-light: #6b7280;
    }

    /* Footer */
    footer {
      background: #1f2937;
      color: white;
      padding: 60px 20px 20px;
    }

    .footer-content {
      max-width: 1200px;
      margin: 0 auto;
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
      gap: 40px;
      margin-bottom: 40px;
    }

    .footer-section h3 {
      font-size: 1.2rem;
      margin-bottom: 20px;
      color: white;
    }

    .footer-section ul {
      list-style: none;
      padding: 0;
      margin: 0;
    }

    .footer-section ul li {
      margin-bottom: 10px;
    }

    .footer-section a {
      color: #d1d5db;
      text-decoration: none;
      transition: color 0.3s;
    }

    .footer-section a:hover {
      color: white;
    }

    /* Body styles */
    body {
      margin: 0;
      font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
      color: var(--text-dark);
      line-height: 1.6;
    }

    * {
      box-sizing: border-box;
    }
  </style>
</head>
<body>
  <!-- Navigation -->
 <nav>
    <div class="nav-container">
      <a href="index.html" class="logo">
        <div class="logo-icon">▲</div>
        Axiom 
      </a>
      
      <!-- Hamburger Menu Button (at far right on mobile) -->
      <div class="hamburger" id="hamburger">
        <span></span>
        <span></span>
        <span></span>
      </div>
      
      <!-- Navigation Links -->
      <ul class="nav-links" id="navLinks">
        <li><a href="index.html">Home</a></li>
        <li><a href="investment-plan.html">Invest</a></li>
        <li><a href="about-us.html" class="active">Company</a></li>
        <li><a href="legal-information.html">Legal</a></li>
        <li><a href="contact.html">Support</a></li>
        <li><a href="signup.php" class="btn btn-secondary">Get Started</a></li>
        <li><a href="login.php" class="btn btn-primary">Log In</a></li>
      </ul>
      
      <!-- Mobile Menu Overlay -->
      <div class="nav-overlay" id="navOverlay"></div>
    </div>
  </nav>


  <!-- Main Auth Section -->
  <section class="auth-section">
    <div class="auth-container">
      
      <!-- Left Side: Login Form -->
      <div class="auth-content">
        <div class="auth-header">
          <h1>Welcome Back</h1>
          <p>Enter your credentials to access your portfolio.</p>
        </div>

        <form id="loginPageForm" class="auth-form"  action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>" method="POST">
          <div class="form-group">
            <label for="email">Email Address</label>
            <div class="input-wrapper">
              <span class="input-icon">✉️</span>
              <input type="email" id="email" name="email" placeholder="name@example.com" required>
            </div>
          </div>

          <div class="form-group">
            <label for="password">Password</label>
            <div class="input-wrapper">
              <span class="input-icon">🔒</span>
              <input type="password" id="password" name="password" placeholder="Enter your password" required>
            </div>
          </div>

          <div class="form-options">
            <div class="checkbox-group">
              <input type="checkbox" id="remember">
              <label for="remember">Remember me</label>
            </div>
         <!--   <a href="#" class="forgot-link">Forgot password?</a> -->
          </div>

          <button type="submit" name="submit" class="btn btn-primary btn-block">Sign In</button>
        </form>

        <div class="auth-footer">
          <p>Protected by reCAPTCHA and subject to the Axiom <a href="#">Privacy Policy</a>.</p>
        </div>
      </div>

      <!-- Right Side: Vector Art -->
      <div class="auth-visual">
        <div class="visual-content">
          <!-- Custom Vector Art: Secure Login -->
          <svg class="auth-vector" viewBox="0 0 400 400" fill="none" xmlns="http://www.w3.org/2000/svg">
            <!-- Background Elements -->
            <circle cx="200" cy="200" r="160" fill="white" fill-opacity="0.1"/>
            <circle cx="200" cy="200" r="120" fill="white" fill-opacity="0.1"/>
            
            <!-- Lock Body -->
            <rect x="130" y="180" width="140" height="120" rx="15" fill="white" />
            
            <!-- Lock Shackle -->
            <path d="M155 180V140C155 115.147 175.147 95 200 95C224.853 95 245 115.147 245 140V180" stroke="white" stroke-width="12" stroke-linecap="round"/>
            
            <!-- Keyhole / Digital Elements -->
            <circle cx="200" cy="230" r="15" fill="var(--primary-color)"/>
            <path d="M200 245V270" stroke="var(--primary-color)" stroke-width="6" stroke-linecap="round"/>
            
            <!-- Floating Elements (Decorations) -->
            <circle cx="320" cy="120" r="8" fill="#14b8a6" class="float-slow"/>
            <circle cx="80" cy="280" r="6" fill="#ec4899" class="float-medium"/>
            <rect x="280" y="280" width="40" height="40" rx="8" fill="rgba(255,255,255,0.2)" class="float-fast"/>
            
            <!-- Shield Badge -->
            <path d="M300 80C300 80 340 95 340 120V140C340 160 300 180 300 180C300 180 260 160 260 140V120C260 95 300 80 300 80Z" fill="#10b981" transform="translate(-20, 20)"/>
            <path d="M290 125L300 135L315 115" stroke="white" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" transform="translate(-20, 20)"/>
          </svg>
          
          <div class="visual-text">
            <h2>Bank-Grade Security</h2>
            <p>Your account is protected by industry-leading encryption and multi-factor authentication.</p>
          </div>
        </div>
      </div>

    </div>
  </section>

</body>
 <!-- Mobile Menu JavaScript -->
  <script>
    // Mobile Menu Toggle
    document.addEventListener('DOMContentLoaded', function() {
      const hamburger = document.getElementById('hamburger');
      const navLinks = document.getElementById('navLinks');
      const navOverlay = document.getElementById('navOverlay');
      
      // Create overlay if it doesn't exist
      if (!navOverlay && hamburger) {
        const overlay = document.createElement('div');
        overlay.className = 'nav-overlay';
        overlay.id = 'navOverlay';
        document.querySelector('nav .nav-container').appendChild(overlay);
      }
      
      // Toggle mobile menu
      function toggleMobileMenu() {
        if (hamburger && navLinks) {
          hamburger.classList.toggle('active');
          navLinks.classList.toggle('active');
          const overlay = document.getElementById('navOverlay');
          if (overlay) overlay.classList.toggle('active');
          document.body.style.overflow = navLinks.classList.contains('active') ? 'hidden' : '';
        }
      }
      
      // Close mobile menu
      function closeMobileMenu() {
        if (hamburger) hamburger.classList.remove('active');
        if (navLinks) navLinks.classList.remove('active');
        const overlay = document.getElementById('navOverlay');
        if (overlay) overlay.classList.remove('active');
        document.body.style.overflow = '';
      }
      
      // Event Listeners
      if (hamburger) {
        hamburger.addEventListener('click', toggleMobileMenu);
      }
      
      // Overlay click to close
      document.addEventListener('click', function(e) {
        const overlay = document.getElementById('navOverlay');
        if (overlay && overlay.classList.contains('active') && e.target === overlay) {
          closeMobileMenu();
        }
      });
      
      // Close menu when clicking on a link
      const navLinksList = document.querySelectorAll('.nav-links a');
      navLinksList.forEach(link => {
        link.addEventListener('click', () => {
          if (window.innerWidth <= 992) {
            closeMobileMenu();
          }
        });
      });
      
      // Close menu on window resize
      window.addEventListener('resize', function() {
        if (window.innerWidth > 992) {
          closeMobileMenu();
        }
      });
      
      // Escape key to close menu
      document.addEventListener('keydown', function(e) {
        if (e.key === 'Escape' && navLinks && navLinks.classList.contains('active')) {
          closeMobileMenu();
        }
      });
    });
  </script><!--Start of Tawk.to Script-->
<script type="text/javascript">
var Tawk_API=Tawk_API||{}, Tawk_LoadStart=new Date();
(function(){
var s1=document.createElement("script"),s0=document.getElementsByTagName("script")[0];
s1.async=true;
s1.src='https://embed.tawk.to/693bf96ef06cff197f812f4c/default';
s1.charset='UTF-8';
s1.setAttribute('crossorigin','*');
s0.parentNode.insertBefore(s1,s0);
})();
</script>
<!--End of Tawk.to Script-->
</html>