import React from 'react';
import { useNavigate } from 'react-router-dom';
import BottomNav from '../components/BottomNav';

const DetailSPK = () => {
  const navigate = useNavigate();

  return (
    <div className="flex flex-col h-screen bg-gray-50">
      {/* Header */}
      <div className="sticky top-0 z-50 bg-white px-4 py-3 shadow-sm">
        <div className="flex items-center justify-between">
          <div className="flex items-center gap-3">
            <button onClick={() => navigate(-1)} className="w-10 h-10 bg-slate-800 rounded-full flex items-center justify-center text-white">
              <svg className="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M15 19l-7-7 7-7" />
              </svg>
            </button>
            <h1 className="text-lg font-bold text-gray-900">Ringkasan SPK</h1>
          </div>
          <button className="text-gray-700">
            <svg className="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
              <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M15 17h5l-1.405-1.405A2.032 2.032 0 0118 14.158V11a6.002 6.002 0 00-4-5.659V5a2 2 0 10-4 0v.341C7.67 6.165 6 8.388 6 11v3.159c0 .538-.214 1.055-.595 1.436L4 17h5m6 0v1a3 3 0 11-6 0v-1m6 0H9" />
            </svg>
          </button>
        </div>
      </div>

      <div className="flex-1 overflow-y-auto pb-20">
        <div className="p-4 space-y-4">
          {/* Status Card */}
          <div className="bg-white rounded-2xl p-4 shadow-sm">
            <div className="flex items-center justify-between">
              <div className="flex items-center gap-3">
                <div className="w-12 h-12 bg-green-500 rounded-full flex items-center justify-center">
                  <svg className="w-6 h-6 text-white" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                    <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M5 13l4 4L19 7" />
                  </svg>
                </div>
                <div>
                  <p className="text-xs text-gray-500 mb-1">STATUS PESANAN</p>
                  <p className="text-lg font-bold text-gray-900">Approved</p>
                </div>
              </div>
              <div className="text-right">
                <p className="text-xs text-gray-500 mb-1">NO. SPK</p>
                <p className="text-sm font-bold text-gray-900">SPK/2024/08/0129</p>
              </div>
            </div>
          </div>

          {/* Car Image & Info */}
          <div className="bg-white rounded-2xl p-4 shadow-sm">
            <div className="bg-white rounded-2xl p-4 mb-4">
              <img 
                src="/images/chery-tiggo-8-pro.png" 
                alt="Chery Tiggo 8 Pro"
                className="w-full h-48 object-contain rounded-xl"
              />
            </div>
            <div className="flex items-start justify-between">
              <div>
                <h2 className="text-xl font-bold text-gray-900 mb-1">Chery Tiggo 8 Pro</h2>
                <p className="text-sm text-gray-600">Premium Luxury Edition • 2.0 Turbo</p>
              </div>
              <span className="bg-gray-100 text-gray-700 text-xs px-3 py-1 rounded-full font-semibold">2024</span>
            </div>
          </div>

          {/* Data Pelanggan */}
          <div className="bg-white rounded-2xl p-4 shadow-sm">
            <div className="flex items-center gap-2 mb-4">
              <svg className="w-5 h-5 text-gray-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z" />
              </svg>
              <h3 className="font-bold text-gray-900">DATA PELANGGAN</h3>
            </div>

            <div className="grid grid-cols-2 gap-4">
              <div>
                <p className="text-xs text-gray-500 mb-1">Nama Pemesanan</p>
                <p className="text-sm font-semibold text-gray-900">Bambang Wijaya</p>
              </div>
              <div>
                <p className="text-xs text-gray-500 mb-1">Metode Bayar</p>
                <p className="text-sm font-semibold text-gray-900">Kredit (BCA Finance)</p>
              </div>
            </div>
          </div>

          {/* Rincian Finansial */}
          <div className="bg-white rounded-2xl p-4 shadow-sm">
            <div className="flex items-center gap-2 mb-4">
              <svg className="w-5 h-5 text-gray-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M17 9V7a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2m2 4h10a2 2 0 002-2v-6a2 2 0 00-2-2H9a2 2 0 00-2 2v6a2 2 0 002 2zm7-5a2 2 0 11-4 0 2 2 0 014 0z" />
              </svg>
              <h3 className="font-bold text-gray-900">RINCIAN FINANSIAL</h3>
            </div>

            <div className="space-y-3">
              <div className="flex justify-between">
                <span className="text-sm text-gray-600">Harga OAR</span>
                <span className="text-sm font-semibold text-gray-900">Rp 558.500.000</span>
              </div>
              <div className="flex justify-between">
                <span className="text-sm text-gray-600">Down Payment (20%)</span>
                <span className="text-sm font-semibold text-gray-900">Rp 111.700.000</span>
              </div>
              <div className="flex justify-between">
                <span className="text-sm text-gray-600">Angsuran (60x)</span>
                <span className="text-sm font-semibold text-gray-900">Rp 9.250.000 / bln</span>
              </div>
              <div className="border-t pt-3 mt-3">
                <div className="flex justify-between">
                  <span className="text-base font-bold text-gray-900">Total Booking Fee</span>
                  <span className="text-base font-bold text-gray-900">Rp 10.000.000</span>
                </div>
              </div>
            </div>
          </div>

          {/* Generate PDF Button */}
          <button className="w-full bg-slate-800 text-white py-4 rounded-xl font-semibold flex items-center justify-center gap-2">
            <svg className="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
              <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z" />
            </svg>
            Generate PDF SPK
          </button>

          <button 
            onClick={() => navigate('/activities')}
            className="w-full bg-white text-gray-600 py-4 rounded-xl font-semibold"
          >
            Lihat Histori Aktivitas
          </button>

          {/* Timeline */}
          <div className="grid grid-cols-2 gap-4">
            <div>
              <p className="text-xs text-gray-500 mb-1">TANGGAL SPK</p>
              <p className="text-sm font-semibold text-gray-900">24 Ags 2024</p>
            </div>
            <div>
              <p className="text-xs text-gray-500 mb-1">ESTIMASI DELIVERY</p>
              <p className="text-sm font-semibold text-gray-900">12 Sep 2024</p>
            </div>
          </div>
        </div>
      </div>

      <BottomNav />
    </div>
  );
};

export default DetailSPK;
