/* global React, ReactDOM, AnimatedBackground, CursorGlow */
const { useState, useEffect } = React;

const PROJECTS = [
  { id: 16, title: "VISAL ERP", slug: "visal-erp", client: "Visal Solutions", category: "Cloud & Infrastructure", categories: ["Cloud & Infrastructure", "Strategy & Operations", "Software Engineering & Development", "Security"], description: "An all-in-one Enterprise Resource Planning (ERP) solution designed to streamline business operations.", fullDescription: "VISAL ERP is a comprehensive enterprise solution that integrates all aspects of your business operations.\n\nCore Modules:\n\n\u2022 Sales Management \u2013 Streamlined Order-to-Cash process with fast order handling, comprehensive analysis, and performance insights\n\n\u2022 Procurement \u2013 Full Purchase Requisition to Goods/Service Received Note process\n\n\u2022 Inventory Control \u2013 Multi-location inventory management with inter-location transfers, dispatch notes, and gate passes\n\n\u2022 Manufacturing \u2013 Simplified Plan-to-Production workflow with automatic manufacturing cost and variance tracking\n\n\u2022 Asset Management \u2013 Full asset life cycle control, including depreciation and disposal management\n\nFinancial Management:\n\n\u2022 General Ledger \u2013 Automatic posting of all module transactions to financial statements (Trial Balance, Balance Sheet, P&L)\n\n\u2022 Accounts Payables \u2013 Manages the full cash flow cycle from petty cash to vendor settlements\n\n\u2022 Accounts Receivables \u2013 Tracks receivables, credits, advances, post-dated cheques, and customer receipts\n\n\u2022 Cashbook \u2013 Multi-bank and cash management, cheque printing, deposit slips, and bank reconciliation\n\nAnalytics & Intelligence:\n\n\u2022 Business Intelligence (BI) \u2013 Powerful analytics and insights for data-driven decision making\n\nVISAL ERP empowers businesses to optimize operations, streamline workflows, and achieve operational excellence.", technologies: ["Angular", "TypeScript", "Node.js", "PostgreSQL", "Docker"], date: "2025-10", imageUrl: "/projects/visal_erp/Featured.png", promotion: "5% OFF This Season", liveUrl: null },
  { id: 18, title: "Altair Tours", slug: "altair-tours", client: "Altair Tours", category: "Software Engineering & Development", categories: ["Software Engineering & Development", "Design & Quality", "Cloud & Infrastructure"], description: "A modern travel platform for Altair Tours Lanka, offering personalized guided tours combining luxury experiences with authentic cultural engagement across Sri Lanka.", fullDescription: "Altair Tours Lanka is a comprehensive travel platform designed to showcase and manage curated travel experiences throughout Sri Lanka.\n\nKey Features:\n\n\u2022 Multi-day round tours with detailed itineraries and pricing\n\n\u2022 Day excursions including wildlife safaris, heritage tours, and adventure activities\n\n\u2022 Tailor-made trip planning with custom quote requests\n\n\u2022 Multi-language support (English, German, French, Spanish, Italian, Chinese)\n\n\u2022 Featured destinations showcase covering 9+ iconic Sri Lankan locations\n\n\u2022 Blog and content management for travel guides\n\nCore Values:\n\n\u2022 Eco-friendly and sustainable travel practices\n\n\u2022 Authentic cultural experiences with local communities\n\n\u2022 Personalized service with expert local guides\n\n\u2022 Luxury combined with meaningful engagement", technologies: ["Next.js", "React", "TypeScript", "Tailwind CSS", "Firebase", "Git"], date: "2025-12", imageUrl: "/projects/altair/Featured.png", liveUrl: "https://altair-tours.web.app/" },
  { id: 19, title: "Winrich Restaurant", slug: "winrich-restaurant", client: "Winrich Restaurant", category: "Software Engineering & Development", categories: ["Software Engineering & Development", "Design & Quality", "Cloud & Infrastructure"], description: "A modern digital platform for Winrich Restaurant, featuring an elegant online presence with menu browsing, reservations, and a seamless dining experience.", technologies: ["Next.js", "React", "TypeScript", "Tailwind CSS", "Firebase", "Git"], date: "2026-01", imageUrl: "/projects/winrich/Featured.png", liveUrl: null },
  { id: 17, title: "RentIo Platform", slug: "rentio", client: "RentIo", category: "Strategy & Operations", categories: ["Strategy & Operations", "Software Engineering & Development", "Cloud & Infrastructure"], description: "A comprehensive rental management platform with integrated service and repair functions, fetching data from client systems and hosted on client servers.", fullDescription: "RentIo is an advanced rental management platform designed to streamline the entire rental process. The platform integrates service and repair management functions, allowing businesses to manage their rental inventory, track maintenance, and provide seamless service to customers. Built with Angular and deployed on client infrastructure for maximum control and security.", technologies: ["Angular", "TypeScript", "RxJS", "Node.js", "Express", "MongoDB", "RESTful APIs", "Git"], date: "2025-10", imageUrl: "/projects/rentio/Featured.png", liveUrl: null },
  { id: 13, title: "SARTC Blog Platform", slug: "sartc-blog", client: "South Asian Research and Training Center", category: "Software Engineering & Development", description: "A professional blog and branding platform developed for the South Asian Research and Training Center, showcasing research insights, publications, and organizational updates.", technologies: ["React", "Nginx", "PostgreSQL", "Git", "Prometheus"], date: "2025-10", imageUrl: "/projects/sartc/Featured.png", liveUrl: null },
  { id: 12, title: "Pera Agros Alumni Platform", slug: "pera-agros-alumni", client: "Peradeniya University Alumni", category: "Software Engineering & Development", description: "A comprehensive WordPress-based platform developed for the Peradeniya University Alumni Association, facilitating community engagement, event management, and alumni networking.", technologies: ["WordPress", "PHP", "MySQL", "JavaScript", "CSS3", "HTML5"], date: "2025-10", imageUrl: "/projects/pera_agros/Featured.png", liveUrl: null },
  { id: 11, title: "Amethyst Gaming Platform", slug: "amethyst-gaming-community", client: "Amethyst SMP Gaming Community", category: "Software Engineering & Development", categories: ["Software Engineering & Development", "Security"], description: "An interactive web application for the Amethyst SMP Gaming community featuring 3D graphics, branding showcase, and an upcoming marketplace for trading Minecraft and game items.", fullDescription: "This is an ongoing project developing a comprehensive platform for the Amethyst SMP Gaming community. The platform currently showcases the community's branding with stunning 3D visuals and is being expanded to include a marketplace where users can buy and sell Minecraft items and other in-game assets. Hosted on Firebase, the application integrates with Mojang and Mineskin APIs for seamless Minecraft integration.", technologies: ["React", "Tailwind CSS", "Three.js", "Firebase", "Mojang API", "Mineskin API", "Axios", "Git"], date: "2025-10", imageUrl: "/projects/amethyst/Featured.png", liveUrl: "https://amethyst-community.web.app/" },
  { id: 22, title: "LankaTiles Ticket Manager", slug: "advanced-task-manager", client: "Lanka Tiles PLC", category: "Strategy & Operations", description: "Lanka Tiles is one of our valued long-term clients. We built this custom Trello-style Kanban ticket manager specifically tailored to their development workflow.", fullDescription: "Lanka Tiles PLC is one of Orca's most valued long-term clients. To better serve their growing development needs, we designed and built this fully custom Kanban ticket manager \u2014 tailored exactly to the workflow stages and reporting requirements their team uses internally.\n\nEvery development request Lanka Tiles submits to our company flows through this system, giving both teams complete visibility, faster turnaround, and detailed analytics on progress, effort, and delivery.\n\nKey Features:\n\n\u2022 Trello-style Kanban board with 7 workflow columns tailored to Lanka Tiles' development pipeline\n\n\u2022 Drag-and-drop tickets between stages: Todo \u2192 Development \u2192 210 \u2192 300 \u2192 400 \u2192 Completed \u2192 Closed\n\n\u2022 Create, edit, and delete tickets with titles, descriptions, dates, and man hours\n\n\u2022 Track TCodes affected and TR lists per ticket\n\n\u2022 Activity log (Summary) tracking all changes with user info and timestamps\n\n\u2022 Google authentication for secure access\n\n\u2022 Full-text search across all columns\n\n\u2022 Dark/light theme toggle\n\n\u2022 Persistent storage using Firebase Firestore\n\n\u2022 Responsive design with horizontal scrolling", technologies: ["HTML5", "CSS3", "JavaScript", "Font Awesome"], date: "2023-01", imageUrl: "/projects/advanced-task-manager/featured.png", demoUrl: "/demos/advanced-task-manager/" },
  { id: 21, title: "Internet Speed Checker", slug: "internet-speed-checker", client: "Personal Project", category: "Software Engineering & Development", description: "An interactive internet speed testing tool with real-time download/upload speed measurement, progress visualization, and dark mode support.", fullDescription: "A sleek and responsive Internet Speed Checker application built with vanilla HTML, CSS, and JavaScript. It provides real-time internet speed testing with a modern UI.\n\nKey Features:\n\n\u2022 Real-time download and upload speed measurement\n\n\u2022 Visual progress bar with speed indicators\n\n\u2022 Dark/light theme toggle\n\n\u2022 Clean, modern UI with Font Awesome icons\n\n\u2022 Fully responsive design for all devices", technologies: ["HTML5", "CSS3", "JavaScript", "Font Awesome"], date: "2023-01", imageUrl: "/projects/internet-speed-checker/Featured.png", demoUrl: "/demos/internet-speed-checker/" },
  { id: 20, title: "Periodic Table App", slug: "periodic-table-app", client: "Personal Project", category: "Software Engineering & Development", description: "An interactive periodic table application that lets you explore all chemical elements with detailed information, search functionality, and category-based filtering.", fullDescription: "An interactive and visually engaging Periodic Table application built with vanilla HTML, CSS, and JavaScript. Designed for educational purposes, it provides a comprehensive view of all chemical elements with rich detail panels.\n\nKey Features:\n\n\u2022 Full periodic table layout with color-coded element categories\n\n\u2022 Search by element name, symbol, or atomic number\n\n\u2022 Category filtering (Alkali Metals, Noble Gases, Transition Metals, etc.)\n\n\u2022 Random element discovery button\n\n\u2022 Detailed element view with physical, atomic, and historical properties", technologies: ["HTML5", "CSS3", "JavaScript"], date: "2023-01", imageUrl: "/projects/periodic-table-app/Featured.png", demoUrl: "/demos/periodic-table-app/" },
  { id: 10, title: "Crypto AI", slug: "crypto-ai", client: "Personal Customer", category: "Security", categories: ["Security", "Data & Intelligence", "Software Engineering & Development"], description: "An advanced AI-powered cryptocurrency trading platform that automates the entire trading process with intelligent analysis and execution.", fullDescription: "An advanced AI-powered cryptocurrency trading platform trained on over 100 proven trading strategies. The system autonomously handles market analysis, signal generation, and trade execution with continuous performance optimization. Our team actively monitors and refines the platform to ensure consistent results and robust security across multiple exchanges.", technologies: ["Python", "Angular", "SQL", "Pine Script", "Azure", "TensorFlow", "SARIMA", "Binance API", "Bybit API", "TradingView Webhooks", "Redis", "Apache Kafka", "Pandas", "NumPy", "Docker", "Git", "FastAPI", "Prometheus"], date: "2025-10", imageUrl: "/projects/crypto_ai/Featured.png", liveUrl: "https://orca-whale.web.app/" },
  { id: 15, title: "Tic Tac Toe Game", slug: "tic-tac-toe", client: "Personal Customer", category: "Software Engineering & Development", description: "An interactive Tic Tac Toe game featuring an intelligent AI bot opponent. Perfect for a quick break from work!", fullDescription: "Tired of scrolling and researching? Try to beat the bot in this little XOX game! This classic Tic Tac Toe game features a smart AI opponent that will challenge your strategic thinking. Built with vanilla JavaScript, it offers smooth gameplay and an intuitive interface.", technologies: ["HTML5", "CSS3", "JavaScript", "Git"], date: "2025-10", imageUrl: "/projects/tick_tack_toe/Featured.png", liveUrl: "https://charaka-janith.github.io/#/tic-tac-toe" },
  { id: 23, title: "Ceylon Cozy Tours", slug: "ceylon-cozy-tours", client: "Ceylon Cozy Tours", category: "Software Engineering & Development", categories: ["Software Engineering & Development", "Design & Quality", "Cloud & Infrastructure"], description: "Sri Lanka's best tailor-made tourism platform \u2014 letting clients design their own journey with custom itineraries, 500+ tour options across 40+ destinations, and 24/7 support.", fullDescription: "Ceylon Cozy Tours is a comprehensive travel platform designed to offer fully personalized travel experiences across Sri Lanka.\n\nKey Features:\n\n\u2022 'Design My Journey' tool for fully custom itinerary planning\n\n\u2022 500+ curated tour packages across 40+ countries and destinations\n\n\u2022 Cultural heritage, beach & wildlife, and complete island experience packages\n\n\u2022 24/7 customer support with 2-hour quote response time\n\n\u2022 Secure booking with flexible payment options and travel insurance\n\n\u2022 10,000+ happy travelers served with 15+ years of experience\n\n\u2022 Multi-language support and responsive design for all devices\n\nThe platform empowers travelers to craft their perfect Sri Lankan adventure, combining luxury with authentic cultural engagement.", technologies: ["Next.js", "React", "TypeScript", "Tailwind CSS", "Firebase"], date: "2025-11", imageUrl: "/projects/ceylon_cozy_tours/Featured.png", liveUrl: "https://ceylon-cozy-tours.web.app/" },
  { id: 24, title: "Tangerine Tours System", slug: "tangerine-tours-system", client: "Tangerine Tours Limited", category: "Strategy & Operations", categories: ["Strategy & Operations", "Software Engineering & Development", "Cloud & Infrastructure", "Security"], description: "A large-scale, fully custom enterprise system built for Tangerine Tours Limited \u2014 managing all operations across their tourism company and multi-company structure. The most comprehensive custom tourism management system we've delivered.", fullDescription: "The Tangerine Tours System is the most complex and comprehensive custom enterprise solution Orca Solutions has delivered to date. Built specifically for Tangerine Tours Limited, it manages the full spectrum of operations across their tourism company and multi-company structure.\n\nThis system was engineered exactly to Tangerine Tours' requirements, covering:\n\n\u2022 End-to-end tour management \u2014 from inquiry to post-trip follow-up\n\n\u2022 Multi-company operations \u2014 unified management across all business entities\n\n\u2022 Booking & reservation management with real-time availability\n\n\u2022 Financial management \u2014 invoicing, payments, commissions, and reporting\n\n\u2022 Customer relationship management (CRM) tailored to tourism workflows\n\n\u2022 Supplier and vendor management across hotels, transport, and activities\n\n\u2022 Staff and resource allocation and scheduling\n\n\u2022 Comprehensive reporting and business intelligence dashboards\n\n\u2022 Role-based access control and audit trails for security\n\nThis is by far the best custom system for tourism companies we have implemented, built to handle the full complexity of a large-scale tourism operation.", technologies: ["Angular", "TypeScript", "Node.js", "PostgreSQL", "Docker"], date: "2026-01", imageUrl: "/projects/tangerine_tours/Featured.png", liveUrl: null },
];

