<!DOCTYPE html>
<html lang="zh-TW">
<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>TTVS 資科競賽檢定練習系統</title>
  <link rel="icon" href="https://i.imgur.com/P3EVpnQ.png" type="image/png">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.1/normalize.min.css"/>
  <link href="https://fonts.googleapis.com/css2?family=Noto+Sans+TC:wght@400;500;700&family=Material+Icons" rel="stylesheet">
  <script async src="https://www.googletagmanager.com/gtag/js?id=G-XELSWLMFDR"></script>
  <script>
    window.dataLayer = window.dataLayer || [];
    function gtag(){dataLayer.push(arguments);}
    gtag('js', new Date());
    gtag('config', 'G-XELSWLMFDR');
  </script>
  <script src="https://www.gstatic.com/firebasejs/8.0.1/firebase-app.js"></script>
  <script src="https://www.gstatic.com/firebasejs/8.0.1/firebase-database.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jsSHA/3.2.0/sha256.min.js"></script>
  <style>
    body {
      font-family: 'Noto Sans TC', sans-serif;
      background: linear-gradient(135deg, #ece9e6, #ffffff);
      display: flex;
      justify-content: center;
      align-items: center;
      height: 100vh;
      margin: 0;
      background-image: url('https://images.unsplash.com/photo-1506784365847-bbad939e9335?ixlib=rb-4.0.3&auto=format&fit=crop&w=1950&q=80');
      background-size: cover;
      background-position: center;
      position: relative;
    }
    body::before {
      content: '';
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      background-color: rgba(255, 255, 255, 0.85);
      z-index: 0;
    }
    .container {
      position: relative;
      z-index: 1;
      background-color: #ffffff;
      border-radius: 20px;
      box-shadow: 0 20px 50px rgba(0, 0, 0, 0.1);
      padding: 60px 40px;
      max-width: 450px;
      width: 90%;
      transition: all 0.3s ease-in-out;
      animation: fadeIn 1s ease-in-out;
    }
    .form-card {
      padding: 10px 0;
    }
    .tab-title {
      display: flex;
      justify-content: center;
      margin-bottom: 30px;
      border-bottom: 2px solid #e0e0e0;
    }
    .tab-title a {
      text-decoration: none;
      font-weight: 500;
      color: #555555;
      padding: 10px 20px;
      margin: 0 10px;
      position: relative;
      transition: color 0.3s;
      display: flex;
      align-items: center;
    }
    .tab-title a::before {
      content: attr(data-icon);
      font-family: 'Material Icons';
      margin-right: 8px;
      font-size: 18px;
    }
    .tab-title a.active {
      color: #007aff;
      font-weight: 700;
    }
    .tab-title a.active::after {
      content: '';
      position: absolute;
      bottom: -2px;
      left: 50%;
      transform: translateX(-50%);
      width: 100%;
      height: 3px;
      background-color: #007aff;
      border-radius: 2px 2px 0 0;
    }
    .input-group {
      margin-bottom: 25px;
      display: flex;
      flex-direction: column;
      width: 100%;
      position: relative;
    }
    .input-group .material-icons {
      position: absolute;
      top: 50%;
      left: 15px;
      transform: translateY(-50%);
      color: #999999;
      pointer-events: none;
    }
    input.u-full-width {
      width: 100%;
      padding: 15px 20px 15px 45px;
      border: 1px solid #dcdcdc;
      border-radius: 8px;
      font-size: 16px;
      box-sizing: border-box;
      transition: border-color 0.3s, box-shadow 0.3s;
    }
    input.u-full-width:focus {
      border-color: #007aff;
      box-shadow: 0 0 5px rgba(0, 122, 255, 0.3);
      outline: none;
    }
    .button-primary, .button-red {
      width: 100%;
      padding: 12px;
      border: none;
      border-radius: 8px;
      font-size: 16px;
      cursor: pointer;
      transition: background-color 0.3s, transform 0.2s;
      display: flex;
      align-items: center;
      justify-content: center;
    }
    .button-primary {
      background-color: #007aff;
      color: #fff;
    }
    .button-primary:hover {
      background-color: #005bb5;
      transform: translateY(-2px);
    }
    .button-red {
      background-color: #ff4d4d;
      color: #fff;
    }
    .button-red:hover {
      background-color: #e60000;
      transform: translateY(-2px);
    }
    .button-primary:active, .button-red:active {
      transform: translateY(0);
    }
    .text-center {
      text-align: center;
      margin-top: 10px;
    }
    .text-center a {
      color: #007aff;
      text-decoration: none;
      font-weight: 500;
      transition: color 0.3s;
    }
    .text-center a:hover {
      color: #005bb5;
    }
    .error {
      color: #ff4d4d;
      margin-top: 15px;
      text-align: center;
      font-weight: 500;
    }
    .none {
      display: none;
    }
    .user-logged p {
      margin: 10px 0;
      font-size: 16px;
      color: #333333;
    }
    .button-primary::before, .button-red::before {
      font-family: 'Material Icons';
      margin-right: 8px;
    }
    .button-primary#clear-cookies::before {
      content: 'logout';
    }
    .button-primary#change-password::before {
      content: 'lock';
    }
    .button-primary#update-profile::before {
      content: 'person';
    }
    .button-red#back-to-menu::before {
      content: 'home';
    }
    @keyframes fadeIn {
      from { opacity: 0; transform: translateY(-20px); }
      to { opacity: 1; transform: translateY(0); }
    }
    @media (max-width: 480px) {
      .container {
        padding: 40px 20px;
      }
      .tab-title a {
        padding: 8px 15px;
        margin: 0 5px;
        font-size: 14px;
      }
      input.u-full-width {
        padding: 12px 15px 12px 40px;
        font-size: 14px;
      }
      .button-primary, .button-red {
        padding: 10px;
        font-size: 14px;
      }
    }
  </style>
