"use client";

import { useEffect, useState } from "react";
import Link from "next/link";

type ProjectImage = {
  id: number;
  image: string;
  projectId: number;
  createdAt: string;
};

type Project = {
  id: number;
  title: string;
  slug: string;
  description: string | null;
  image: string | null;
  projectUrl: string | null;
  technologies: string | null;
  startDate: string | null;
  endDate: string | null;
  featured: boolean;

  // SESUAI DENGAN SCHEMA PRISMA
  projectimage: ProjectImage[];
};

export default function ProjectsAdminPage() {
  const [projects, setProjects] = useState<Project[]>([]);
  const [loading, setLoading] = useState(true);
  const [sidebarOpen, setSidebarOpen] = useState(false);

  /* =========================================================
     GET PROJECTS
  ========================================================= */

  const getProjects = async () => {
    try {
      setLoading(true);

      const response = await fetch("/api/projects", {
        cache: "no-store",
      });

      const result = await response.json();

      if (result.success) {
        setProjects(result.data);
      } else {
        console.error(
          "GET PROJECTS ERROR:",
          result.message
        );
      }
    } catch (error) {
      console.error("GET PROJECTS:", error);
    } finally {
      setLoading(false);
    }
  };

  /* =========================================================
     LOAD DATA
  ========================================================= */

  useEffect(() => {
    getProjects();
  }, []);

  /* =========================================================
     DELETE PROJECT
  ========================================================= */

  const deleteProject = async (id: number) => {
    const confirmDelete = window.confirm(
      "Yakin ingin menghapus project ini?"
    );

    if (!confirmDelete) {
      return;
    }

    try {
      const response = await fetch(
        `/api/projects?id=${id}`,
        {
          method: "DELETE",
        }
      );

      const result = await response.json();

      if (result.success) {
        alert("Project berhasil dihapus");
        getProjects();
      } else {
        alert(
          result.message ||
            "Gagal menghapus project"
        );
      }
    } catch (error) {
      console.error("DELETE PROJECT:", error);

      alert("Gagal menghapus project");
    }
  };

  /* =========================================================
     SIDEBAR
  ========================================================= */

  const closeSidebar = () => {
    setSidebarOpen(false);
  };

  /* =========================================================
     PROJECT IMAGES
  ========================================================= */

  const getProjectImages = (
    project: Project
  ): ProjectImage[] => {
    if (
      project.projectimage &&
      project.projectimage.length > 0
    ) {
      return project.projectimage;
    }

    if (project.image) {
      return [
        {
          id: 0,
          image: project.image,
          projectId: project.id,
          createdAt: "",
        },
      ];
    }

    return [];
  };

  /* =========================================================
     DATE FORMAT
  ========================================================= */

  const formatDate = (
    date: string | null
  ) => {
    if (!date) {
      return null;
    }

    const parsed = new Date(date);

    if (Number.isNaN(parsed.getTime())) {
      return null;
    }

    return parsed.toLocaleDateString(
      "id-ID",
      {
        month: "short",
        year: "numeric",
      }
    );
  };

  /* =========================================================
     LOADING
  ========================================================= */

  if (loading) {
    return (
      <>
        <style>{`
          * {
            box-sizing: border-box;
          }

          html,
          body {
            margin: 0;
            padding: 0;
            max-width: 100%;
            overflow-x: hidden;
          }

          body {
            background: #f5f7fb;
          }

          .projects-loading-page {
            min-height: 100vh;
            width: 100%;
            display: flex;
            align-items: center;
            justify-content: center;
            background: #f5f7fb;
            padding: 20px;
          }

          .loading-box {
            width: 100%;
            max-width: 420px;
            background: #ffffff;
            border: 1px solid #e5e9ee;
            border-radius: 18px;
            padding: 45px 25px;
            text-align: center;
            box-shadow:
              0 8px 30px rgba(20, 30, 45, 0.045),
              0 2px 8px rgba(20, 30, 45, 0.025);
          }

          .loading-icon {
            width: 55px;
            height: 55px;
            margin: 0 auto 16px;
            border-radius: 15px;
            display: flex;
            align-items: center;
            justify-content: center;
            background: #eaf7f0;
            color: #198754;
          }

          .loading-title {
            margin: 0 0 5px;
            color: #202b38;
            font-size: 15px;
            font-weight: 800;
          }

          .loading-text {
            margin: 0;
            color: #929baa;
            font-size: 11px;
            line-height: 1.7;
            text-align: justify;
            text-justify: inter-word;
          }
        `}</style>

        <main className="projects-loading-page">
          <div className="loading-box">
            <div className="loading-icon">
              <span
                className="spinner-border spinner-border-sm text-success"
                role="status"
                aria-hidden="true"
              ></span>
            </div>

            <h1 className="loading-title">
              Memuat Projects
            </h1>

            <p className="loading-text">
              Sedang mengambil data Projects dari
              sistem. Mohon tunggu sebentar.
            </p>
          </div>
        </main>
      </>
    );
  }

  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,
        select {
          -webkit-tap-highlight-color: transparent;
        }

        .projects-admin-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-header-right {
          flex-shrink: 0;
        }

        .back-link {
          display: inline-flex;
          align-items: center;
          gap: 7px;
          margin-bottom: 17px;
          color: #7b8492;
          text-decoration: none;
          font-size: 11px;
          font-weight: 600;
          transition: 0.2s ease;
        }

        .back-link:hover {
          color: #198754;
        }

        .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: 820px;
          text-align: justify;
          text-justify: inter-word;
          overflow-wrap: anywhere;
          word-break: break-word;
        }

        .add-project-button {
          min-height: 43px;
          display: inline-flex;
          align-items: center;
          justify-content: center;
          gap: 7px;
          padding: 10px 16px;
          border-radius: 10px;
          color: #ffffff;
          background: linear-gradient(
            135deg,
            #198754,
            #20a46c
          );
          border: 1px solid #198754;
          box-shadow:
            0 7px 17px rgba(25, 135, 84, 0.15);
          text-decoration: none;
          font-size: 11px;
          font-weight: 700;
          white-space: nowrap;
          transition: 0.2s ease;
        }

        .add-project-button:hover {
          color: #ffffff;
          transform: translateY(-1px);
          box-shadow:
            0 10px 22px rgba(25, 135, 84, 0.22);
        }

        /* =========================================================
           PROJECT CARD WRAPPER
        ========================================================= */

        .project-container {
          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);
        }

        .project-container-header {
          min-height: 76px;
          padding: 17px 23px;
          display: flex;
          align-items: center;
          justify-content: space-between;
          gap: 15px;
          border-bottom: 1px solid #edf0f3;
          background: linear-gradient(
            180deg,
            #ffffff 0%,
            #fcfdfd 100%
          );
        }

        .project-container-header-left {
          display: flex;
          align-items: center;
          gap: 12px;
          min-width: 0;
        }

        .container-header-icon {
          width: 41px;
          height: 41px;
          min-width: 41px;
          border-radius: 10px;
          display: flex;
          align-items: center;
          justify-content: center;
          background: #f0f8f4;
          color: #198754;
          font-size: 17px;
        }

        .container-header-text {
          min-width: 0;
        }

        .container-header-title {
          margin: 0;
          color: #202b38;
          font-size: 14px;
          font-weight: 800;
        }

        .container-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;
        }

        .project-count {
          flex-shrink: 0;
          min-width: 32px;
          height: 28px;
          padding: 4px 9px;
          display: inline-flex;
          align-items: center;
          justify-content: center;
          border-radius: 8px;
          background: #f0f8f4;
          color: #198754;
          font-size: 10px;
          font-weight: 800;
        }

        /* =========================================================
           DESKTOP TABLE
        ========================================================= */

        .desktop-project-table {
          display: block;
          width: 100%;
          overflow-x: auto;
        }

        .project-table {
          width: 100%;
          min-width: 930px;
          border-collapse: separate;
          border-spacing: 0;
        }

        .project-table thead th {
          padding: 14px 18px;
          background: #fafbfc;
          border-bottom: 1px solid #e9edf1;
          color: #8b95a5;
          font-size: 9px;
          font-weight: 800;
          letter-spacing: 0.07em;
          text-transform: uppercase;
          white-space: nowrap;
        }

        .project-table tbody td {
          padding: 17px 18px;
          border-bottom: 1px solid #eef1f4;
          vertical-align: middle;
          color: #475467;
          font-size: 11px;
        }

        .project-table tbody tr:last-child td {
          border-bottom: 0;
        }

        .project-table tbody tr {
          transition:
            background 0.2s ease;
        }

        .project-table tbody tr:hover {
          background: #fbfdfc;
        }

        /* =========================================================
           PROJECT CELL
        ========================================================= */

        .project-main-cell {
          display: flex;
          align-items: center;
          gap: 13px;
          min-width: 310px;
          max-width: 520px;
        }

        .project-image-group {
          width: 132px;
          min-width: 132px;
          height: 48px;
          display: flex;
          align-items: center;
          gap: 3px;
          overflow: hidden;
        }

        .project-image-thumb {
          width: 42px;
          height: 45px;
          object-fit: cover;
          border-radius: 7px;
          border: 1px solid #e5e9ee;
          background: #f8fafb;
          flex-shrink: 0;
        }

        .project-image-more {
          width: 42px;
          height: 45px;
          flex-shrink: 0;
          display: flex;
          align-items: center;
          justify-content: center;
          border-radius: 7px;
          background: #f1f3f5;
          color: #667085;
          font-size: 9px;
          font-weight: 800;
        }

        .project-image-empty {
          width: 132px;
          height: 45px;
          min-width: 132px;
          display: flex;
          align-items: center;
          justify-content: center;
          border-radius: 7px;
          background: #f4f6f8;
          color: #98a2b3;
          font-size: 15px;
        }

        .project-main-info {
          min-width: 0;
          flex: 1;
        }

        .project-title {
          margin: 0;
          color: #263241;
          font-size: 12px;
          line-height: 1.45;
          font-weight: 800;
          overflow-wrap: anywhere;
          word-break: break-word;
        }

        .project-description {
          margin-top: 4px;
          color: #8b95a5;
          font-size: 9px;
          line-height: 1.6;
          text-align: justify;
          text-justify: inter-word;
          overflow-wrap: anywhere;
          word-break: break-word;
        }

        .project-image-count {
          display: flex;
          align-items: center;
          gap: 4px;
          margin-top: 5px;
          color: #198754;
          font-size: 8px;
          font-weight: 700;
        }

        /* =========================================================
           TECHNOLOGIES
        ========================================================= */

        .technology-text {
          max-width: 220px;
          color: #667085;
          font-size: 10px;
          line-height: 1.6;
          text-align: justify;
          text-justify: inter-word;
          overflow-wrap: anywhere;
          word-break: break-word;
        }

        .empty-value {
          color: #b0b7c2;
          font-size: 10px;
        }

        /* =========================================================
           BADGES
        ========================================================= */

        .status-badge {
          display: inline-flex;
          align-items: center;
          gap: 5px;
          min-height: 25px;
          padding: 5px 8px;
          border-radius: 7px;
          font-size: 8px;
          font-weight: 800;
          white-space: nowrap;
        }

        .status-featured {
          color: #198754;
          background: #eaf7f0;
          border: 1px solid #d5eddf;
        }

        .status-normal {
          color: #667085;
          background: #f2f4f7;
          border: 1px solid #e4e7ec;
        }

        /* =========================================================
           URL
        ========================================================= */

        .url-button {
          width: 34px;
          height: 34px;
          display: inline-flex;
          align-items: center;
          justify-content: center;
          border-radius: 8px;
          color: #198754;
          border: 1px solid #b9dcc9;
          background: #ffffff;
          text-decoration: none;
          font-size: 15px;
          transition: 0.2s ease;
        }

        .url-button:hover {
          color: #ffffff;
          background: #198754;
          border-color: #198754;
        }

        /* =========================================================
           DATE
        ========================================================= */

        .project-date {
          color: #7b8492;
          font-size: 9px;
          line-height: 1.6;
          white-space: nowrap;
        }

        .project-date-current {
          color: #198754;
          font-weight: 700;
        }

        /* =========================================================
           ACTIONS
        ========================================================= */

        .project-actions {
          display: flex;
          align-items: center;
          justify-content: flex-end;
          gap: 6px;
          white-space: nowrap;
        }

        .action-button {
          min-height: 33px;
          display: inline-flex;
          align-items: center;
          justify-content: center;
          gap: 5px;
          padding: 6px 9px;
          border-radius: 8px;
          font-size: 9px;
          font-weight: 700;
          text-decoration: none;
          cursor: pointer;
          transition: 0.2s ease;
        }

        .edit-button {
          color: #0d6efd;
          border: 1px solid #b9d2f5;
          background: #ffffff;
        }

        .edit-button:hover {
          color: #ffffff;
          background: #0d6efd;
          border-color: #0d6efd;
        }

        .delete-button {
          color: #dc3545;
          border: 1px solid #efbdc3;
          background: #ffffff;
        }

        .delete-button:hover {
          color: #ffffff;
          background: #dc3545;
          border-color: #dc3545;
        }

        /* =========================================================
           MOBILE PROJECT CARDS
        ========================================================= */

        .mobile-project-list {
          display: none;
        }

        .project-mobile-card {
          background: #ffffff;
          border: 1px solid #e5e9ee;
          border-radius: 14px;
          overflow: hidden;
          box-shadow:
            0 5px 18px rgba(20, 30, 45, 0.035);
          transition:
            transform 0.2s ease,
            box-shadow 0.2s ease;
        }

        .project-mobile-card:hover {
          transform: translateY(-1px);
          box-shadow:
            0 9px 24px rgba(20, 30, 45, 0.06);
        }

        .mobile-card-images {
          width: 100%;
          height: 155px;
          display: flex;
          gap: 3px;
          overflow: hidden;
          background: #f2f4f6;
        }

        .mobile-card-image {
          height: 100%;
          object-fit: cover;
          min-width: 0;
          flex: 1;
        }

        .mobile-card-image.single {
          width: 100%;
          flex: none;
        }

        .mobile-card-image-placeholder {
          width: 100%;
          height: 155px;
          display: flex;
          align-items: center;
          justify-content: center;
          background: #f3f5f7;
          color: #98a2b3;
          font-size: 25px;
        }

        .mobile-image-count {
          position: absolute;
          right: 9px;
          bottom: 9px;
          padding: 5px 8px;
          border-radius: 7px;
          background: rgba(23, 32, 42, 0.76);
          color: #ffffff;
          font-size: 8px;
          font-weight: 700;
        }

        .mobile-image-wrapper {
          position: relative;
          width: 100%;
        }

        .mobile-card-body {
          padding: 15px;
        }

        .mobile-card-top {
          display: flex;
          align-items: flex-start;
          justify-content: space-between;
          gap: 10px;
        }

        .mobile-project-title {
          min-width: 0;
          margin: 0;
          color: #202b38;
          font-size: 14px;
          line-height: 1.4;
          font-weight: 800;
          overflow-wrap: anywhere;
          word-break: break-word;
        }

        .mobile-project-slug {
          margin-top: 3px;
          color: #a0a8b4;
          font-size: 8px;
          line-height: 1.5;
          overflow-wrap: anywhere;
          word-break: break-word;
        }

        .mobile-featured-badge {
          flex-shrink: 0;
        }

        .mobile-project-description {
          margin: 12px 0 0;
          color: #727d8c;
          font-size: 10px;
          line-height: 1.75;
          text-align: justify;
          text-justify: inter-word;
          overflow-wrap: anywhere;
          word-break: break-word;
        }

        .mobile-project-meta {
          margin-top: 14px;
          padding-top: 13px;
          border-top: 1px solid #edf0f3;
          display: grid;
          grid-template-columns: repeat(2, minmax(0, 1fr));
          gap: 11px;
        }

        .mobile-meta-item {
          min-width: 0;
        }

        .mobile-meta-label {
          display: block;
          margin-bottom: 4px;
          color: #a0a8b4;
          font-size: 7px;
          font-weight: 800;
          letter-spacing: 0.08em;
          text-transform: uppercase;
        }

        .mobile-meta-value {
          color: #596579;
          font-size: 9px;
          line-height: 1.6;
          overflow-wrap: anywhere;
          word-break: break-word;
          text-align: justify;
          text-justify: inter-word;
        }

        .mobile-card-actions {
          margin-top: 14px;
          display: grid;
          grid-template-columns: 1fr 1fr 1fr;
          gap: 6px;
        }

        .mobile-action-button {
          min-height: 38px;
          display: inline-flex;
          align-items: center;
          justify-content: center;
          gap: 5px;
          padding: 7px 5px;
          border-radius: 8px;
          text-decoration: none;
          font-size: 9px;
          font-weight: 700;
          transition: 0.2s ease;
        }

        .mobile-edit {
          color: #0d6efd;
          background: #f4f8ff;
          border: 1px solid #d2e2fa;
        }

        .mobile-edit:hover {
          color: #ffffff;
          background: #0d6efd;
          border-color: #0d6efd;
        }

        .mobile-view {
          color: #198754;
          background: #f1faf5;
          border: 1px solid #d3ecdd;
        }

        .mobile-view:hover {
          color: #ffffff;
          background: #198754;
          border-color: #198754;
        }

        .mobile-delete {
          color: #dc3545;
          background: #fff6f7;
          border: 1px solid #f0cdd1;
          cursor: pointer;
        }

        .mobile-delete:hover {
          color: #ffffff;
          background: #dc3545;
          border-color: #dc3545;
        }

        /* =========================================================
           EMPTY STATE
        ========================================================= */

        .empty-state {
          padding: 60px 25px;
          text-align: center;
        }

        .empty-icon {
          width: 60px;
          height: 60px;
          margin: 0 auto 15px;
          display: flex;
          align-items: center;
          justify-content: center;
          border-radius: 16px;
          background: #f0f8f4;
          color: #198754;
          font-size: 23px;
        }

        .empty-title {
          margin: 0 0 5px;
          color: #263241;
          font-size: 15px;
          font-weight: 800;
        }

        .empty-description {
          max-width: 450px;
          margin: 0 auto 18px;
          color: #929baa;
          font-size: 10px;
          line-height: 1.7;
          text-align: justify;
          text-justify: inter-word;
          overflow-wrap: anywhere;
        }

        .empty-add-button {
          min-height: 38px;
          display: inline-flex;
          align-items: center;
          justify-content: center;
          gap: 6px;
          padding: 8px 13px;
          border-radius: 9px;
          color: #ffffff;
          background: #198754;
          border: 1px solid #198754;
          text-decoration: none;
          font-size: 10px;
          font-weight: 700;
        }

        .empty-add-button:hover {
          color: #ffffff;
          background: #157347;
        }

        /* =========================================================
           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;
          }

          .project-table {
            min-width: 900px;
          }
        }

        /* =========================================================
           TABLET / LAPTOP
        ========================================================= */

        @media (max-width: 1199.98px) {
          .admin-content {
            padding: 28px;
          }

          .page-header {
            align-items: flex-start;
          }

          .project-table {
            min-width: 860px;
          }

          .project-main-cell {
            min-width: 280px;
          }
        }

        /* =========================================================
           OFF CANVAS SIDEBAR
        ========================================================= */

        @media (max-width: 991.98px) {
          .admin-sidebar {
            transform: translateX(-100%);
            box-shadow:
              15px 0 40px rgba(20, 30, 45, 0.1);
          }

          .admin-sidebar.open {
            transform: translateX(0);
          }

          .admin-main {
            width: 100%;
            margin-left: 0;
          }

          .sidebar-overlay {
            position: fixed;
            inset: 0;
            z-index: 1040;
            display: block;
            background: rgba(15, 23, 42, 0.35);
            backdrop-filter: blur(2px);
          }

          .admin-topbar {
            padding: 0 24px;
          }

          .page-header {
            flex-direction: column;
            align-items: stretch;
          }

          .page-header-right {
            display: flex;
            justify-content: flex-start;
          }

          .add-project-button {
            width: auto;
          }
        }

        /* =========================================================
           TABLET
        ========================================================= */

        @media (max-width: 767.98px) {
          .admin-topbar {
            height: 68px;
            padding: 0 16px;
          }

          .topbar-title {
            font-size: 13px;
          }

          .admin-content {
            width: 100%;
            max-width: 100%;
            padding: 22px 16px;
          }

          .page-header {
            margin-bottom: 22px;
          }

          .page-title-row {
            gap: 12px;
          }

          .page-title-icon {
            width: 48px;
            height: 48px;
            min-width: 48px;
            border-radius: 13px;
            font-size: 20px;
          }

          .page-title {
            font-size: 26px;
          }

          .page-description {
            font-size: 11px;
            line-height: 1.7;
            text-align: justify;
            text-justify: inter-word;
          }

          .add-project-button {
            width: 100%;
          }

          .project-container {
            border-radius: 15px;
          }

          .project-container-header {
            padding: 15px 16px;
          }

          .container-header-description {
            font-size: 9px;
          }

          .desktop-project-table {
            display: none;
          }

          .mobile-project-list {
            display: grid;
            grid-template-columns: repeat(2, minmax(0, 1fr));
            gap: 12px;
            padding: 13px;
            background: #f8fafb;
          }

          .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;
          }

          .back-link {
            font-size: 10px;
            margin-bottom: 14px;
          }

          .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;
          }

          .project-container-header {
            padding: 14px;
          }

          .container-header-icon {
            width: 37px;
            height: 37px;
            min-width: 37px;
            font-size: 15px;
          }

          .container-header-title {
            font-size: 12px;
          }

          .container-header-description {
            display: none;
          }

          .project-count {
            height: 26px;
            min-width: 29px;
            font-size: 9px;
          }

          .mobile-project-list {
            grid-template-columns: 1fr;
            gap: 10px;
            padding: 10px;
          }

          .mobile-card-images {
            height: 175px;
          }

          .mobile-card-image-placeholder {
            height: 175px;
          }

          .mobile-card-body {
            padding: 14px;
          }

          .mobile-project-title {
            font-size: 13px;
          }

          .mobile-project-description {
            font-size: 9px;
            line-height: 1.75;
          }

          .mobile-project-meta {
            grid-template-columns: 1fr 1fr;
          }

          .mobile-card-actions {
            grid-template-columns: 1fr 1fr 1fr;
          }

          .mobile-action-button {
            min-height: 37px;
            font-size: 8px;
          }

          .empty-state {
            padding: 45px 18px;
          }
        }

        /* =========================================================
           EXTRA SMALL
        ========================================================= */

        @media (max-width: 399.98px) {
          .topbar-title {
            max-width: 130px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
          }

          .admin-content {
            padding-left: 10px;
            padding-right: 10px;
          }

          .page-title {
            font-size: 21px;
          }

          .page-title-icon {
            width: 40px;
            height: 40px;
            min-width: 40px;
          }

          .mobile-project-list {
            padding: 8px;
          }

          .mobile-card-images {
            height: 155px;
          }

          .mobile-card-image-placeholder {
            height: 155px;
          }

          .mobile-card-body {
            padding: 12px;
          }

          .mobile-project-title {
            font-size: 12px;
          }

          .mobile-project-description {
            font-size: 8px;
          }

          .mobile-meta-label {
            font-size: 6px;
          }

          .mobile-meta-value {
            font-size: 8px;
          }

          .mobile-action-button {
            min-height: 36px;
            font-size: 7px;
          }
        }

        /* =========================================================
           VERY SMALL
        ========================================================= */

        @media (max-width: 340px) {
          .admin-content {
            padding-left: 8px;
            padding-right: 8px;
          }

          .topbar-title {
            max-width: 105px;
          }

          .page-title {
            font-size: 19px;
          }

          .page-description {
            font-size: 9px;
            text-align: justify;
            text-justify: inter-word;
          }

          .project-container-header {
            padding: 11px;
          }

          .mobile-project-list {
            padding: 7px;
            gap: 8px;
          }

          .mobile-card-images {
            height: 140px;
          }

          .mobile-card-image-placeholder {
            height: 140px;
          }

          .mobile-card-body {
            padding: 10px;
          }

          .mobile-project-title {
            font-size: 11px;
          }

          .mobile-project-slug {
            font-size: 7px;
          }

          .mobile-project-description {
            font-size: 8px;
            line-height: 1.7;
          }

          .mobile-project-meta {
            gap: 8px;
          }

          .mobile-meta-value {
            font-size: 7px;
          }

          .mobile-card-actions {
            gap: 4px;
          }

          .mobile-action-button {
            min-height: 34px;
            padding: 5px 3px;
            font-size: 7px;
          }

          .mobile-action-button i {
            font-size: 9px;
          }

          .empty-state {
            padding: 35px 12px;
          }
        }

        /* =========================================================
           REDUCED MOTION
        ========================================================= */

        @media (prefers-reduced-motion: reduce) {
          .projects-admin-page *,
          .projects-admin-page *::before,
          .projects-admin-page *::after {
            animation-duration: 0.01ms !important;
            animation-iteration-count: 1 !important;
            transition-duration: 0.01ms !important;
          }
        }
      `}</style>

      <div className="projects-admin-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">

              {/* 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">

                {/* HERO */}

                <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>

                {/* ABOUT */}

                <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>

                {/* STATS */}

                <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>

                {/* EDUCATION */}

                <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>

                {/* SKILLS */}

                <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>

                {/* EXPERIENCE */}

                <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>

                {/* PROJECTS */}

                <Link
                  href="/secure-panel/projects"
                  className="sidebar-link active"
                  onClick={closeSidebar}
                >
                  <span className="sidebar-link-icon">
                    <i className="bi bi-code-square"></i>
                  </span>

                  <span>Projects</span>
                </Link>

                {/* CERTIFICATION */}

                <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>

                {/* ACHIEVEMENT */}

                <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>

                {/* SERVICES */}

                <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>

                {/* GALLERY */}

                <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>

                {/* CONTACT */}

                <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>

                {/* ARTICLES */}

                <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
          ===================================================== */}

          <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">
                    Projects 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="/secure-panel/login"
                  className="topbar-logout"
                  title="Logout"
                  aria-label="Logout"
                >
                  <i className="bi bi-box-arrow-right"></i>

                  <span className="d-none d-sm-inline">
                    Logout
                  </span>
                </Link>

              </div>

            </header>

            {/* ===================================================
                CONTENT
            =================================================== */}

            <main className="admin-content">

              {/* =================================================
                  PAGE HEADER
              ================================================= */}

              <section className="page-header">

                <div className="page-header-left">

                  <Link
                    href="/secure-panel"
                    className="back-link"
                  >
                    <i className="bi bi-arrow-left"></i>

                    <span>
                      Kembali ke Dashboard
                    </span>
                  </Link>

                  <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-code-square"></i>
                    </div>

                    <div>

                      <h1 className="page-title">
                        Projects
                      </h1>

                      <p className="page-description">
                        Kelola project dan portfolio yang
                        ditampilkan pada website GloVaTech.
                        Tambahkan project baru, perbarui
                        informasi project, kelola gambar,
                        teknologi yang digunakan, periode
                        pengerjaan, status featured, serta
                        tautan project agar portfolio tetap
                        terlihat profesional dan terstruktur.
                      </p>

                    </div>

                  </div>

                </div>

                <div className="page-header-right">

                  <Link
                    href="/secure-panel/projects/create"
                    className="add-project-button"
                  >
                    <i className="bi bi-plus-lg"></i>

                    <span>
                      Tambah Project
                    </span>
                  </Link>

                </div>

              </section>

              {/* =================================================
                  PROJECT CONTAINER
              ================================================= */}

              {projects.length === 0 ? (

                <section className="project-container">

                  <div className="empty-state">

                    <div className="empty-icon">
                      <i className="bi bi-folder2-open"></i>
                    </div>

                    <h2 className="empty-title">
                      Belum Ada Project
                    </h2>

                    <p className="empty-description">
                      Belum terdapat data project yang
                      tersimpan. Tambahkan project pertama
                      untuk mulai membangun portfolio
                      website GloVaTech.
                    </p>

                    <Link
                      href="/secure-panel/projects/create"
                      className="empty-add-button"
                    >
                      <i className="bi bi-plus-lg"></i>

                      Tambah Project
                    </Link>

                  </div>

                </section>

              ) : (

                <section className="project-container">

                  {/* CONTAINER HEADER */}

                  <div className="project-container-header">

                    <div className="project-container-header-left">

                      <div className="container-header-icon">
                        <i className="bi bi-kanban"></i>
                      </div>

                      <div className="container-header-text">

                        <h2 className="container-header-title">
                          Project Portfolio
                        </h2>

                        <p className="container-header-description">
                          Daftar project yang tersedia pada
                          sistem admin GloVaTech.
                        </p>

                      </div>

                    </div>

                    <div className="project-count">
                      {projects.length}
                    </div>

                  </div>

                  {/* =================================================
                      DESKTOP TABLE
                  ================================================= */}

                  <div className="desktop-project-table">

                    <table className="project-table">

                      <thead>

                        <tr>

                          <th>
                            Project
                          </th>

                          <th>
                            Technologies
                          </th>

                          <th>
                            Period
                          </th>

                          <th>
                            Featured
                          </th>

                          <th>
                            URL
                          </th>

                          <th className="text-end">
                            Action
                          </th>

                        </tr>

                      </thead>

                      <tbody>

                        {projects.map(
                          (project) => {

                            const projectImages =
                              getProjectImages(
                                project
                              );

                            const start =
                              formatDate(
                                project.startDate
                              );

                            const end =
                              formatDate(
                                project.endDate
                              );

                            return (
                              <tr
                                key={
                                  project.id
                                }
                              >

                                {/* PROJECT */}

                                <td>

                                  <div className="project-main-cell">

                                    {projectImages.length >
                                    0 ? (

                                      <div className="project-image-group">

                                        {projectImages
                                          .slice(
                                            0,
                                            3
                                          )
                                          .map(
                                            (
                                              item,
                                              index
                                            ) => (

                                              <img
                                                key={`${item.id}-${index}`}
                                                src={
                                                  item.image
                                                }
                                                alt={`${project.title} ${
                                                  index +
                                                  1
                                                }`}
                                                className="project-image-thumb"
                                              />

                                            )
                                          )}

                                        {projectImages.length >
                                          3 && (

                                          <div className="project-image-more">

                                            +
                                            {projectImages.length -
                                              3}

                                          </div>

                                        )}

                                      </div>

                                    ) : (

                                      <div className="project-image-empty">

                                        <i className="bi bi-image"></i>

                                      </div>

                                    )}

                                    <div className="project-main-info">

                                      <h3 className="project-title">
                                        {
                                          project.title
                                        }
                                      </h3>

                                      {project.description && (

                                        <div className="project-description">

                                          {project.description
                                            .length >
                                          100
                                            ? `${project.description.substring(
                                                0,
                                                100
                                              )}...`
                                            : project.description}

                                        </div>

                                      )}

                                      {projectImages.length >
                                        0 && (

                                        <div className="project-image-count">

                                          <i className="bi bi-images"></i>

                                          <span>
                                            {
                                              projectImages.length
                                            }{" "}
                                            gambar
                                          </span>

                                        </div>

                                      )}

                                    </div>

                                  </div>

                                </td>

                                {/* TECHNOLOGIES */}

                                <td>

                                  {project.technologies ? (

                                    <div className="technology-text">
                                      {
                                        project.technologies
                                      }
                                    </div>

                                  ) : (

                                    <span className="empty-value">
                                      -
                                    </span>

                                  )}

                                </td>

                                {/* PERIOD */}

                                <td>

                                  {start || end ? (

                                    <div className="project-date">

                                      {start && (
                                        <div>
                                          {start}
                                        </div>
                                      )}

                                      {end ? (

                                        <div>
                                          <span>
                                            sampai{" "}
                                          </span>

                                          {end}
                                        </div>

                                      ) : (

                                        project.startDate && (

                                          <div className="project-date-current">
                                            Saat ini
                                          </div>

                                        )

                                      )}

                                    </div>

                                  ) : (

                                    <span className="empty-value">
                                      -
                                    </span>

                                  )}

                                </td>

                                {/* FEATURED */}

                                <td>

                                  {project.featured ? (

                                    <span className="status-badge status-featured">

                                      <i className="bi bi-star-fill"></i>

                                      Featured

                                    </span>

                                  ) : (

                                    <span className="status-badge status-normal">

                                      Normal

                                    </span>

                                  )}

                                </td>

                                {/* URL */}

                                <td>

                                  {project.projectUrl ? (

                                    <a
                                      href={
                                        project.projectUrl
                                      }
                                      target="_blank"
                                      rel="noopener noreferrer"
                                      className="url-button"
                                      title={
                                        project.projectUrl
                                      }
                                      aria-label={`Open ${project.title}`}
                                    >
                                      <i className="bi bi-box-arrow-up-right"></i>
                                    </a>

                                  ) : (

                                    <span className="empty-value">
                                      -
                                    </span>

                                  )}

                                </td>

                                {/* ACTION */}

                                <td>

                                  <div className="project-actions">

                                    <Link
                                      href={`/secure-panel/projects/${project.id}/edit`}
                                      className="action-button edit-button"
                                    >
                                      <i className="bi bi-pencil"></i>

                                      <span>
                                        Edit
                                      </span>
                                    </Link>

                                    <button
                                      type="button"
                                      className="action-button delete-button"
                                      onClick={() =>
                                        deleteProject(
                                          project.id
                                        )
                                      }
                                    >
                                      <i className="bi bi-trash"></i>

                                      <span>
                                        Hapus
                                      </span>
                                    </button>

                                  </div>

                                </td>

                              </tr>
                            );
                          }
                        )}

                      </tbody>

                    </table>

                  </div>

                  {/* =================================================
                      MOBILE CARDS
                  ================================================= */}

                  <div className="mobile-project-list">

                    {projects.map(
                      (project) => {

                        const projectImages =
                          getProjectImages(
                            project
                          );

                        const start =
                          formatDate(
                            project.startDate
                          );

                        const end =
                          formatDate(
                            project.endDate
                          );

                        return (
                          <article
                            key={
                              project.id
                            }
                            className="project-mobile-card"
                          >

                            {/* IMAGE */}

                            {projectImages.length >
                            0 ? (

                              <div className="mobile-image-wrapper">

                                <div className="mobile-card-images">

                                  {projectImages
                                    .slice(
                                      0,
                                      3
                                    )
                                    .map(
                                      (
                                        item,
                                        index
                                      ) => (

                                        <img
                                          key={`${item.id}-${index}`}
                                          src={
                                            item.image
                                          }
                                          alt={`${project.title} ${
                                            index +
                                            1
                                          }`}
                                          className={`mobile-card-image ${
                                            projectImages.length ===
                                              1
                                              ? "single"
                                              : ""
                                          }`}
                                        />

                                      )
                                    )}

                                </div>

                                <div className="mobile-image-count">

                                  <i className="bi bi-images me-1"></i>

                                  {
                                    projectImages.length
                                  }

                                </div>

                              </div>

                            ) : (

                              <div className="mobile-card-image-placeholder">

                                <i className="bi bi-image"></i>

                              </div>

                            )}

                            {/* BODY */}

                            <div className="mobile-card-body">

                              <div className="mobile-card-top">

                                <div
                                  style={{
                                    minWidth: 0,
                                  }}
                                >

                                  <h3 className="mobile-project-title">
                                    {
                                      project.title
                                    }
                                  </h3>

                                  {project.slug && (

                                    <div className="mobile-project-slug">
                                      /{project.slug}
                                    </div>

                                  )}

                                </div>

                                <div className="mobile-featured-badge">

                                  {project.featured ? (

                                    <span className="status-badge status-featured">

                                      <i className="bi bi-star-fill"></i>

                                      Featured

                                    </span>

                                  ) : (

                                    <span className="status-badge status-normal">
                                      Normal
                                    </span>

                                  )}

                                </div>

                              </div>

                              {project.description && (

                                <p className="mobile-project-description">

                                  {project.description}

                                </p>

                              )}

                              {/* META */}

                              <div className="mobile-project-meta">

                                {/* TECHNOLOGY */}

                                <div className="mobile-meta-item">

                                  <span className="mobile-meta-label">
                                    Technologies
                                  </span>

                                  <div className="mobile-meta-value">

                                    {project.technologies ||
                                      "-"}

                                  </div>

                                </div>

                                {/* PERIOD */}

                                <div className="mobile-meta-item">

                                  <span className="mobile-meta-label">
                                    Period
                                  </span>

                                  <div className="mobile-meta-value">

                                    {start || end ? (

                                      <>
                                        {start && (
                                          <div>
                                            {start}
                                          </div>
                                        )}

                                        {end ? (

                                          <div>
                                            sampai{" "}
                                            {end}
                                          </div>

                                        ) : (

                                          project.startDate && (

                                            <div
                                              style={{
                                                color:
                                                  "#198754",
                                                fontWeight:
                                                  700,
                                              }}
                                            >
                                              Saat ini
                                            </div>

                                          )

                                        )}
                                      </>

                                    ) : (

                                      "-"
                                    )}

                                  </div>

                                </div>

                                {/* URL */}

                                <div className="mobile-meta-item">

                                  <span className="mobile-meta-label">
                                    Project URL
                                  </span>

                                  <div className="mobile-meta-value">

                                    {project.projectUrl ? (

                                      <a
                                        href={
                                          project.projectUrl
                                        }
                                        target="_blank"
                                        rel="noopener noreferrer"
                                        style={{
                                          color:
                                            "#198754",
                                          textDecoration:
                                            "none",
                                          fontWeight:
                                            700,
                                          overflowWrap:
                                            "anywhere",
                                        }}
                                      >
                                        Buka Project
                                      </a>

                                    ) : (

                                      "-"
                                    )}

                                  </div>

                                </div>

                                {/* IMAGES */}

                                <div className="mobile-meta-item">

                                  <span className="mobile-meta-label">
                                    Gallery
                                  </span>

                                  <div className="mobile-meta-value">

                                    <i className="bi bi-images me-1"></i>

                                    {
                                      projectImages.length
                                    }{" "}
                                    gambar

                                  </div>

                                </div>

                              </div>

                              {/* ACTIONS */}

                              <div className="mobile-card-actions">

                                <Link
                                  href={`/secure-panel/projects/${project.id}/edit`}
                                  className="mobile-action-button mobile-edit"
                                >
                                  <i className="bi bi-pencil"></i>

                                  <span>
                                    Edit
                                  </span>
                                </Link>

                                {project.projectUrl ? (

                                  <a
                                    href={
                                      project.projectUrl
                                    }
                                    target="_blank"
                                    rel="noopener noreferrer"
                                    className="mobile-action-button mobile-view"
                                  >
                                    <i className="bi bi-box-arrow-up-right"></i>

                                    <span>
                                      View
                                    </span>
                                  </a>

                                ) : (

                                  <span
                                    className="mobile-action-button"
                                    style={{
                                      color:
                                        "#98a2b3",
                                      background:
                                        "#f4f5f6",
                                      border:
                                        "1px solid #e4e7ec",
                                    }}
                                  >
                                    <i className="bi bi-link-45deg"></i>

                                    <span>
                                      No URL
                                    </span>
                                  </span>

                                )}

                                <button
                                  type="button"
                                  className="mobile-action-button mobile-delete"
                                  onClick={() =>
                                    deleteProject(
                                      project.id
                                    )
                                  }
                                >
                                  <i className="bi bi-trash"></i>

                                  <span>
                                    Hapus
                                  </span>
                                </button>

                              </div>

                            </div>

                          </article>
                        );
                      }
                    )}

                  </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">
                  <i className="bi bi-arrow-left me-1"></i>

                  Dashboard
                </Link>

              </footer>

            </main>

          </div>

        </div>
      </div>
    </>
  );
}

