// Copyright.jsx
import React, { useState, useEffect } from "react";

export default function Copyright({ isLoginPage, isLoggedIn }) {
  const [isCentered, setIsCentered] = useState(true);

  useEffect(() => {
    if (isLoginPage) {
      // On login page, start centered then transition to bottom
      const timer = setTimeout(() => {
        setIsCentered(false);
      }, 1000);
      return () => clearTimeout(timer);
    } else {
      // Not on login page, go to bottom immediately
      setIsCentered(false);
    }
  }, [isLoginPage]);

  // Show copyright on login page with transition, or at bottom after login
  if (!isLoginPage && !isLoggedIn) {
    return null;
  }

  return (
    <div
      style={{
        textAlign: "center",
        marginTop: "1rem",
        transition: "all 0.8s ease-in-out",
        position: isLoginPage ? "fixed" : "relative",
        top: isLoginPage ? (isCentered ? "65%" : "90%") : "auto",
        left: isLoginPage ? "50%" : "auto",
        transform: isLoginPage ? "translate(-50%, -50%)" : "none"
      }}
    >
      <p>
        &copy; 2025 Derek L. Seitz{"  |  "}
        <a href="https://dlseitz.dev" target="_blank" rel="noopener noreferrer" style={{ 
          color: '#d94f27', 
          textDecoration: 'none',
          transition: 'color 0.2s ease'
        }}
        onMouseEnter={(e) => e.target.style.color = '#ff6f48'}
        onMouseLeave={(e) => e.target.style.color = '#d94f27'}>
          dlseitz.dev
        </a>{"  |  "}All Rights Reserved
      </p>
    </div>
  );
}
