<?php session_start(); ?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Staff Portal – Collège Saint Joseph</title>
<link href="https://fonts.googleapis.com/css2?family=Cormorant+Garamond:wght@400;600;700&family=Jost:wght@300;400;500&display=swap" rel="stylesheet">
<style>
  *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

  :root {
    --navy:  #1a2942;
    --gold:  #c9a84c;
    --cream: #f7f4ef;
    --white: #ffffff;
    --red:   #9b2335;
    --text:  #2c2c2c;
    --muted: #7a7468;
  }

  body {
    min-height: 100vh;
    background: var(--navy);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Jost', sans-serif;
    position: relative;
    overflow: hidden;
  }

  /* Decorative background pattern */
  body::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
      radial-gradient(ellipse 80% 60% at 20% 50%, rgba(201,168,76,0.08) 0%, transparent 60%),
      radial-gradient(ellipse 60% 80% at 80% 30%, rgba(201,168,76,0.05) 0%, transparent 60%);
    pointer-events: none;
  }

  body::after {
    content: '';
    position: absolute;
    inset: 0;
    background-image: repeating-linear-gradient(
      0deg, transparent, transparent 39px,
      rgba(255,255,255,0.015) 39px, rgba(255,255,255,0.015) 40px
    ),
    repeating-linear-gradient(
      90deg, transparent, transparent 39px,
      rgba(255,255,255,0.015) 39px, rgba(255,255,255,0.015) 40px
    );
    pointer-events: none;
  }

  .card {
    position: relative;
    z-index: 1;
    background: var(--white);
    width: 100%;
    max-width: 420px;
    border-radius: 4px;
    overflow: hidden;
    box-shadow: 0 32px 80px rgba(0,0,0,0.45), 0 0 0 1px rgba(201,168,76,0.2);
    animation: rise 0.6s cubic-bezier(0.16,1,0.3,1) both;
  }

  @keyframes rise {
    from { opacity:0; transform: translateY(24px); }
    to   { opacity:1; transform: translateY(0); }
  }

  /* Gold top accent bar */
  .card-accent {
    height: 4px;
    background: linear-gradient(90deg, var(--gold), #e8c96a, var(--gold));
  }

  /* Header */
  .card-header {
    background: var(--navy);
    padding: 32px 40px 28px;
    text-align: center;
    position: relative;
  }

  .card-header .logo-wrap {
    width: 72px;
    height: 72px;
    margin: 0 auto 16px;
    border-radius: 50%;
    background: rgba(255,255,255,0.06);
    border: 1.5px solid rgba(201,168,76,0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
  }

  .card-header .logo-wrap img {
    width: 60px;
    height: 60px;
    object-fit: contain;
  }

  .card-header h1 {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.45rem;
    font-weight: 700;
    color: var(--white);
    letter-spacing: 0.03em;
    line-height: 1.2;
  }

  .card-header p {
    font-size: 0.72rem;
    color: rgba(255,255,255,0.45);
    margin-top: 5px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    font-weight: 400;
  }

  /* Body */
  .card-body {
    padding: 36px 40px 40px;
    background: var(--white);
  }

  .card-body .access-label {
    font-size: 0.7rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--muted);
    font-weight: 500;
    text-align: center;
    margin-bottom: 28px;
    display: flex;
    align-items: center;
    gap: 10px;
  }

  .card-body .access-label::before,
  .card-body .access-label::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #e0ddd8;
  }

  .field { margin-bottom: 20px; }

  .field label {
    display: block;
    font-size: 0.7rem;
    font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--navy);
    margin-bottom: 7px;
  }

  .field input {
    width: 100%;
    padding: 11px 14px;
    border: 1.5px solid #dedad4;
    border-radius: 3px;
    font-family: 'Jost', sans-serif;
    font-size: 0.9rem;
    color: var(--text);
    background: #faf9f7;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
  }

  .field input:focus {
    border-color: var(--navy);
    box-shadow: 0 0 0 3px rgba(26,41,66,0.08);
    background: var(--white);
  }

  .btn-login {
    width: 100%;
    margin-top: 8px;
    padding: 13px;
    background: var(--navy);
    color: var(--white);
    border: none;
    border-radius: 3px;
    font-family: 'Jost', sans-serif;
    font-size: 0.82rem;
    font-weight: 500;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    cursor: pointer;
    transition: background 0.2s, box-shadow 0.2s;
    position: relative;
    overflow: hidden;
  }

  .btn-login::after {
    content: '';
    position: absolute;
    left: 0; bottom: 0;
    width: 100%; height: 2px;
    background: var(--gold);
    transform: scaleX(0);
    transition: transform 0.3s;
    transform-origin: left;
  }

  .btn-login:hover { background: #243a5e; box-shadow: 0 4px 14px rgba(26,41,66,0.25); }
  .btn-login:hover::after { transform: scaleX(1); }

  .error-msg {
    margin-top: 16px;
    padding: 10px 14px;
    background: #fff0f0;
    border-left: 3px solid var(--red);
    border-radius: 2px;
    font-size: 0.82rem;
    color: var(--red);
    font-weight: 500;
  }

  .card-footer {
    padding: 14px 40px;
    background: #f7f4ef;
    border-top: 1px solid #ede9e2;
    text-align: center;
    font-size: 0.68rem;
    color: var(--muted);
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }
</style>
</head>
<body>

<div class="card">
  <div class="card-accent"></div>

  <div class="card-header">
    <div class="logo-wrap">
      <img src="logo.jpg" alt="School Logo" onerror="this.style.display='none'">
    </div>
    <h1>Collège Saint Joseph</h1>
    <p>Staff Portal</p>
  </div>

  <div class="card-body">
    <span class="access-label">Authorized Access Only</span>

    <form method="post" action="menuprofEn.php">
      <div class="field">
        <label for="login">Username</label>
        <input type="text" id="login" name="login" placeholder="Enter your username" autocomplete="username" onclick="this.value=''">
      </div>
      <div class="field">
        <label for="pass">Password</label>
        <input type="password" id="pass" name="pass" placeholder="••••••••" autocomplete="current-password" onclick="this.value=''">
      </div>
      <button type="submit" name="envoi" class="btn-login">Sign In</button>

      <?php
      if (isset($_POST['envoi'])) {
        $login = $_POST['login'];
        $pass  = $_POST['pass'];
        include("_serveur.php");
        $sql = 'SELECT * FROM users WHERE username="' . $login . '" AND password="' . $pass . '" AND type=2';
        $req  = mysqli_query($link, $sql);
        if ($data = mysqli_fetch_array($req)) {
          $id = $data['id'];
          $_SESSION['id'] = $id;
          echo '<META HTTP-EQUIV="Refresh" Content="0; URL=menuprofsadminEn.php">';
        } else {
          echo '<div class="error-msg">Invalid username or password. Please try again.</div>';
        }
      }
      ?>
    </form>
  </div>

  <div class="card-footer">Collège Saint Joseph &mdash; Miniara &nbsp;|&nbsp; <?php echo date('Y'); ?></div>
</div>

</body>
</html>
