"use client";

import { useState } from "react";
import Link from "next/navigation";
import { useRouter } from "next/navigation";

type HeroImage = {
  id: number;
  image: string;
  heroId: number;
  createdAt: Date;
};

type HeroFormProps = {
  hero: {
    id: number;
    badge: string | null;
    title: string;
    highlight: string | null;
    description: string | null;
    primaryButtonText: string | null;
    primaryButtonUrl: string | null;
    secondaryButtonText: string | null;
    secondaryButtonUrl: string | null;
    photo: string | null;
    githubUrl: string | null;
    linkedinUrl: string | null;
    email: string | null;
    cv: string | null;
    active: boolean;
    heroimage: HeroImage[];
  };
};

export default function EditHeroForm({ hero }: HeroFormProps) {
  const router = useRouter();
  const [sidebarOpen, setSidebarOpen] = useState(false);

  const [badge, setBadge] = useState(hero.badge ?? "");
  const [title, setTitle] = useState(hero.title);
  const [highlight, setHighlight] = useState(hero.highlight ?? "");
  const [description, setDescription] = useState(
    hero.description ?? ""
  );

  const [primaryButtonText, setPrimaryButtonText] = useState(
    hero.primaryButtonText ?? ""
  );

  const [primaryButtonUrl, setPrimaryButtonUrl] = useState(
    hero.primaryButtonUrl ?? ""
  );

  const [secondaryButtonText, setSecondaryButtonText] = useState(
    hero.secondaryButtonText ?? ""
  );

  const [secondaryButtonUrl, setSecondaryButtonUrl] = useState(
    hero.secondaryButtonUrl ?? ""
  );

  const [githubUrl, setGithubUrl] = useState(
    hero.githubUrl ?? ""
  );

  const [linkedinUrl, setLinkedinUrl] = useState(
    hero.linkedinUrl ?? ""
  );

  const [email, setEmail] = useState(hero.email ?? "");

  const [active, setActive] = useState(hero.active);

  const [heroImages, setHeroImages] = useState<HeroImage[]>(
    hero.heroimage ?? []
  );

  const [newPhotoFiles, setNewPhotoFiles] = useState<File[]>(
    []
  );

  const [newPhotoPreviews, setNewPhotoPreviews] = useState<
    string[]
  >([]);

  const [cvFile, setCvFile] = useState<File | null>(null);

  const [loading, setLoading] = useState(false);
  const [message, setMessage] = useState("");
  const [error, setError] = useState("");

  // =====================================================
  // PILIH FOTO BARU
  // =====================================================

  function handlePhotoChange(
    e: React.ChangeEvent<HTMLInputElement>
  ) {
    const files = Array.from(e.target.files || []);

    if (files.length === 0) {
      return;
    }

    const imageFiles = files.filter((file) =>
      file.type.startsWith("image/")
    );

    if (imageFiles.length !== files.length) {
      setError("Semua file harus berupa gambar.");
      return;
    }

    setError("");

    setNewPhotoFiles(imageFiles);

    const previews = imageFiles.map((file) =>
      URL.createObjectURL(file)
    );

    setNewPhotoPreviews(previews);
  }

  // =====================================================
  // PILIH CV
  // =====================================================

  function handleCvChange(
    e: React.ChangeEvent<HTMLInputElement>
  ) {
    const file = e.target.files?.[0] || null;

    if (!file) {
      setCvFile(null);
      return;
    }

    if (file.type !== "application/pdf") {
      setError("File CV harus berupa PDF.");
      e.target.value = "";
      return;
    }

    setError("");
    setCvFile(file);
  }

  // =====================================================
  // HAPUS FOTO HERO
  // =====================================================

  async function handleDeleteImage(imageId: number) {
    const confirmed = window.confirm(
      "Apakah Anda yakin ingin menghapus foto ini?"
    );

    if (!confirmed) {
      return;
    }

    try {
      setError("");

      const response = await fetch(
        `/api/hero/images?id=${imageId}`,
        {
          method: "DELETE",
        }
      );

      const result = await response.json();

      if (!response.ok || !result.success) {
        throw new Error(
          result.message || "Gagal menghapus foto."
        );
      }

      setHeroImages((prev) =>
        prev.filter((image) => image.id !== imageId)
      );

      setMessage("Foto berhasil dihapus.");
    } catch (error) {
      console.error(error);

      setError(
        error instanceof Error
          ? error.message
          : "Gagal menghapus foto."
      );
    }
  }

  // =====================================================
  // UPLOAD FOTO
  // =====================================================

  async function uploadPhotos() {
    const uploadedPhotos: string[] = [];

    for (const file of newPhotoFiles) {
      const formData = new FormData();

      formData.append("file", file);

      const response = await fetch(
        "/api/hero/upload",
        {
          method: "POST",
          body: formData,
        }
      );

      const result = await response.json();

      if (!response.ok || !result.success) {
        throw new Error(
          result.message || "Gagal upload foto Hero."
        );
      }

      uploadedPhotos.push(result.data);
    }

    return uploadedPhotos;
  }

  // =====================================================
  // UPLOAD CV
  // =====================================================

  async function uploadCv() {
    if (!cvFile) {
      return hero.cv ?? "";
    }

    const formData = new FormData();

    formData.append("file", cvFile);

    const response = await fetch(
      "/api/hero/cv",
      {
        method: "POST",
        body: formData,
      }
    );

    const result = await response.json();

    if (!response.ok || !result.success) {
      throw new Error(
        result.message || "Gagal upload CV."
      );
    }

    return result.data;
  }

  // =====================================================
  // SUBMIT
  // =====================================================

  async function handleSubmit(
    e: React.FormEvent<HTMLFormElement>
  ) {
    e.preventDefault();

    setLoading(true);
    setMessage("");
    setError("");

    try {
      // -----------------------------------------------
      // 1. UPDATE DATA HERO
      // -----------------------------------------------

      const cvUrl = await uploadCv();

      const response = await fetch(
        "/api/hero",
        {
          method: "PUT",
          headers: {
            "Content-Type": "application/json",
          },
          body: JSON.stringify({
            id: hero.id,
            badge,
            title,
            highlight,
            description,
            primaryButtonText,
            primaryButtonUrl,
            secondaryButtonText,
            secondaryButtonUrl,
            githubUrl: githubUrl || null,
            linkedinUrl: linkedinUrl || null,
            email: email || null,
            cv: cvUrl || null,
            active,
          }),
        }
      );

      const result = await response.json();

      if (!response.ok || !result.success) {
        throw new Error(
          result.message || "Gagal memperbarui Hero."
        );
      }

      // -----------------------------------------------
      // 2. UPLOAD FOTO BARU
      // -----------------------------------------------

      if (newPhotoFiles.length > 0) {
        const uploadedPhotos = await uploadPhotos();

        for (const image of uploadedPhotos) {
          const imageResponse = await fetch(
            "/api/hero/images",
            {
              method: "POST",
              headers: {
                "Content-Type": "application/json",
              },
              body: JSON.stringify({
                heroId: hero.id,
                image,
              }),
            }
          );

          const imageResult =
            await imageResponse.json();

          if (
            !imageResponse.ok ||
            !imageResult.success
          ) {
            throw new Error(
              imageResult.message ||
                "Gagal menyimpan foto Hero."
            );
          }

          setHeroImages((prev) => [
            ...prev,
            imageResult.data,
          ]);
        }
      }

      setNewPhotoFiles([]);
      setNewPhotoPreviews([]);

      setCvFile(null);

      setMessage("Hero berhasil diperbarui.");

      setTimeout(() => {
        router.push("/secure-panel/hero");
      }, 500);
    } catch (error) {
      console.error(
        "UPDATE HERO ERROR:",
        error
      );

      setError(
        error instanceof Error
          ? error.message
          : "Gagal memperbarui Hero."
      );
    } finally {
      setLoading(false);
    }
  }

  return (
    <>
      <style>{`
        * {
          box-sizing: border-box;
        }

        html,
        body {
          margin: 0;
          padding: 0;
          max-width: 100%;
          overflow-x: hidden;
        }

        body {
          background: #f5f7fb;
        }

        button,
        a,
        input,
        textarea {
          -webkit-tap-highlight-color: transparent;
        }

        .hero-edit-page {
          min-height: 100vh;
          width: 100%;
          background: #f5f7fb;
          color: #1f2937;
        }

        .admin-layout {
          min-height: 100vh;
          width: 100%;
          display: flex;
          position: relative;
        }

        /* =====================================================
           SIDEBAR
        ===================================================== */

        .admin-sidebar {
          width: 270px;
          min-width: 270px;
          height: 100vh;
          position: fixed;
          top: 0;
          left: 0;
          z-index: 1050;
          background: #ffffff;
          border-right: 1px solid #e8ecf1;
          transition: transform 0.3s ease;
        }

        .sidebar-inner {
          height: 100%;
          display: flex;
          flex-direction: column;
          padding: 24px 16px;
          overflow-y: auto;
          overflow-x: hidden;
        }

        .sidebar-brand {
          display: flex;
          align-items: center;
          gap: 12px;
          padding: 4px 10px 28px;
          border-bottom: 1px solid #edf0f4;
          margin-bottom: 22px;
        }

        .brand-icon {
          width: 42px;
          height: 42px;
          min-width: 42px;
          border-radius: 12px;
          display: flex;
          align-items: center;
          justify-content: center;
          background: linear-gradient(
            135deg,
            #198754,
            #20c997
          );
          color: #ffffff;
          font-size: 18px;
          box-shadow:
            0 8px 20px rgba(25, 135, 84, 0.2);
        }

        .brand-text {
          min-width: 0;
        }

        .brand-text strong {
          display: block;
          font-size: 16px;
          line-height: 1.2;
          color: #17202a;
        }

        .brand-text span {
          display: block;
          margin-top: 3px;
          font-size: 11px;
          color: #8b95a5;
          font-weight: 600;
          letter-spacing: 0.08em;
          text-transform: uppercase;
        }

        .sidebar-close {
          margin-left: auto;
          border: 0;
          background: transparent;
          color: #7b8492;
          font-size: 17px;
          cursor: pointer;
          padding: 5px;
        }

        .sidebar-section-label {
          padding: 0 12px;
          margin-bottom: 8px;
          color: #9aa3af;
          font-size: 10px;
          font-weight: 700;
          letter-spacing: 0.1em;
        }

        .sidebar-nav {
          display: flex;
          flex-direction: column;
          gap: 4px;
        }

        .sidebar-link {
          display: flex;
          align-items: center;
          gap: 12px;
          min-height: 44px;
          padding: 10px 12px;
          border-radius: 11px;
          color: #697386;
          text-decoration: none;
          font-size: 14px;
          font-weight: 500;
          transition:
            background 0.2s ease,
            color 0.2s ease,
            transform 0.2s ease;
        }

        .sidebar-link:hover {
          background: #f0f8f4;
          color: #198754;
          transform: translateX(2px);
        }

        .sidebar-link.active {
          background: linear-gradient(
            90deg,
            rgba(25, 135, 84, 0.12),
            rgba(25, 135, 84, 0.06)
          );
          color: #198754;
          font-weight: 700;
        }

        .sidebar-link-icon {
          width: 23px;
          min-width: 23px;
          text-align: center;
          font-size: 16px;
          flex-shrink: 0;
        }

        .sidebar-bottom {
          margin-top: auto;
          padding-top: 18px;
          border-top: 1px solid #edf0f4;
        }

        .sidebar-bottom a {
          display: flex;
          align-items: center;
          gap: 10px;
          padding: 11px 12px;
          border-radius: 10px;
          color: #6b7280;
          text-decoration: none;
          font-size: 13px;
          transition: 0.2s ease;
        }

        .sidebar-bottom a:hover {
          background: #f5f7fa;
          color: #198754;
        }

        /* =====================================================
           MAIN
        ===================================================== */

        .admin-main {
          width: calc(100% - 270px);
          margin-left: 270px;
          min-width: 0;
        }

        /* =====================================================
           TOPBAR
        ===================================================== */

        .admin-topbar {
          width: 100%;
          height: 76px;
          background: rgba(255, 255, 255, 0.96);
          border-bottom: 1px solid #e9edf2;
          display: flex;
          align-items: center;
          justify-content: space-between;
          gap: 15px;
          padding: 0 34px;
          position: sticky;
          top: 0;
          z-index: 900;
          backdrop-filter: blur(12px);
        }

        .topbar-left {
          display: flex;
          align-items: center;
          gap: 14px;
          min-width: 0;
        }

        .mobile-menu-button {
          width: 40px;
          height: 40px;
          border: 1px solid #e2e7ed;
          background: #ffffff;
          border-radius: 10px;
          color: #344054;
          font-size: 18px;
          cursor: pointer;
          transition: 0.2s ease;
          flex-shrink: 0;
        }

        .mobile-menu-button:hover {
          background: #f5f8f6;
          color: #198754;
          border-color: #cde5d7;
        }

        .topbar-left > div:last-child {
          min-width: 0;
        }

        .topbar-label {
          color: #9aa3af;
          font-size: 10px;
          font-weight: 700;
          letter-spacing: 0.1em;
          margin-bottom: 3px;
        }

        .topbar-title {
          color: #17202a;
          font-size: 15px;
          font-weight: 700;
          white-space: nowrap;
        }

        .topbar-right {
          display: flex;
          align-items: center;
          gap: 10px;
          flex-shrink: 0;
        }

        .topbar-website,
        .topbar-logout {
          min-height: 40px;
          display: inline-flex;
          align-items: center;
          justify-content: center;
          gap: 8px;
          border-radius: 10px;
          padding: 8px 13px;
          text-decoration: none;
          font-size: 13px;
          font-weight: 600;
          transition: 0.2s ease;
          white-space: nowrap;
        }

        .topbar-website {
          color: #667085;
          border: 1px solid #e4e8ed;
          background: #ffffff;
        }

        .topbar-website:hover {
          color: #198754;
          border-color: #b7ddca;
          background: #f4fbf7;
        }

        .topbar-logout {
          color: #dc3545;
          border: 1px solid #f1c4c9;
          background: #ffffff;
        }

        .topbar-logout:hover {
          background: #fff5f6;
          border-color: #e8aeb5;
        }

        /* =====================================================
           CONTENT
        ===================================================== */

        .admin-content {
          width: 100%;
          max-width: 1550px;
          margin: 0 auto;
          padding: 34px;
          animation: contentEnter 0.45s ease both;
        }

        @keyframes contentEnter {
          from {
            opacity: 0;
            transform: translateY(10px);
          }

          to {
            opacity: 1;
            transform: translateY(0);
          }
        }

        /* =====================================================
           PAGE HEADER
        ===================================================== */

        .page-header {
          display: flex;
          align-items: flex-end;
          justify-content: space-between;
          gap: 25px;
          margin-bottom: 28px;
        }

        .page-header-left {
          min-width: 0;
          flex: 1;
        }

        .page-eyebrow {
          display: flex;
          align-items: center;
          gap: 7px;
          color: #198754;
          font-size: 10px;
          font-weight: 800;
          letter-spacing: 0.11em;
          margin-bottom: 8px;
        }

        .page-eyebrow-dot {
          width: 6px;
          height: 6px;
          border-radius: 50%;
          background: #20c997;
          flex-shrink: 0;
        }

        .page-title-row {
          display: flex;
          align-items: flex-start;
          gap: 15px;
        }

        .page-title-icon {
          width: 56px;
          height: 56px;
          min-width: 56px;
          border-radius: 15px;
          background: linear-gradient(
            135deg,
            rgba(25, 135, 84, 0.13),
            rgba(32, 201, 151, 0.08)
          );
          color: #198754;
          display: flex;
          align-items: center;
          justify-content: center;
          font-size: 23px;
          flex-shrink: 0;
        }

        .page-title {
          margin: 0;
          font-size: clamp(26px, 3vw, 35px);
          font-weight: 800;
          letter-spacing: -0.025em;
          color: #182230;
          line-height: 1.15;
        }

        .page-description {
          margin: 8px 0 0;
          color: #7a8493;
          font-size: 13px;
          line-height: 1.7;
          max-width: 760px;
          text-align: justify;
          text-justify: inter-word;
          overflow-wrap: anywhere;
        }

        .back-button {
          min-height: 44px;
          display: inline-flex;
          align-items: center;
          justify-content: center;
          gap: 8px;
          padding: 9px 15px;
          border-radius: 10px;
          color: #667085;
          background: #ffffff;
          border: 1px solid #e0e5ea;
          text-decoration: none;
          font-size: 12px;
          font-weight: 700;
          white-space: nowrap;
          transition: 0.2s ease;
          flex-shrink: 0;
        }

        .back-button:hover {
          color: #198754;
          background: #f4fbf7;
          border-color: #b7ddca;
        }

        /* =====================================================
           FORM WRAPPER
        ===================================================== */

        .form-wrapper {
          width: 100%;
        }

        .form-card {
          width: 100%;
          background: #ffffff;
          border: 1px solid #e5e9ee;
          border-radius: 18px;
          overflow: hidden;
          box-shadow:
            0 8px 30px rgba(20, 30, 45, 0.045),
            0 2px 8px rgba(20, 30, 45, 0.025);
        }

        .form-section {
          padding: 26px 28px;
          border-bottom: 1px solid #edf0f3;
        }

        .form-section:last-child {
          border-bottom: 0;
        }

        .section-heading {
          display: flex;
          align-items: flex-start;
          gap: 13px;
          margin-bottom: 23px;
        }

        .section-icon {
          width: 42px;
          height: 42px;
          min-width: 42px;
          border-radius: 11px;
          background: #eaf7f0;
          color: #198754;
          display: flex;
          align-items: center;
          justify-content: center;
          font-size: 17px;
        }

        .section-heading-content {
          min-width: 0;
        }

        .section-title {
          margin: 0;
          color: #202b38;
          font-size: 15px;
          font-weight: 800;
          line-height: 1.35;
        }

        .section-description {
          margin: 4px 0 0;
          color: #929baa;
          font-size: 11px;
          line-height: 1.65;
          text-align: justify;
          text-justify: inter-word;
          overflow-wrap: anywhere;
        }

        /* =====================================================
           FORM GRID
        ===================================================== */

        .form-grid {
          display: grid;
          grid-template-columns: repeat(2, minmax(0, 1fr));
          gap: 19px;
        }

        .form-group {
          min-width: 0;
        }

        .form-group.full {
          grid-column: 1 / -1;
        }

        .form-label-custom {
          display: flex;
          align-items: center;
          gap: 6px;
          margin-bottom: 7px;
          color: #344054;
          font-size: 11px;
          font-weight: 750;
        }

        .required-mark {
          color: #dc3545;
        }

        .form-control-custom {
          width: 100%;
          min-height: 43px;
          padding: 10px 12px;
          border: 1px solid #dfe4e9;
          border-radius: 9px;
          background: #ffffff;
          color: #27313d;
          font-size: 12px;
          outline: none;
          transition:
            border-color 0.2s ease,
            box-shadow 0.2s ease,
            background 0.2s ease;
        }

        .form-control-custom::placeholder {
          color: #a3abb5;
        }

        .form-control-custom:hover {
          border-color: #c7ced6;
        }

        .form-control-custom:focus {
          border-color: #55ad82;
          background: #ffffff;
          box-shadow:
            0 0 0 3px rgba(25, 135, 84, 0.09);
        }

        textarea.form-control-custom {
          min-height: 125px;
          resize: vertical;
          line-height: 1.7;
          text-align: justify;
          text-justify: inter-word;
        }

        .form-help {
          margin-top: 6px;
          color: #9aa3af;
          font-size: 10px;
          line-height: 1.6;
          text-align: justify;
          text-justify: inter-word;
        }

        /* =====================================================
           IMAGE GRID
        ===================================================== */

        .image-grid {
          display: grid;
          grid-template-columns: repeat(
            4,
            minmax(0, 1fr)
          );
          gap: 15px;
        }

        .image-card {
          min-width: 0;
          background: #ffffff;
          border: 1px solid #e4e9ee;
          border-radius: 13px;
          overflow: hidden;
          box-shadow:
            0 4px 15px rgba(20, 30, 45, 0.035);
          transition:
            transform 0.2s ease,
            box-shadow 0.2s ease;
        }

        .image-card:hover {
          transform: translateY(-2px);
          box-shadow:
            0 8px 22px rgba(20, 30, 45, 0.07);
        }

        .image-preview-wrapper {
          position: relative;
          width: 100%;
          background: #f4f6f8;
        }

        .image-preview {
          display: block;
          width: 100%;
          height: 175px;
          object-fit: cover;
        }

        .image-number {
          position: absolute;
          top: 9px;
          left: 9px;
          min-width: 27px;
          height: 27px;
          padding: 0 7px;
          display: inline-flex;
          align-items: center;
          justify-content: center;
          border-radius: 8px;
          background: rgba(25, 135, 84, 0.95);
          color: #ffffff;
          font-size: 9px;
          font-weight: 800;
          box-shadow:
            0 3px 10px rgba(0, 0, 0, 0.12);
        }

        .image-card-body {
          padding: 10px;
        }

        .delete-image-button {
          width: 100%;
          min-height: 36px;
          display: inline-flex;
          align-items: center;
          justify-content: center;
          gap: 6px;
          padding: 7px 9px;
          border-radius: 8px;
          background: #ffffff;
          border: 1px solid #f1c4c9;
          color: #dc3545;
          font-size: 10px;
          font-weight: 700;
          cursor: pointer;
          transition: 0.2s ease;
        }

        .delete-image-button:hover {
          background: #fff5f6;
          border-color: #e8aeb5;
          color: #bb2d3b;
        }

        .empty-images {
          display: flex;
          align-items: center;
          gap: 12px;
          padding: 16px;
          border: 1px dashed #dce2e8;
          border-radius: 11px;
          background: #fafbfc;
        }

        .empty-images-icon {
          width: 39px;
          height: 39px;
          min-width: 39px;
          display: flex;
          align-items: center;
          justify-content: center;
          border-radius: 10px;
          background: #f0f2f4;
          color: #8d96a2;
        }

        .empty-images-text {
          color: #8d96a2;
          font-size: 11px;
          line-height: 1.6;
          text-align: justify;
          text-justify: inter-word;
        }

        /* =====================================================
           UPLOAD AREA
        ===================================================== */

        .upload-box {
          padding: 17px;
          border: 1px dashed #cfd8d2;
          border-radius: 12px;
          background: #fbfdfc;
        }

        .file-input {
          width: 100%;
          min-height: 43px;
          padding: 8px 10px;
          border: 1px solid #dfe4e9;
          border-radius: 9px;
          background: #ffffff;
          color: #475467;
          font-size: 11px;
        }

        .file-input:focus {
          outline: none;
          border-color: #55ad82;
          box-shadow:
            0 0 0 3px rgba(25, 135, 84, 0.09);
        }

        .new-preview-title {
          margin-bottom: 10px;
          color: #344054;
          font-size: 11px;
          font-weight: 750;
        }

        .new-image-grid {
          display: grid;
          grid-template-columns: repeat(
            4,
            minmax(0, 1fr)
          );
          gap: 13px;
        }

        .new-image-preview {
          position: relative;
          overflow: hidden;
          border-radius: 11px;
          border: 1px solid #dfe5e9;
          background: #f5f7f8;
        }

        .new-image-preview img {
          display: block;
          width: 100%;
          height: 145px;
          object-fit: cover;
        }

        .new-image-label {
          position: absolute;
          top: 8px;
          left: 8px;
          padding: 5px 8px;
          border-radius: 7px;
          background: rgba(25, 135, 84, 0.94);
          color: #ffffff;
          font-size: 8px;
          font-weight: 800;
        }

        /* =====================================================
           BUTTON SETTINGS
        ===================================================== */

        .button-section {
          padding: 15px;
          border: 1px solid #e6ebef;
          border-radius: 12px;
          background: #fbfcfd;
        }

        .button-section + .button-section {
          margin-top: 13px;
        }

        .button-section-header {
          display: flex;
          align-items: center;
          gap: 9px;
          margin-bottom: 14px;
        }

        .button-section-icon {
          width: 34px;
          height: 34px;
          min-width: 34px;
          border-radius: 9px;
          display: flex;
          align-items: center;
          justify-content: center;
          background: #eaf7f0;
          color: #198754;
          font-size: 14px;
        }

        .button-section-title {
          color: #344054;
          font-size: 12px;
          font-weight: 800;
        }

        .button-grid {
          display: grid;
          grid-template-columns: repeat(
            2,
            minmax(0, 1fr)
          );
          gap: 14px;
        }

        /* =====================================================
           SOCIAL
        ===================================================== */

        .social-input-wrapper {
          position: relative;
        }

        .social-icon {
          position: absolute;
          left: 12px;
          top: 50%;
          transform: translateY(-50%);
          z-index: 2;
          color: #7b8492;
          font-size: 14px;
          pointer-events: none;
        }

        .social-input {
          padding-left: 37px;
        }

        /* =====================================================
           CV
        ===================================================== */

        .cv-current {
          display: flex;
          align-items: center;
          gap: 12px;
          margin-top: 12px;
          padding: 13px;
          border: 1px solid #e0e5e9;
          border-radius: 10px;
          background: #f8fafb;
        }

        .cv-icon {
          width: 40px;
          height: 40px;
          min-width: 40px;
          display: flex;
          align-items: center;
          justify-content: center;
          border-radius: 10px;
          background: #fff0f1;
          color: #dc3545;
          font-size: 17px;
        }

        .cv-info {
          min-width: 0;
        }

        .cv-info-title {
          color: #344054;
          font-size: 11px;
          font-weight: 750;
        }

        .cv-info-description {
          margin-top: 2px;
          color: #929baa;
          font-size: 10px;
          line-height: 1.55;
          text-align: justify;
          text-justify: inter-word;
        }

        .cv-selected {
          display: flex;
          align-items: center;
          gap: 10px;
          margin-top: 12px;
          padding: 12px;
          border: 1px solid #bfe3cd;
          border-radius: 10px;
          background: #f0faf4;
          color: #198754;
        }

        .cv-selected i {
          font-size: 16px;
          flex-shrink: 0;
        }

        .cv-selected-content {
          min-width: 0;
        }

        .cv-selected-name {
          display: block;
          color: #198754;
          font-size: 11px;
          font-weight: 800;
          overflow-wrap: anywhere;
        }

        .cv-selected-text {
          margin-top: 2px;
          color: #6f8e7b;
          font-size: 9px;
        }

        /* =====================================================
           ACTIVE
        ===================================================== */

        .active-box {
          display: flex;
          align-items: center;
          justify-content: space-between;
          gap: 15px;
          padding: 16px;
          border: 1px solid #e2e7eb;
          border-radius: 12px;
          background: #ffffff;
        }

        .active-info {
          min-width: 0;
        }

        .active-title {
          color: #344054;
          font-size: 12px;
          font-weight: 800;
        }

        .active-description {
          margin-top: 3px;
          color: #929baa;
          font-size: 10px;
          line-height: 1.6;
          text-align: justify;
          text-justify: inter-word;
        }

        .custom-switch {
          width: 46px;
          height: 24px;
          min-width: 46px;
          position: relative;
          display: inline-block;
        }

        .custom-switch input {
          opacity: 0;
          width: 0;
          height: 0;
        }

        .switch-slider {
          position: absolute;
          inset: 0;
          cursor: pointer;
          border-radius: 50px;
          background: #d9dee4;
          transition: 0.25s ease;
        }

        .switch-slider::before {
          content: "";
          position: absolute;
          width: 18px;
          height: 18px;
          left: 3px;
          top: 3px;
          border-radius: 50%;
          background: #ffffff;
          box-shadow:
            0 2px 5px rgba(0, 0, 0, 0.16);
          transition: 0.25s ease;
        }

        .custom-switch input:checked
          + .switch-slider {
          background: #198754;
        }

        .custom-switch input:checked
          + .switch-slider::before {
          transform: translateX(22px);
        }

        /* =====================================================
           ALERTS
        ===================================================== */

        .alert-custom {
          display: flex;
          align-items: flex-start;
          gap: 10px;
          margin: 0 28px 18px;
          padding: 13px 14px;
          border-radius: 10px;
          font-size: 11px;
          line-height: 1.6;
        }

        .alert-custom i {
          margin-top: 1px;
          flex-shrink: 0;
          font-size: 14px;
        }

        .alert-error {
          color: #b02a37;
          background: #fff5f6;
          border: 1px solid #f1c4c9;
        }

        .alert-success {
          color: #146c43;
          background: #effaf4;
          border: 1px solid #bfe3cd;
        }

        .alert-text {
          min-width: 0;
          text-align: justify;
          text-justify: inter-word;
          overflow-wrap: anywhere;
        }

        /* =====================================================
           FORM ACTIONS
        ===================================================== */

        .form-actions {
          display: flex;
          align-items: center;
          justify-content: space-between;
          gap: 15px;
          padding: 20px 28px;
          background: #fcfdfd;
          border-top: 1px solid #edf0f3;
        }

        .form-actions-left {
          min-width: 0;
        }

        .save-info {
          display: flex;
          align-items: center;
          gap: 7px;
          color: #929baa;
          font-size: 10px;
        }

        .save-info i {
          color: #198754;
        }

        .form-actions-right {
          display: flex;
          align-items: center;
          gap: 8px;
          flex-shrink: 0;
        }

        .action-button {
          min-height: 42px;
          display: inline-flex;
          align-items: center;
          justify-content: center;
          gap: 8px;
          padding: 9px 15px;
          border-radius: 9px;
          font-size: 11px;
          font-weight: 750;
          text-decoration: none;
          cursor: pointer;
          transition: 0.2s ease;
          white-space: nowrap;
        }

        .save-button {
          border: 1px solid #198754;
          background: linear-gradient(
            135deg,
            #198754,
            #20a46c
          );
          color: #ffffff;
          box-shadow:
            0 7px 16px rgba(25, 135, 84, 0.16);
        }

        .save-button:hover:not(:disabled) {
          color: #ffffff;
          transform: translateY(-1px);
          box-shadow:
            0 10px 21px rgba(25, 135, 84, 0.24);
        }

        .save-button:disabled {
          opacity: 0.7;
          cursor: not-allowed;
        }

        .cancel-button {
          border: 1px solid #dfe4e9;
          background: #ffffff;
          color: #667085;
        }

        .cancel-button:hover {
          color: #344054;
          background: #f7f8fa;
          border-color: #cbd2d9;
        }

        /* =====================================================
           FOOTER
        ===================================================== */

        .admin-page-footer {
          padding: 20px 2px 5px;
          display: flex;
          align-items: center;
          justify-content: space-between;
          gap: 15px;
          color: #9aa3af;
          font-size: 10px;
        }

        .admin-page-footer div {
          display: flex;
          align-items: center;
          gap: 7px;
        }

        .admin-page-footer i {
          color: #198754;
        }

        .admin-page-footer a {
          display: inline-flex;
          align-items: center;
          color: #7b8492;
          text-decoration: none;
          font-weight: 600;
        }

        .admin-page-footer a:hover {
          color: #198754;
        }

        /* =====================================================
           SIDEBAR OVERLAY
        ===================================================== */

        .sidebar-overlay {
          display: none;
        }

        /* =====================================================
           LARGE DESKTOP
        ===================================================== */

        @media (max-width: 1399.98px) {
          .admin-content {
            padding: 30px;
          }

          .image-grid,
          .new-image-grid {
            grid-template-columns: repeat(
              4,
              minmax(0, 1fr)
            );
          }
        }

        /* =====================================================
           LAPTOP / TABLET
        ===================================================== */

        @media (max-width: 1199.98px) {
          .admin-content {
            padding: 28px;
          }

          .page-header {
            align-items: flex-start;
          }

          .image-grid,
          .new-image-grid {
            grid-template-columns: repeat(
              3,
              minmax(0, 1fr)
            );
          }
        }

        /* =====================================================
           MOBILE SIDEBAR
        ===================================================== */

        @media (max-width: 991.98px) {
          .admin-sidebar {
            transform: translateX(-100%);
            box-shadow:
              15px 0 40px rgba(20, 30, 45, 0.1);
          }

          .admin-sidebar.open {
            transform: translateX(0);
          }

          .admin-main {
            width: 100%;
            margin-left: 0;
          }

          .sidebar-overlay {
            position: fixed;
            inset: 0;
            z-index: 1040;
            display: block;
            background: rgba(15, 23, 42, 0.35);
            backdrop-filter: blur(2px);
          }

          .admin-topbar {
            padding: 0 24px;
          }

          .page-header {
            flex-direction: column;
            align-items: stretch;
          }

          .back-button {
            align-self: flex-start;
          }

          .image-grid,
          .new-image-grid {
            grid-template-columns: repeat(
              3,
              minmax(0, 1fr)
            );
          }
        }

        /* =====================================================
           TABLET
        ===================================================== */

        @media (max-width: 767.98px) {
          .admin-topbar {
            height: 68px;
            padding: 0 16px;
          }

          .topbar-title {
            font-size: 13px;
          }

          .admin-content {
            width: 100%;
            max-width: 100%;
            padding: 22px 16px;
          }

          .page-header {
            margin-bottom: 22px;
          }

          .page-title-row {
            gap: 12px;
          }

          .page-title-icon {
            width: 48px;
            height: 48px;
            min-width: 48px;
            border-radius: 13px;
            font-size: 20px;
          }

          .page-title {
            font-size: 26px;
          }

          .page-description {
            font-size: 11px;
            line-height: 1.7;
            text-align: justify;
            text-justify: inter-word;
          }

          .back-button {
            width: 100%;
          }

          .form-section {
            padding: 22px 18px;
          }

          .form-grid,
          .button-grid {
            grid-template-columns: 1fr;
            gap: 16px;
          }

          .form-group.full {
            grid-column: auto;
          }

          .image-grid,
          .new-image-grid {
            grid-template-columns: repeat(
              2,
              minmax(0, 1fr)
            );
          }

          .image-preview {
            height: 155px;
          }

          .new-image-preview img {
            height: 140px;
          }

          .section-heading {
            margin-bottom: 20px;
          }

          .section-description {
            font-size: 10px;
          }

          .form-actions {
            padding: 17px 18px;
            align-items: stretch;
            flex-direction: column;
          }

          .form-actions-left {
            width: 100%;
          }

          .form-actions-right {
            width: 100%;
            display: grid;
            grid-template-columns: 1fr 1fr;
          }

          .action-button {
            width: 100%;
          }

          .alert-custom {
            margin-left: 18px;
            margin-right: 18px;
          }

          .admin-page-footer {
            flex-direction: column;
            align-items: flex-start;
            padding-top: 17px;
          }
        }

        /* =====================================================
           MOBILE
        ===================================================== */

        @media (max-width: 575.98px) {
          .admin-content {
            padding: 19px 12px;
          }

          .admin-topbar {
            padding-left: 12px;
            padding-right: 12px;
          }

          .topbar-left {
            gap: 9px;
          }

          .topbar-right {
            gap: 6px;
          }

          .topbar-website,
          .topbar-logout {
            width: 38px;
            height: 38px;
            min-height: 38px;
            padding: 0;
            border-radius: 9px;
          }

          .mobile-menu-button {
            width: 38px;
            height: 38px;
          }

          .page-title-row {
            align-items: flex-start;
            gap: 10px;
          }

          .page-title-icon {
            width: 43px;
            height: 43px;
            min-width: 43px;
            border-radius: 11px;
            font-size: 17px;
          }

          .page-title {
            font-size: 23px;
          }

          .page-description {
            font-size: 10px;
            line-height: 1.7;
            text-align: justify;
            text-justify: inter-word;
          }

          .form-card {
            border-radius: 14px;
          }

          .form-section {
            padding: 18px 14px;
          }

          .section-heading {
            gap: 10px;
          }

          .section-icon {
            width: 38px;
            height: 38px;
            min-width: 38px;
            border-radius: 10px;
            font-size: 15px;
          }

          .section-title {
            font-size: 13px;
          }

          .section-description {
            font-size: 9px;
            line-height: 1.65;
          }

          .form-label-custom {
            font-size: 10px;
          }

          .form-control-custom {
            min-height: 41px;
            padding: 9px 10px;
            font-size: 11px;
          }

          textarea.form-control-custom {
            min-height: 115px;
          }

          .form-help {
            font-size: 9px;
          }

          .image-grid,
          .new-image-grid {
            grid-template-columns: 1fr 1fr;
            gap: 9px;
          }

          .image-preview {
            height: 125px;
          }

          .new-image-preview img {
            height: 120px;
          }

          .image-card-body {
            padding: 8px;
          }

          .delete-image-button {
            min-height: 34px;
            font-size: 9px;
          }

          .upload-box {
            padding: 12px;
          }

          .file-input {
            font-size: 10px;
          }

          .button-section {
            padding: 12px;
          }

          .button-grid {
            gap: 12px;
          }

          .active-box {
            align-items: flex-start;
          }

          .active-description {
            font-size: 9px;
          }

          .form-actions {
            padding: 15px 14px;
          }

          .form-actions-right {
            grid-template-columns: 1fr;
          }

          .action-button {
            min-height: 41px;
          }

          .alert-custom {
            margin-left: 14px;
            margin-right: 14px;
            font-size: 10px;
          }
        }

        /* =====================================================
           EXTRA SMALL
        ===================================================== */

        @media (max-width: 399.98px) {
          .topbar-title {
            max-width: 130px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
          }

          .page-title {
            font-size: 21px;
          }

          .page-title-icon {
            width: 40px;
            height: 40px;
            min-width: 40px;
          }

          .admin-content {
            padding-left: 10px;
            padding-right: 10px;
          }

          .image-grid,
          .new-image-grid {
            grid-template-columns: 1fr;
          }

          .image-preview {
            height: 180px;
          }

          .new-image-preview img {
            height: 170px;
          }
        }

        /* =====================================================
           VERY SMALL
        ===================================================== */

        @media (max-width: 340px) {
          .admin-content {
            padding-left: 8px;
            padding-right: 8px;
          }

          .topbar-title {
            max-width: 105px;
          }

          .page-title {
            font-size: 19px;
          }

          .page-description {
            font-size: 9px;
            text-align: justify;
            text-justify: inter-word;
          }

          .form-section {
            padding-left: 12px;
            padding-right: 12px;
          }

          .form-control-custom {
            font-size: 10px;
          }

          .active-box {
            flex-direction: column;
          }

          .alert-custom {
            margin-left: 12px;
            margin-right: 12px;
          }
        }

        /* =====================================================
           REDUCED MOTION
        ===================================================== */

        @media (prefers-reduced-motion: reduce) {
          .hero-edit-page *,
          .hero-edit-page *::before,
          .hero-edit-page *::after {
            animation-duration: 0.01ms !important;
            animation-iteration-count: 1 !important;
            transition-duration: 0.01ms !important;
          }
        }
      `}</style>

      <div className="hero-edit-page">
        <div className="admin-layout">

          {/* =====================================================
              MOBILE OVERLAY
          ===================================================== */}

          {sidebarOpen && (
  <div
    className="sidebar-overlay"
    onClick={() => setSidebarOpen(false)}
    aria-hidden="true"
  />
)}

          {/* =====================================================
              SIDEBAR
          ===================================================== */}

          <aside
  className={`admin-sidebar ${sidebarOpen ? "open" : ""}`}
>
            <div className="sidebar-inner">

              <div className="sidebar-brand">

                <div className="brand-icon">
                  <i className="bi bi-grid-1x2-fill"></i>
                </div>

                <div className="brand-text">
                  <strong>GloVaTech</strong>
                  <span>Admin Panel</span>
                </div>

                <button
  type="button"
  className="sidebar-close d-lg-none"
  aria-label="Close sidebar"
  onClick={() => setSidebarOpen(false)}
>
                  <i className="bi bi-x-lg"></i>
                </button>

              </div>

              <div className="sidebar-section-label">
  MAIN MENU
</div>

<nav className="sidebar-nav">

  {/* DASHBOARD */}

  <a
    href="/secure-panel"
    className="sidebar-link"
  >
    <span className="sidebar-link-icon">
      <i className="bi bi-speedometer2"></i>
    </span>

    <span>Dashboard</span>
  </a>

</nav>

<div className="sidebar-section-label mt-4">
  CONTENT
</div>

<nav className="sidebar-nav">

  {/* HERO */}

  <a
    href="/secure-panel/hero"
    className="sidebar-link active"
  >
    <span className="sidebar-link-icon">
      <i className="bi bi-stars"></i>
    </span>

    <span>Hero</span>
  </a>

  {/* ABOUT */}

  <a
    href="/secure-panel/about"
    className="sidebar-link"
  >
    <span className="sidebar-link-icon">
      <i className="bi bi-person-vcard"></i>
    </span>

    <span>About</span>
  </a>

  {/* ABOUT STATS */}

  <a
    href="/secure-panel/about/stats"
    className="sidebar-link"
  >
    <span className="sidebar-link-icon">
      <i className="bi bi-bar-chart-line"></i>
    </span>

    <span>About Stats</span>
  </a>

  {/* EDUCATION */}

  <a
    href="/secure-panel/education"
    className="sidebar-link"
  >
    <span className="sidebar-link-icon">
      <i className="bi bi-mortarboard"></i>
    </span>

    <span>Education</span>
  </a>

  {/* SKILLS */}

  <a
    href="/secure-panel/skills"
    className="sidebar-link"
  >
    <span className="sidebar-link-icon">
      <i className="bi bi-tools"></i>
    </span>

    <span>Skills</span>
  </a>

  {/* EXPERIENCE */}

  <a
    href="/secure-panel/experience"
    className="sidebar-link"
  >
    <span className="sidebar-link-icon">
      <i className="bi bi-briefcase"></i>
    </span>

    <span>Experience</span>
  </a>

  {/* PROJECTS */}

  <a
    href="/secure-panel/projects"
    className="sidebar-link"
  >
    <span className="sidebar-link-icon">
      <i className="bi bi-code-square"></i>
    </span>

    <span>Projects</span>
  </a>

  {/* CERTIFICATION */}

  <a
    href="/secure-panel/certifications"
    className="sidebar-link"
  >
    <span className="sidebar-link-icon">
      <i className="bi bi-patch-check"></i>
    </span>

    <span>Certification</span>
  </a>

  {/* ACHIEVEMENT */}

  <a
    href="/secure-panel/achievements"
    className="sidebar-link"
  >
    <span className="sidebar-link-icon">
      <i className="bi bi-trophy"></i>
    </span>

    <span>Achievement</span>
  </a>

  {/* SERVICES */}

  <a
    href="/secure-panel/services"
    className="sidebar-link"
  >
    <span className="sidebar-link-icon">
      <i className="bi bi-gear-wide-connected"></i>
    </span>

    <span>Services</span>
  </a>

  {/* GALLERY */}

  <a
    href="/secure-panel/gallery"
    className="sidebar-link"
  >
    <span className="sidebar-link-icon">
      <i className="bi bi-images"></i>
    </span>

    <span>Gallery</span>
  </a>

  {/* CONTACT INFO */}

  <a
    href="/secure-panel/contact-info"
    className="sidebar-link"
  >
    <span className="sidebar-link-icon">
      <i className="bi bi-person-lines-fill"></i>
    </span>

    <span>Contact Info</span>
  </a>

  {/* CONTACT SOCIAL MEDIA */}

  <a
    href="/secure-panel/contact-info/list"
    className="sidebar-link"
  >
    <span className="sidebar-link-icon">
      <i className="bi bi-share-fill"></i>
    </span>

    <span>Contact Social Media</span>
  </a>

  {/* ARTICLES */}

  <a
    href="/secure-panel/articles"
    className="sidebar-link"
  >
    <span className="sidebar-link-icon">
      <i className="bi bi-journal-text"></i>
    </span>

    <span>Articles</span>
  </a>

  {/* CONTACT MESSAGES */}

  <a
    href="/secure-panel/contact-messages"
    className="sidebar-link"
  >
    <span className="sidebar-link-icon">
      <i className="bi bi-chat-left-text"></i>
    </span>

    <span>Contact Messages</span>
  </a>

  {/* CONTACT USER */}

  <a
    href="/secure-panel/contact-users"
    className="sidebar-link"
  >
    <span className="sidebar-link-icon">
      <i className="bi bi-people-fill"></i>
    </span>

    <span>Contact User</span>
  </a>

</nav>

              <div className="sidebar-bottom">

                <a href="/">
                  <i className="bi bi-globe2"></i>

                  <span>View Website</span>

                  <i className="bi bi-arrow-up-right ms-auto"></i>
                </a>

              </div>

            </div>
          </aside>

          {/* =====================================================
              MAIN AREA
          ===================================================== */}

          <div className="admin-main">

            {/* =====================================================
                TOPBAR
            ===================================================== */}

            <header className="admin-topbar">

              <div className="topbar-left">

                <button
  type="button"
  className="mobile-menu-button d-lg-none"
  aria-label="Open menu"
  onClick={() => setSidebarOpen(true)}
>
                  <i className="bi bi-list"></i>
                </button>

                <div>

                  <div className="topbar-label">
                    ADMIN PANEL
                  </div>

                  <div className="topbar-title">
                    Edit Hero
                  </div>

                </div>

              </div>

              <div className="topbar-right">

                <a
                  href="/"
                  className="topbar-website"
                  title="View Website"
                  aria-label="View Website"
                >
                  <i className="bi bi-globe2"></i>

                  <span className="d-none d-sm-inline">
                    Website
                  </span>
                </a>

                <a
                  href="/secure-panel/login"
                  className="topbar-logout"
                  title="Logout"
                  aria-label="Logout"
                >
                  <i className="bi bi-box-arrow-right"></i>

                  <span className="d-none d-sm-inline">
                    Logout
                  </span>
                </a>

              </div>

            </header>

            {/* =====================================================
                CONTENT
            ===================================================== */}

            <main className="admin-content">

              {/* =====================================================
                  PAGE HEADER
              ===================================================== */}

              <section className="page-header">

                <div className="page-header-left">

                  <div className="page-eyebrow">
                    <span className="page-eyebrow-dot"></span>
                    CONTENT MANAGEMENT
                  </div>

                  <div className="page-title-row">

                    <div className="page-title-icon">
                      <i className="bi bi-pencil-square"></i>
                    </div>

                    <div>

                      <h1 className="page-title">
                        Edit Hero
                      </h1>

                      <p className="page-description">
                        Perbarui konten Hero pada halaman utama
                        website GloVaTech. Anda dapat mengubah
                        informasi Hero, foto, tombol, sosial media,
                        CV, serta status publikasi sesuai kebutuhan.
                      </p>

                    </div>

                  </div>

                </div>

                <a
                  href="/secure-panel/hero"
                  className="back-button"
                >
                  <i className="bi bi-arrow-left"></i>
                  <span>Kembali ke Hero</span>
                </a>

              </section>

              {/* =====================================================
                  FORM
              ===================================================== */}

              <div className="form-wrapper">

                <form onSubmit={handleSubmit}>

                  <div className="form-card">

                    {/* =================================================
                        INFORMASI HERO
                    ================================================= */}

                    <section className="form-section">

                      <div className="section-heading">

                        <div className="section-icon">
                          <i className="bi bi-stars"></i>
                        </div>

                        <div className="section-heading-content">

                          <h2 className="section-title">
                            Informasi Hero
                          </h2>

                          <p className="section-description">
                            Kelola informasi utama yang ditampilkan
                            pada bagian Hero website, termasuk badge,
                            judul, highlight, dan deskripsi.
                          </p>

                        </div>

                      </div>

                      <div className="form-grid">

                        {/* BADGE */}

                        <div className="form-group">

                          <label className="form-label-custom">
                            Badge
                          </label>

                          <input
                            type="text"
                            className="form-control-custom"
                            value={badge}
                            onChange={(e) =>
                              setBadge(e.target.value)
                            }
                            placeholder="Contoh: Welcome to my portfolio"
                          />

                        </div>

                        {/* TITLE */}

                        <div className="form-group">

                          <label className="form-label-custom">
                            Title
                            <span className="required-mark">
                              *
                            </span>
                          </label>

                          <input
                            type="text"
                            className="form-control-custom"
                            value={title}
                            onChange={(e) =>
                              setTitle(e.target.value)
                            }
                            required
                            placeholder="Masukkan title Hero"
                          />

                        </div>

                        {/* HIGHLIGHT */}

                        <div className="form-group">

                          <label className="form-label-custom">
                            Highlight
                          </label>

                          <input
                            type="text"
                            className="form-control-custom"
                            value={highlight}
                            onChange={(e) =>
                              setHighlight(e.target.value)
                            }
                            placeholder="Contoh: Web Programmer"
                          />

                        </div>

                        {/* DESCRIPTION */}

                        <div className="form-group full">

                          <label className="form-label-custom">
                            Description
                          </label>

                          <textarea
                            className="form-control-custom"
                            rows={5}
                            value={description}
                            onChange={(e) =>
                              setDescription(e.target.value)
                            }
                            placeholder="Masukkan deskripsi Hero..."
                          />

                          <div className="form-help">
                            Gunakan deskripsi singkat dan profesional
                            untuk memperkenalkan diri atau menjelaskan
                            fokus utama website.
                          </div>

                        </div>

                      </div>

                    </section>

                    {/* =================================================
                        FOTO HERO
                    ================================================= */}

                    <section className="form-section">

                      <div className="section-heading">

                        <div className="section-icon">
                          <i className="bi bi-images"></i>
                        </div>

                        <div className="section-heading-content">

                          <h2 className="section-title">
                            Foto Hero
                          </h2>

                          <p className="section-description">
                            Kelola foto yang digunakan pada bagian
                            Hero. Foto lama dapat dihapus dan Anda
                            dapat menambahkan beberapa foto baru
                            sekaligus.
                          </p>

                        </div>

                      </div>

                      {/* FOTO LAMA */}

                      <div className="form-group">

                        <label className="form-label-custom">
                          <i className="bi bi-image"></i>
                          Foto Hero Saat Ini
                        </label>

                        {heroImages.length > 0 ? (

                          <div className="image-grid">

                            {heroImages.map(
                              (item, index) => (

                                <div
                                  key={item.id}
                                  className="image-card"
                                >

                                  <div className="image-preview-wrapper">

                                    <img
                                      src={item.image}
                                      alt={`Hero ${
                                        index + 1
                                      }`}
                                      className="image-preview"
                                    />

                                    <span className="image-number">
                                      {index + 1}
                                    </span>

                                  </div>

                                  <div className="image-card-body">

                                    <button
                                      type="button"
                                      className="delete-image-button"
                                      onClick={() =>
                                        handleDeleteImage(
                                          item.id
                                        )
                                      }
                                    >
                                      <i className="bi bi-trash"></i>
                                      <span>
                                        Hapus Foto
                                      </span>
                                    </button>

                                  </div>

                                </div>

                              )
                            )}

                          </div>

                        ) : (

                          <div className="empty-images">

                            <div className="empty-images-icon">
                              <i className="bi bi-image"></i>
                            </div>

                            <div className="empty-images-text">
                              Belum ada foto Hero yang tersimpan.
                              Tambahkan foto baru menggunakan
                              area upload di bawah.
                            </div>

                          </div>

                        )}

                      </div>

                      {/* UPLOAD FOTO */}

                      <div
                        className="form-group"
                        style={{ marginTop: "22px" }}
                      >

                        <label className="form-label-custom">
                          <i className="bi bi-cloud-arrow-up"></i>
                          Upload Foto Baru
                        </label>

                        <div className="upload-box">

                          <input
                            type="file"
                            className="file-input"
                            accept="image/*"
                            multiple
                            onChange={handlePhotoChange}
                          />

                          <div className="form-help">
                            Anda dapat memilih satu atau lebih
                            gambar sekaligus. Pastikan file yang
                            dipilih merupakan file gambar.
                          </div>

                        </div>

                      </div>

                      {/* PREVIEW FOTO BARU */}

                      {newPhotoPreviews.length > 0 && (

                        <div
                          className="form-group"
                          style={{ marginTop: "22px" }}
                        >

                          <div className="new-preview-title">
                            <i className="bi bi-eye me-1"></i>
                            Foto Baru yang Dipilih
                          </div>

                          <div className="new-image-grid">

                            {newPhotoPreviews.map(
                              (preview, index) => (

                                <div
                                  key={index}
                                  className="new-image-preview"
                                >

                                  <img
                                    src={preview}
                                    alt={`Preview ${
                                      index + 1
                                    }`}
                                  />

                                  <span className="new-image-label">
                                    Baru {index + 1}
                                  </span>

                                </div>

                              )
                            )}

                          </div>

                        </div>

                      )}

                    </section>

                    {/* =================================================
                        PRIMARY BUTTON
                    ================================================= */}

                    <section className="form-section">

                      <div className="section-heading">

                        <div className="section-icon">
                          <i className="bi bi-cursor"></i>
                        </div>

                        <div className="section-heading-content">

                          <h2 className="section-title">
                            Button Navigation
                          </h2>

                          <p className="section-description">
                            Atur teks dan URL untuk tombol utama
                            yang ditampilkan pada bagian Hero.
                          </p>

                        </div>

                      </div>

                      {/* PRIMARY */}

                      <div className="button-section">

                        <div className="button-section-header">

                          <div className="button-section-icon">
                            <i className="bi bi-arrow-up-right"></i>
                          </div>

                          <div className="button-section-title">
                            Primary Button
                          </div>

                        </div>

                        <div className="button-grid">

                          <div className="form-group">

                            <label className="form-label-custom">
                              Button Text
                            </label>

                            <input
                              type="text"
                              className="form-control-custom"
                              value={
                                primaryButtonText
                              }
                              onChange={(e) =>
                                setPrimaryButtonText(
                                  e.target.value
                                )
                              }
                              placeholder="Contoh: View Projects"
                            />

                          </div>

                          <div className="form-group">

                            <label className="form-label-custom">
                              Button URL
                            </label>

                            <input
                              type="text"
                              className="form-control-custom"
                              value={
                                primaryButtonUrl
                              }
                              onChange={(e) =>
                                setPrimaryButtonUrl(
                                  e.target.value
                                )
                              }
                              placeholder="Contoh: /projects"
                            />

                          </div>

                        </div>

                      </div>

                      {/* SECONDARY */}

                      <div className="button-section">

                        <div className="button-section-header">

                          <div className="button-section-icon">
                            <i className="bi bi-link-45deg"></i>
                          </div>

                          <div className="button-section-title">
                            Secondary Button
                          </div>

                        </div>

                        <div className="button-grid">

                          <div className="form-group">

                            <label className="form-label-custom">
                              Button Text
                            </label>

                            <input
                              type="text"
                              className="form-control-custom"
                              value={
                                secondaryButtonText
                              }
                              onChange={(e) =>
                                setSecondaryButtonText(
                                  e.target.value
                                )
                              }
                              placeholder="Contoh: Contact Me"
                            />

                          </div>

                          <div className="form-group">

                            <label className="form-label-custom">
                              Button URL
                            </label>

                            <input
                              type="text"
                              className="form-control-custom"
                              value={
                                secondaryButtonUrl
                              }
                              onChange={(e) =>
                                setSecondaryButtonUrl(
                                  e.target.value
                                )
                              }
                              placeholder="Contoh: /contact"
                            />

                          </div>

                        </div>

                      </div>

                    </section>

                    {/* =================================================
                        SOCIAL MEDIA
                    ================================================= */}

                    <section className="form-section">

                      <div className="section-heading">

                        <div className="section-icon">
                          <i className="bi bi-share"></i>
                        </div>

                        <div className="section-heading-content">

                          <h2 className="section-title">
                            Social Media
                          </h2>

                          <p className="section-description">
                            Masukkan tautan sosial media dan alamat
                            email yang akan digunakan pada bagian
                            Hero website.
                          </p>

                        </div>

                      </div>

                      <div className="form-grid">

                        {/* GITHUB */}

                        <div className="form-group">

                          <label className="form-label-custom">
                            GitHub URL
                          </label>

                          <div className="social-input-wrapper">

                            <i className="bi bi-github social-icon"></i>

                            <input
                              type="url"
                              className="form-control-custom social-input"
                              value={githubUrl}
                              onChange={(e) =>
                                setGithubUrl(
                                  e.target.value
                                )
                              }
                              placeholder="https://github.com/..."
                            />

                          </div>

                        </div>

                        {/* LINKEDIN */}

                        <div className="form-group">

                          <label className="form-label-custom">
                            LinkedIn URL
                          </label>

                          <div className="social-input-wrapper">

                            <i className="bi bi-linkedin social-icon"></i>

                            <input
                              type="url"
                              className="form-control-custom social-input"
                              value={linkedinUrl}
                              onChange={(e) =>
                                setLinkedinUrl(
                                  e.target.value
                                )
                              }
                              placeholder="https://linkedin.com/in/..."
                            />

                          </div>

                        </div>

                        {/* EMAIL */}

                        <div className="form-group full">

                          <label className="form-label-custom">
                            Email
                          </label>

                          <div className="social-input-wrapper">

                            <i className="bi bi-envelope social-icon"></i>

                            <input
                              type="email"
                              className="form-control-custom social-input"
                              value={email}
                              onChange={(e) =>
                                setEmail(
                                  e.target.value
                                )
                              }
                              placeholder="email@example.com"
                            />

                          </div>

                        </div>

                      </div>

                    </section>

                    {/* =================================================
                        CV
                    ================================================= */}

                    <section className="form-section">

                      <div className="section-heading">

                        <div className="section-icon">
                          <i className="bi bi-file-earmark-pdf"></i>
                        </div>

                        <div className="section-heading-content">

                          <h2 className="section-title">
                            CV / Resume
                          </h2>

                          <p className="section-description">
                            Kelola file CV atau Resume yang dapat
                            digunakan pada halaman utama website.
                            File baru harus menggunakan format PDF.
                          </p>

                        </div>

                      </div>

                      <div className="upload-box">

                        <label className="form-label-custom">
                          Upload CV Baru
                        </label>

                        <input
                          type="file"
                          className="file-input"
                          accept="application/pdf"
                          onChange={handleCvChange}
                        />

                        <div className="form-help">
                          Upload CV dalam format PDF.
                        </div>

                      </div>

                      {hero.cv && !cvFile && (

                        <div className="cv-current">

                          <div className="cv-icon">
                            <i className="bi bi-file-earmark-pdf"></i>
                          </div>

                          <div className="cv-info">

                            <div className="cv-info-title">
                              CV sudah tersedia
                            </div>

                            <div className="cv-info-description">
                              File CV saat ini akan tetap
                              digunakan apabila Anda tidak
                              memilih file baru.
                            </div>

                          </div>

                        </div>

                      )}

                      {cvFile && (

                        <div className="cv-selected">

                          <i className="bi bi-check-circle-fill"></i>

                          <div className="cv-selected-content">

                            <span className="cv-selected-name">
                              {cvFile.name}
                            </span>

                            <div className="cv-selected-text">
                              CV baru siap diupload.
                            </div>

                          </div>

                        </div>

                      )}

                    </section>

                    {/* =================================================
                        STATUS
                    ================================================= */}

                    <section className="form-section">

                      <div className="section-heading">

                        <div className="section-icon">
                          <i className="bi bi-toggle-on"></i>
                        </div>

                        <div className="section-heading-content">

                          <h2 className="section-title">
                            Publication Status
                          </h2>

                          <p className="section-description">
                            Tentukan apakah konten Hero ini aktif
                            dan dapat ditampilkan pada halaman utama
                            website.
                          </p>

                        </div>

                      </div>

                      <div className="active-box">

                        <div className="active-info">

                          <div className="active-title">
                            Hero Aktif
                          </div>

                          <div className="active-description">
                            Aktifkan opsi ini apabila Hero ingin
                            ditampilkan pada website publik.
                          </div>

                        </div>

                        <label className="custom-switch">

                          <input
                            type="checkbox"
                            role="switch"
                            checked={active}
                            onChange={(e) =>
                              setActive(
                                e.target.checked
                              )
                            }
                            id="heroActive"
                          />

                          <span className="switch-slider"></span>

                        </label>

                      </div>

                    </section>

                    {/* =================================================
                        ERROR
                    ================================================= */}

                    {error && (

                      <div className="alert-custom alert-error">

                        <i className="bi bi-exclamation-circle"></i>

                        <div className="alert-text">
                          {error}
                        </div>

                      </div>

                    )}

                    {/* =================================================
                        SUCCESS
                    ================================================= */}

                    {message && (

                      <div className="alert-custom alert-success">

                        <i className="bi bi-check-circle"></i>

                        <div className="alert-text">
                          {message}
                        </div>

                      </div>

                    )}

                    {/* =================================================
                        ACTIONS
                    ================================================= */}

                    <div className="form-actions">

                      <div className="form-actions-left">

                        <div className="save-info">

                          <i className="bi bi-shield-check"></i>

                          <span>
                            Hero Management System
                          </span>

                        </div>

                      </div>

                      <div className="form-actions-right">

                        <a
                          href="/secure-panel/hero"
                          className="action-button cancel-button"
                        >
                          <i className="bi bi-x-lg"></i>

                          <span>
                            Batal
                          </span>
                        </a>

                        <button
                          type="submit"
                          className="action-button save-button"
                          disabled={loading}
                        >

                          {loading ? (
                            <>
                              <span
                                className="spinner-border spinner-border-sm"
                                role="status"
                                aria-hidden="true"
                              ></span>

                              <span>
                                Menyimpan...
                              </span>
                            </>
                          ) : (
                            <>
                              <i className="bi bi-save"></i>

                              <span>
                                Simpan Perubahan
                              </span>
                            </>
                          )}

                        </button>

                      </div>

                    </div>

                  </div>

                </form>

              </div>

              {/* =====================================================
                  FOOTER
              ===================================================== */}

              <footer className="admin-page-footer">

                <div>

                  <i className="bi bi-shield-check"></i>

                  <span>
                    Admin Content Management System
                  </span>

                </div>

                <a href="/secure-panel">

                  <i className="bi bi-arrow-left me-1"></i>

                  Dashboard

                </a>

              </footer>

            </main>

          </div>

        </div>
      </div>
    </>
  );
}