"use client";

import {
  FormEvent,
  useState,
} from "react";

export default function CreateAboutPage() {
  const [loading, setLoading] = useState(false);

  const [form, setForm] = useState({
    badge: "",
    title: "",
    highlight: "",
    description: "",
    photo: "",
    github: "",
    facebook: "",
    instagram: "",
    twitter: "",
    tiktok: "",
    email: "",
    active: true,
  });

  const [photoFile, setPhotoFile] =
    useState<File | null>(null);

  const [photoPreview, setPhotoPreview] =
    useState<string>("");

  // =====================================================
  // HANDLE CHANGE
  // =====================================================

  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,
    }));
  };

  // =====================================================
  // HANDLE 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);

    // Agar file yang sama dapat dipilih kembali
    e.target.value = "";
  };

  // =====================================================
  // UPLOAD PHOTO
  // =====================================================

  const uploadPhoto = async () => {
    if (!photoFile) {
      return null;
    }

    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 upload foto"
      );
    }

    return result.data as string;
  };

  // =====================================================
  // SUBMIT
  // =====================================================

  const handleSubmit = async (e: FormEvent) => {
    e.preventDefault();

    if (!form.title.trim()) {
      alert("Title wajib diisi.");
      return;
    }

    setLoading(true);

    try {
      // Upload foto terlebih dahulu
      const photoUrl = await uploadPhoto();

      // Simpan About
      const response = await fetch(
        "/api/about",
        {
          method: "POST",
          headers: {
            "Content-Type": "application/json",
          },
          body: JSON.stringify({
            ...form,
            photo: photoUrl,
          }),
        }
      );

      const result = await response.json();

      if (!response.ok || !result.success) {
        throw new Error(
          result.message ||
            "Gagal menambahkan About"
        );
      }

      alert("About berhasil ditambahkan");

      window.location.href =
        "/secure-panel/about";
    } catch (error) {
      console.error(
        "CREATE ABOUT ERROR:",
        error
      );

      alert(
        error instanceof Error
          ? error.message
          : "Terjadi kesalahan saat menambahkan About"
      );
    } finally {
      setLoading(false);
    }
  };

  return (
    <>
      {/* =================================================
          STYLE
      ================================================= */}

      <style>{`
        * {
          box-sizing: border-box;
        }

        html,
        body {
          max-width: 100%;
          overflow-x: hidden;
        }

        body {
          margin: 0;
          background: #f5f7fb;
        }

        /* =================================================
           MAIN WRAPPER
        ================================================= */

        .about-create-page {
          min-height: 100vh;
          background: #f5f7fb;
          color: #1f2937;
        }

        .about-layout {
          min-height: 100vh;
          display: flex;
          position: relative;
        }

        /* =================================================
           SIDEBAR
        ================================================= */

        .about-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;
        }

        .about-sidebar-inner {
          height: 100%;
          display: flex;
          flex-direction: column;
          padding: 24px 16px;
          overflow-y: auto;
        }

        .about-brand {
          display: flex;
          align-items: center;
          gap: 12px;
          padding: 4px 10px 28px;
          border-bottom: 1px solid #edf0f4;
          margin-bottom: 22px;
        }

        .about-brand-icon {
          width: 42px;
          height: 42px;
          border-radius: 12px;
          display: flex;
          align-items: center;
          justify-content: center;
          background: linear-gradient(
            135deg,
            #198754,
            #20c997
          );
          color: #ffffff;
          font-size: 18px;
          flex-shrink: 0;
          box-shadow:
            0 8px 20px
            rgba(25, 135, 84, 0.2);
        }

        .about-brand-text {
          min-width: 0;
        }

        .about-brand-text strong {
          display: block;
          color: #17202a;
          font-size: 16px;
          line-height: 1.2;
        }

        .about-brand-text span {
          display: block;
          margin-top: 3px;
          color: #8b95a5;
          font-size: 11px;
          font-weight: 600;
          letter-spacing: 0.08em;
          text-transform: uppercase;
        }

        .about-sidebar-close {
          margin-left: auto;
          border: 0;
          background: transparent;
          color: #7b8492;
          font-size: 17px;
        }

        .about-menu-label {
          padding: 0 12px;
          margin-bottom: 8px;
          color: #9aa3af;
          font-size: 10px;
          font-weight: 700;
          letter-spacing: 0.1em;
        }

        .about-sidebar-nav {
          display: flex;
          flex-direction: column;
          gap: 4px;
        }

        .about-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;
        }

        .about-sidebar-link:hover {
          background: #f0f8f4;
          color: #198754;
          transform: translateX(2px);
        }

        .about-sidebar-link.active {
          background: linear-gradient(
            90deg,
            rgba(25, 135, 84, 0.12),
            rgba(25, 135, 84, 0.06)
          );
          color: #198754;
          font-weight: 700;
        }

        .about-sidebar-icon {
          width: 23px;
          text-align: center;
          font-size: 16px;
          flex-shrink: 0;
        }

        .about-sidebar-bottom {
          margin-top: auto;
          padding-top: 18px;
          border-top: 1px solid #edf0f4;
        }

        .about-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;
        }

        .about-sidebar-bottom a:hover {
          background: #f5f7fa;
          color: #198754;
        }

        /* =================================================
           MAIN
        ================================================= */

        .about-main {
          width: calc(100% - 270px);
          margin-left: 270px;
          min-width: 0;
        }

        /* =================================================
           TOPBAR
        ================================================= */

        .about-topbar {
          height: 76px;
          background: rgba(
            255,
            255,
            255,
            0.96
          );
          border-bottom: 1px solid #e9edf2;
          display: flex;
          align-items: center;
          justify-content: space-between;
          padding: 0 34px;
          position: sticky;
          top: 0;
          z-index: 900;
          backdrop-filter: blur(12px);
        }

        .about-topbar-left {
          display: flex;
          align-items: center;
          gap: 14px;
          min-width: 0;
        }

        .about-mobile-menu {
          width: 40px;
          height: 40px;
          border: 1px solid #e2e7ed;
          background: #ffffff;
          border-radius: 10px;
          color: #344054;
          font-size: 18px;
        }

        .about-topbar-label {
          color: #9aa3af;
          font-size: 10px;
          font-weight: 700;
          letter-spacing: 0.1em;
          margin-bottom: 3px;
        }

        .about-topbar-title {
          color: #17202a;
          font-size: 15px;
          font-weight: 700;
        }

        .about-topbar-right {
          display: flex;
          align-items: center;
          gap: 10px;
          flex-shrink: 0;
        }

        .about-topbar-button {
          min-height: 40px;
          display: inline-flex;
          align-items: center;
          justify-content: center;
          gap: 8px;
          padding: 8px 13px;
          border-radius: 10px;
          text-decoration: none;
          font-size: 13px;
          font-weight: 600;
          transition: 0.2s ease;
        }

        .about-website-button {
          color: #667085;
          border: 1px solid #e4e8ed;
          background: #ffffff;
        }

        .about-website-button:hover {
          color: #198754;
          border-color: #b7ddca;
          background: #f4fbf7;
        }

        .about-logout-button {
          color: #dc3545;
          border: 1px solid #f1c4c9;
          background: #ffffff;
        }

        .about-logout-button:hover {
          background: #fff5f6;
          border-color: #e8aeb5;
        }

        /* =================================================
           CONTENT
        ================================================= */

        .about-content {
          width: 100%;
          max-width: 1180px;
          margin: 0 auto;
          padding: 34px 32px 40px;
        }

        /* =================================================
           PAGE HEADER
        ================================================= */

        .about-page-header {
          margin-bottom: 25px;
        }

        .about-back-link {
          display: inline-flex;
          align-items: center;
          gap: 7px;
          color: #6b7280;
          text-decoration: none;
          font-size: 13px;
          font-weight: 600;
          margin-bottom: 18px;
          transition: 0.2s ease;
        }

        .about-back-link:hover {
          color: #198754;
          transform: translateX(-2px);
        }

        .about-heading {
          display: flex;
          align-items: center;
          gap: 15px;
        }

        .about-heading-icon {
          width: 55px;
          height: 55px;
          border-radius: 15px;
          display: flex;
          align-items: center;
          justify-content: center;
          background: linear-gradient(
            135deg,
            rgba(25, 135, 84, 0.13),
            rgba(32, 201, 151, 0.08)
          );
          color: #198754;
          font-size: 22px;
          flex-shrink: 0;
        }

        .about-eyebrow {
          color: #198754;
          font-size: 10px;
          font-weight: 800;
          letter-spacing: 0.11em;
          margin-bottom: 4px;
        }

        .about-page-title {
          margin: 0;
          color: #182230;
          font-size: clamp(
            27px,
            3vw,
            35px
          );
          font-weight: 800;
          letter-spacing: -0.025em;
        }

        .about-page-description {
          max-width: 700px;
          margin: 7px 0 0;
          color: #7a8493;
          font-size: 14px;
          line-height: 1.7;
          text-align: justify;
        }

        /* =================================================
           FORM CARD
        ================================================= */

        .about-form-card {
          width: 100%;
          max-width: 920px;
          margin: 0 auto;
          background: #ffffff;
          border: 1px solid #e5eaf0;
          border-radius: 18px;
          box-shadow:
            0 8px 30px
            rgba(20, 30, 45, 0.045);
          overflow: hidden;
        }

        .about-form-header {
          padding: 23px 28px;
          border-bottom: 1px solid #edf0f3;
          background: linear-gradient(
            180deg,
            #ffffff,
            #fbfdfc
          );
        }

        .about-form-header-title {
          display: flex;
          align-items: center;
          gap: 10px;
          margin: 0;
          color: #1d2939;
          font-size: 17px;
          font-weight: 800;
        }

        .about-form-header-title i {
          color: #198754;
        }

        .about-form-header-description {
          margin: 6px 0 0 29px;
          color: #8a93a0;
          font-size: 12px;
          line-height: 1.6;
          text-align: justify;
        }

        .about-form-body {
          padding: 30px;
        }

        /* =================================================
           FORM SECTION
        ================================================= */

        .about-section {
          padding-bottom: 28px;
          margin-bottom: 28px;
          border-bottom: 1px solid #edf0f3;
        }

        .about-section:last-of-type {
          padding-bottom: 0;
          margin-bottom: 28px;
          border-bottom: 0;
        }

        .about-section-title {
          display: flex;
          align-items: center;
          gap: 9px;
          color: #263241;
          font-size: 14px;
          font-weight: 800;
          margin-bottom: 5px;
        }

        .about-section-title i {
          color: #198754;
          font-size: 16px;
        }

        .about-section-description {
          color: #8a93a0;
          font-size: 11px;
          line-height: 1.6;
          margin-bottom: 20px;
          text-align: justify;
        }

        /* =================================================
           FORM CONTROLS
        ================================================= */

        .about-form-group {
          margin-bottom: 19px;
        }

        .about-form-group:last-child {
          margin-bottom: 0;
        }

        .about-form-label {
          display: block;
          color: #344054;
          font-size: 12px;
          font-weight: 700;
          margin-bottom: 7px;
        }

        .about-form-label span {
          color: #dc3545;
        }

        .about-form-control {
          width: 100%;
          min-height: 45px;
          padding: 10px 13px;
          border: 1px solid #dfe5eb;
          border-radius: 10px;
          background: #ffffff;
          color: #263241;
          font-size: 13px;
          outline: none;
          transition:
            border-color 0.2s ease,
            box-shadow 0.2s ease,
            background 0.2s ease;
        }

        .about-form-control::placeholder {
          color: #b0b7c2;
        }

        .about-form-control:hover {
          border-color: #c8d1da;
        }

        .about-form-control:focus {
          border-color: #198754;
          box-shadow:
            0 0 0 3px
            rgba(25, 135, 84, 0.09);
          background: #ffffff;
        }

        textarea.about-form-control {
          min-height: 145px;
          resize: vertical;
          line-height: 1.65;
        }

        .about-form-help {
          margin-top: 6px;
          color: #98a1ae;
          font-size: 10px;
          line-height: 1.55;
          text-align: justify;
        }

        /* =================================================
           TWO COLUMN FORM
        ================================================= */

        .about-form-grid {
          display: grid;
          grid-template-columns:
            repeat(2, minmax(0, 1fr));
          gap: 18px;
        }

        /* =================================================
           PHOTO UPLOAD
        ================================================= */

        .about-upload-box {
          border: 1px dashed #cfd8e2;
          border-radius: 13px;
          padding: 18px;
          background: #fbfcfd;
        }

        .about-upload-box:hover {
          border-color: #8fc9aa;
          background: #f8fcfa;
        }

        .about-photo-preview {
          width: 100%;
          max-width: 320px;
          margin-top: 15px;
        }

        .about-photo-preview img {
          display: block;
          width: 100%;
          height: 240px;
          object-fit: cover;
          border-radius: 13px;
          border: 1px solid #e3e8ed;
          box-shadow:
            0 8px 20px
            rgba(20, 30, 45, 0.07);
        }

        .about-preview-label {
          display: block;
          color: #667085;
          font-size: 10px;
          font-weight: 800;
          letter-spacing: 0.06em;
          text-transform: uppercase;
          margin-bottom: 8px;
        }

        /* =================================================
           SOCIAL
        ================================================= */

        .about-social-item {
          position: relative;
        }

        .about-social-label {
          display: flex;
          align-items: center;
          gap: 7px;
        }

        .about-social-label i {
          color: #198754;
          font-size: 14px;
        }

        /* =================================================
           ACTIVE
        ================================================= */

        .about-active-box {
          display: flex;
          align-items: center;
          gap: 12px;
          padding: 14px 16px;
          border: 1px solid #dfe8e3;
          border-radius: 12px;
          background: #f8fcfa;
        }

        .about-active-box .form-check-input {
          width: 38px;
          height: 21px;
          margin: 0;
          cursor: pointer;
        }

        .about-active-box
          .form-check-input:checked {
          background-color: #198754;
          border-color: #198754;
        }

        .about-active-text strong {
          display: block;
          color: #344054;
          font-size: 12px;
          margin-bottom: 2px;
        }

        .about-active-text span {
          display: block;
          color: #8a93a0;
          font-size: 10px;
          line-height: 1.5;
        }

        /* =================================================
           ACTIONS
        ================================================= */

        .about-form-actions {
          display: flex;
          align-items: center;
          justify-content: flex-end;
          gap: 9px;
          padding-top: 22px;
          border-top: 1px solid #edf0f3;
        }

        .about-action-button {
          min-height: 44px;
          display: inline-flex;
          align-items: center;
          justify-content: center;
          gap: 8px;
          padding: 9px 18px;
          border-radius: 10px;
          text-decoration: none;
          font-size: 12px;
          font-weight: 700;
          transition: 0.2s ease;
          cursor: pointer;
        }

        .about-cancel-button {
          color: #667085;
          background: #ffffff;
          border: 1px solid #dfe4ea;
        }

        .about-cancel-button:hover {
          color: #344054;
          background: #f8f9fa;
          border-color: #cbd2da;
        }

        .about-save-button {
          color: #ffffff;
          background: linear-gradient(
            135deg,
            #198754,
            #20a46c
          );
          border: 1px solid #198754;
          box-shadow:
            0 7px 18px
            rgba(25, 135, 84, 0.16);
        }

        .about-save-button:hover:not(:disabled) {
          color: #ffffff;
          transform: translateY(-1px);
          box-shadow:
            0 10px 23px
            rgba(25, 135, 84, 0.23);
        }

        .about-save-button:disabled {
          opacity: 0.7;
          cursor: not-allowed;
        }

        /* =================================================
           FOOTER
        ================================================= */

        .about-page-footer {
          max-width: 920px;
          margin: 18px auto 0;
          padding: 8px 2px;
          display: flex;
          align-items: center;
          justify-content: space-between;
          gap: 15px;
          color: #9aa3af;
          font-size: 10px;
        }

        .about-page-footer a {
          color: #7b8492;
          text-decoration: none;
          font-weight: 600;
        }

        .about-page-footer a:hover {
          color: #198754;
        }

        /* =================================================
           OVERLAY
        ================================================= */

        .about-sidebar-overlay {
          display: none;
        }

        /* =================================================
           TABLET
        ================================================= */

        @media (max-width: 1199.98px) {
          .about-content {
            max-width: 1050px;
            padding: 30px 25px 38px;
          }

          .about-form-card {
            max-width: 900px;
          }

          .about-topbar {
            padding: 0 25px;
          }
        }

        /* =================================================
           MOBILE SIDEBAR
        ================================================= */

        @media (max-width: 991.98px) {
          .about-sidebar {
            transform: translateX(-100%);
            box-shadow:
              15px 0 40px
              rgba(20, 30, 45, 0.1);
          }

          .about-sidebar.open {
            transform: translateX(0);
          }

          .about-main {
            width: 100%;
            margin-left: 0;
          }

          .about-sidebar-overlay {
            position: fixed;
            inset: 0;
            z-index: 1040;
            display: block;
            background:
              rgba(15, 23, 42, 0.35);
            backdrop-filter: blur(2px);
          }

          .about-topbar {
            padding: 0 20px;
          }
        }

        /* =================================================
           MOBILE
        ================================================= */

        @media (max-width: 767.98px) {
          .about-topbar {
            height: 68px;
            padding: 0 16px;
          }

          .about-topbar-title {
            font-size: 13px;
          }

          .about-content {
            width: 100%;
            padding: 22px 14px 30px;
          }

          .about-heading {
            align-items: flex-start;
          }

          .about-heading-icon {
            width: 48px;
            height: 48px;
            border-radius: 13px;
            font-size: 19px;
          }

          .about-page-title {
            font-size: 27px;
          }

          .about-page-description {
            font-size: 12px;
            line-height: 1.65;
          }

          .about-form-card {
            border-radius: 15px;
          }

          .about-form-header {
            padding: 19px;
          }

          .about-form-header-title {
            font-size: 15px;
          }

          .about-form-header-description {
            margin-left: 0;
            font-size: 11px;
          }

          .about-form-body {
            padding: 20px;
          }

          .about-section {
            padding-bottom: 23px;
            margin-bottom: 23px;
          }

          .about-form-grid {
            grid-template-columns: 1fr;
            gap: 0;
          }

          .about-form-control {
            min-height: 44px;
            font-size: 12px;
          }

          textarea.about-form-control {
            min-height: 135px;
          }

          .about-photo-preview {
            max-width: 100%;
          }

          .about-photo-preview img {
            height: 220px;
          }

          .about-form-actions {
            flex-direction: column-reverse;
            align-items: stretch;
          }

          .about-action-button {
            width: 100%;
          }

          .about-page-footer {
            flex-direction: column;
            align-items: flex-start;
          }
        }

        /* =================================================
           SMALL MOBILE
        ================================================= */

        @media (max-width: 575.98px) {
          .about-content {
            padding: 19px 11px 28px;
          }

          .about-page-title {
            font-size: 24px;
          }

          .about-heading {
            gap: 11px;
          }

          .about-heading-icon {
            width: 43px;
            height: 43px;
            font-size: 17px;
          }

          .about-page-description {
            font-size: 11px;
          }

          .about-form-body {
            padding: 16px;
          }

          .about-form-header {
            padding: 17px;
          }

          .about-section-title {
            font-size: 13px;
          }

          .about-section-description {
            font-size: 10px;
          }

          .about-form-label {
            font-size: 11px;
          }

          .about-active-box {
            padding: 12px;
          }

          .about-topbar-right {
            gap: 6px;
          }

          .about-topbar-button {
            width: 38px;
            height: 38px;
            min-height: 38px;
            padding: 0;
            border-radius: 9px;
          }
        }

        /* =================================================
           EXTRA SMALL
        ================================================= */

        @media (max-width: 399.98px) {
          .about-content {
            padding-left: 9px;
            padding-right: 9px;
          }

          .about-form-body {
            padding: 14px;
          }

          .about-page-title {
            font-size: 22px;
          }

          .about-topbar-title {
            max-width: 140px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
          }
        }

        /* =================================================
           REDUCED MOTION
        ================================================= */

        @media (prefers-reduced-motion: reduce) {
          .about-create-page *,
          .about-create-page
            *::before,
          .about-create-page
            *::after {
            animation-duration: 0.01ms !important;
            animation-iteration-count: 1 !important;
            transition-duration: 0.01ms !important;
          }
        }
      `}</style>

      <div className="about-create-page">
        <div className="about-layout">

          {/* =================================================
              SIDEBAR OVERLAY
          ================================================= */}

          {false && (
            <div
              className="about-sidebar-overlay"
            />
          )}

          {/* =================================================
              SIDEBAR
          ================================================= */}

          <aside
            className="about-sidebar"
          >
            <div className="about-sidebar-inner">

              {/* BRAND */}

              <div className="about-brand">

                <div className="about-brand-icon">
                  <i className="bi bi-grid-1x2-fill"></i>
                </div>

                <div className="about-brand-text">
                  <strong>
                    GloVaTech
                  </strong>

                  <span>
                    Admin Panel
                  </span>
                </div>

              </div>

              {/* MAIN MENU */}

              <div className="about-menu-label">
                MAIN MENU
              </div>

              <nav className="about-sidebar-nav">

                <a
                  href="/secure-panel"
                  className="about-sidebar-link"
                >
                  <span className="about-sidebar-icon">
                    <i className="bi bi-speedometer2"></i>
                  </span>

                  <span>
                    Dashboard
                  </span>
                </a>

              </nav>

              {/* CONTENT */}

              <div
                className="about-menu-label"
                style={{
                  marginTop: "24px",
                }}
              >
                CONTENT
              </div>

              <nav className="about-sidebar-nav">

                <a
                  href="/secure-panel/hero"
                  className="about-sidebar-link"
                >
                  <span className="about-sidebar-icon">
                    <i className="bi bi-stars"></i>
                  </span>

                  <span>
                    Hero
                  </span>
                </a>

                <a
                  href="/secure-panel/about"
                  className="about-sidebar-link active"
                >
                  <span className="about-sidebar-icon">
                    <i className="bi bi-person-vcard"></i>
                  </span>

                  <span>
                    About
                  </span>
                </a>

                <a
  href="/secure-panel/about/stats"
  className="about-sidebar-link"
>
  <span className="about-sidebar-icon">
    <i className="bi bi-bar-chart"></i>
  </span>

  <span>
    About Stats
  </span>
</a>

                <a
                  href="/secure-panel/education"
                  className="about-sidebar-link"
                >
                  <span className="about-sidebar-icon">
                    <i className="bi bi-mortarboard"></i>
                  </span>

                  <span>
                    Education
                  </span>
                </a>

                <a
                  href="/secure-panel/skills"
                  className="about-sidebar-link"
                >
                  <span className="about-sidebar-icon">
                    <i className="bi bi-tools"></i>
                  </span>

                  <span>
                    Skills
                  </span>
                </a>

                <a
                  href="/secure-panel/experience"
                  className="about-sidebar-link"
                >
                  <span className="about-sidebar-icon">
                    <i className="bi bi-briefcase"></i>
                  </span>

                  <span>
                    Experience
                  </span>
                </a>

                <a
                  href="/secure-panel/projects"
                  className="about-sidebar-link"
                >
                  <span className="about-sidebar-icon">
                    <i className="bi bi-code-square"></i>
                  </span>

                  <span>
                    Projects
                  </span>
                </a>

                <a
                  href="/secure-panel/certifications"
                  className="about-sidebar-link"
                >
                  <span className="about-sidebar-icon">
                    <i className="bi bi-patch-check"></i>
                  </span>

                  <span>
                    Certification
                  </span>
                </a>

                <a
                  href="/secure-panel/achievements"
                  className="about-sidebar-link"
                >
                  <span className="about-sidebar-icon">
                    <i className="bi bi-trophy"></i>
                  </span>

                  <span>
                    Achievement
                  </span>
                </a>

                <a
                  href="/secure-panel/services"
                  className="about-sidebar-link"
                >
                  <span className="about-sidebar-icon">
                    <i className="bi bi-gear-wide-connected"></i>
                  </span>

                  <span>
                    Services
                  </span>
                </a>

                <a
                  href="/secure-panel/gallery"
                  className="about-sidebar-link"
                >
                  <span className="about-sidebar-icon">
                    <i className="bi bi-images"></i>
                  </span>

                  <span>
                    Gallery
                  </span>
                </a>

                <a
                  href="/secure-panel/contact"
                  className="about-sidebar-link"
                >
                  <span className="about-sidebar-icon">
                    <i className="bi bi-person-lines-fill"></i>
                  </span>

                  <span>
                    Contact
                  </span>
                </a>

                <a
  href="/secure-panel/contact-info/list"
  className="about-sidebar-link"
>
  <span className="about-sidebar-icon">
     <i className="bi bi-share-fill"></i>
  </span>

  <span>
    Contact Info List
  </span>
</a>

                <a
                  href="/secure-panel/articles"
                  className="about-sidebar-link"
                >
                  <span className="about-sidebar-icon">
                    <i className="bi bi-journal-text"></i>
                  </span>

                  <span>
                    Articles
                  </span>
                </a>

<a
  href="/secure-panel/contact-messages"
  className="about-sidebar-link"
>
  <span className="about-sidebar-icon">
    <i className="bi bi-chat-left-text"></i>
  </span>

  <span>
    Contact Messages
  </span>
</a>

<a
  href="/secure-panel/contact-users"
  className="about-sidebar-link"
>
  <span className="about-sidebar-icon">
    <i className="bi bi-people-fill"></i>
  </span>

  <span>
    Contact User
  </span>
</a>
              </nav>

              {/* SIDEBAR BOTTOM */}

              <div className="about-sidebar-bottom">

                <a href="/">
                  <i className="bi bi-globe2"></i>

                  <span>
                    View Website
                  </span>

                  <i
                    className="bi bi-arrow-up-right"
                    style={{
                      marginLeft: "auto",
                    }}
                  ></i>
                </a>

              </div>

            </div>
          </aside>

          {/* =================================================
              MAIN
          ================================================= */}

          <div className="about-main">

            {/* =================================================
                TOPBAR
            ================================================= */}

            <header className="about-topbar">

              <div className="about-topbar-left">

                <button
                  type="button"
                  className="about-mobile-menu d-lg-none"
                  onClick={() => {
                    const sidebar =
                      document.querySelector(
                        ".about-sidebar"
                      );

                    const overlay =
                      document.querySelector(
                        ".about-sidebar-overlay"
                      );

                    sidebar?.classList.add(
                      "open"
                    );

                    if (overlay) {
                      (
                        overlay as HTMLElement
                      ).style.display =
                        "block";
                    }
                  }}
                  aria-label="Open menu"
                >
                  <i className="bi bi-list"></i>
                </button>

                <div>

                  <div className="about-topbar-label">
                    ADMIN PANEL
                  </div>

                  <div className="about-topbar-title">
                    About Management
                  </div>

                </div>

              </div>

              <div className="about-topbar-right">

                <a
                  href="/"
                  className="
                    about-topbar-button
                    about-website-button
                  "
                  title="View Website"
                >
                  <i className="bi bi-globe2"></i>

                  <span className="d-none d-sm-inline">
                    Website
                  </span>
                </a>

                <a
                  href="/secure-panel/login"
                  className="
                    about-topbar-button
                    about-logout-button
                  "
                  title="Logout"
                >
                  <i className="bi bi-box-arrow-right"></i>

                  <span className="d-none d-sm-inline">
                    Logout
                  </span>
                </a>

              </div>

            </header>

            {/* =================================================
                PAGE CONTENT
            ================================================= */}

            <main className="about-content">

              {/* =================================================
                  HEADER
              ================================================= */}

              <section className="about-page-header">

                <a
                  href="/secure-panel/about"
                  className="about-back-link"
                >
                  <i className="bi bi-arrow-left"></i>

                  Kembali ke About
                </a>

                <div className="about-heading">

                  <div className="about-heading-icon">
                    <i className="bi bi-person-vcard-fill"></i>
                  </div>

                  <div>

                    <div className="about-eyebrow">
                      WEBSITE CONTENT
                    </div>

                    <h1 className="about-page-title">
                      Tambah About
                    </h1>

                    <p className="about-page-description">
                      Tambahkan informasi About Me,
                      deskripsi singkat, foto profil,
                      sosial media, dan informasi kontak
                      yang akan ditampilkan pada website
                      portfolio GloVaTech.
                    </p>

                  </div>

                </div>

              </section>

              {/* =================================================
                  FORM CARD
              ================================================= */}

              <section className="about-form-card">

                {/* HEADER */}

                <div className="about-form-header">

                  <h2 className="about-form-header-title">
                    <i className="bi bi-pencil-square"></i>

                    About Information
                  </h2>

                  <p className="about-form-header-description">
                    Lengkapi informasi di bawah ini
                    dengan data yang ingin ditampilkan
                    pada halaman About website.
                  </p>

                </div>

                {/* BODY */}

                <div className="about-form-body">

                  <form
                    onSubmit={handleSubmit}
                  >

                    {/* =================================================
                        BASIC INFORMATION
                    ================================================= */}

                    <section className="about-section">

                      <h3 className="about-section-title">
                        <i className="bi bi-person-vcard"></i>

                        Basic Information
                      </h3>

                      <p className="about-section-description">
                        Masukkan informasi utama yang
                        akan digunakan untuk memperkenalkan
                        diri pada bagian About Me.
                      </p>

                      {/* BADGE */}

                      <div className="about-form-group">

                        <label
                          htmlFor="badge"
                          className="about-form-label"
                        >
                          Badge
                        </label>

                        <input
                          type="text"
                          id="badge"
                          name="badge"
                          className="about-form-control"
                          placeholder="Contoh: ABOUT ME"
                          value={form.badge}
                          onChange={
                            handleChange
                          }
                        />

                      </div>

                      {/* TITLE */}

                      <div className="about-form-group">

                        <label
                          htmlFor="title"
                          className="about-form-label"
                        >
                          Title <span>*</span>
                        </label>

                        <input
                          type="text"
                          id="title"
                          name="title"
                          className="about-form-control"
                          placeholder="Contoh: I am a"
                          value={form.title}
                          onChange={
                            handleChange
                          }
                          required
                        />

                      </div>

                      {/* HIGHLIGHT */}

                      <div className="about-form-group">

                        <label
                          htmlFor="highlight"
                          className="about-form-label"
                        >
                          Highlight
                        </label>

                        <input
                          type="text"
                          id="highlight"
                          name="highlight"
                          className="about-form-control"
                          placeholder="Contoh: Web Programmer"
                          value={
                            form.highlight
                          }
                          onChange={
                            handleChange
                          }
                        />

                        <div className="about-form-help">
                          Teks yang ingin ditampilkan
                          menggunakan warna utama
                          pada bagian About.
                        </div>

                      </div>

                      {/* DESCRIPTION */}

                      <div className="about-form-group">

                        <label
                          htmlFor="description"
                          className="about-form-label"
                        >
                          Description
                        </label>

                        <textarea
                          id="description"
                          name="description"
                          className="about-form-control"
                          rows={6}
                          placeholder="Tulis deskripsi About Me..."
                          value={
                            form.description
                          }
                          onChange={
                            handleChange
                          }
                        ></textarea>

                        <div className="about-form-help">
                          Gunakan deskripsi singkat,
                          profesional, dan mudah dibaca
                          untuk menjelaskan profil,
                          keahlian, atau fokus utama.
                        </div>

                      </div>

                    </section>

                    {/* =================================================
                        PHOTO
                    ================================================= */}

                    <section className="about-section">

                      <h3 className="about-section-title">
                        <i className="bi bi-image"></i>

                        Profile Photo
                      </h3>

                      <p className="about-section-description">
                        Upload foto yang akan digunakan
                        pada bagian About Me. Gunakan
                        gambar dengan kualitas baik dan
                        rasio yang sesuai.
                      </p>

                      <div className="about-upload-box">

                        <label
                          htmlFor="photo"
                          className="about-form-label"
                        >
                          Upload Foto
                        </label>

                        <input
                          type="file"
                          id="photo"
                          name="photo"
                          className="about-form-control"
                          accept="image/*"
                          onChange={
                            handlePhotoChange
                          }
                        />

                        <div className="about-form-help">
                          Format gambar seperti JPG,
                          JPEG, PNG, atau WebP.
                        </div>

                        {photoPreview && (
                          <div className="about-photo-preview">

                            <span className="about-preview-label">
                              Preview Foto
                            </span>

                            <img
                              src={
                                photoPreview
                              }
                              alt="Preview About"
                            />

                          </div>
                        )}

                      </div>

                    </section>

                    {/* =================================================
                        SOCIAL MEDIA
                    ================================================= */}

                    <section className="about-section">

                      <h3 className="about-section-title">
                        <i className="bi bi-share"></i>

                        Social Media & Contact
                      </h3>

                      <p className="about-section-description">
                        Isi hanya sosial media dan kontak
                        yang ingin ditampilkan pada
                        website. Field yang dikosongkan
                        dapat digunakan sebagai informasi
                        yang tidak ingin ditampilkan.
                      </p>

                      <div className="about-form-grid">

                        {/* GITHUB */}

                        <div className="about-form-group">

                          <label
                            htmlFor="github"
                            className="
                              about-form-label
                              about-social-label
                            "
                          >
                            <i className="bi bi-github"></i>
                            GitHub
                          </label>

                          <input
                            type="url"
                            id="github"
                            name="github"
                            className="about-form-control"
                            placeholder="https://github.com/username"
                            value={
                              form.github
                            }
                            onChange={
                              handleChange
                            }
                          />

                        </div>

                        {/* FACEBOOK */}

                        <div className="about-form-group">

                          <label
                            htmlFor="facebook"
                            className="
                              about-form-label
                              about-social-label
                            "
                          >
                            <i className="bi bi-facebook"></i>
                            Facebook
                          </label>

                          <input
                            type="url"
                            id="facebook"
                            name="facebook"
                            className="about-form-control"
                            placeholder="https://facebook.com/username"
                            value={
                              form.facebook
                            }
                            onChange={
                              handleChange
                            }
                          />

                        </div>

                        {/* INSTAGRAM */}

                        <div className="about-form-group">

                          <label
                            htmlFor="instagram"
                            className="
                              about-form-label
                              about-social-label
                            "
                          >
                            <i className="bi bi-instagram"></i>
                            Instagram
                          </label>

                          <input
                            type="url"
                            id="instagram"
                            name="instagram"
                            className="about-form-control"
                            placeholder="https://instagram.com/username"
                            value={
                              form.instagram
                            }
                            onChange={
                              handleChange
                            }
                          />

                        </div>

                        {/* TWITTER */}

                        <div className="about-form-group">

                          <label
                            htmlFor="twitter"
                            className="
                              about-form-label
                              about-social-label
                            "
                          >
                            <i className="bi bi-twitter-x"></i>
                            Twitter / X
                          </label>

                          <input
                            type="url"
                            id="twitter"
                            name="twitter"
                            className="about-form-control"
                            placeholder="https://x.com/username"
                            value={
                              form.twitter
                            }
                            onChange={
                              handleChange
                            }
                          />

                        </div>

                        {/* TIKTOK */}

                        <div className="about-form-group">

                          <label
                            htmlFor="tiktok"
                            className="
                              about-form-label
                              about-social-label
                            "
                          >
                            <i className="bi bi-tiktok"></i>
                            TikTok
                          </label>

                          <input
                            type="url"
                            id="tiktok"
                            name="tiktok"
                            className="about-form-control"
                            placeholder="https://tiktok.com/@username"
                            value={
                              form.tiktok
                            }
                            onChange={
                              handleChange
                            }
                          />

                        </div>

                        {/* EMAIL */}

                        <div className="about-form-group">

                          <label
                            htmlFor="email"
                            className="
                              about-form-label
                              about-social-label
                            "
                          >
                            <i className="bi bi-envelope"></i>
                            Email
                          </label>

                          <input
                            type="email"
                            id="email"
                            name="email"
                            className="about-form-control"
                            placeholder="nama@email.com"
                            value={
                              form.email
                            }
                            onChange={
                              handleChange
                            }
                          />

                        </div>

                      </div>

                    </section>

                    {/* =================================================
                        STATUS
                    ================================================= */}

                    <section className="about-section">

                      <h3 className="about-section-title">
                        <i className="bi bi-toggle2-on"></i>

                        Publication Status
                      </h3>

                      <p className="about-section-description">
                        Tentukan apakah konten About
                        ini langsung diaktifkan dan
                        ditampilkan pada website.
                      </p>

                      <div className="about-active-box">

                        <input
                          className="form-check-input"
                          type="checkbox"
                          role="switch"
                          id="active"
                          name="active"
                          checked={
                            form.active
                          }
                          onChange={
                            handleChange
                          }
                        />

                        <label
                          htmlFor="active"
                          className="about-active-text"
                        >
                          <strong>
                            Aktifkan About
                          </strong>

                          <span>
                            About akan tersedia dan
                            dapat ditampilkan pada
                            website ketika status
                            ini aktif.
                          </span>
                        </label>

                      </div>

                    </section>

                    {/* =================================================
                        ACTIONS
                    ================================================= */}

                    <div className="about-form-actions">

                      <a
                        href="/secure-panel/about"
                        className="
                          about-action-button
                          about-cancel-button
                        "
                      >
                        <i className="bi bi-x-lg"></i>

                        Batal
                      </a>

                      <button
                        type="submit"
                        className="
                          about-action-button
                          about-save-button
                        "
                        disabled={loading}
                      >

                        {loading ? (
                          <>
                            <span
                              className="
                                spinner-border
                                spinner-border-sm
                              "
                              role="status"
                              aria-hidden="true"
                            ></span>

                            Menyimpan...
                          </>
                        ) : (
                          <>
                            <i className="bi bi-check-lg"></i>

                            Simpan About
                          </>
                        )}

                      </button>

                    </div>

                  </form>

                </div>

              </section>

              {/* =================================================
                  FOOTER
              ================================================= */}

              <footer className="about-page-footer">

                <span>
                  <i className="bi bi-shield-check me-1"></i>
                  Admin Content Management System
                </span>

                <a href="/secure-panel/about">
                  <i className="bi bi-arrow-left me-1"></i>
                  Back to About
                </a>

              </footer>

            </main>

          </div>

        </div>
      </div>
    </>
  );
}