function getProjectFromSlug() {
  const path = window.location.pathname;
  const slug = path.split('/projects/')[1]?.replace(/\/$/, '');
  return PROJECTS.find(p => p.slug === slug) || null;
}

function DetailNav() {
  const [scrolled, setScrolled] = useState(false);
  useEffect(() => {
    const onScroll = () => setScrolled(window.scrollY > 12);
    window.addEventListener('scroll', onScroll);
    return () => window.removeEventListener('scroll', onScroll);
  }, []);
  return (
    <header className={`nav ${scrolled ? 'nav--scrolled' : ''}`}>
      <div className="nav__inner">
        <a href="/" className="nav__brand">
          <span className="nav__logo-plate">
            <img src="/logos/logo dark.png" alt="" className="nav__logo" />
          </span>
          <span className="nav__wordmark">Orca</span>
          <span className="nav__sub">/ Solutions</span>
        </a>
        <nav className="nav__links">
          <a href="/">Home</a>
          <a href="/projects">Projects</a>
          <a href="#contact">Contact</a>
        </nav>
        <div className="nav__cta">
          <a href="#contact" className="btn btn--ghost nav__cta-btn">Start a project</a>
        </div>
      </div>
    </header>
  );
}

function ProjectDetailPage() {
  const project = getProjectFromSlug();
  const [showCopyToast, setShowCopyToast] = useState(false);

  if (!project) {
    return (
      <>
        <CursorGlow />
        <AnimatedBackground enabled={true} />
        <DetailNav />
        <div className="pd" style={{ textAlign: 'center', paddingTop: '200px' }}>
          <h1>Project not found</h1>
          <a href="/projects" className="btn btn--primary" style={{ marginTop: '24px', display: 'inline-flex' }}>Back to Projects</a>
        </div>
      </>
    );
  }

  const shareUrl = 'https://orca-software.web.app/projects/' + project.slug;
  const shareTitle = project.title + ' - Orca Solutions Limited';

  const copyLink = () => {
    navigator.clipboard.writeText(shareUrl);
    setShowCopyToast(true);
    setTimeout(() => setShowCopyToast(false), 3000);
  };

  const formatDate = (d) => {
    if (!d) return '';
    const [y, m] = d.split('-');
    const months = ['January','February','March','April','May','June','July','August','September','October','November','December'];
    return months[parseInt(m,10)-1] + ' ' + y;
  };

  return (
    <>
      <AnimatedBackground enabled={true} />
      <DetailNav />
      <div className="pd">
        {/* Breadcrumb */}
        <div className="pd__bread">
          <a href="/">Home</a>
          <span>/</span>
          <a href="/projects">Projects</a>
          <span>/</span>
          <span className="pd__bread-cur">{project.title}</span>
        </div>

        {/* Promotion */}
        {project.promotion && (
          <div className="pd__promo">
            <svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" strokeLinecap="round" strokeLinejoin="round">
              <path d="M20.59 13.41l-7.17 7.17a2 2 0 0 1-2.83 0L2 12V2h10l8.59 8.59a2 2 0 0 1 0 2.82z"/>
              <line x1="7" y1="7" x2="7.01" y2="7"/>
            </svg>
            <div>
              <div className="pd__promo-label">Special Seasonal Offer</div>
              <div className="pd__promo-value">{project.promotion}</div>
            </div>
          </div>
        )}

        {/* Header */}
        <div className="pd__header">
          <div className="pd__cats">
            {(project.categories || [project.category]).map((c, i) => (
              <span key={i} className="pd__cat">{c}</span>
            ))}
          </div>
          <h1 className="pd__title">{project.title}</h1>
          <div className="pd__meta">
            <span>Client: {project.client}</span>
            <span>{formatDate(project.date)}</span>
          </div>
          {project.liveUrl && (
            <a href={project.liveUrl} target="_blank" rel="noopener noreferrer" className="pd__live">
              <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
                <path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/>
                <polyline points="15 3 21 3 21 9"/>
                <line x1="10" y1="14" x2="21" y2="3"/>
              </svg>
              Visit Live Site
            </a>
          )}
          {project.demoUrl && (
            <a href={project.demoUrl} target="_blank" rel="noopener noreferrer" className="pd__live">
              <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
                <path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/>
                <polyline points="15 3 21 3 21 9"/>
                <line x1="10" y1="14" x2="21" y2="3"/>
              </svg>
              Live Preview
            </a>
          )}
        </div>

        {/* Featured Image */}
        <div className="pd__image">
          <img src={project.imageUrl} alt={project.title} />
        </div>

        {/* Description */}
        <div className="pd__content">
          <h2>Project Overview</h2>
          <p>{project.description}</p>
          {project.fullDescription && (
            <>
              <h3>Detailed Description</h3>
              <div className="pd__full-desc">
                {project.fullDescription.split('\n').map((line, i) => {
                  const trimmed = line.trim();
                  if (!trimmed) return null;
                  const isBullet = trimmed.startsWith('\u2022');
                  const isHeader = !isBullet && trimmed.endsWith(':');
                  return <p key={i} className={isHeader ? 'pd__desc-header' : isBullet ? 'pd__desc-bullet' : ''}>{line}</p>;
                })}
              </div>
            </>
          )}
        </div>

        {/* Share */}
        <div className="pd__share">
          <h3>Share this project</h3>
          <div className="pd__share-btns">
            <a href={'https://www.linkedin.com/sharing/share-offsite/?url=' + encodeURIComponent(shareUrl)} target="_blank" rel="noopener noreferrer" className="pd__share-btn">
              <svg width="18" height="18" viewBox="0 0 24 24" fill="currentColor"><path d="M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85 3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433a2.062 2.062 0 01-2.063-2.065 2.064 2.064 0 112.063 2.065zm1.782 13.019H3.555V9h3.564v11.452zM22.225 0H1.771C.792 0 0 .774 0 1.729v20.542C0 23.227.792 24 1.771 24h20.451C23.2 24 24 23.227 24 22.271V1.729C24 .774 23.2 0 22.222 0h.003z"/></svg>
              LinkedIn
            </a>
            <a href={'https://twitter.com/intent/tweet?url=' + encodeURIComponent(shareUrl) + '&text=' + encodeURIComponent(shareTitle)} target="_blank" rel="noopener noreferrer" className="pd__share-btn">
              <svg width="18" height="18" viewBox="0 0 24 24" fill="currentColor"><path d="M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"/></svg>
              Twitter
            </a>
            <a href={'https://api.whatsapp.com/send?text=' + encodeURIComponent(shareTitle + ' - ' + shareUrl)} target="_blank" rel="noopener noreferrer" className="pd__share-btn">
              <svg width="18" height="18" viewBox="0 0 24 24" fill="currentColor"><path d="M17.472 14.382c-.297-.149-1.758-.867-2.03-.967-.273-.099-.471-.148-.67.15-.197.297-.767.966-.94 1.164-.173.199-.347.223-.644.075-.297-.15-1.255-.463-2.39-1.475-.883-.788-1.48-1.761-1.653-2.059-.173-.297-.018-.458.13-.606.134-.133.298-.347.446-.52.149-.174.198-.298.298-.497.099-.198.05-.371-.025-.52-.075-.149-.669-1.612-.916-2.207-.242-.579-.487-.5-.669-.51-.173-.008-.371-.01-.57-.01-.198 0-.52.074-.792.372-.272.297-1.04 1.016-1.04 2.479 0 1.462 1.065 2.875 1.213 3.074.149.198 2.096 3.2 5.077 4.487.709.306 1.262.489 1.694.625.712.227 1.36.195 1.871.118.571-.085 1.758-.719 2.006-1.413.248-.694.248-1.289.173-1.413-.074-.124-.272-.198-.57-.347m-5.421 7.403h-.004a9.87 9.87 0 01-5.031-1.378l-.361-.214-3.741.982.998-3.648-.235-.374a9.86 9.86 0 01-1.51-5.26c.001-5.45 4.436-9.884 9.888-9.884 2.64 0 5.122 1.03 6.988 2.898a9.825 9.825 0 012.893 6.994c-.003 5.45-4.437 9.884-9.885 9.884m8.413-18.297A11.815 11.815 0 0012.05 0C5.495 0 .16 5.335.157 11.892c0 2.096.547 4.142 1.588 5.945L.057 24l6.305-1.654a11.882 11.882 0 005.683 1.448h.005c6.554 0 11.89-5.335 11.893-11.893a11.821 11.821 0 00-3.48-8.413z"/></svg>
              WhatsApp
            </a>
            <button onClick={copyLink} className="pd__share-btn">
              <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
                <path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/>
                <path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"/>
              </svg>
              Copy Link
            </button>
          </div>
        </div>

        {/* Back */}
        <div className="pd__back">
          <a href="/projects" className="btn btn--ghost">
            <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><path d="M19 12H5M12 19l-7-7 7-7"/></svg>
            Back to Projects
          </a>
        </div>
      </div>

      {/* Contact */}
      <ProjectContact />

      {/* Footer */}
      <footer className="foot">
        <div className="foot__top">
          <div className="foot__brand-col">
            <div className="foot__brand">
              <span className="foot__logo-plate">
                <img src="/logos/logo dark.png" alt="" className="foot__logo" />
              </span>
              <span className="foot__word">Orca Solutions Limited</span>
            </div>
            <div className="foot__socials">
              <a href="https://www.linkedin.com/company/109359186/" target="_blank" rel="noopener noreferrer" className="foot__social" aria-label="LinkedIn"><svg width="18" height="18" viewBox="0 0 24 24" fill="currentColor"><path d="M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85 3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433a2.062 2.062 0 01-2.063-2.065 2.064 2.064 0 112.063 2.065zm1.782 13.019H3.555V9h3.564v11.452zM22.225 0H1.771C.792 0 0 .774 0 1.729v20.542C0 23.227.792 24 1.771 24h20.451C23.2 24 24 23.227 24 22.271V1.729C24 .774 23.2 0 22.222 0h.003z"/></svg></a>
              <a href="https://x.com/OrcaSolutionsLK" target="_blank" rel="noopener noreferrer" className="foot__social" aria-label="X / Twitter"><svg width="18" height="18" viewBox="0 0 24 24" fill="currentColor"><path d="M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"/></svg></a>
              <a href="https://github.com/AspireVX15" target="_blank" rel="noopener noreferrer" className="foot__social" aria-label="GitHub"><svg width="18" height="18" viewBox="0 0 24 24" fill="currentColor"><path d="M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12"/></svg></a>
              <a href="https://wa.me/94711818119" target="_blank" rel="noopener noreferrer" className="foot__social" aria-label="WhatsApp"><svg width="18" height="18" viewBox="0 0 24 24" fill="currentColor"><path d="M17.472 14.382c-.297-.149-1.758-.867-2.03-.967-.273-.099-.471-.148-.67.15-.197.297-.767.966-.94 1.164-.173.199-.347.223-.644.075-.297-.15-1.255-.463-2.39-1.475-.883-.788-1.48-1.761-1.653-2.059-.173-.297-.018-.458.13-.606.134-.133.298-.347.446-.52.149-.174.198-.298.298-.497.099-.198.05-.371-.025-.52-.075-.149-.669-1.612-.916-2.207-.242-.579-.487-.5-.669-.51-.173-.008-.371-.01-.57-.01-.198 0-.52.074-.792.372-.272.297-1.04 1.016-1.04 2.479 0 1.462 1.065 2.875 1.213 3.074.149.198 2.096 3.2 5.077 4.487.709.306 1.262.489 1.694.625.712.227 1.36.195 1.871.118.571-.085 1.758-.719 2.006-1.413.248-.694.248-1.289.173-1.413-.074-.124-.272-.198-.57-.347m-5.421 7.403h-.004a9.87 9.87 0 01-5.031-1.378l-.361-.214-3.741.982.998-3.648-.235-.374a9.86 9.86 0 01-1.51-5.26c.001-5.45 4.436-9.884 9.888-9.884 2.64 0 5.122 1.03 6.988 2.898a9.825 9.825 0 012.893 6.994c-.003 5.45-4.437 9.884-9.885 9.884m8.413-18.297A11.815 11.815 0 0012.05 0C5.495 0 .16 5.335.157 11.892c0 2.096.547 4.142 1.588 5.945L.057 24l6.305-1.654a11.882 11.882 0 005.683 1.448h.005c6.554 0 11.89-5.335 11.893-11.893a11.821 11.821 0 00-3.48-8.413z"/></svg></a>
              <a href="mailto:orca.softwares.limited@gmail.com" className="foot__social" aria-label="Email"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><rect x="2" y="4" width="20" height="16" rx="2"/><path d="m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7"/></svg></a>
            </div>
          </div>
          <div className="foot__cols">
            <div><h5>Services</h5><a href="/#services">Engineering</a><a href="/#services">Cloud</a><a href="/#services">Security</a><a href="/#services">Data</a></div>
            <div><h5>Company</h5><a href="/#about">About</a><a href="/#work">Work</a><a href="/projects">Projects</a><a href="/#contact">Contact</a></div>
            <div><h5>Connect</h5><a href="https://www.linkedin.com/company/109359186/" target="_blank" rel="noopener noreferrer">LinkedIn</a><a href="https://x.com/OrcaSolutionsLK" target="_blank" rel="noopener noreferrer">X / Twitter</a><a href="https://wa.me/94711818119" target="_blank" rel="noopener noreferrer">WhatsApp</a><a href="mailto:orca.softwares.limited@gmail.com">Email</a></div>
          </div>
        </div>
        <div className="foot__bot">
          <span>&copy; 2026 Orca Solutions Limited</span>
          <span>Colombo &middot; Sri Lanka</span>
          <span className="foot__pulse"><span className="foot__dot"></span>All systems operational</span>
        </div>
      </footer>

      {showCopyToast && (
        <div className="pd__toast">
          <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" strokeLinecap="round" strokeLinejoin="round"><path d="M20 6L9 17l-5-5"/></svg>
          Link copied!
        </div>
      )}
    </>
  );
}

