@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap");
:root {
    --primaryblack: #1A1A1A;
    --primarygray: #757575;
    --primarywhite: #F8F9FA;
    --secondarywhite: #FFFFFF;
}

* {
  font-family: "Poppins", sans-serif;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  text-decoration: none;
  list-style: none;
}

body {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: var(--primarygray);
}

.container {
  position: relative;
  width: 850px;
  height: 550px;
  background: var(--primarywhite);
  margin: 20px;
  border-radius: 30px;
  box-shadow: 0 0 30px rgba(0, 0, 0, 0.2);
  overflow: hidden;
}

/* ===== GLITCH FIXES ===== */

/* 1. No transitions on first paint — kills the flash on page load.
      The .preload class is removed by JS on window load. */
.container.preload *,
.container.preload .toggle-box::before {
  transition: none !important;
}

/* 2. While the 1.8s sweep is running, swallow all clicks so a fast
      double-tap can't restart the animation halfway through. */
.container.is-animating {
  pointer-events: none;
}

/* 3. The outgoing form must stop catching clicks immediately, not
      after its 0.6s slide finishes. */
.form-box.login,
.container.active .form-box.register {
  pointer-events: auto;
}

.container.active .form-box.login,
.form-box.register {
  pointer-events: none;
}

/* ===== END GLITCH FIXES ===== */

.container h1 {
  font-size: 36px;
  margin: -10px 0;
}

.container p {
  font-size: 14.5px;
  margin: 15px 0;
}

form {
  width: 100%;
}

.form-box {
  position: absolute;
  top: 0;
  width: 50%;
  height: 100%;
  background: var(--primarywhite);
  display: flex;
  justify-content: center;
  align-items: center;
  color: var(--primaryblack);
  text-align: center;
  padding: 40px;
  z-index: 1;
  transition: 0.6s ease-in-out;
}

/* --- LOGIN FORM --- */
.form-box.login {
  right: 0;
}

.container.active .form-box.login {
  right: -50%;
  visibility: hidden;
}

/* --- REGISTER FORM --- */
.form-box.register {
  left: -50%;
  visibility: hidden;
}

.container.active .form-box.register {
  left: 0;
  visibility: visible;
}

.input-box {
  position: relative;
  margin: 30px 0;
}

.input-box input {
  width: 100%;
  padding: 13px 45px 13px 20px;
  background: var(--primarywhite);
  border-radius: 8px;
  border: none;
  outline: none;
  font-size: 16px;
  color: var(--primaryblack);
  font-weight: 500;
}

.input-box input::placeholder {
  font-weight: 400;
  color: var(--primarygray);
}

.input-box i {
  position: absolute;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 20px;
}

/* Password Eye Toggle Icon Fix */
.input-box .toggle-password {
  position: absolute;
  right: 18px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 18px;
  cursor: pointer;
  color: var(--primarygray);
  z-index: 10;
  pointer-events: auto;
}

.input-box .toggle-password:hover {
  color: var(--primaryblack);
}

.forget-link {
  margin: -15px 0 15px;
}

.forget-link a {
  font-size: 14.5px;
  color: #333;
}

.btn {
  width: 100%;
  height: 48px;
  background: var(--primaryblack);
  border-radius: 8px;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
  border: none;
  outline: none;
  cursor: pointer;
  font-size: 16px;
  color: var(--primarywhite);
  font-weight: 600;
}

.toggle-box {
  position: absolute;
  width: 100%;
  height: 100%;
}

.toggle-box::before {
  content: "";
  position: absolute;
  left: -250%;
  width: 300%;
  height: 100%;
  background: var(--primaryblack);
  border-radius: 150px;
  z-index: 2;
  transition: 1.8s ease-in-out;
}

.container.active .toggle-box::before {
  left: 50%;
}

.toggle-panel {
  position: absolute;
  width: 50%;
  height: 100%;
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 2;
  transition: 0.6s ease-in-out;
}

.logo {
    height: 150px;
    width: auto;
    object-fit: contain;
    margin-bottom: 10px;
}

.toggle-panel.toggle-left {
  left: 0;
  transition-delay: 1.2s;
  visibility: visible;
  opacity: 1;
}

.container.active .toggle-panel.toggle-left {
  left: -50%;
  transition-delay: 0.6s;
  visibility: hidden;
  opacity: 0;
}

.toggle-panel.toggle-right {
  right: -50%;
  transition-delay: 0.6s;
  visibility: hidden;
  opacity: 0;
}

.container.active .toggle-panel.toggle-right {
  right: 0;
  transition-delay: 1.2s;
  visibility: visible;
  opacity: 1;
}

.toggle-panel p {
  margin-bottom: 20px;
}

.toggle-panel .btn {
  width: 160px;
  height: 46px;
  background: transparent;
  border: 2px solid #fff;
  box-shadow: none;
}

/* RESPONSIVE */
@media screen and (max-width: 650px) {
  .container {
    height: calc(100vh - 40px);
  }
  .logo {
    height: 55px; 
    margin-bottom: 5px;
  }
  .form-box {
    width: 100%;
    height: 75%;
    bottom: 0;
    padding: 10px 30px;
    justify-content: flex-start;
    align-items: center;
  }
  
  .form-box.login form {
    width: 100%;
    max-width: 320px;
    margin-top: 180px; /* Pulled down further */
  }

  .form-box.register form {
    width: 100%;
    max-width: 320px;
    margin-top: 20px;
  }

  .form-box.login {
    right: 0;
    bottom: 0;
    left: auto;
  }
  .container.active .form-box.login {
    right: 0;
    bottom: -100%;
    left: auto;
  }
  .form-box.register {
    left: 0;
    bottom: -100%;
    visibility: hidden;
    right: auto;
  }
  .container.active .form-box.register {
    bottom: 20px;
    visibility: visible;
    display: flex;
    align-items: center;
    justify-content: center;
    left: 0;
    right: auto;
  }
  .toggle-box::before {
    left: 0;
    top: -270%;
    width: 100%;
    height: 300%;
    border-radius: 20vw;
  }
  .container.active .toggle-box::before {
    left: 0;
    top: 70%;
  }
  .toggle-panel {
    width: 100%;
    height: 30%;
  }
  .toggle-panel.toggle-left {
    top: 0;
    left: 0 !important;
  }
  .container.active .toggle-panel.toggle-left {
    left: 0;
    top: -30%;
  }
  .toggle-panel.toggle-right {
    right: 0;
    bottom: -30%;
    left: auto !important;
  }
  .container.active .toggle-panel.toggle-right {
    bottom: 0;
  }
}

@media screen and (max-width: 400px) {
  .logo {
    height: 40px;
  }
  .form-box {
    padding: 10px 20px;
  }
  
  .form-box.login form {
    margin-top: 320px; /* Pulled down further for smaller screens */
  }

  .form-box.register form {
    margin-top: 10px;
  }

  .container h1 {
    font-size: 28px;
  }
  .input-box input {
    font-size: 14px;
    padding: 12px 45px 12px 15px;
  }
  .btn {
    height: 45px;
    font-size: 14px;
  }
  .toggle-panel p {
    font-size: 13px;
    text-align: center;
  }
}