"use client";

import { FormEvent, useState } from "react";
import Link from "next/link";

export default function CreateSkillPage() {
  const [saving, setSaving] = useState(false);
  const [sidebarOpen, setSidebarOpen] = useState(false);

  const [form, setForm] = useState({
    name: "",
    category: "",
    level: "",
    icon: "",
  });

  const handleChange = (
    e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>
  ) => {
    const { name, value } = e.target;

    setForm((prev) => ({
      ...prev,
      [name]: value,
    }));
  };

  const handleSubmit = async (e: FormEvent) => {
    e.preventDefault();

    if (!form.name.trim()) {
      alert("Nama Skill wajib diisi");
      return;
    }

    if (
      form.level &&
      (Number(form.level) < 0 || Number(form.level) > 100)
    ) {
      alert("Level harus berada di antara 0 sampai 100");
      return;
    }

    setSaving(true);

    try {
      const response = await fetch("/api/skills", {
        method: "POST",
        headers: {
          "Content-Type": "application/json",
        },
        body: JSON.stringify({
          name: form.name,
          category: form.category,
          level: form.level ? Number(form.level) : null,
          icon: form.icon,
        }),
      });

      const result = await response.json();

      if (!response.ok || !result.success) {
        alert(result.message || "Gagal menambahkan Skill");
        return;
      }

      alert("Skill berhasil ditambahkan");

      window.location.href = "/secure-panel/skills";
    } catch (error) {
      console.error("CREATE SKILL ERROR:", error);
      alert("Terjadi kesalahan saat menambahkan Skill");
    } finally {
      setSaving(false);
    }
  };

  const closeSidebar = () => {
    setSidebarOpen(false);
  };

  return (
    <>
      <style>{`
        * {
          box-sizing: border-box;
        }

        html,
        body {
          margin: 0;
          padding: 0;
          max-width: 100%;
          overflow-x: hidden;
        }

        body {
          background: #f5f7fb;
        }

        button,
        a,
        input,
        textarea {
          -webkit-tap-highlight-color: transparent;
        }

        .skill-create-page {
          min-height: 100vh;
          width: 100%;
          background: #f5f7fb;
          color: #1f2937;
        }

        .admin-layout {
          min-height: 100vh;
          width: 100%;
          display: flex;
          position: relative;
        }

        /* =========================================================
           SIDEBAR
        ========================================================= */

        .admin-sidebar {
          width: 270px;
          min-width: 270px;
          height: 100vh;
          position: fixed;
          top: 0;
          left: 0;
          z-index: 1050;
          background: #ffffff;
          border-right: 1px solid #e8ecf1;
          transition: transform 0.3s ease;
        }

        .sidebar-inner {
          height: 100%;
          display: flex;
          flex-direction: column;
          padding: 24px 16px;
          overflow-y: auto;
          overflow-x: hidden;
        }

        .sidebar-brand {
          display: flex;
          align-items: center;
          gap: 12px;
          padding: 4px 10px 28px;
          border-bottom: 1px solid #edf0f4;
          margin-bottom: 22px;
        }

        .brand-icon {
          width: 42px;
          height: 42px;
          min-width: 42px;
          border-radius: 12px;
          display: flex;
          align-items: center;
          justify-content: center;
          background: linear-gradient(
            135deg,
            #198754,
            #20c997
          );
          color: #ffffff;
          font-size: 18px;
          box-shadow: 0 8px 20px rgba(25, 135, 84, 0.2);
        }

        .brand-text {
          min-width: 0;
        }

        .brand-text strong {
          display: block;
          font-size: 16px;
          line-height: 1.2;
          color: #17202a;
        }

        .brand-text span {
          display: block;
          margin-top: 3px;
          font-size: 11px;
          color: #8b95a5;
          font-weight: 600;
          letter-spacing: 0.08em;
          text-transform: uppercase;
        }

        .sidebar-close {
          margin-left: auto;
          border: 0;
          background: transparent;
          color: #7b8492;
          font-size: 17px;
          cursor: pointer;
          padding: 5px;
        }

        .sidebar-section-label {
          padding: 0 12px;
          margin-bottom: 8px;
          color: #9aa3af;
          font-size: 10px;
          font-weight: 700;
          letter-spacing: 0.1em;
        }

        .sidebar-nav {
          display: flex;
          flex-direction: column;
          gap: 4px;
        }

        .sidebar-link {
          display: flex;
          align-items: center;
          gap: 12px;
          min-height: 44px;
          padding: 10px 12px;
          border-radius: 11px;
          color: #697386;
          text-decoration: none;
          font-size: 14px;
          font-weight: 500;
          transition:
            background 0.2s ease,
            color 0.2s ease,
            transform 0.2s ease;
        }

        .sidebar-link:hover {
          background: #f0f8f4;
          color: #198754;
          transform: translateX(2px);
        }

        .sidebar-link.active {
          background: linear-gradient(
            90deg,
            rgba(25, 135, 84, 0.12),
            rgba(25, 135, 84, 0.06)
          );
          color: #198754;
          font-weight: 700;
        }

        .sidebar-link-icon {
          width: 23px;
          min-width: 23px;
          text-align: center;
          font-size: 16px;
          flex-shrink: 0;
        }

        .sidebar-bottom {
          margin-top: auto;
          padding-top: 18px;
          border-top: 1px solid #edf0f4;
        }

        .sidebar-bottom a {
          display: flex;
          align-items: center;
          gap: 10px;
          padding: 11px 12px;
          border-radius: 10px;
          color: #6b7280;
          text-decoration: none;
          font-size: 13px;
          transition: 0.2s ease;
        }

        .sidebar-bottom a:hover {
          background: #f5f7fa;
          color: #198754;
        }

        /* =========================================================
           MAIN
        ========================================================= */

        .admin-main {
          width: calc(100% - 270px);
          margin-left: 270px;
          min-width: 0;
        }

        /* =========================================================
           TOPBAR
        ========================================================= */

        .admin-topbar {
          width: 100%;
          height: 76px;
          background: rgba(255, 255, 255, 0.96);
          border-bottom: 1px solid #e9edf2;
          display: flex;
          align-items: center;
          justify-content: space-between;
          gap: 15px;
          padding: 0 34px;
          position: sticky;
          top: 0;
          z-index: 900;
          backdrop-filter: blur(12px);
        }

        .topbar-left {
          display: flex;
          align-items: center;
          gap: 14px;
          min-width: 0;
        }

        .mobile-menu-button {
          width: 40px;
          height: 40px;
          border: 1px solid #e2e7ed;
          background: #ffffff;
          border-radius: 10px;
          color: #344054;
          font-size: 18px;
          cursor: pointer;
          transition: 0.2s ease;
          flex-shrink: 0;
        }

        .mobile-menu-button:hover {
          background: #f5f8f6;
          color: #198754;
          border-color: #cde5d7;
        }

        .topbar-left > div:last-child {
          min-width: 0;
        }

        .topbar-label {
          color: #9aa3af;
          font-size: 10px;
          font-weight: 700;
          letter-spacing: 0.1em;
          margin-bottom: 3px;
        }

        .topbar-title {
          color: #17202a;
          font-size: 15px;
          font-weight: 700;
          white-space: nowrap;
        }

        .topbar-right {
          display: flex;
          align-items: center;
          gap: 10px;
          flex-shrink: 0;
        }

        .topbar-website,
        .topbar-logout {
          min-height: 40px;
          display: inline-flex;
          align-items: center;
          justify-content: center;
          gap: 8px;
          border-radius: 10px;
          padding: 8px 13px;
          text-decoration: none;
          font-size: 13px;
          font-weight: 600;
          transition: 0.2s ease;
          white-space: nowrap;
        }

        .topbar-website {
          color: #667085;
          border: 1px solid #e4e8ed;
          background: #ffffff;
        }

        .topbar-website:hover {
          color: #198754;
          border-color: #b7ddca;
          background: #f4fbf7;
        }

        .topbar-logout {
          color: #dc3545;
          border: 1px solid #f1c4c9;
          background: #ffffff;
        }

        .topbar-logout:hover {
          background: #fff5f6;
          border-color: #e8aeb5;
        }

        /* =========================================================
           CONTENT
        ========================================================= */

        .admin-content {
          width: 100%;
          max-width: 1550px;
          margin: 0 auto;
          padding: 34px;
          animation: contentEnter 0.45s ease both;
        }

        @keyframes contentEnter {
          from {
            opacity: 0;
            transform: translateY(10px);
          }

          to {
            opacity: 1;
            transform: translateY(0);
          }
        }

        /* =========================================================
           PAGE HEADER
        ========================================================= */

        .page-header {
          display: flex;
          align-items: flex-end;
          justify-content: space-between;
          gap: 25px;
          margin-bottom: 28px;
        }

        .page-header-left {
          min-width: 0;
          flex: 1;
        }

        .page-eyebrow {
          display: flex;
          align-items: center;
          gap: 7px;
          color: #198754;
          font-size: 10px;
          font-weight: 800;
          letter-spacing: 0.11em;
          margin-bottom: 8px;
        }

        .page-eyebrow-dot {
          width: 6px;
          height: 6px;
          border-radius: 50%;
          background: #20c997;
          flex-shrink: 0;
        }

        .page-title-row {
          display: flex;
          align-items: flex-start;
          gap: 15px;
        }

        .page-title-icon {
          width: 56px;
          height: 56px;
          min-width: 56px;
          border-radius: 15px;
          background: linear-gradient(
            135deg,
            rgba(25, 135, 84, 0.13),
            rgba(32, 201, 151, 0.08)
          );
          color: #198754;
          display: flex;
          align-items: center;
          justify-content: center;
          font-size: 23px;
          flex-shrink: 0;
        }

        .page-title {
          margin: 0;
          font-size: clamp(26px, 3vw, 35px);
          font-weight: 800;
          letter-spacing: -0.025em;
          color: #182230;
          line-height: 1.15;
        }

        .page-description {
          margin: 8px 0 0;
          color: #7a8493;
          font-size: 13px;
          line-height: 1.7;
          max-width: 760px;
          text-align: justify;
          text-justify: inter-word;
          overflow-wrap: anywhere;
        }

        .back-button {
          min-height: 44px;
          display: inline-flex;
          align-items: center;
          justify-content: center;
          gap: 8px;
          padding: 10px 15px;
          border-radius: 10px;
          color: #667085;
          background: #ffffff;
          border: 1px solid #e1e6eb;
          text-decoration: none;
          font-size: 12px;
          font-weight: 700;
          white-space: nowrap;
          transition: 0.2s ease;
          flex-shrink: 0;
        }

        .back-button:hover {
          color: #198754;
          border-color: #b7ddca;
          background: #f4fbf7;
          transform: translateY(-1px);
        }

        /* =========================================================
           FORM CARD
        ========================================================= */

        .form-card {
          width: 100%;
          background: #ffffff;
          border: 1px solid #e5e9ee;
          border-radius: 18px;
          overflow: hidden;
          box-shadow:
            0 8px 30px rgba(20, 30, 45, 0.045),
            0 2px 8px rgba(20, 30, 45, 0.025);
        }

        .form-card-header {
          min-height: 74px;
          padding: 16px 24px;
          display: flex;
          align-items: center;
          gap: 13px;
          border-bottom: 1px solid #edf0f3;
          background: linear-gradient(
            180deg,
            #ffffff 0%,
            #fcfdfd 100%
          );
        }

        .form-header-icon {
          width: 42px;
          height: 42px;
          min-width: 42px;
          border-radius: 11px;
          display: flex;
          align-items: center;
          justify-content: center;
          background: #eaf7f0;
          color: #198754;
          font-size: 18px;
        }

        .form-header-text {
          min-width: 0;
        }

        .form-header-title {
          margin: 0;
          color: #202b38;
          font-size: 14px;
          font-weight: 800;
        }

        .form-header-description {
          margin: 3px 0 0;
          color: #9aa3af;
          font-size: 11px;
          line-height: 1.6;
          text-align: justify;
          text-justify: inter-word;
          overflow-wrap: anywhere;
        }

        .form-card-body {
          padding: 28px 30px 30px;
        }

        .form-grid {
          display: grid;
          grid-template-columns: repeat(2, minmax(0, 1fr));
          gap: 22px;
        }

        .form-group {
          min-width: 0;
        }

        .form-group.full-width {
          grid-column: 1 / -1;
        }

        .form-label {
          display: flex;
          align-items: center;
          gap: 7px;
          margin-bottom: 8px;
          color: #344054;
          font-size: 12px;
          font-weight: 700;
        }

        .form-label i {
          color: #198754;
          font-size: 13px;
        }

        .required-mark {
          color: #dc3545;
        }

        .form-control-custom {
          width: 100%;
          min-height: 46px;
          padding: 10px 13px;
          border: 1px solid #dfe4ea;
          border-radius: 10px;
          background: #ffffff;
          color: #344054;
          font-size: 12px;
          outline: none;
          transition:
            border-color 0.2s ease,
            box-shadow 0.2s ease,
            background 0.2s ease;
        }

        .form-control-custom::placeholder {
          color: #adb5bf;
        }

        .form-control-custom:hover {
          border-color: #c8d0d8;
        }

        .form-control-custom:focus {
          border-color: #198754;
          box-shadow: 0 0 0 3px rgba(25, 135, 84, 0.1);
          background: #ffffff;
        }

        .form-help {
          margin-top: 7px;
          color: #98a2b3;
          font-size: 10px;
          line-height: 1.6;
          text-align: justify;
          text-justify: inter-word;
          overflow-wrap: anywhere;
        }

        .icon-preview {
          margin-top: 9px;
          min-height: 42px;
          padding: 8px 11px;
          border: 1px dashed #dce3e8;
          border-radius: 9px;
          background: #fafbfc;
          display: flex;
          align-items: center;
          gap: 9px;
          color: #7b8492;
          font-size: 10px;
        }

        .icon-preview i {
          color: #198754;
          font-size: 17px;
        }

        .icon-preview-text {
          overflow-wrap: anywhere;
        }

        .level-wrapper {
          position: relative;
        }

        .level-input {
          padding-right: 45px;
        }

        .level-unit {
          position: absolute;
          top: 50%;
          right: 14px;
          transform: translateY(-50%);
          color: #8b95a5;
          font-size: 11px;
          font-weight: 700;
          pointer-events: none;
        }

        /* =========================================================
           FORM ACTIONS
        ========================================================= */

        .form-actions {
          margin-top: 28px;
          padding-top: 22px;
          border-top: 1px solid #edf0f3;
          display: flex;
          align-items: center;
          justify-content: space-between;
          gap: 15px;
        }

        .form-actions-info {
          min-width: 0;
          display: flex;
          align-items: center;
          gap: 8px;
          color: #9aa3af;
          font-size: 10px;
          line-height: 1.5;
        }

        .form-actions-info i {
          color: #198754;
          flex-shrink: 0;
        }

        .form-buttons {
          display: flex;
          align-items: center;
          gap: 8px;
          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: 11px;
          font-weight: 700;
          cursor: pointer;
          text-decoration: none;
          transition: 0.2s ease;
        }

        .cancel-button {
          color: #667085;
          border: 1px solid #dfe4ea;
          background: #ffffff;
        }

        .cancel-button:hover {
          color: #344054;
          border-color: #c8d0d8;
          background: #f8fafb;
        }

        .save-button {
          color: #ffffff;
          border: 1px solid #198754;
          background: linear-gradient(
            135deg,
            #198754,
            #20a46c
          );
          box-shadow: 0 7px 16px rgba(25, 135, 84, 0.16);
        }

        .save-button:hover:not(:disabled) {
          color: #ffffff;
          transform: translateY(-1px);
          box-shadow: 0 10px 21px rgba(25, 135, 84, 0.23);
        }

        .save-button:disabled,
        .cancel-button:disabled {
          opacity: 0.65;
          cursor: not-allowed;
          transform: none;
        }

        /* =========================================================
           PAGE FOOTER
        ========================================================= */

        .admin-page-footer {
          padding: 20px 2px 5px;
          display: flex;
          align-items: center;
          justify-content: space-between;
          gap: 15px;
          color: #9aa3af;
          font-size: 10px;
        }

        .admin-page-footer div {
          display: flex;
          align-items: center;
          gap: 7px;
        }

        .admin-page-footer i {
          color: #198754;
        }

        .admin-page-footer a {
          display: inline-flex;
          align-items: center;
          color: #7b8492;
          text-decoration: none;
          font-weight: 600;
        }

        .admin-page-footer a:hover {
          color: #198754;
        }

        /* =========================================================
           SIDEBAR OVERLAY
        ========================================================= */

        .sidebar-overlay {
          display: none;
        }

        /* =========================================================
           LARGE DESKTOP
        ========================================================= */

        @media (max-width: 1399.98px) {
          .admin-content {
            padding: 30px;
          }
        }

        /* =========================================================
           TABLET / LAPTOP
        ========================================================= */

        @media (max-width: 1199.98px) {
          .admin-content {
            padding: 28px;
          }

          .form-card-body {
            padding: 25px;
          }
        }

        /* =========================================================
           MOBILE SIDEBAR
        ========================================================= */

        @media (max-width: 991.98px) {
          .admin-sidebar {
            transform: translateX(-100%);
            box-shadow: 15px 0 40px rgba(20, 30, 45, 0.1);
          }

          .admin-sidebar.open {
            transform: translateX(0);
          }

          .admin-main {
            width: 100%;
            margin-left: 0;
          }

          .sidebar-overlay {
            position: fixed;
            inset: 0;
            z-index: 1040;
            display: block;
            background: rgba(15, 23, 42, 0.35);
            backdrop-filter: blur(2px);
          }

          .admin-topbar {
            padding: 0 24px;
          }

          .page-header {
            align-items: flex-start;
          }
        }

        /* =========================================================
           TABLET
        ========================================================= */

        @media (max-width: 767.98px) {
          .admin-topbar {
            height: 68px;
            padding: 0 16px;
          }

          .topbar-title {
            font-size: 13px;
          }

          .admin-content {
            width: 100%;
            max-width: 100%;
            padding: 22px 16px;
          }

          .page-header {
            flex-direction: column;
            align-items: stretch;
            gap: 16px;
            margin-bottom: 22px;
          }

          .page-title-row {
            gap: 12px;
          }

          .page-title-icon {
            width: 48px;
            height: 48px;
            min-width: 48px;
            border-radius: 13px;
            font-size: 20px;
          }

          .page-title {
            font-size: 26px;
          }

          .page-description {
            font-size: 11px;
            line-height: 1.7;
            text-align: justify;
            text-justify: inter-word;
          }

          .back-button {
            width: 100%;
            min-height: 44px;
          }

          .form-card {
            border-radius: 15px;
          }

          .form-card-header {
            padding: 15px 16px;
            min-height: 65px;
          }

          .form-card-body {
            padding: 21px 16px;
          }

          .form-grid {
            grid-template-columns: 1fr;
            gap: 18px;
          }

          .form-group.full-width {
            grid-column: auto;
          }

          .form-actions {
            align-items: stretch;
            flex-direction: column;
            gap: 14px;
          }

          .form-actions-info {
            align-items: flex-start;
          }

          .form-buttons {
            width: 100%;
          }

          .cancel-button,
          .save-button {
            flex: 1;
          }

          .admin-page-footer {
            flex-direction: column;
            align-items: flex-start;
            padding-top: 17px;
          }
        }

        /* =========================================================
           MOBILE
        ========================================================= */

        @media (max-width: 575.98px) {
          .admin-content {
            padding: 19px 12px;
          }

          .admin-topbar {
            padding-left: 12px;
            padding-right: 12px;
          }

          .topbar-left {
            gap: 9px;
          }

          .topbar-right {
            gap: 6px;
          }

          .topbar-website,
          .topbar-logout {
            width: 38px;
            height: 38px;
            min-height: 38px;
            padding: 0;
            border-radius: 9px;
          }

          .mobile-menu-button {
            width: 38px;
            height: 38px;
          }

          .page-title-row {
            align-items: flex-start;
            gap: 10px;
          }

          .page-title-icon {
            width: 43px;
            height: 43px;
            min-width: 43px;
            border-radius: 11px;
            font-size: 17px;
          }

          .page-title {
            font-size: 23px;
          }

          .page-description {
            font-size: 10px;
            line-height: 1.7;
            text-align: justify;
            text-justify: inter-word;
          }

          .form-card-header {
            padding: 14px;
          }

          .form-header-icon {
            width: 38px;
            height: 38px;
            min-width: 38px;
            border-radius: 10px;
            font-size: 16px;
          }

          .form-header-title {
            font-size: 13px;
          }

          .form-header-description {
            display: none;
          }

          .form-card-body {
            padding: 18px 14px;
          }

          .form-grid {
            gap: 16px;
          }

          .form-label {
            font-size: 11px;
          }

          .form-control-custom {
            min-height: 44px;
            padding: 9px 11px;
            font-size: 11px;
          }

          .form-help {
            font-size: 9px;
            line-height: 1.65;
          }

          .icon-preview {
            font-size: 9px;
          }

          .form-actions {
            margin-top: 22px;
            padding-top: 18px;
          }

          .form-actions-info {
            font-size: 9px;
          }

          .form-buttons {
            gap: 7px;
          }

          .cancel-button,
          .save-button {
            min-height: 40px;
            padding: 8px 10px;
            font-size: 10px;
          }
        }

        /* =========================================================
           EXTRA SMALL
        ========================================================= */

        @media (max-width: 399.98px) {
          .topbar-title {
            max-width: 130px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
          }

          .page-title {
            font-size: 21px;
          }

          .page-title-icon {
            width: 40px;
            height: 40px;
            min-width: 40px;
          }

          .admin-content {
            padding-left: 10px;
            padding-right: 10px;
          }

          .form-card-body {
            padding-left: 12px;
            padding-right: 12px;
          }

          .form-buttons {
            flex-direction: column;
          }

          .cancel-button,
          .save-button {
            width: 100%;
          }
        }

        /* =========================================================
           VERY SMALL SCREEN
        ========================================================= */

        @media (max-width: 340px) {
          .admin-content {
            padding-left: 8px;
            padding-right: 8px;
          }

          .topbar-title {
            max-width: 105px;
          }

          .page-title {
            font-size: 19px;
          }

          .page-description {
            font-size: 9px;
            text-align: justify;
            text-justify: inter-word;
          }

          .form-card-body {
            padding-left: 10px;
            padding-right: 10px;
          }
        }

        /* =========================================================
           REDUCED MOTION
        ========================================================= */

        @media (prefers-reduced-motion: reduce) {
          .skill-create-page *,
          .skill-create-page *::before,
          .skill-create-page *::after {
            animation-duration: 0.01ms !important;
            animation-iteration-count: 1 !important;
            transition-duration: 0.01ms !important;
          }
        }
      `}</style>

      <div className="skill-create-page">
        <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">

              <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-line"></i>
                  </span>
                  <span>Stats</span>
                </Link>

                <Link
                  href="/secure-panel/education"
                  className="sidebar-link"
                  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 active"
                  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>

                {/* CONTACT MESSAGES */}

<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>

{/* CONTACT USER */}

<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="/"
                  onClick={closeSidebar}
                >
                  <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 AREA
          ===================================================== */}

          <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">
                    Skills Management
                  </div>

                </div>

              </div>

              <div className="topbar-right">

                <Link
                  href="/"
                  className="topbar-website"
                  title="View Website"
                  aria-label="View Website"
                >
                  <i className="bi bi-globe2"></i>

                  <span className="d-none d-sm-inline">
                    Website
                  </span>
                </Link>

                <Link
                  href="/login"
                  className="topbar-logout"
                  title="Logout"
                  aria-label="Logout"
                >
                  <i className="bi bi-box-arrow-right"></i>

                  <span className="d-none d-sm-inline">
                    Logout
                  </span>
                </Link>

              </div>

            </header>

            {/* =====================================================
                CONTENT
            ===================================================== */}

            <main className="admin-content">

              {/* PAGE HEADER */}

              <section className="page-header">

                <div className="page-header-left">

                  <div className="page-eyebrow">
                    <span className="page-eyebrow-dot"></span>
                    CONTENT MANAGEMENT
                  </div>

                  <div className="page-title-row">

                    <div className="page-title-icon">
                      <i className="bi bi-tools"></i>
                    </div>

                    <div>

                      <h1 className="page-title">
                        Tambah Skill
                      </h1>

                      <p className="page-description">
                        Tambahkan kemampuan atau keahlian baru
                        ke dalam sistem Skills GloVaTech. Isi
                        nama skill, kategori, tingkat kemampuan,
                        dan Bootstrap Icon yang akan digunakan
                        pada halaman website.
                      </p>

                    </div>

                  </div>

                </div>

                <Link
                  href="/secure-panel/skills"
                  className="back-button"
                >
                  <i className="bi bi-arrow-left"></i>
                  <span>Kembali ke Skills</span>
                </Link>

              </section>

              {/* FORM CARD */}

              <section className="form-card">

                {/* HEADER */}

                <div className="form-card-header">

                  <div className="form-header-icon">
                    <i className="bi bi-plus-circle"></i>
                  </div>

                  <div className="form-header-text">

                    <h2 className="form-header-title">
                      Skill Information
                    </h2>

                    <p className="form-header-description">
                      Lengkapi informasi skill yang ingin
                      ditambahkan ke database.
                    </p>

                  </div>

                </div>

                {/* BODY */}

                <div className="form-card-body">

                  <form onSubmit={handleSubmit}>

                    <div className="form-grid">

                      {/* NAME */}

                      <div className="form-group">

                        <label
                          htmlFor="name"
                          className="form-label"
                        >
                          <i className="bi bi-type"></i>
                          <span>Nama Skill</span>
                          <span className="required-mark">
                            *
                          </span>
                        </label>

                        <input
                          type="text"
                          id="name"
                          name="name"
                          className="form-control-custom"
                          placeholder="Contoh: Python"
                          value={form.name}
                          onChange={handleChange}
                          disabled={saving}
                          required
                        />

                        <div className="form-help">
                          Masukkan nama kemampuan atau teknologi
                          yang ingin ditampilkan.
                        </div>

                      </div>

                      {/* CATEGORY - MANUAL INPUT */}

                      <div className="form-group">

                        <label
                          htmlFor="category"
                          className="form-label"
                        >
                          <i className="bi bi-folder2-open"></i>
                          <span>Category</span>
                        </label>

                        <input
                          type="text"
                          id="category"
                          name="category"
                          className="form-control-custom"
                          placeholder="Contoh: Programming"
                          value={form.category}
                          onChange={handleChange}
                          disabled={saving}
                        />

                        <div className="form-help">
                          Ketik kategori skill secara manual,
                          misalnya Programming, Framework,
                          Database, Tools, Networking, Data & AI,
                          atau kategori lainnya.
                        </div>

                      </div>

                      {/* LEVEL */}

                      <div className="form-group">

                        <label
                          htmlFor="level"
                          className="form-label"
                        >
                          <i className="bi bi-bar-chart-line"></i>
                          <span>Level Kemampuan</span>
                        </label>

                        <div className="level-wrapper">

                          <input
                            type="number"
                            id="level"
                            name="level"
                            className="form-control-custom level-input"
                            placeholder="Contoh: 90"
                            min="0"
                            max="100"
                            value={form.level}
                            onChange={handleChange}
                            disabled={saving}
                          />

                          <span className="level-unit">
                            %
                          </span>

                        </div>

                        <div className="form-help">
                          Masukkan nilai kemampuan antara 0
                          sampai 100.
                        </div>

                      </div>

                      {/* ICON */}

                      <div className="form-group">

                        <label
                          htmlFor="icon"
                          className="form-label"
                        >
                          <i className="bi bi-bootstrap"></i>
                          <span>Bootstrap Icon</span>
                        </label>

                        <input
                          type="text"
                          id="icon"
                          name="icon"
                          className="form-control-custom"
                          placeholder="Contoh: bi bi-code-slash"
                          value={form.icon}
                          onChange={handleChange}
                          disabled={saving}
                        />

                        <div className="form-help">
                          Gunakan class Bootstrap Icons, misalnya
                          bi bi-code-slash.
                        </div>

                        {form.icon.trim() && (
                          <div className="icon-preview">

                            <i
                              className={form.icon.trim()}
                              aria-hidden="true"
                            ></i>

                            <span className="icon-preview-text">
                              Preview: {form.icon.trim()}
                            </span>

                          </div>
                        )}

                      </div>

                    </div>

                    {/* ACTIONS */}

                    <div className="form-actions">

                      <div className="form-actions-info">

                        <i className="bi bi-shield-check"></i>

                        <span>
                          Data skill akan disimpan melalui
                          Skills Management System.
                        </span>

                      </div>

                      <div className="form-buttons">

                        <Link
                          href="/secure-panel/skills"
                          className="cancel-button"
                          aria-disabled={saving}
                        >
                          <i className="bi bi-x-lg"></i>
                          <span>Batal</span>
                        </Link>

                        <button
                          type="submit"
                          className="save-button"
                          disabled={saving}
                        >

                          {saving ? (
                            <>
                              <span
                                className="spinner-border spinner-border-sm"
                                role="status"
                                aria-hidden="true"
                              ></span>

                              <span>
                                Menyimpan...
                              </span>
                            </>
                          ) : (
                            <>
                              <i className="bi bi-check-lg"></i>

                              <span>
                                Simpan Skill
                              </span>
                            </>
                          )}

                        </button>

                      </div>

                    </div>

                  </form>

                </div>

              </section>

              {/* PAGE 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/skills">

                  <i className="bi bi-arrow-left me-1"></i>

                  Skills

                </Link>

              </footer>

            </main>

          </div>

        </div>
      </div>
    </>
  );
}