function ProjectContact() {
  const [sent, setSent] = useState(false);
  const [form, setForm] = useState({ name: '', email: '', company: '', scope: 'Web platform', msg: '' });
  const upd = (k) => (e) => setForm((f) => ({ ...f, [k]: e.target.value }));
  const handleSubmit = (e) => {
    e.preventDefault();
    if (typeof firebase !== 'undefined' && firebase.firestore) {
      firebase.firestore().collection('contacts').add({
        name: form.name, email: form.email, company: form.company, scope: form.scope, message: form.msg, status: 'new',
        createdAt: firebase.firestore.FieldValue.serverTimestamp(),
      }).catch(() => {});
    }
    setSent(true);
  };
  return (
    <section className="contact" id="contact">
      <div className="contact__inner">
        <div className="contact__left">
          <span className="eyebrow">Contact</span>
          <h2 className="contact__title">Have a project in mind?<br /><span className="contact__title-muted">Let's map it out.</span></h2>
          <p className="contact__lede">Tell us a little about what you're building. We reply within one business day, usually faster.</p>
          <div className="contact__cards">
            <a href="tel:+94711818119" className="contact__card contact__card--phone">
              <div className="contact__card-icon"><svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><path d="M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z"/></svg></div>
              <span className="contact__card-label">Prefer to talk?</span>
              <span className="contact__card-title">Call our Technical Consultant</span>
              <span className="contact__card-name">Charaka Janith</span>
              <span className="contact__card-value">+94 71 181 8119</span>
            </a>
            <a href="https://wa.me/94711818119" target="_blank" rel="noopener noreferrer" className="contact__card contact__card--whatsapp">
              <div className="contact__card-icon"><svg width="24" height="24" viewBox="0 0 24 24" fill="currentColor"><path d="M17.472 14.382c-.297-.149-1.758-.867-2.03-.967-.273-.099-.471-.148-.67.15-.197.297-.767.966-.94 1.164-.173.199-.347.223-.644.075-.297-.15-1.255-.463-2.39-1.475-.883-.788-1.48-1.761-1.653-2.059-.173-.297-.018-.458.13-.606.134-.133.298-.347.446-.52.149-.174.198-.298.298-.497.099-.198.05-.371-.025-.52-.075-.149-.669-1.612-.916-2.207-.242-.579-.487-.5-.669-.51-.173-.008-.371-.01-.57-.01-.198 0-.52.074-.792.372-.272.297-1.04 1.016-1.04 2.479 0 1.462 1.065 2.875 1.213 3.074.149.198 2.096 3.2 5.077 4.487.709.306 1.262.489 1.694.625.712.227 1.36.195 1.871.118.571-.085 1.758-.719 2.006-1.413.248-.694.248-1.289.173-1.413-.074-.124-.272-.198-.57-.347m-5.421 7.403h-.004a9.87 9.87 0 0 1-5.031-1.378l-.361-.214-3.741.982.998-3.648-.235-.374a9.86 9.86 0 0 1-1.51-5.26c.001-5.45 4.436-9.884 9.888-9.884 2.64 0 5.122 1.03 6.988 2.898a9.825 9.825 0 0 1 2.893 6.994c-.003 5.45-4.437 9.884-9.885 9.884m8.413-18.297A11.815 11.815 0 0 0 12.05 0C5.495 0 .16 5.335.157 11.892c0 2.096.547 4.142 1.588 5.945L.057 24l6.305-1.654a11.882 11.882 0 0 0 5.683 1.448h.005c6.554 0 11.89-5.335 11.893-11.893a11.821 11.821 0 0 0-3.48-8.413z"/></svg></div>
              <span className="contact__card-label">Quick chat?</span>
              <span className="contact__card-title">Message us on WhatsApp</span>
              <span className="contact__card-value">wa.me/94711818119</span>
            </a>
          </div>
        </div>
        <form className="contact__form" onSubmit={handleSubmit}>
          {sent ?
            <div className="contact__sent">
              <div className="contact__sent-mark">&#10003;</div>
              <h4>Message received.</h4>
              <p>We'll be in touch shortly, {form.name || 'there'}.</p>
            </div> :
            <>
              <label className="field"><span>Name</span><input value={form.name} onChange={upd('name')} placeholder="Jane Perera" required /></label>
              <label className="field"><span>Email</span><input type="email" value={form.email} onChange={upd('email')} placeholder="jane@company.com" required /></label>
              <label className="field"><span>Company</span><input value={form.company} onChange={upd('company')} placeholder="Acme Ltd." /></label>
              <label className="field">
                <span>Scope</span>
                <select value={form.scope} onChange={upd('scope')}>
                  <option>Web platform</option><option>Mobile app</option><option>ERP / internal tools</option><option>Cloud / DevOps</option><option>AI / data</option><option>Other</option>
                </select>
              </label>
              <label className="field field--full"><span>What are you building?</span>
                <textarea value={form.msg} onChange={upd('msg')} rows="4" placeholder="A few sentences is plenty. Links welcome." required></textarea>
              </label>
              <button className="btn btn--primary btn--full" type="submit">Send message<span className="btn__arrow"> &rarr;</span></button>
            </>
          }
        </form>
      </div>
    </section>
  );
}

ReactDOM.createRoot(document.getElementById('root')).render(<ProjectDetailPage />);
