import React, { useState } from 'react';
import './LoginForm.css';

function LoginForm() {
  const [loginVisible, setLoginVisible] = useState(true);

  const toggleLogin = () => {
    setLoginVisible(true);
  };

  const toggleRegister = () => {
    setLoginVisible(false);
  };

  return (
    <>
      <div className="wrapper">

        <div className="form-box">

          <div className="login-container" id="login" style={{ left: loginVisible ? '4px' : '-510px', opacity: loginVisible ? 1 : 0 }}>
            <div className="top">
              <span>No tienes cuenta? <a href="#" onClick={toggleRegister}>Registrate</a></span>
              <header>Inicia Sesión</header>
            </div>
            <div className="input-box">
              <input type="text" className="input-field" placeholder="Correo" />
              <i className="bx bx-user"></i>
            </div>
            <div className="input-box">
              <input type="password" className="input-field" placeholder="Contraseña" />
              <i className="bx bx-lock-alt"></i>
            </div>
            <div className="input-box">
              <input type="submit" className="submit" value="Entrar" />
            </div>
            <div className="two-col">
              <div className="one">
                <input type="checkbox" id="login-check" />
                <label htmlFor="login-check"> Recuerdame</label>
              </div>
              <div className="two">
                <label><a href="#">Olvidaste la contraseña?</a></label>
              </div>
            </div>
          </div>

          <div className="register-container" id="register" style={{ right: loginVisible ? '-520px' : '5px', opacity: loginVisible ? 0 : 1 }}>
            <div className="top">
              <span>Ya tienes cuenta? <a href="#" onClick={toggleLogin}>Inicia Sesión</a></span>
              <header>Registrarse</header>
            </div>
            <div className="two-forms">
              <div className="input-box">
                <input type="text" className="input-field" placeholder="Nombre" />
                <i className="bx bx-user"></i>
              </div>
              <div className="input-box">
                <input type="text" className="input-field" placeholder="Apellido" />
                <i className="bx bx-user"></i>
              </div>
            </div>
            <div className="input-box">
              <input type="text" className="input-field" placeholder="Correo" />
              <i className="bx bx-envelope"></i>
            </div>
            <div className="input-box">
              <input type="password" className="input-field" placeholder="Contraseña" />
              <i className="bx bx-lock-alt"></i>
            </div>
            <div className="input-box">
              <input type="submit" className="submit" value="Registrarse" />
            </div>
            <div className="two-col">
              <div className="one">
                <input type="checkbox" id="register-check" />
                <label htmlFor="register-check"> Recuerdame</label>
              </div>
            </div>
          </div>
        </div>
      </div>
    </>
  );
}

export default LoginForm;
