"use client";

import { FormEvent, useEffect, useState } from "react";
import Link from "next/link";

type About = {
  id: number;
  badge: string | null;
  title: string;
  highlight: string | null;
  description: string | null;
  photo: string | null;

  github: string | null;
  facebook: string | null;
  instagram: string | null;
  twitter: string | null;
  tiktok: string | null;
  email: string | null;

  active: boolean;
};

type PageProps = {
  params: Promise<{
    id: string;
  }>;
};

export default function EditAboutPage({ params }: PageProps) {
  const [aboutId, setAboutId] = useState<number | null>(null);

  const [loading, setLoading] = useState(true);
  const [saving, setSaving] = useState(false);
  const [uploading, setUploading] = useState(false);

  const [photoPreview, setPhotoPreview] = useState("");
  const [photoFile, setPhotoFile] = useState<File | null>(null);

  const [sidebarOpen, setSidebarOpen] = useState(false);

  const [form, setForm] = useState({
    badge: "",
    title: "",
    highlight: "",
    description: "",
    photo: "",

    github: "",
    facebook: "",
    instagram: "",
    twitter: "",
    tiktok: "",
    email: "",

    active: true,
  });

  // =========================================================
  // GET DATA
  // =========================================================

  useEffect(() => {
    const loadAbout = async () => {
      try {
        const { id } = await params;
        const numericId = Number(id);

        if (!numericId) {
          alert("ID About tidak valid");
          return;
        }

        setAboutId(numericId);

        const response = await fetch("/api/about");
        const result = await response.json();

        if (!response.ok || !result.success) {
          alert(result.message || "Gagal mengambil data About");
          return;
        }

        const about: About | undefined = result.data.find(
          (item: About) => item.id === numericId
        );

        if (!about) {
          alert("Data About tidak ditemukan");
          return;
        }

        setForm({
          badge: about.badge ?? "",
          title: about.title ?? "",
          highlight: about.highlight ?? "",
          description: about.description ?? "",
          photo: about.photo ?? "",

          github: about.github ?? "",
          facebook: about.facebook ?? "",
          instagram: about.instagram ?? "",
          twitter: about.twitter ?? "",
          tiktok: about.tiktok ?? "",
          email: about.email ?? "",

          active: about.active,
        });
      } catch (error) {
        console.error("GET ABOUT EDIT ERROR:", error);
        alert("Terjadi kesalahan saat mengambil data About");
      } finally {
        setLoading(false);
      }
    };

    loadAbout();
  }, [params]);

  // =========================================================
  // HANDLE INPUT
  // =========================================================

  const handleChange = (
    e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>
  ) => {
    const { name, value, type } = e.target;

    setForm((prev) => ({
      ...prev,
      [name]:
        type === "checkbox"
          ? (e.target as HTMLInputElement).checked
          : value,
    }));
  };

  // =========================================================
  // SELECT PHOTO
  // =========================================================

  const handlePhotoChange = (
    e: React.ChangeEvent<HTMLInputElement>
  ) => {
    const file = e.target.files?.[0];

    if (!file) {
      return;
    }

    if (!file.type.startsWith("image/")) {
      alert("File yang dipilih harus berupa gambar");
      return;
    }

    setPhotoFile(file);

    const preview = URL.createObjectURL(file);

    setPhotoPreview(preview);

    e.target.value = "";
  };

  // =========================================================
  // UPLOAD PHOTO
  // =========================================================

  const uploadPhoto = async () => {
    if (!photoFile) {
      return form.photo;
    }

    setUploading(true);

    try {
      const formData = new FormData();

      formData.append("file", photoFile);

      const response = await fetch("/api/about/upload", {
        method: "POST",
        body: formData,
      });

      const result = await response.json();

      if (!response.ok || !result.success) {
        throw new Error(
          result.message || "Gagal mengupload Photo"
        );
      }

      return result.data as string;
    } finally {
      setUploading(false);
    }
  };

  // =========================================================
  // UPDATE
  // =========================================================

  const handleSubmit = async (e: FormEvent) => {
    e.preventDefault();

    if (!aboutId) {
      alert("ID About tidak ditemukan");
      return;
    }

    setSaving(true);

    try {
      const uploadedPhoto = await uploadPhoto();

      const response = await fetch("/api/about", {
        method: "PUT",
        headers: {
          "Content-Type": "application/json",
        },
        body: JSON.stringify({
          id: aboutId,
          ...form,
          photo: uploadedPhoto,
        }),
      });

      const result = await response.json();

      if (!response.ok || !result.success) {
        alert(result.message || "Gagal memperbarui About");
        return;
      }

      alert("About berhasil diperbarui");

      window.location.href = "/secure-panel/about";
    } catch (error) {
      console.error("UPDATE ABOUT ERROR:", error);
      alert("Terjadi kesalahan saat memperbarui About");
    } finally {
      setSaving(false);
    }
  };

  // =========================================================
  // LOADING
  // =========================================================

  if (loading) {
    return (
      <div
        className="min-vh-100 d-flex align-items-center justify-content-center"
        style={{
          background:
            "linear-gradient(135deg, #f5faf7 0%, #eef8f2 100%)",
        }}
      >
        <div className="text-center">
          <div
            className="spinner-border text-success mb-3"
            style={{ width: "3rem", height: "3rem" }}
            role="status"
          />

          <h5 className="fw-bold mb-2">
            Memuat data About
          </h5>

          <p className="text-secondary mb-0">
            Sedang mengambil informasi dari database...
          </p>
        </div>
      </div>
    );
  }

  // =========================================================
  // MAIN
  // =========================================================

  return (
    <>
      {/* MOBILE OVERLAY */}
      {sidebarOpen && (
        <div
          onClick={() => setSidebarOpen(false)}
          className="position-fixed top-0 start-0 w-100 h-100 bg-dark bg-opacity-50 d-lg-none"
          style={{
            zIndex: 1040,
          }}
        />
      )}

      <div
        className="d-flex min-vh-100"
        style={{
          background: "#f6f8f7",
        }}
      >
        {/* =====================================================
            SIDEBAR
        ===================================================== */}

        <aside
          className={`bg-white border-end position-fixed top-0 bottom-0 start-0 ${
            sidebarOpen ? "translate-visible" : ""
          }`}
          style={{
            width: "270px",
            zIndex: 1050,
            transform: sidebarOpen
              ? "translateX(0)"
              : undefined,
            transition: "transform 0.3s ease",
          }}
        >
          <div
            className="d-flex flex-column h-100"
            style={{
              overflowY: "auto",
            }}
          >
            {/* BRAND */}
            <div className="px-4 py-4 border-bottom">
              <div className="d-flex align-items-center gap-3">
                <div
                  className="rounded-3 d-flex align-items-center justify-content-center text-white"
                  style={{
                    width: "44px",
                    height: "44px",
                    minWidth: "44px",
                    background:
                      "linear-gradient(135deg, #198754, #20c997)",
                    boxShadow:
                      "0 8px 20px rgba(25,135,84,.20)",
                  }}
                >
                  <i className="bi bi-grid-1x2-fill fs-5" />
                </div>

                <div>
                  <div className="fw-bold">
                    GloVaTech
                  </div>

                  <small className="text-secondary">
                    Admin Panel
                  </small>
                </div>

                <button
                  type="button"
                  onClick={() => setSidebarOpen(false)}
                  className="btn btn-sm btn-light ms-auto d-lg-none"
                  aria-label="Tutup sidebar"
                >
                  <i className="bi bi-x-lg" />
                </button>
              </div>
            </div>

            {/* NAVIGATION */}
            <div className="px-3 py-4 flex-grow-1">
              <small
                className="text-uppercase fw-bold text-secondary px-2"
                style={{
                  fontSize: "10px",
                  letterSpacing: "1.2px",
                }}
              >
                Main Menu
              </small>

              
<nav className="mt-3">
  {/* HERO */}
  <Link
    href="/secure-panel/hero"
    className="text-decoration-none text-dark d-flex align-items-center gap-3 px-3 py-2 rounded-3 mb-1"
    onClick={() => setSidebarOpen(false)}
  >
    <i className="bi bi-stars text-secondary" />
    <span>Hero</span>
  </Link>

  {/* ABOUT */}
  <Link
    href="/secure-panel/about"
    className="text-decoration-none d-flex align-items-center gap-3 px-3 py-2 rounded-3 mb-1"
    style={{
      background: "#eaf7ef",
      color: "#198754",
      fontWeight: 600,
    }}
    onClick={() => setSidebarOpen(false)}
  >
    <i className="bi bi-person-vcard-fill" />
    <span>About</span>
  </Link>

  {/* ABOUT STATS */}
  <Link
    href="/secure-panel/about/stats"
    className="text-decoration-none text-dark d-flex align-items-center gap-3 px-3 py-2 rounded-3 mb-1"
    onClick={() => setSidebarOpen(false)}
  >
    <i className="bi bi-bar-chart text-secondary" />
    <span>About Stats</span>
  </Link>

  {/* EDUCATION */}
  <Link
    href="/secure-panel/education"
    className="text-decoration-none text-dark d-flex align-items-center gap-3 px-3 py-2 rounded-3 mb-1"
    onClick={() => setSidebarOpen(false)}
  >
    <i className="bi bi-mortarboard text-secondary" />
    <span>Education</span>
  </Link>

  {/* SKILLS */}
  <Link
    href="/secure-panel/skills"
    className="text-decoration-none text-dark d-flex align-items-center gap-3 px-3 py-2 rounded-3 mb-1"
    onClick={() => setSidebarOpen(false)}
  >
    <i className="bi bi-tools text-secondary" />
    <span>Skills</span>
  </Link>

  {/* EXPERIENCE */}
  <Link
    href="/secure-panel/experience"
    className="text-decoration-none text-dark d-flex align-items-center gap-3 px-3 py-2 rounded-3 mb-1"
    onClick={() => setSidebarOpen(false)}
  >
    <i className="bi bi-briefcase text-secondary" />
    <span>Experience</span>
  </Link>

  {/* PROJECTS */}
  <Link
    href="/secure-panel/projects"
    className="text-decoration-none text-dark d-flex align-items-center gap-3 px-3 py-2 rounded-3 mb-1"
    onClick={() => setSidebarOpen(false)}
  >
    <i className="bi bi-code-square text-secondary" />
    <span>Projects</span>
  </Link>

  {/* CERTIFICATION */}
  <Link
    href="/secure-panel/certifications"
    className="text-decoration-none text-dark d-flex align-items-center gap-3 px-3 py-2 rounded-3 mb-1"
    onClick={() => setSidebarOpen(false)}
  >
    <i className="bi bi-patch-check text-secondary" />
    <span>Certification</span>
  </Link>

  {/* ACHIEVEMENT */}
  <Link
    href="/secure-panel/achievements"
    className="text-decoration-none text-dark d-flex align-items-center gap-3 px-3 py-2 rounded-3 mb-1"
    onClick={() => setSidebarOpen(false)}
  >
    <i className="bi bi-trophy text-secondary" />
    <span>Achievement</span>
  </Link>

  {/* SERVICES */}
  <Link
    href="/secure-panel/services"
    className="text-decoration-none text-dark d-flex align-items-center gap-3 px-3 py-2 rounded-3 mb-1"
    onClick={() => setSidebarOpen(false)}
  >
    <i className="bi bi-gear-wide-connected text-secondary" />
    <span>Services</span>
  </Link>

  {/* GALLERY */}
  <Link
    href="/secure-panel/gallery"
    className="text-decoration-none text-dark d-flex align-items-center gap-3 px-3 py-2 rounded-3 mb-1"
    onClick={() => setSidebarOpen(false)}
  >
    <i className="bi bi-images text-secondary" />
    <span>Gallery</span>
  </Link>

  
{/* CONTACT INFO */}
<Link
  href="/secure-panel/contact-info"
  className="text-decoration-none text-dark d-flex align-items-center gap-3 px-3 py-2 rounded-3 mb-1"
  onClick={() => setSidebarOpen(false)}
>
  <i className="bi bi-person-lines-fill text-secondary" />
  <span>Contact Info</span>
</Link>

{/* CONTACT SOCIAL MEDIA */}
<Link
  href="/secure-panel/contact-info/list"
  className="text-decoration-none text-dark d-flex align-items-center gap-3 px-3 py-2 rounded-3 mb-1"
  onClick={() => setSidebarOpen(false)}
>
  <i className="bi bi-share-fill text-secondary" />
  <span>Contact Social Media</span>
</Link>


    {/* ARTICLES */}
  <Link
    href="/secure-panel/articles"
    className="text-decoration-none text-dark d-flex align-items-center gap-3 px-3 py-2 rounded-3 mb-1"
    onClick={() => setSidebarOpen(false)}
  >
    <i className="bi bi-journal-text text-secondary" />
    <span>Articles</span>
  </Link>

  {/* CONTACT MESSAGES */}
  <Link
    href="/secure-panel/contact-messages"
    className="text-decoration-none text-dark d-flex align-items-center gap-3 px-3 py-2 rounded-3 mb-1"
    onClick={() => setSidebarOpen(false)}
  >
    <i className="bi bi-chat-left-text text-secondary" />
    <span>Contact Messages</span>
  </Link>

  {/* CONTACT USER */}
  <Link
    href="/secure-panel/contact-users"
    className="text-decoration-none text-dark d-flex align-items-center gap-3 px-3 py-2 rounded-3 mb-1"
    onClick={() => setSidebarOpen(false)}
  >
    <i className="bi bi-people-fill text-secondary" />
    <span>Contact User</span>
  </Link>
</nav>


            </div>

            {/* SIDEBAR BOTTOM */}
            <div className="border-top p-3">
              <Link
                href="/"
                className="text-decoration-none text-secondary d-flex align-items-center gap-3 px-3 py-2 rounded-3"
              >
                <i className="bi bi-globe2" />
                <span>View Website</span>

                <i className="bi bi-arrow-up-right ms-auto" />
              </Link>
            </div>
          </div>
        </aside>

        {/* =====================================================
            MAIN AREA
        ===================================================== */}

        <div
          className="flex-grow-1"
          style={{
            marginLeft: "270px",
            minWidth: 0,
          }}
        >
          {/* TOPBAR */}
          <header
            className="bg-white border-bottom sticky-top"
            style={{
              height: "72px",
              zIndex: 1000,
            }}
          >
            <div className="h-100 px-3 px-md-4 px-xl-5 d-flex align-items-center justify-content-between">
              <div className="d-flex align-items-center gap-3">
                <button
                  type="button"
                  className="btn btn-light d-lg-none"
                  onClick={() => setSidebarOpen(true)}
                  aria-label="Buka menu"
                >
                  <i className="bi bi-list fs-5" />
                </button>

                <div>
                  <small
                    className="text-uppercase fw-bold text-success"
                    style={{
                      fontSize: "10px",
                      letterSpacing: "1px",
                    }}
                  >
                    Admin Panel
                  </small>

                  <h6 className="fw-bold mb-0">
                    Edit About
                  </h6>
                </div>
              </div>

              <div className="d-flex align-items-center gap-2">
                <Link
                  href="/"
                  className="btn btn-light border d-flex align-items-center gap-2"
                >
                  <i className="bi bi-globe2" />

                  <span className="d-none d-sm-inline">
                    Website
                  </span>
                </Link>

                <Link
                  href="/secure-panel/login"
                  className="btn btn-outline-danger d-flex align-items-center gap-2"
                >
                  <i className="bi bi-box-arrow-right" />

                  <span className="d-none d-sm-inline">
                    Logout
                  </span>
                </Link>
              </div>
            </div>
          </header>

          {/* =====================================================
              CONTENT
          ===================================================== */}

          <main className="p-3 p-md-4 p-xl-5">
            <div
              className="mx-auto"
              style={{
                maxWidth: "1200px",
              }}
            >
              {/* BREADCRUMB */}
              <div className="mb-4">
                <Link
                  href="/secure-panel"
                  className="text-decoration-none text-secondary small"
                >
                  <i className="bi bi-arrow-left me-2" />
                  Kembali ke Dashboard
                </Link>
              </div>

              {/* PAGE HEADER */}
              <div className="d-flex flex-column flex-md-row justify-content-between align-items-md-center gap-3 mb-4">
                <div>
                  <div className="d-flex align-items-center gap-3">
                    <div
                      className="rounded-4 d-flex align-items-center justify-content-center text-success"
                      style={{
                        width: "56px",
                        height: "56px",
                        background: "#e8f6ee",
                      }}
                    >
                      <i className="bi bi-person-vcard-fill fs-4" />
                    </div>

                    <div>
                      <div
                        className="text-success fw-bold text-uppercase"
                        style={{
                          fontSize: "11px",
                          letterSpacing: "1px",
                        }}
                      >
                        Website Content
                      </div>

                      <h1 className="fw-bold mb-0">
                        Edit About
                      </h1>
                    </div>
                  </div>

                  <p
                    className="text-secondary mt-3 mb-0"
                    style={{
                      maxWidth: "700px",
                      textAlign: "justify",
                    }}
                  >
                    Perbarui informasi About Me yang
                    ditampilkan pada halaman utama website
                    portfolio GloVaTech.
                  </p>
                </div>

                <Link
                  href="/secure-panel/about"
                  className="btn btn-outline-secondary px-4 align-self-start align-self-md-center"
                >
                  <i className="bi bi-arrow-left me-2" />
                  Kembali ke About
                </Link>
              </div>

              {/* FORM CARD */}
              <div
                className="bg-white rounded-4 border-0"
                style={{
                  boxShadow:
                    "0 10px 35px rgba(0,0,0,.06)",
                }}
              >
                <div className="p-3 p-md-4 p-lg-5">
                  <form onSubmit={handleSubmit}>
                    {/* =================================================
                        BASIC INFORMATION
                    ================================================= */}

                    <div className="mb-4">
                      <div className="d-flex align-items-center gap-3 mb-1">
                        <div
                          className="rounded-3 d-flex align-items-center justify-content-center text-success"
                          style={{
                            width: "40px",
                            height: "40px",
                            background: "#eaf7ef",
                          }}
                        >
                          <i className="bi bi-person-lines-fill" />
                        </div>

                        <div>
                          <h5 className="fw-bold mb-0">
                            Informasi Utama
                          </h5>

                          <small className="text-secondary">
                            Informasi dasar About Me.
                          </small>
                        </div>
                      </div>
                    </div>

                    <div className="row g-4">
                      {/* BADGE */}
                      <div className="col-12 col-md-6">
                        <label
                          htmlFor="badge"
                          className="form-label fw-semibold"
                        >
                          Badge
                        </label>

                        <input
                          type="text"
                          id="badge"
                          name="badge"
                          className="form-control form-control-lg"
                          placeholder="Contoh: ABOUT ME"
                          value={form.badge}
                          onChange={handleChange}
                        />
                      </div>

                      {/* TITLE */}
                      <div className="col-12 col-md-6">
                        <label
                          htmlFor="title"
                          className="form-label fw-semibold"
                        >
                          Title
                          <span className="text-danger ms-1">
                            *
                          </span>
                        </label>

                        <input
                          type="text"
                          id="title"
                          name="title"
                          className="form-control form-control-lg"
                          placeholder="Contoh: I am a"
                          value={form.title}
                          onChange={handleChange}
                          required
                        />
                      </div>

                      {/* HIGHLIGHT */}
                      <div className="col-12">
                        <label
                          htmlFor="highlight"
                          className="form-label fw-semibold"
                        >
                          Highlight
                        </label>

                        <input
                          type="text"
                          id="highlight"
                          name="highlight"
                          className="form-control form-control-lg"
                          placeholder="Contoh: Web Programmer"
                          value={form.highlight}
                          onChange={handleChange}
                        />

                        <div className="form-text">
                          Teks yang ditampilkan dengan warna
                          utama pada halaman About.
                        </div>
                      </div>

                      {/* DESCRIPTION */}
                      <div className="col-12">
                        <label
                          htmlFor="description"
                          className="form-label fw-semibold"
                        >
                          Description
                        </label>

                        <textarea
                          id="description"
                          name="description"
                          className="form-control"
                          rows={6}
                          placeholder="Tulis deskripsi About Me..."
                          value={form.description}
                          onChange={handleChange}
                          style={{
                            resize: "vertical",
                            textAlign: "justify",
                          }}
                        />

                        <div className="form-text">
                          Gunakan deskripsi yang singkat,
                          jelas, profesional, dan mudah dibaca.
                        </div>
                      </div>
                    </div>

                    {/* =================================================
                        PHOTO
                    ================================================= */}

                    <hr className="my-5" />

                    <div className="mb-4">
                      <div className="d-flex align-items-center gap-3 mb-1">
                        <div
                          className="rounded-3 d-flex align-items-center justify-content-center text-success"
                          style={{
                            width: "40px",
                            height: "40px",
                            background: "#eaf7ef",
                          }}
                        >
                          <i className="bi bi-image" />
                        </div>

                        <div>
                          <h5 className="fw-bold mb-0">
                            Photo About
                          </h5>

                          <small className="text-secondary">
                            Kelola foto profil yang digunakan
                            pada section About.
                          </small>
                        </div>
                      </div>
                    </div>

                    <div className="row g-4 align-items-start">
                      <div className="col-12 col-lg-7">
                        <label
                          htmlFor="photo"
                          className="form-label fw-semibold"
                        >
                          Upload Photo
                        </label>

                        <input
                          type="file"
                          id="photo"
                          className="form-control form-control-lg"
                          accept="image/*"
                          onChange={handlePhotoChange}
                        />

                        <div className="form-text">
                          Pilih gambar dengan format JPG, JPEG,
                          PNG, atau WebP.
                        </div>
                      </div>

                      {(photoPreview || form.photo) && (
                        <div className="col-12 col-lg-5">
                          <div className="fw-semibold mb-2">
                            Preview Photo
                          </div>

                          <div
                            className="rounded-4 overflow-hidden border bg-light"
                            style={{
                              width: "100%",
                              maxWidth: "280px",
                              aspectRatio: "1 / 1",
                            }}
                          >
                            <img
                              src={
                                photoPreview ||
                                form.photo
                              }
                              alt="Preview Photo"
                              className="w-100 h-100"
                              style={{
                                objectFit: "cover",
                              }}
                            />
                          </div>

                          {photoFile && (
                            <small className="text-success d-block mt-2">
                              <i className="bi bi-check-circle me-1" />
                              Foto baru dipilih
                            </small>
                          )}
                        </div>
                      )}
                    </div>

                    {/* =================================================
                        SOCIAL MEDIA
                    ================================================= */}

                    <hr className="my-5" />

                    <div className="mb-4">
                      <div className="d-flex align-items-center gap-3 mb-1">
                        <div
                          className="rounded-3 d-flex align-items-center justify-content-center text-success"
                          style={{
                            width: "40px",
                            height: "40px",
                            background: "#eaf7ef",
                          }}
                        >
                          <i className="bi bi-share-fill" />
                        </div>

                        <div>
                          <h5 className="fw-bold mb-0">
                            Social Media & Contact
                          </h5>

                          <small className="text-secondary">
                            Masukkan akun sosial media dan
                            email yang ingin ditampilkan.
                          </small>
                        </div>
                      </div>
                    </div>

                    <div className="row g-4">
                      {/* GITHUB */}
                      <div className="col-12 col-md-6">
                        <label
                          htmlFor="github"
                          className="form-label fw-semibold"
                        >
                          <i className="bi bi-github me-2" />
                          GitHub
                        </label>

                        <input
                          type="url"
                          id="github"
                          name="github"
                          className="form-control"
                          placeholder="https://github.com/username"
                          value={form.github}
                          onChange={handleChange}
                        />
                      </div>

                      {/* FACEBOOK */}
                      <div className="col-12 col-md-6">
                        <label
                          htmlFor="facebook"
                          className="form-label fw-semibold"
                        >
                          <i className="bi bi-facebook me-2" />
                          Facebook
                        </label>

                        <input
                          type="url"
                          id="facebook"
                          name="facebook"
                          className="form-control"
                          placeholder="https://facebook.com/username"
                          value={form.facebook}
                          onChange={handleChange}
                        />
                      </div>

                      {/* INSTAGRAM */}
                      <div className="col-12 col-md-6">
                        <label
                          htmlFor="instagram"
                          className="form-label fw-semibold"
                        >
                          <i className="bi bi-instagram me-2" />
                          Instagram
                        </label>

                        <input
                          type="url"
                          id="instagram"
                          name="instagram"
                          className="form-control"
                          placeholder="https://instagram.com/username"
                          value={form.instagram}
                          onChange={handleChange}
                        />
                      </div>

                      {/* TWITTER */}
                      <div className="col-12 col-md-6">
                        <label
                          htmlFor="twitter"
                          className="form-label fw-semibold"
                        >
                          <i className="bi bi-twitter-x me-2" />
                          Twitter / X
                        </label>

                        <input
                          type="url"
                          id="twitter"
                          name="twitter"
                          className="form-control"
                          placeholder="https://x.com/username"
                          value={form.twitter}
                          onChange={handleChange}
                        />
                      </div>

                      {/* TIKTOK */}
                      <div className="col-12 col-md-6">
                        <label
                          htmlFor="tiktok"
                          className="form-label fw-semibold"
                        >
                          <i className="bi bi-tiktok me-2" />
                          TikTok
                        </label>

                        <input
                          type="url"
                          id="tiktok"
                          name="tiktok"
                          className="form-control"
                          placeholder="https://tiktok.com/@username"
                          value={form.tiktok}
                          onChange={handleChange}
                        />
                      </div>

                      {/* EMAIL */}
                      <div className="col-12 col-md-6">
                        <label
                          htmlFor="email"
                          className="form-label fw-semibold"
                        >
                          <i className="bi bi-envelope-fill me-2" />
                          Email
                        </label>

                        <input
                          type="email"
                          id="email"
                          name="email"
                          className="form-control"
                          placeholder="email@example.com"
                          value={form.email}
                          onChange={handleChange}
                        />
                      </div>
                    </div>

                    {/* =================================================
                        STATUS
                    ================================================= */}

                    <hr className="my-5" />

                    <div
                      className="rounded-4 p-3 p-md-4"
                      style={{
                        background: "#f8faf9",
                        border: "1px solid #e6ece8",
                      }}
                    >
                      <div className="d-flex align-items-center justify-content-between gap-3">
                        <div>
                          <div className="fw-bold">
                            Status About
                          </div>

                          <small className="text-secondary">
                            Tentukan apakah data About ini
                            ditampilkan pada website.
                          </small>
                        </div>

                        <div className="form-check form-switch m-0">
                          <input
                            className="form-check-input"
                            type="checkbox"
                            role="switch"
                            id="active"
                            name="active"
                            checked={form.active}
                            onChange={handleChange}
                            style={{
                              width: "3rem",
                              height: "1.5rem",
                              cursor: "pointer",
                            }}
                          />
                        </div>
                      </div>

                      <div className="mt-3">
                        {form.active ? (
                          <span className="badge rounded-pill bg-success-subtle text-success px-3 py-2">
                            <i className="bi bi-check-circle me-1" />
                            About Aktif
                          </span>
                        ) : (
                          <span className="badge rounded-pill bg-secondary-subtle text-secondary px-3 py-2">
                            <i className="bi bi-pause-circle me-1" />
                            About Tidak Aktif
                          </span>
                        )}
                      </div>
                    </div>

                    {/* =================================================
                        ACTION
                    ================================================= */}

                    <div className="d-flex flex-column flex-sm-row justify-content-end gap-2 mt-5">
                      <Link
                        href="/secure-panel/about"
                        className="btn btn-outline-secondary px-4 py-2"
                      >
                        <i className="bi bi-x-lg me-2" />
                        Batal
                      </Link>

                      <button
                        type="submit"
                        className="btn btn-success px-4 py-2"
                        disabled={saving || uploading}
                      >
                        {saving || uploading ? (
                          <>
                            <span
                              className="spinner-border spinner-border-sm me-2"
                              role="status"
                            />

                            {uploading
                              ? "Mengupload..."
                              : "Menyimpan..."}
                          </>
                        ) : (
                          <>
                            <i className="bi bi-check-lg me-2" />
                            Simpan Perubahan
                          </>
                        )}
                      </button>
                    </div>
                  </form>
                </div>
              </div>

              {/* FOOTER */}
              <div className="d-flex flex-column flex-sm-row justify-content-between align-items-sm-center gap-2 py-4">
                <small className="text-secondary">
                  <i className="bi bi-shield-check me-1 text-success" />
                  Admin Content Management System
                </small>

                <Link
                  href="/secure-panel"
                  className="text-decoration-none text-secondary small"
                >
                  <i className="bi bi-arrow-left me-1" />
                  Dashboard
                </Link>
              </div>
            </div>
          </main>
        </div>
      </div>

      {/* =========================================================
          RESPONSIVE INLINE STYLE
      ========================================================= */}

      <style
        dangerouslySetInnerHTML={{
          __html: `
            @media (max-width: 991.98px) {
              aside {
                transform: translateX(-100%) !important;
              }

              aside.translate-visible {
                transform: translateX(0) !important;
              }

              .flex-grow-1 {
                margin-left: 0 !important;
              }
            }

            @media (max-width: 575.98px) {
              header {
                height: 64px !important;
              }

              main {
                padding-bottom: 20px !important;
              }
            }
          `,
        }}
      />
    </>
  );
}