"use client";

import { FormEvent, useState } from "react";
import Link from "next/link";

export default function CreateEducationPage() {
  const [saving, setSaving] = useState(false);
  const [sidebarOpen, setSidebarOpen] = useState(false);

  const [form, setForm] = useState({
    institution: "",
    degree: "S1",
    field: "",
    startDate: "",
    endDate: "",
    description: "",
  });

  // =========================================
  // HANDLE CHANGE
  // =========================================

  const handleChange = (
    e: React.ChangeEvent<
      HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement
    >
  ) => {
    const { name, value } = e.target;

    setForm((prev) => ({
      ...prev,
      [name]: value,
    }));
  };

  // =========================================
  // SUBMIT
  // BACKEND TIDAK DIUBAH
  // =========================================

  const handleSubmit = async (e: FormEvent) => {
    e.preventDefault();

    if (!form.institution.trim()) {
      alert("Institution is required.");
      return;
    }

    if (!form.startDate) {
      alert("Start year is required.");
      return;
    }

    setSaving(true);

    try {
      const response = await fetch("/api/education", {
        method: "POST",
        headers: {
          "Content-Type": "application/json",
        },
        body: JSON.stringify({
          institution: form.institution.trim(),
          degree: form.degree,
          field: form.field.trim(),
          startDate: form.startDate,
          endDate: form.endDate || null,
          description: form.description.trim(),
        }),
      });

      const result = await response.json();

      if (!response.ok || !result.success) {
        console.error("CREATE EDUCATION API ERROR:", result);

        alert(result.message || "Failed to add education.");

        return;
      }

      alert("Education successfully added.");

      window.location.href = "/secure-panel/education";
    } catch (error) {
      console.error("CREATE EDUCATION ERROR:", error);

      alert("An error occurred while adding education.");
    } finally {
      setSaving(false);
    }
  };

  // =========================================
  // CLOSE SIDEBAR
  // =========================================

  const closeSidebar = () => {
    setSidebarOpen(false);
  };

  return (
    <>
      <style>{`
        * {
          box-sizing: border-box;
        }

        html,
        body {
          max-width: 100%;
          overflow-x: hidden;
        }

        /* ========================================
           MAIN
        ======================================== */

        .education-create-admin {
          min-height: 100vh;
          background: #f5f7fb;
          color: #1f2937;
        }

        .admin-layout {
          min-height: 100vh;
          display: flex;
          position: relative;
        }

        /* ========================================
           SIDEBAR
        ======================================== */

        .admin-sidebar {
          width: 270px;
          min-width: 270px;
          height: 100vh;
          position: fixed;
          top: 0;
          left: 0;
          z-index: 1050;
          background: #ffffff;
          border-right: 1px solid #e8ecf1;
          transition: transform 0.3s ease;
        }

        .sidebar-inner {
          height: 100%;
          display: flex;
          flex-direction: column;
          padding: 24px 16px;
          overflow-y: auto;
        }

        .sidebar-brand {
          display: flex;
          align-items: center;
          gap: 12px;
          padding: 4px 10px 28px;
          border-bottom: 1px solid #edf0f4;
          margin-bottom: 22px;
        }

        .brand-icon {
          width: 42px;
          height: 42px;
          border-radius: 12px;
          display: flex;
          align-items: center;
          justify-content: center;
          background: linear-gradient(135deg, #198754, #20c997);
          color: white;
          font-size: 18px;
          box-shadow: 0 8px 20px rgba(25, 135, 84, 0.2);
          flex-shrink: 0;
        }

        .brand-text {
          min-width: 0;
        }

        .brand-text strong {
          display: block;
          font-size: 16px;
          line-height: 1.2;
          color: #17202a;
        }

        .brand-text span {
          display: block;
          margin-top: 3px;
          font-size: 11px;
          color: #8b95a5;
          font-weight: 600;
          letter-spacing: 0.08em;
          text-transform: uppercase;
        }

        .sidebar-close {
          margin-left: auto;
          border: 0;
          background: transparent;
          color: #7b8492;
          font-size: 17px;
        }

        .sidebar-section-label {
          padding: 0 12px;
          margin-bottom: 8px;
          color: #9aa3af;
          font-size: 10px;
          font-weight: 700;
          letter-spacing: 0.1em;
        }

        .sidebar-nav {
          display: flex;
          flex-direction: column;
          gap: 4px;
        }

        .sidebar-link {
          display: flex;
          align-items: center;
          gap: 12px;
          min-height: 44px;
          padding: 10px 12px;
          border-radius: 11px;
          color: #697386;
          text-decoration: none;
          font-size: 14px;
          font-weight: 500;
          transition:
            background 0.2s ease,
            color 0.2s ease,
            transform 0.2s ease;
        }

        .sidebar-link:hover {
          background: #f0f8f4;
          color: #198754;
          transform: translateX(2px);
        }

        .sidebar-link.active {
          background: linear-gradient(
            90deg,
            rgba(25, 135, 84, 0.12),
            rgba(25, 135, 84, 0.06)
          );
          color: #198754;
          font-weight: 700;
        }

        .sidebar-link-icon {
          width: 23px;
          text-align: center;
          font-size: 16px;
          flex-shrink: 0;
        }

        .sidebar-bottom {
          margin-top: auto;
          padding-top: 18px;
          border-top: 1px solid #edf0f4;
        }

        .sidebar-bottom a {
          display: flex;
          align-items: center;
          gap: 10px;
          padding: 11px 12px;
          border-radius: 10px;
          color: #6b7280;
          text-decoration: none;
          font-size: 13px;
          transition: 0.2s ease;
        }

        .sidebar-bottom a:hover {
          background: #f5f7fa;
          color: #198754;
        }

        /* ========================================
           MAIN AREA
        ======================================== */

        .admin-main {
          width: calc(100% - 270px);
          margin-left: 270px;
          min-width: 0;
        }

        /* ========================================
           TOPBAR
        ======================================== */

        .admin-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);
        }

        .topbar-left {
          display: flex;
          align-items: center;
          gap: 14px;
          min-width: 0;
        }

        .mobile-menu-button {
          width: 40px;
          height: 40px;
          border: 1px solid #e2e7ed;
          background: #fff;
          border-radius: 10px;
          color: #344054;
          font-size: 18px;
        }

        .mobile-menu-button:hover {
          background: #f5f8f6;
          color: #198754;
        }

        .topbar-label {
          color: #9aa3af;
          font-size: 10px;
          font-weight: 700;
          letter-spacing: 0.1em;
          margin-bottom: 3px;
        }

        .topbar-title {
          color: #17202a;
          font-size: 15px;
          font-weight: 700;
        }

        .topbar-right {
          display: flex;
          align-items: center;
          gap: 10px;
          flex-shrink: 0;
        }

        .topbar-website,
        .topbar-logout {
          min-height: 40px;
          display: inline-flex;
          align-items: center;
          justify-content: center;
          gap: 8px;
          border-radius: 10px;
          padding: 8px 13px;
          text-decoration: none;
          font-size: 13px;
          font-weight: 600;
          transition: 0.2s ease;
        }

        .topbar-website {
          color: #667085;
          border: 1px solid #e4e8ed;
          background: #fff;
        }

        .topbar-website:hover {
          color: #198754;
          border-color: #b7ddca;
          background: #f4fbf7;
        }

        .topbar-logout {
          color: #dc3545;
          border: 1px solid #f1c4c9;
          background: #fff;
        }

        .topbar-logout:hover {
          background: #fff5f6;
          border-color: #e8aeb5;
        }

        /* ========================================
           CONTENT
        ======================================== */

        .admin-content {
          width: 100%;
          max-width: 1500px;
          margin: 0 auto;
          padding: 34px;
          animation: contentEnter 0.45s ease both;
        }

        @keyframes contentEnter {
          from {
            opacity: 0;
            transform: translateY(10px);
          }

          to {
            opacity: 1;
            transform: translateY(0);
          }
        }

        /* ========================================
           PAGE HEADER
        ======================================== */

        .page-heading {
          width: 100%;
          max-width: 1100px;
          margin: 0 auto 28px;
        }

        .back-dashboard {
          display: inline-flex;
          align-items: center;
          gap: 7px;
          margin-bottom: 18px;
          color: #6b7280;
          font-size: 13px;
          font-weight: 600;
          text-decoration: none;
          transition: 0.2s ease;
        }

        .back-dashboard:hover {
          color: #198754;
          transform: translateX(-2px);
        }

        .page-title-row {
          display: flex;
          align-items: flex-start;
          gap: 15px;
        }

        .page-title-icon {
          width: 54px;
          height: 54px;
          border-radius: 15px;
          background: linear-gradient(
            135deg,
            rgba(25, 135, 84, 0.13),
            rgba(32, 201, 151, 0.08)
          );
          color: #198754;
          display: flex;
          align-items: center;
          justify-content: center;
          font-size: 22px;
          flex-shrink: 0;
        }

        .page-eyebrow {
          color: #198754;
          font-size: 10px;
          font-weight: 800;
          letter-spacing: 0.11em;
          margin-bottom: 4px;
        }

        .page-title {
          margin: 0;
          font-size: clamp(26px, 3vw, 34px);
          font-weight: 800;
          letter-spacing: -0.025em;
          color: #182230;
        }

        .page-description {
          margin: 7px 0 0;
          color: #7a8493;
          font-size: 14px;
          line-height: 1.7;
          max-width: 720px;

          /* JUSTIFY */
          text-align: justify;
          text-justify: inter-word;
        }

        /* ========================================
           FORM CARD
        ======================================== */

        .form-card-wrapper {
          width: 100%;
          max-width: 1100px;
          margin: 0 auto;
        }

        .form-card {
          width: 100%;
          background: #ffffff;
          border: 1px solid #e6ebef;
          border-radius: 20px;
          overflow: hidden;
          box-shadow:
            0 8px 30px rgba(20, 30, 45, 0.045),
            0 2px 8px rgba(20, 30, 45, 0.025);
        }

        .form-card-header {
          padding: 24px 28px;
          border-bottom: 1px solid #edf0f3;
          display: flex;
          align-items: center;
          justify-content: space-between;
          gap: 20px;
          background: linear-gradient(
            180deg,
            #ffffff 0%,
            #fcfdfd 100%
          );
        }

        .form-header-left {
          display: flex;
          align-items: center;
          gap: 13px;
          min-width: 0;
        }

        .form-header-icon {
          width: 44px;
          height: 44px;
          border-radius: 12px;
          background: #eaf7f0;
          color: #198754;
          display: flex;
          align-items: center;
          justify-content: center;
          font-size: 18px;
          flex-shrink: 0;
        }

        .form-header-title {
          margin: 0;
          color: #182230;
          font-size: 17px;
          font-weight: 800;
        }

        .form-header-description {
          margin: 4px 0 0;
          color: #8a93a0;
          font-size: 12px;
          line-height: 1.55;

          /* JUSTIFY */
          text-align: justify;
          text-justify: inter-word;
        }

        .form-status {
          display: inline-flex;
          align-items: center;
          gap: 6px;
          padding: 7px 10px;
          border-radius: 8px;
          background: #f1f8f4;
          color: #198754;
          font-size: 10px;
          font-weight: 700;
          white-space: nowrap;
          flex-shrink: 0;
        }

        .form-status-dot {
          width: 6px;
          height: 6px;
          border-radius: 50%;
          background: #198754;
        }

        .form-card-body {
          padding: 30px;
        }

        .form-inner {
          width: 100%;
          max-width: 900px;
          margin: 0 auto;
        }

        /* ========================================
           FORM SECTION
        ======================================== */

        .form-section {
          margin-bottom: 28px;
        }

        .form-section:last-child {
          margin-bottom: 0;
        }

        .form-section-heading {
          display: flex;
          align-items: center;
          gap: 10px;
          margin-bottom: 18px;
          padding-bottom: 10px;
          border-bottom: 1px solid #edf0f3;
        }

        .form-section-number {
          width: 28px;
          height: 28px;
          border-radius: 8px;
          display: flex;
          align-items: center;
          justify-content: center;
          background: #eaf7f0;
          color: #198754;
          font-size: 11px;
          font-weight: 800;
          flex-shrink: 0;
        }

        .form-section-title {
          margin: 0;
          color: #263241;
          font-size: 13px;
          font-weight: 800;
        }

        .form-section-description {
          margin: 2px 0 0;
          color: #9aa3af;
          font-size: 10px;
          line-height: 1.5;

          /* JUSTIFY */
          text-align: justify;
          text-justify: inter-word;
        }

        /* ========================================
           FORM GROUP
        ======================================== */

        .form-group {
          margin-bottom: 20px;
        }

        .form-group:last-child {
          margin-bottom: 0;
        }

        .form-label-custom {
          display: flex;
          align-items: center;
          gap: 5px;
          margin-bottom: 8px;
          color: #344054;
          font-size: 12px;
          font-weight: 700;
        }

        .required-mark {
          color: #dc3545;
          font-size: 12px;
        }

        .form-control-custom,
        .form-select-custom {
          width: 100%;
          min-height: 46px;
          border: 1px solid #dfe5eb;
          border-radius: 10px;
          background: #ffffff;
          color: #344054;
          padding: 10px 13px;
          font-size: 13px;
          outline: none;
          transition:
            border-color 0.2s ease,
            box-shadow 0.2s ease,
            background 0.2s ease;
        }

        .form-control-custom::placeholder {
          color: #adb5bf;
        }

        .form-control-custom:hover,
        .form-select-custom:hover {
          border-color: #c7d0d9;
        }

        .form-control-custom:focus,
        .form-select-custom:focus {
          border-color: #198754;
          box-shadow: 0 0 0 3px rgba(25, 135, 84, 0.1);
          background: #ffffff;
        }

        .form-select-custom {
          cursor: pointer;
        }

        .textarea-custom {
          min-height: 150px;
          resize: vertical;
          line-height: 1.65;

          /* JUSTIFY */
          text-align: justify;
          text-justify: inter-word;
        }

        .field-help {
          margin-top: 6px;
          color: #9aa3af;
          font-size: 10px;
          line-height: 1.5;

          /* JUSTIFY */
          text-align: justify;
          text-justify: inter-word;
        }

        /* ========================================
           DATE GRID
        ======================================== */

        .date-grid {
          display: grid;
          grid-template-columns: repeat(2, minmax(0, 1fr));
          gap: 18px;
        }

        /* ========================================
           FORM FOOTER
        ======================================== */

        .form-footer {
          margin-top: 30px;
          padding-top: 22px;
          border-top: 1px solid #edf0f3;
          display: flex;
          align-items: center;
          justify-content: space-between;
          gap: 15px;
        }

        .form-footer-note {
          display: flex;
          align-items: flex-start;
          gap: 8px;
          color: #98a1ae;
          font-size: 10px;
          line-height: 1.5;
          max-width: 400px;

          /* JUSTIFY */
          text-align: justify;
          text-justify: inter-word;
        }

        .form-footer-note i {
          color: #198754;
          font-size: 13px;
          margin-top: 1px;
          flex-shrink: 0;
        }

        .form-actions {
          display: flex;
          align-items: center;
          justify-content: flex-end;
          gap: 9px;
          flex-shrink: 0;
        }

        .cancel-button,
        .save-button {
          min-height: 43px;
          display: inline-flex;
          align-items: center;
          justify-content: center;
          gap: 7px;
          padding: 9px 16px;
          border-radius: 10px;
          font-size: 12px;
          font-weight: 700;
          text-decoration: none;
          transition: 0.2s ease;
          cursor: pointer;
        }

        .cancel-button {
          color: #667085;
          background: #ffffff;
          border: 1px solid #dfe4e9;
        }

        .cancel-button:hover {
          color: #344054;
          background: #f7f8fa;
          border-color: #cfd6dd;
        }

        .save-button {
          color: #ffffff;
          background: linear-gradient(
            135deg,
            #198754,
            #20a46c
          );
          border: 1px solid #198754;
          box-shadow: 0 7px 16px rgba(25, 135, 84, 0.18);
        }

        .save-button:hover:not(:disabled) {
          color: #ffffff;
          transform: translateY(-1px);
          box-shadow: 0 10px 22px rgba(25, 135, 84, 0.25);
        }

        .save-button:disabled {
          opacity: 0.65;
          cursor: not-allowed;
          box-shadow: none;
        }

        /* ========================================
           PAGE FOOTER
        ======================================== */

        .admin-page-footer {
          width: 100%;
          max-width: 1100px;
          margin: 0 auto;
          padding: 20px 3px 5px;
          display: flex;
          align-items: center;
          justify-content: space-between;
          gap: 15px;
          color: #9aa3af;
          font-size: 11px;
        }

        .admin-page-footer div {
          display: flex;
          align-items: center;
          gap: 7px;
        }

        .admin-page-footer i {
          color: #198754;
        }

        .admin-page-footer a {
          color: #7b8492;
          text-decoration: none;
          font-weight: 600;
        }

        .admin-page-footer a:hover {
          color: #198754;
        }

        /* ========================================
           OVERLAY
        ======================================== */

        .sidebar-overlay {
          display: none;
        }

        /* ========================================
           LARGE DESKTOP
        ======================================== */

        @media (max-width: 1399.98px) {
          .admin-content {
            padding: 30px;
          }

          .form-card-body {
            padding: 28px;
          }
        }

        /* ========================================
           TABLET
        ======================================== */

        @media (max-width: 1199.98px) {
          .admin-content {
            padding: 28px;
          }

          .page-heading,
          .form-card-wrapper,
          .admin-page-footer {
            max-width: 950px;
          }

          .form-inner {
            max-width: 800px;
          }
        }

        /* ========================================
           MOBILE SIDEBAR
        ======================================== */

        @media (max-width: 991.98px) {
          .admin-sidebar {
            transform: translateX(-100%);
            box-shadow: 15px 0 40px rgba(20, 30, 45, 0.1);
          }

          .admin-sidebar.open {
            transform: translateX(0);
          }

          .admin-main {
            width: 100%;
            margin-left: 0;
          }

          .sidebar-overlay {
            position: fixed;
            inset: 0;
            z-index: 1040;
            display: block;
            background: rgba(15, 23, 42, 0.35);
            backdrop-filter: blur(2px);
          }

          .admin-topbar {
            padding: 0 24px;
          }
        }

        /* ========================================
           MOBILE
        ======================================== */

        @media (max-width: 767.98px) {
          .admin-topbar {
            height: 68px;
            padding: 0 16px;
          }

          .topbar-title {
            font-size: 13px;
          }

          .admin-content {
            width: 100%;
            max-width: 100%;
            padding: 22px 16px;
          }

          .page-heading {
            max-width: 100%;
            margin-bottom: 22px;
          }

          .page-title-row {
            gap: 12px;
          }

          .page-title-icon {
            width: 47px;
            height: 47px;
            border-radius: 13px;
            font-size: 19px;
          }

          .page-title {
            font-size: 26px;
          }

          .page-description {
            font-size: 12px;
            line-height: 1.7;
          }

          .form-card-wrapper {
            max-width: 100%;
          }

          .form-card {
            border-radius: 15px;
          }

          .form-card-header {
            padding: 19px;
            align-items: flex-start;
          }

          .form-header-title {
            font-size: 15px;
          }

          .form-header-description {
            font-size: 11px;
          }

          .form-status {
            font-size: 9px;
            padding: 6px 8px;
          }

          .form-status span {
            display: none;
          }

          .form-card-body {
            padding: 20px 18px;
          }

          .form-inner {
            max-width: 100%;
          }

          .form-section {
            margin-bottom: 24px;
          }

          .date-grid {
            grid-template-columns: 1fr;
            gap: 18px;
          }

          .form-footer {
            align-items: stretch;
            flex-direction: column;
          }

          .form-footer-note {
            max-width: 100%;
          }

          .form-actions {
            width: 100%;
            display: grid;
            grid-template-columns: 1fr 1fr;
          }

          .cancel-button,
          .save-button {
            width: 100%;
          }

          .admin-page-footer {
            max-width: 100%;
            flex-direction: column;
            align-items: flex-start;
          }
        }

        /* ========================================
           SMALL MOBILE
        ======================================== */

        @media (max-width: 575.98px) {
          .admin-content {
            padding: 19px 12px;
          }

          .page-title-row {
            align-items: flex-start;
          }

          .page-title-icon {
            width: 43px;
            height: 43px;
            border-radius: 11px;
            font-size: 17px;
          }

          .page-title {
            font-size: 23px;
          }

          .page-description {
            font-size: 11px;
          }

          .form-card-header {
            padding: 17px;
          }

          .form-header-icon {
            width: 39px;
            height: 39px;
            border-radius: 10px;
            font-size: 16px;
          }

          .form-header-title {
            font-size: 14px;
          }

          .form-header-description {
            font-size: 10px;
          }

          .form-card-body {
            padding: 18px 15px;
          }

          .form-section-heading {
            margin-bottom: 15px;
          }

          .form-section-title {
            font-size: 12px;
          }

          .form-label-custom {
            font-size: 11px;
          }

          .form-control-custom,
          .form-select-custom {
            min-height: 44px;
            font-size: 12px;
            padding: 9px 11px;
          }

          .textarea-custom {
            min-height: 140px;
          }

          .form-actions {
            grid-template-columns: 1fr;
          }

          .cancel-button,
          .save-button {
            min-height: 42px;
          }

          .admin-page-footer {
            padding-left: 2px;
            padding-right: 2px;
          }
        }

        /* ========================================
           EXTRA SMALL
        ======================================== */

        @media (max-width: 399.98px) {
          .topbar-right {
            gap: 6px;
          }

          .topbar-website,
          .topbar-logout {
            width: 38px;
            height: 38px;
            min-height: 38px;
            padding: 0;
            border-radius: 9px;
          }

          .topbar-title {
            max-width: 145px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
          }

          .page-title {
            font-size: 21px;
          }

          .page-title-row {
            gap: 10px;
          }

          .form-card {
            border-radius: 13px;
          }

          .form-card-body {
            padding: 16px 13px;
          }
        }

        /* ========================================
           REDUCED MOTION
        ======================================== */

        @media (prefers-reduced-motion: reduce) {
          .education-create-admin *,
          .education-create-admin *::before,
          .education-create-admin *::after {
            animation-duration: 0.01ms !important;
            animation-iteration-count: 1 !important;
            transition-duration: 0.01ms !important;
          }
        }
      `}</style>

      <div className="education-create-admin">
        <div className="admin-layout">

          {/* ======================================
              MOBILE OVERLAY
          ====================================== */}

          {sidebarOpen && (
            <div
              className="sidebar-overlay"
              onClick={closeSidebar}
              aria-hidden="true"
            />
          )}

          {/* ======================================
              SIDEBAR
          ====================================== */}

          <aside
            className={`admin-sidebar ${
              sidebarOpen ? "open" : ""
            }`}
          >
            <div className="sidebar-inner">

              {/* BRAND */}

              <div className="sidebar-brand">
                <div className="brand-icon">
                  <i className="bi bi-grid-1x2-fill"></i>
                </div>

                <div className="brand-text">
                  <strong>GloVaTech</strong>
                  <span>Admin Panel</span>
                </div>

                <button
                  type="button"
                  className="sidebar-close d-lg-none"
                  onClick={closeSidebar}
                  aria-label="Close sidebar"
                >
                  <i className="bi bi-x-lg"></i>
                </button>
              </div>

              {/* MAIN MENU */}

              <div className="sidebar-section-label">
                MAIN MENU
              </div>

              <nav className="sidebar-nav">
                <Link
                  href="/secure-panel"
                  className="sidebar-link"
                  onClick={closeSidebar}
                >
                  <span className="sidebar-link-icon">
                    <i className="bi bi-speedometer2"></i>
                  </span>

                  <span>Dashboard</span>
                </Link>
              </nav>

              {/* CONTENT */}

              <div className="sidebar-section-label mt-4">
                CONTENT
              </div>

              <nav className="sidebar-nav">

                <Link
                  href="/secure-panel/hero"
                  className="sidebar-link"
                  onClick={closeSidebar}
                >
                  <span className="sidebar-link-icon">
                    <i className="bi bi-stars"></i>
                  </span>

                  <span>Hero</span>
                </Link>

                <Link
                  href="/secure-panel/about"
                  className="sidebar-link"
                  onClick={closeSidebar}
                >
                  <span className="sidebar-link-icon">
                    <i className="bi bi-person-vcard"></i>
                  </span>

                  <span>About</span>
                </Link>

                <Link
  href="/secure-panel/about/stats"
  className="sidebar-link"
  onClick={closeSidebar}
>
  <span className="sidebar-link-icon">
    <i className="bi bi-bar-chart"></i>
  </span>

  <span>About Stats</span>
</Link>

                <Link
                  href="/secure-panel/education"
                  className="sidebar-link active"
                  onClick={closeSidebar}
                >
                  <span className="sidebar-link-icon">
                    <i className="bi bi-mortarboard"></i>
                  </span>

                  <span>Education</span>
                </Link>

                <Link
                  href="/secure-panel/skills"
                  className="sidebar-link"
                  onClick={closeSidebar}
                >
                  <span className="sidebar-link-icon">
                    <i className="bi bi-tools"></i>
                  </span>

                  <span>Skills</span>
                </Link>

                <Link
                  href="/secure-panel/experience"
                  className="sidebar-link"
                  onClick={closeSidebar}
                >
                  <span className="sidebar-link-icon">
                    <i className="bi bi-briefcase"></i>
                  </span>

                  <span>Experience</span>
                </Link>

                <Link
                  href="/secure-panel/projects"
                  className="sidebar-link"
                  onClick={closeSidebar}
                >
                  <span className="sidebar-link-icon">
                    <i className="bi bi-code-square"></i>
                  </span>

                  <span>Projects</span>
                </Link>

                <Link
                  href="/secure-panel/certifications"
                  className="sidebar-link"
                  onClick={closeSidebar}
                >
                  <span className="sidebar-link-icon">
                    <i className="bi bi-patch-check"></i>
                  </span>

                  <span>Certification</span>
                </Link>

                <Link
                  href="/secure-panel/achievements"
                  className="sidebar-link"
                  onClick={closeSidebar}
                >
                  <span className="sidebar-link-icon">
                    <i className="bi bi-trophy"></i>
                  </span>

                  <span>Achievement</span>
                </Link>

                <Link
                  href="/secure-panel/services"
                  className="sidebar-link"
                  onClick={closeSidebar}
                >
                  <span className="sidebar-link-icon">
                    <i className="bi bi-gear-wide-connected"></i>
                  </span>

                  <span>Services</span>
                </Link>

                <Link
                  href="/secure-panel/gallery"
                  className="sidebar-link"
                  onClick={closeSidebar}
                >
                  <span className="sidebar-link-icon">
                    <i className="bi bi-images"></i>
                  </span>

                  <span>Gallery</span>
                </Link>

                <Link
                  href="/secure-panel/contact-info"
                  className="sidebar-link"
                  onClick={closeSidebar}
                >
                  <span className="sidebar-link-icon">
                    <i className="bi bi-person-lines-fill"></i>
                  </span>

                  <span>Contact</span>
                </Link>

                <Link
  href="/secure-panel/contact-info/list"
  className="sidebar-link"
  onClick={closeSidebar}
>
  <span className="sidebar-link-icon">
    <i className="bi bi-share-fill"></i>
  </span>

  <span>Contact Social Media</span>
</Link>

                <Link
                  href="/secure-panel/articles"
                  className="sidebar-link"
                  onClick={closeSidebar}
                >
                  <span className="sidebar-link-icon">
                    <i className="bi bi-journal-text"></i>
                  </span>

                  <span>Articles</span>
                </Link>

                <Link
  href="/secure-panel/contact-messages"
  className="sidebar-link"
  onClick={closeSidebar}
>
  <span className="sidebar-link-icon">
    <i className="bi bi-chat-left-text"></i>
  </span>

  <span>Contact Messages</span>
</Link>

<Link
  href="/secure-panel/contact-users"
  className="sidebar-link"
  onClick={closeSidebar}
>
  <span className="sidebar-link-icon">
    <i className="bi bi-people-fill"></i>
  </span>

  <span>Contact User</span>
</Link>

              </nav>

              {/* SIDEBAR BOTTOM */}

              <div className="sidebar-bottom">
                <Link href="/">
                  <i className="bi bi-globe2"></i>

                  <span>View Website</span>

                  <i className="bi bi-arrow-up-right ms-auto"></i>
                </Link>
              </div>

            </div>
          </aside>

          {/* ======================================
              MAIN
          ====================================== */}

          <div className="admin-main">

            {/* ====================================
                TOPBAR
            ==================================== */}

            <header className="admin-topbar">

              <div className="topbar-left">

                <button
                  type="button"
                  className="mobile-menu-button d-lg-none"
                  onClick={() => setSidebarOpen(true)}
                  aria-label="Open menu"
                >
                  <i className="bi bi-list"></i>
                </button>

                <div>
                  <div className="topbar-label">
                    ADMIN PANEL
                  </div>

                  <div className="topbar-title">
                    Create Education
                  </div>
                </div>

              </div>

              <div className="topbar-right">

                <Link
                  href="/"
                  className="topbar-website"
                  title="View Website"
                >
                  <i className="bi bi-globe2"></i>

                  <span className="d-none d-sm-inline">
                    Website
                  </span>
                </Link>

                <Link
                  href="/secure-panel/login"
                  className="topbar-logout"
                  title="Logout"
                >
                  <i className="bi bi-box-arrow-right"></i>

                  <span className="d-none d-sm-inline">
                    Logout
                  </span>
                </Link>

              </div>

            </header>

            {/* ====================================
                CONTENT
            ==================================== */}

            <main className="admin-content">

              {/* ==================================
                  PAGE HEADER
              ================================== */}

              <section className="page-heading">

                <Link
                  href="/secure-panel/education"
                  className="back-dashboard"
                >
                  <i className="bi bi-arrow-left"></i>

                  Back to Education
                </Link>

                <div className="page-title-row">

                  <div className="page-title-icon">
                    <i className="bi bi-mortarboard-fill"></i>
                  </div>

                  <div>

                    <div className="page-eyebrow">
                      EDUCATION MANAGEMENT
                    </div>

                    <h1 className="page-title">
                      Add Education
                    </h1>

                    <p className="page-description">
                      Tambahkan riwayat pendidikan dan latar
                      belakang akademik ke dalam website
                      portfolio GloVaTech. Lengkapi informasi
                      institusi, jenjang pendidikan, bidang studi,
                      periode pendidikan, dan deskripsi akademik
                      secara terstruktur.
                    </p>

                  </div>

                </div>

              </section>

              {/* ==================================
                  FORM CARD
              ================================== */}

              <section className="form-card-wrapper">

                <div className="form-card">

                  {/* CARD HEADER */}

                  <div className="form-card-header">

                    <div className="form-header-left">

                      <div className="form-header-icon">
                        <i className="bi bi-pencil-square"></i>
                      </div>

                      <div>

                        <h2 className="form-header-title">
                          Education Information
                        </h2>

                        <p className="form-header-description">
                          Masukkan informasi pendidikan yang
                          ingin ditampilkan pada halaman
                          portfolio.
                        </p>

                      </div>

                    </div>

                    <div className="form-status">
                      <span className="form-status-dot"></span>
                      <span>New Record</span>
                    </div>

                  </div>

                  {/* CARD BODY */}

                  <div className="form-card-body">

                    <form
                      onSubmit={handleSubmit}
                      className="form-inner"
                    >

                      {/* ==================================
                          BASIC INFORMATION
                      ================================== */}

                      <section className="form-section">

                        <div className="form-section-heading">

                          <div className="form-section-number">
                            01
                          </div>

                          <div>
                            <h3 className="form-section-title">
                              Basic Information
                            </h3>

                            <p className="form-section-description">
                              Informasi utama mengenai institusi
                              dan jenjang pendidikan.
                            </p>
                          </div>

                        </div>

                        {/* INSTITUTION */}

                        <div className="form-group">

                          <label
                            htmlFor="institution"
                            className="form-label-custom"
                          >
                            Institution Name
                            <span className="required-mark">
                              *
                            </span>
                          </label>

                          <input
                            type="text"
                            id="institution"
                            name="institution"
                            className="form-control-custom"
                            placeholder="Example: Universitas Putra Indonesia YPTK Padang"
                            value={form.institution}
                            onChange={handleChange}
                            required
                          />

                        </div>

                        {/* DEGREE */}

                        <div className="form-group">

                          <label
                            htmlFor="degree"
                            className="form-label-custom"
                          >
                            Education Level
                            <span className="required-mark">
                              *
                            </span>
                          </label>

                          <select
                            id="degree"
                            name="degree"
                            className="form-select-custom"
                            value={form.degree}
                            onChange={handleChange}
                            required
                          >

                            <option value="SMA">
                              High School (SMA)
                            </option>

                            <option value="SMK">
                              Vocational High School (SMK)
                            </option>

                            <option value="D3">
                              Diploma (D3)
                            </option>

                            <option value="S1">
                              Bachelor's Degree (S1)
                            </option>

                            <option value="S2">
                              Master's Degree (S2)
                            </option>

                            <option value="S3">
                              Doctoral Degree (S3)
                            </option>

                          </select>

                        </div>

                        {/* FIELD */}

                        <div className="form-group">

                          <label
                            htmlFor="field"
                            className="form-label-custom"
                          >
                            Field of Study / Major
                          </label>

                          <input
                            type="text"
                            id="field"
                            name="field"
                            className="form-control-custom"
                            placeholder="Example: Information Technology"
                            value={form.field}
                            onChange={handleChange}
                          />

                          <div className="field-help">
                            Masukkan jurusan, program studi, atau
                            bidang keahlian yang relevan dengan
                            pendidikan tersebut.
                          </div>

                        </div>

                      </section>

                      {/* ==================================
                          PERIOD
                      ================================== */}

                      <section className="form-section">

                        <div className="form-section-heading">

                          <div className="form-section-number">
                            02
                          </div>

                          <div>
                            <h3 className="form-section-title">
                              Education Period
                            </h3>

                            <p className="form-section-description">
                              Tentukan tahun mulai dan tahun
                              selesai pendidikan.
                            </p>
                          </div>

                        </div>

                        <div className="date-grid">

                          {/* START */}

                          <div className="form-group">

                            <label
                              htmlFor="startDate"
                              className="form-label-custom"
                            >
                              <i className="bi bi-calendar-event"></i>
                              Start Year
                              <span className="required-mark">
                                *
                              </span>
                            </label>

                            <input
                              type="number"
                              id="startDate"
                              name="startDate"
                              className="form-control-custom"
                              placeholder="Example: 2022"
                              min="1900"
                              max="2100"
                              value={form.startDate}
                              onChange={handleChange}
                              required
                            />

                          </div>

                          {/* END */}

                          <div className="form-group">

                            <label
                              htmlFor="endDate"
                              className="form-label-custom"
                            >
                              <i className="bi bi-calendar-check"></i>
                              Graduation Year
                            </label>

                            <input
                              type="number"
                              id="endDate"
                              name="endDate"
                              className="form-control-custom"
                              placeholder="Example: 2026"
                              min="1900"
                              max="2100"
                              value={form.endDate}
                              onChange={handleChange}
                            />

                            <div className="field-help">
                              Kosongkan jika pendidikan masih
                              berlangsung.
                            </div>

                          </div>

                        </div>

                      </section>

                      {/* ==================================
                          DESCRIPTION
                      ================================== */}

                      <section className="form-section">

                        <div className="form-section-heading">

                          <div className="form-section-number">
                            03
                          </div>

                          <div>
                            <h3 className="form-section-title">
                              Academic Description
                            </h3>

                            <p className="form-section-description">
                              Tambahkan informasi tambahan
                              mengenai perjalanan akademik.
                            </p>
                          </div>

                        </div>

                        <div className="form-group">

                          <label
                            htmlFor="description"
                            className="form-label-custom"
                          >
                            Description
                          </label>

                          <textarea
                            id="description"
                            name="description"
                            className="form-control-custom textarea-custom"
                            rows={6}
                            placeholder="Describe your activities, achievements, organizations, research, or other important experiences..."
                            value={form.description}
                            onChange={handleChange}
                          ></textarea>

                          <div className="field-help">
                            Kamu dapat menambahkan aktivitas,
                            pencapaian, organisasi, penelitian,
                            pengalaman akademik, atau informasi
                            relevan lainnya.
                          </div>

                        </div>

                      </section>

                      {/* ==================================
                          FOOTER ACTION
                      ================================== */}

                      <div className="form-footer">

                        <div className="form-footer-note">
                          <i className="bi bi-shield-check"></i>

                          <span>
                            Data akan disimpan melalui sistem
                            Education Management yang sudah
                            tersedia.
                          </span>
                        </div>

                        <div className="form-actions">

                          <Link
                            href="/secure-panel/education"
                            className="cancel-button"
                          >
                            <i className="bi bi-x-lg"></i>

                            Cancel
                          </Link>

                          <button
                            type="submit"
                            className="save-button"
                            disabled={saving}
                          >

                            {saving ? (
                              <>
                                <span
                                  className="spinner-border spinner-border-sm"
                                  role="status"
                                  style={{
                                    width: "13px",
                                    height: "13px",
                                    borderWidth: "2px",
                                  }}
                                ></span>

                                Saving...
                              </>
                            ) : (
                              <>
                                <i className="bi bi-check-lg"></i>

                                Save Education
                              </>
                            )}

                          </button>

                        </div>

                      </div>

                    </form>

                  </div>

                </div>

              </section>

              {/* ==================================
                  FOOTER
              ================================== */}

              <footer className="admin-page-footer">

                <div>
                  <i className="bi bi-shield-check"></i>

                  <span>
                    Admin Content Management System
                  </span>
                </div>

                <Link href="/secure-panel/education">
                  <i className="bi bi-arrow-left me-1"></i>

                  Education
                </Link>

              </footer>

            </main>

          </div>

        </div>
      </div>
    </>
  );
}