</head>
<body>
  <input id="type" type="hidden" value="signin"/>
  <div class="container">
    <section class="user-null">
      <div class="form-card">
        <div class="tab-title mb-4">
          <a class="active" href="#" id="signin-tab" data-value="signin" data-icon="login">登入</a>
          <a href="#" id="signup-tab" data-value="create" data-icon="person_add">註冊</a>
        </div>
        <div class="input-group mb-4">
          <span class="material-icons">email</span>
          <input class="u-full-width" id="email" type="email" placeholder="輸入電子郵件"/>
        </div>
        <div class="input-group mb-4">
          <span class="material-icons">lock</span>
          <input class="u-full-width" id="password" type="password" placeholder="輸入密碼"/>
        </div>
        <div class="input-group mb-4" id="confirm-password-group" style="display: none;">
          <span class="material-icons">lock_outline</span>
          <input class="u-full-width" id="confirm-password" type="password" placeholder="確認密碼"/>
        </div>
        <div class="input-group mb-4">
          <button class="button button-primary" id="sign-action" type="button">登入</button>
        </div>
        <div class="text-center">
          <a class="text-muted" id="forgot" href="javascript:void(0)">忘記密碼？</a>
        </div>
      </div>
    </section>
    <section class="user-logged none">
      <div class="text-center mb-4">
        <p id="user-email"></p>
        <p id="user-name"></p>
      </div>
      <div class="input-group mb-4">
        <button class="button button-red" id="back-to-menu" type="button">返回系統主選單</button>
      </div>
      <div class="input-group mb-4">
        <button class="button button-primary" id="clear-cookies" type="button">登出</button>
      </div>
      <div class="input-group mb-4">
        <button class="button button-primary" id="change-password" type="button">更改密碼</button>
      </div>
      <div class="input-group mb-4">
        <button class="button button-primary" id="update-profile" type="button">更改個人資料</button>
      </div>
    </section>
    <div class="error" id="error-message"></div>
  </div>

  <script>
    const encodedSrc = "amF2YS9sb2dpbmtrLmpz"; 
    const scriptSrc = atob(encodedSrc);
    const script = document.createElement("script");
    script.src = scriptSrc;
    document.body.appendChild(script);
</script>
</body>
</html>
