%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /home2/rezakur1/muakita.rezakurnia.com/Mua-Kita-Web/src/components/views/
Upload File :
Create Path :
Current File : /home2/rezakur1/muakita.rezakurnia.com/Mua-Kita-Web/src/components/views/PelangganView.tsx

import React, { useState } from 'react';
import { 
  Users, Star, RefreshCw, Gem, Wallet, Search, Plus, Download, Upload, 
  Filter, X, Eye, MoreVertical, Calendar, Phone, Mail, ChevronLeft, 
  ChevronRight, Check, MessageCircle, Tag, ArrowUp, ArrowLeft, User,
  MapPin, Image as ImageIcon, Heart, Save, Sparkles, CheckCircle2
} from 'lucide-react';

interface Customer {
  id: string;
  name: string;
  joinDate: string;
  phone: string;
  email: string;
  avatar: string;
  tags: { label: string; color: 'purple' | 'green' | 'pink' | 'blue' | 'orange' }[];
  totalBookings: number;
  totalSpend: string;
  lastBookingDate: string;
  status: 'Aktif' | 'Tidak Aktif';
}

interface PelangganViewProps {
  onNavigateToCreateReservation?: () => void;
  initialSubView?: 'daftar' | 'tambah';
  triggerToast: (msg: string) => void;
}

export const PelangganView: React.FC<PelangganViewProps> = ({ 
  onNavigateToCreateReservation, 
  initialSubView = 'daftar',
  triggerToast 
}) => {
  const [subView, setSubView] = useState<'daftar' | 'tambah'>(initialSubView);

  // Daftar Pelanggan State
  const [searchTerm, setSearchTerm] = useState('');
  const [selectedTab, setSelectedTab] = useState<'Semua' | 'Baru' | 'Repeat' | 'VIP'>('Semua');
  const [isFilterPanelOpen, setIsFilterPanelOpen] = useState(true);
  const [selectedCustomer, setSelectedCustomer] = useState<Customer | null>(null);
  const [selectedCustomers, setSelectedCustomers] = useState<string[]>([]);

  // Filter Form State
  const [filterGroup, setFilterGroup] = useState('Semua Grup');
  const [filterTag, setFilterTag] = useState('Semua Tag');
  const [filterStatus, setFilterStatus] = useState('Semua Status');
  const [filterSort, setFilterSort] = useState('Terbaru');

  // Customer List matching the reference image exactly
  const [customersList, setCustomersList] = useState<Customer[]>([
    {
      id: 'cust-1',
      name: 'Maya Salsabila',
      joinDate: '12 Jan 2025',
      phone: '0812 8888 9999',
      email: 'maya.salsa@email.com',
      avatar: 'https://images.unsplash.com/photo-1534528741775-53994a69daeb?auto=format&fit=crop&q=80&w=200',
      tags: [
        { label: 'VIP', color: 'purple' },
        { label: 'Repeat', color: 'green' }
      ],
      totalBookings: 5,
      totalSpend: 'Rp15.750.000',
      lastBookingDate: '20 Mei 2025',
      status: 'Aktif'
    },
    {
      id: 'cust-2',
      name: 'Anisa Rahma',
      joinDate: '05 Feb 2025',
      phone: '0812 7777 6666',
      email: 'anisa.rahma@email.com',
      avatar: 'https://images.unsplash.com/photo-1544005313-94ddf0286df2?auto=format&fit=crop&q=80&w=200',
      tags: [
        { label: 'Repeat', color: 'green' },
        { label: 'Wedding', color: 'pink' }
      ],
      totalBookings: 3,
      totalSpend: 'Rp9.250.000',
      lastBookingDate: '18 Mei 2025',
      status: 'Aktif'
    },
    {
      id: 'cust-3',
      name: 'Fahira Nur',
      joinDate: '20 Feb 2025',
      phone: '0812 1234 5678',
      email: 'fahira.nur@email.com',
      avatar: '',
      tags: [
        { label: 'Graduation', color: 'blue' }
      ],
      totalBookings: 2,
      totalSpend: 'Rp5.500.000',
      lastBookingDate: '10 Mei 2025',
      status: 'Aktif'
    },
    {
      id: 'cust-4',
      name: 'Clara Dewi',
      joinDate: '01 Mar 2025',
      phone: '0812 4444 5555',
      email: 'clara.dewi@email.com',
      avatar: 'https://images.unsplash.com/photo-1517841905240-472988babdf9?auto=format&fit=crop&q=80&w=200',
      tags: [
        { label: 'Repeat', color: 'green' },
        { label: 'Event', color: 'orange' }
      ],
      totalBookings: 4,
      totalSpend: 'Rp12.300.000',
      lastBookingDate: '25 Mei 2025',
      status: 'Aktif'
    },
    {
      id: 'cust-5',
      name: 'Nadia Putri',
      joinDate: '15 Mar 2025',
      phone: '0813 2222 3333',
      email: 'nadia.putri@email.com',
      avatar: 'https://images.unsplash.com/photo-1524504388940-b1c1722653e1?auto=format&fit=crop&q=80&w=200',
      tags: [
        { label: 'VIP', color: 'purple' }
      ],
      totalBookings: 6,
      totalSpend: 'Rp18.200.000',
      lastBookingDate: '22 Mei 2025',
      status: 'Aktif'
    },
    {
      id: 'cust-6',
      name: 'Reza Amelia',
      joinDate: '18 Mar 2025',
      phone: '0812 3456 7890',
      email: 'reza.amelia@email.com',
      avatar: '',
      tags: [
        { label: 'VIP', color: 'purple' },
        { label: 'Wedding', color: 'pink' }
      ],
      totalBookings: 7,
      totalSpend: 'Rp21.500.000',
      lastBookingDate: '24 Mei 2025',
      status: 'Aktif'
    },
    {
      id: 'cust-7',
      name: 'Dian Permata',
      joinDate: '05 Apr 2025',
      phone: '0812 9999 8888',
      email: 'dian.permata@email.com',
      avatar: 'https://images.unsplash.com/photo-1508214751196-bcfd4ca60f91?auto=format&fit=crop&q=80&w=200',
      tags: [
        { label: 'Event', color: 'orange' }
      ],
      totalBookings: 1,
      totalSpend: 'Rp2.000.000',
      lastBookingDate: '08 Mei 2025',
      status: 'Aktif'
    },
    {
      id: 'cust-8',
      name: 'Rina Tamara',
      joinDate: '10 Apr 2025',
      phone: '0813 6666 7777',
      email: 'rina.tamara@email.com',
      avatar: 'https://images.unsplash.com/photo-1494790108377-be9c29b29330?auto=format&fit=crop&q=80&w=200',
      tags: [
        { label: 'Repeat', color: 'green' }
      ],
      totalBookings: 3,
      totalSpend: 'Rp7.800.000',
      lastBookingDate: '17 Mei 2025',
      status: 'Tidak Aktif'
    }
  ]);

  // FORM STATE FOR TAMBAH PELANGGAN
  const [formName, setFormName] = useState('');
  const [formPhoneCode, setFormPhoneCode] = useState('+62');
  const [formPhoneNum, setFormPhoneNum] = useState('');
  const [formEmail, setFormEmail] = useState('');
  const [formDob, setFormDob] = useState('');
  const [formGender, setFormGender] = useState('Pilih jenis kelamin');
  const [formMarital, setFormMarital] = useState('Pilih status pernikahan');
  const [formJob, setFormJob] = useState('');
  const [formSource, setFormSource] = useState('Pilih sumber pelanggan');
  const [formNote, setFormNote] = useState('');
  
  // Contact
  const [formAddress, setFormAddress] = useState('');
  const [formCity, setFormCity] = useState('');
  const [formProvince, setFormProvince] = useState('Pilih provinsi');
  const [formPostalCode, setFormPostalCode] = useState('');

  // Right Side Form
  const [formAvatar, setFormAvatar] = useState('');
  const [formGroup, setFormGroup] = useState('Pilih grup pelanggan');
  const [tagInput, setTagInput] = useState('');
  const [formTags, setFormTags] = useState<string[]>([]);
  const [formPreference, setFormPreference] = useState('');
  const [formExtraNotes, setFormExtraNotes] = useState('');

  // Add tag handler
  const handleAddTag = (e: React.KeyboardEvent<HTMLInputElement>) => {
    if (e.key === 'Enter') {
      e.preventDefault();
      if (tagInput.trim() && formTags.length < 5) {
        if (!formTags.includes(tagInput.trim())) {
          setFormTags([...formTags, tagInput.trim()]);
        }
        setTagInput('');
      } else if (formTags.length >= 5) {
        triggerToast('Maksimal 5 label tag');
      }
    }
  };

  const handleRemoveTag = (tagToRemove: string) => {
    setFormTags(formTags.filter(t => t !== tagToRemove));
  };

  // Submit Handler
  const handleSaveCustomer = (e: React.FormEvent) => {
    e.preventDefault();
    if (!formName.trim()) {
      triggerToast('Nama Lengkap wajib diisi!');
      return;
    }
    if (!formPhoneNum.trim()) {
      triggerToast('Nomor WhatsApp wajib diisi!');
      return;
    }

    const formattedPhone = `${formPhoneCode} ${formPhoneNum}`.replace(/\+62\s*/, '08');

    const newCustomer: Customer = {
      id: `cust-${Date.now()}`,
      name: formName,
      joinDate: 'Hari Ini',
      phone: formattedPhone,
      email: formEmail || 'pelanggan@email.com',
      avatar: formAvatar || 'https://images.unsplash.com/photo-1534528741775-53994a69daeb?auto=format&fit=crop&q=80&w=200',
      tags: formTags.length > 0 
        ? formTags.map(t => ({ label: t, color: 'purple' as const }))
        : [{ label: 'Baru', color: 'blue' as const }],
      totalBookings: 0,
      totalSpend: 'Rp0',
      lastBookingDate: '-',
      status: 'Aktif'
    };

    setCustomersList([newCustomer, ...customersList]);
    triggerToast(`Pelanggan ${formName} berhasil ditambahkan!`);
    
    // Reset Form
    setFormName('');
    setFormPhoneNum('');
    setFormEmail('');
    setFormDob('');
    setFormGender('Pilih jenis kelamin');
    setFormMarital('Pilih status pernikahan');
    setFormJob('');
    setFormSource('Pilih sumber pelanggan');
    setFormNote('');
    setFormAddress('');
    setFormCity('');
    setFormProvince('Pilih provinsi');
    setFormPostalCode('');
    setFormAvatar('');
    setFormGroup('Pilih grup pelanggan');
    setFormTags([]);
    setFormPreference('');
    setFormExtraNotes('');

    setSubView('daftar');
  };

  // Checkbox functions
  const toggleSelectAll = () => {
    if (selectedCustomers.length === customersList.length) {
      setSelectedCustomers([]);
    } else {
      setSelectedCustomers(customersList.map(c => c.id));
    }
  };

  const toggleSelectCustomer = (id: string) => {
    if (selectedCustomers.includes(id)) {
      setSelectedCustomers(selectedCustomers.filter(i => i !== id));
    } else {
      setSelectedCustomers([...selectedCustomers, id]);
    }
  };

  const getTagBadgeStyle = (color: string) => {
    switch (color) {
      case 'purple':
        return 'bg-purple-100 text-purple-700 border-purple-200';
      case 'green':
        return 'bg-emerald-100 text-emerald-700 border-emerald-200';
      case 'pink':
        return 'bg-pink-100 text-pink-700 border-pink-200';
      case 'blue':
        return 'bg-sky-100 text-sky-700 border-sky-200';
      case 'orange':
        return 'bg-amber-100 text-amber-800 border-amber-200';
      default:
        return 'bg-slate-100 text-slate-700 border-slate-200';
    }
  };

  const filteredCustomers = customersList.filter(c => {
    const matchSearch = c.name.toLowerCase().includes(searchTerm.toLowerCase()) || 
                        c.phone.includes(searchTerm) || 
                        c.email.toLowerCase().includes(searchTerm.toLowerCase());
    
    if (selectedTab === 'VIP') {
      return matchSearch && c.tags.some(t => t.label === 'VIP');
    }
    if (selectedTab === 'Repeat') {
      return matchSearch && c.tags.some(t => t.label === 'Repeat');
    }
    if (selectedTab === 'Baru') {
      return matchSearch && c.totalBookings <= 2;
    }
    return matchSearch;
  });

  // ==========================================
  // RENDER: SUB-VIEW "TAMBAH PELANGGAN"
  // ==========================================
  if (subView === 'tambah') {
    return (
      <div className="space-y-6 animate-in fade-in duration-300 text-slate-800">
        
        {/* Header Title & Kembali Button */}
        <div className="flex items-center justify-between pb-1">
          <div>
            <h1 className="text-xl font-extrabold text-slate-900 tracking-tight">Tambah Pelanggan</h1>
            <p className="text-xs text-slate-500 font-medium mt-0.5">
              Lengkapi data pelanggan untuk memudahkan pengelolaan dan komunikasi
            </p>
          </div>

          <button
            type="button"
            onClick={() => setSubView('daftar')}
            className="px-4 py-2 bg-white hover:bg-slate-50 text-slate-700 border border-slate-200/90 text-xs font-bold rounded-xl shadow-2xs transition-all flex items-center gap-2 cursor-pointer"
          >
            <ArrowLeft className="w-4 h-4 text-slate-500" />
            <span>Kembali</span>
          </button>
        </div>

        {/* Main Form Container */}
        <form onSubmit={handleSaveCustomer} className="space-y-6">
          <div className="grid grid-cols-1 lg:grid-cols-12 gap-6 items-start">
            
            {/* LEFT COLUMN (Cols 8) */}
            <div className="lg:col-span-8 space-y-6">
              
              {/* Card 1: Informasi Pribadi */}
              <div className="bg-white p-6 rounded-3xl border border-slate-200/80 shadow-2xs space-y-5">
                <div className="flex items-center gap-3">
                  <div className="w-9 h-9 rounded-full bg-pink-50 text-[#EC167F] flex items-center justify-center font-bold shrink-0">
                    <User className="w-4 h-4" />
                  </div>
                  <h2 className="text-sm font-extrabold text-slate-900">Informasi Pribadi</h2>
                </div>

                <div className="grid grid-cols-1 md:grid-cols-3 gap-4 text-xs">
                  
                  {/* Nama Lengkap */}
                  <div>
                    <label className="block font-bold text-slate-700 mb-1.5">
                      Nama Lengkap <span className="text-[#EC167F]">*</span>
                    </label>
                    <input
                      type="text"
                      required
                      placeholder="Masukkan nama lengkap pelanggan"
                      value={formName}
                      onChange={(e) => setFormName(e.target.value)}
                      className="w-full p-3 bg-slate-50/70 border border-slate-200/90 rounded-xl font-semibold text-slate-800 placeholder:text-slate-400 focus:bg-white focus:outline-none focus:border-[#EC167F] transition-all"
                    />
                  </div>

                  {/* No. WhatsApp */}
                  <div>
                    <label className="block font-bold text-slate-700 mb-1.5">
                      No. WhatsApp <span className="text-[#EC167F]">*</span>
                    </label>
                    <div className="flex items-center gap-1.5">
                      <select 
                        value={formPhoneCode}
                        onChange={(e) => setFormPhoneCode(e.target.value)}
                        className="p-3 bg-slate-50/70 border border-slate-200/90 rounded-xl font-bold text-slate-700 focus:outline-none cursor-pointer"
                      >
                        <option value="+62">+62</option>
                        <option value="+1">+1</option>
                        <option value="+60">+60</option>
                        <option value="+65">+65</option>
                      </select>
                      <input
                        type="text"
                        required
                        placeholder="812 3456 7890"
                        value={formPhoneNum}
                        onChange={(e) => setFormPhoneNum(e.target.value)}
                        className="w-full p-3 bg-slate-50/70 border border-slate-200/90 rounded-xl font-semibold text-slate-800 placeholder:text-slate-400 focus:bg-white focus:outline-none focus:border-[#EC167F] transition-all"
                      />
                    </div>
                  </div>

                  {/* Email */}
                  <div>
                    <label className="block font-bold text-slate-700 mb-1.5">Email</label>
                    <input
                      type="email"
                      placeholder="Masukkan email pelanggan"
                      value={formEmail}
                      onChange={(e) => setFormEmail(e.target.value)}
                      className="w-full p-3 bg-slate-50/70 border border-slate-200/90 rounded-xl font-semibold text-slate-800 placeholder:text-slate-400 focus:bg-white focus:outline-none focus:border-[#EC167F] transition-all"
                    />
                  </div>

                  {/* Tanggal Lahir */}
                  <div>
                    <label className="block font-bold text-slate-700 mb-1.5">Tanggal Lahir</label>
                    <div className="relative">
                      <input
                        type="text"
                        placeholder="Pilih tanggal lahir"
                        value={formDob}
                        onChange={(e) => setFormDob(e.target.value)}
                        onFocus={(e) => (e.target.type = 'date')}
                        onBlur={(e) => { if(!e.target.value) e.target.type = 'text'; }}
                        className="w-full p-3 pr-10 bg-slate-50/70 border border-slate-200/90 rounded-xl font-semibold text-slate-800 placeholder:text-slate-400 focus:bg-white focus:outline-none focus:border-[#EC167F] transition-all"
                      />
                      <Calendar className="w-4 h-4 text-slate-400 absolute right-3 top-3.5 pointer-events-none" />
                    </div>
                  </div>

                  {/* Jenis Kelamin */}
                  <div>
                    <label className="block font-bold text-slate-700 mb-1.5">Jenis Kelamin</label>
                    <select
                      value={formGender}
                      onChange={(e) => setFormGender(e.target.value)}
                      className="w-full p-3 bg-slate-50/70 border border-slate-200/90 rounded-xl font-bold text-slate-700 focus:bg-white focus:outline-none focus:border-[#EC167F] transition-all cursor-pointer"
                    >
                      <option disabled value="Pilih jenis kelamin">Pilih jenis kelamin</option>
                      <option value="Wanita">Wanita</option>
                      <option value="Pria">Pria</option>
                    </select>
                  </div>

                  {/* Status Pernikahan */}
                  <div>
                    <label className="block font-bold text-slate-700 mb-1.5">Status Pernikahan</label>
                    <select
                      value={formMarital}
                      onChange={(e) => setFormMarital(e.target.value)}
                      className="w-full p-3 bg-slate-50/70 border border-slate-200/90 rounded-xl font-bold text-slate-700 focus:bg-white focus:outline-none focus:border-[#EC167F] transition-all cursor-pointer"
                    >
                      <option disabled value="Pilih status pernikahan">Pilih status pernikahan</option>
                      <option value="Belum Menikah">Belum Menikah</option>
                      <option value="Menikah">Menikah</option>
                    </select>
                  </div>

                  {/* Pekerjaan */}
                  <div>
                    <label className="block font-bold text-slate-700 mb-1.5">Pekerjaan</label>
                    <input
                      type="text"
                      placeholder="Masukkan pekerjaan"
                      value={formJob}
                      onChange={(e) => setFormJob(e.target.value)}
                      className="w-full p-3 bg-slate-50/70 border border-slate-200/90 rounded-xl font-semibold text-slate-800 placeholder:text-slate-400 focus:bg-white focus:outline-none focus:border-[#EC167F] transition-all"
                    />
                  </div>

                  {/* Sumber Pelanggan */}
                  <div>
                    <label className="block font-bold text-slate-700 mb-1.5">Sumber Pelanggan</label>
                    <select
                      value={formSource}
                      onChange={(e) => setFormSource(e.target.value)}
                      className="w-full p-3 bg-slate-50/70 border border-slate-200/90 rounded-xl font-bold text-slate-700 focus:bg-white focus:outline-none focus:border-[#EC167F] transition-all cursor-pointer"
                    >
                      <option disabled value="Pilih sumber pelanggan">Pilih sumber pelanggan</option>
                      <option value="Instagram">Instagram</option>
                      <option value="TikTok">TikTok</option>
                      <option value="Referral">Teman / Referral</option>
                      <option value="Website">Website</option>
                      <option value="Lainnya">Lainnya</option>
                    </select>
                  </div>

                  {/* Catatan */}
                  <div>
                    <label className="block font-bold text-slate-700 mb-1.5">Catatan</label>
                    <div className="relative">
                      <textarea
                        maxLength={200}
                        rows={2}
                        placeholder="Tulis catatan tentang pelanggan (opsional)"
                        value={formNote}
                        onChange={(e) => setFormNote(e.target.value)}
                        className="w-full p-3 bg-slate-50/70 border border-slate-200/90 rounded-xl font-semibold text-slate-800 placeholder:text-slate-400 focus:bg-white focus:outline-none focus:border-[#EC167F] transition-all resize-none"
                      />
                      <span className="text-[10px] text-slate-400 font-semibold absolute right-2.5 bottom-2">
                        {formNote.length}/200
                      </span>
                    </div>
                  </div>

                </div>
              </div>

              {/* Card 2: Informasi Kontak */}
              <div className="bg-white p-6 rounded-3xl border border-slate-200/80 shadow-2xs space-y-5">
                <div className="flex items-center gap-3">
                  <div className="w-9 h-9 rounded-full bg-pink-50 text-[#EC167F] flex items-center justify-center font-bold shrink-0">
                    <MapPin className="w-4 h-4" />
                  </div>
                  <h2 className="text-sm font-extrabold text-slate-900">Informasi Kontak</h2>
                </div>

                <div className="grid grid-cols-1 md:grid-cols-3 gap-4 text-xs">
                  
                  {/* Alamat */}
                  <div>
                    <label className="block font-bold text-slate-700 mb-1.5">Alamat</label>
                    <div className="relative">
                      <textarea
                        maxLength={200}
                        rows={2}
                        placeholder="Masukkan alamat lengkap pelanggan"
                        value={formAddress}
                        onChange={(e) => setFormAddress(e.target.value)}
                        className="w-full p-3 bg-slate-50/70 border border-slate-200/90 rounded-xl font-semibold text-slate-800 placeholder:text-slate-400 focus:bg-white focus:outline-none focus:border-[#EC167F] transition-all resize-none"
                      />
                      <span className="text-[10px] text-slate-400 font-semibold absolute right-2.5 bottom-2">
                        {formAddress.length}/200
                      </span>
                    </div>
                  </div>

                  {/* Kota / Kabupaten */}
                  <div>
                    <label className="block font-bold text-slate-700 mb-1.5">Kota / Kabupaten</label>
                    <input
                      type="text"
                      placeholder="Masukkan kota / kabupaten"
                      value={formCity}
                      onChange={(e) => setFormCity(e.target.value)}
                      className="w-full p-3 bg-slate-50/70 border border-slate-200/90 rounded-xl font-semibold text-slate-800 placeholder:text-slate-400 focus:bg-white focus:outline-none focus:border-[#EC167F] transition-all"
                    />
                  </div>

                  {/* Provinsi */}
                  <div>
                    <label className="block font-bold text-slate-700 mb-1.5">Provinsi</label>
                    <select
                      value={formProvince}
                      onChange={(e) => setFormProvince(e.target.value)}
                      className="w-full p-3 bg-slate-50/70 border border-slate-200/90 rounded-xl font-bold text-slate-700 focus:bg-white focus:outline-none focus:border-[#EC167F] transition-all cursor-pointer"
                    >
                      <option disabled value="Pilih provinsi">Pilih provinsi</option>
                      <option value="DKI Jakarta">DKI Jakarta</option>
                      <option value="Jawa Barat">Jawa Barat</option>
                      <option value="Jawa Tengah">Jawa Tengah</option>
                      <option value="Jawa Timur">Jawa Timur</option>
                      <option value="Banten">Banten</option>
                      <option value="Bali">Bali</option>
                      <option value="Lainnya">Lainnya</option>
                    </select>
                  </div>

                  {/* Kode Pos */}
                  <div>
                    <label className="block font-bold text-slate-700 mb-1.5">Kode Pos</label>
                    <input
                      type="text"
                      placeholder="Masukkan kode pos"
                      value={formPostalCode}
                      onChange={(e) => setFormPostalCode(e.target.value)}
                      className="w-full p-3 bg-slate-50/70 border border-slate-200/90 rounded-xl font-semibold text-slate-800 placeholder:text-slate-400 focus:bg-white focus:outline-none focus:border-[#EC167F] transition-all"
                    />
                  </div>

                </div>
              </div>

            </div>

            {/* RIGHT COLUMN (Cols 4) */}
            <div className="lg:col-span-4 space-y-6">
              
              {/* Card 1: Foto Profil */}
              <div className="bg-white p-6 rounded-3xl border border-slate-200/80 shadow-2xs space-y-5">
                <div className="flex items-center gap-3">
                  <div className="w-9 h-9 rounded-full bg-pink-50 text-[#EC167F] flex items-center justify-center font-bold shrink-0">
                    <ImageIcon className="w-4 h-4" />
                  </div>
                  <h2 className="text-sm font-extrabold text-slate-900">Foto Profil</h2>
                </div>

                {/* Upload Box */}
                <div className="border-2 border-dashed border-pink-200 bg-pink-50/20 hover:bg-pink-50/40 transition-colors p-6 rounded-2xl text-center flex flex-col items-center justify-center space-y-2">
                  {formAvatar ? (
                    <div className="relative group">
                      <img src={formAvatar} alt="Preview" className="w-20 h-20 rounded-full object-cover border-2 border-pink-500 shadow-md" />
                      <button
                        type="button"
                        onClick={() => setFormAvatar('')}
                        className="absolute -top-1 -right-1 bg-red-500 text-white rounded-full p-1 hover:bg-red-600 shadow-xs cursor-pointer"
                      >
                        <X className="w-3.5 h-3.5" />
                      </button>
                    </div>
                  ) : (
                    <>
                      <div className="w-10 h-10 rounded-full bg-pink-100/70 text-[#EC167F] flex items-center justify-center font-bold">
                        <Upload className="w-5 h-5" />
                      </div>
                      <span className="font-extrabold text-slate-900 text-xs block">Upload foto pelanggan</span>
                      <span className="text-[10px] text-slate-400 font-medium block">PNG, JPG, JPEG maksimal 2MB</span>
                      <button
                        type="button"
                        onClick={() => {
                          const sampleAvatars = [
                            'https://images.unsplash.com/photo-1534528741775-53994a69daeb?auto=format&fit=crop&q=80&w=200',
                            'https://images.unsplash.com/photo-1544005313-94ddf0286df2?auto=format&fit=crop&q=80&w=200',
                            'https://images.unsplash.com/photo-1517841905240-472988babdf9?auto=format&fit=crop&q=80&w=200'
                          ];
                          setFormAvatar(sampleAvatars[Math.floor(Math.random() * sampleAvatars.length)]);
                          triggerToast('Foto profil berhasil diupload');
                        }}
                        className="mt-2 border border-pink-300 text-[#EC167F] bg-white font-extrabold text-xs px-4 py-1.5 rounded-xl hover:bg-pink-50 transition-all cursor-pointer shadow-2xs"
                      >
                        Pilih Foto
                      </button>
                    </>
                  )}
                </div>
              </div>

              {/* Card 2: Grup & Label */}
              <div className="bg-white p-6 rounded-3xl border border-slate-200/80 shadow-2xs space-y-5">
                <div className="flex items-center gap-3">
                  <div className="w-9 h-9 rounded-full bg-pink-50 text-[#EC167F] flex items-center justify-center font-bold shrink-0">
                    <Tag className="w-4 h-4" />
                  </div>
                  <h2 className="text-sm font-extrabold text-slate-900">Grup & Label</h2>
                </div>

                <div className="space-y-4 text-xs">
                  <div>
                    <label className="block font-bold text-slate-700 mb-1.5">Grup Pelanggan</label>
                    <select
                      value={formGroup}
                      onChange={(e) => setFormGroup(e.target.value)}
                      className="w-full p-3 bg-slate-50/70 border border-slate-200/90 rounded-xl font-bold text-slate-700 focus:bg-white focus:outline-none focus:border-[#EC167F] transition-all cursor-pointer"
                    >
                      <option disabled value="Pilih grup pelanggan">Pilih grup pelanggan</option>
                      <option value="Bridal / Wedding">Bridal / Wedding</option>
                      <option value="Graduation">Graduation</option>
                      <option value="Event / Party">Event / Party</option>
                      <option value="Reguler">Reguler</option>
                    </select>
                  </div>

                  <div>
                    <label className="block font-bold text-slate-700 mb-1.5">Label / Tag</label>
                    <div className="relative">
                      <input
                        type="text"
                        placeholder="Pilih atau buat label"
                        value={tagInput}
                        onChange={(e) => setTagInput(e.target.value)}
                        onKeyDown={handleAddTag}
                        className="w-full p-3 pr-8 bg-slate-50/70 border border-slate-200/90 rounded-xl font-semibold text-slate-800 placeholder:text-slate-400 focus:bg-white focus:outline-none focus:border-[#EC167F] transition-all"
                      />
                      <Tag className="w-4 h-4 text-slate-400 absolute right-3 top-3.5 pointer-events-none" />
                    </div>

                    <div className="flex items-center justify-between text-[10px] text-slate-400 font-semibold mt-1">
                      <span>Tekan Enter untuk menambah label baru</span>
                      <span>{formTags.length}/5</span>
                    </div>

                    {/* Tag Badges List */}
                    {formTags.length > 0 && (
                      <div className="flex items-center gap-1.5 flex-wrap mt-2">
                        {formTags.map((t, idx) => (
                          <span key={idx} className="px-2.5 py-1 text-[11px] font-extrabold rounded-lg bg-pink-100 text-pink-700 border border-pink-200 flex items-center gap-1">
                            <span>{t}</span>
                            <button type="button" onClick={() => handleRemoveTag(t)} className="hover:text-pink-900 cursor-pointer">
                              <X className="w-3 h-3" />
                            </button>
                          </span>
                        ))}
                      </div>
                    )}
                  </div>
                </div>
              </div>

              {/* Card 3: Preferensi & Catatan Tambahan */}
              <div className="bg-white p-6 rounded-3xl border border-slate-200/80 shadow-2xs space-y-5">
                <div className="flex items-center gap-3">
                  <div className="w-9 h-9 rounded-full bg-pink-50 text-[#EC167F] flex items-center justify-center font-bold shrink-0">
                    <Heart className="w-4 h-4" />
                  </div>
                  <h2 className="text-sm font-extrabold text-slate-900">Preferensi & Catatan Tambahan</h2>
                </div>

                <div className="space-y-4 text-xs">
                  <div>
                    <label className="block font-bold text-slate-700 mb-1.5">Preferensi Layanan</label>
                    <div className="relative">
                      <textarea
                        maxLength={100}
                        rows={2}
                        placeholder="Contoh: Makeup Natural, Hairdo Modern, dll"
                        value={formPreference}
                        onChange={(e) => setFormPreference(e.target.value)}
                        className="w-full p-3 bg-slate-50/70 border border-slate-200/90 rounded-xl font-semibold text-slate-800 placeholder:text-slate-400 focus:bg-white focus:outline-none focus:border-[#EC167F] transition-all resize-none"
                      />
                      <span className="text-[10px] text-slate-400 font-semibold absolute right-2.5 bottom-2">
                        {formPreference.length}/100
                      </span>
                    </div>
                  </div>

                  <div>
                    <label className="block font-bold text-slate-700 mb-1.5">Catatan Tambahan</label>
                    <div className="relative">
                      <textarea
                        maxLength={300}
                        rows={3}
                        placeholder="Informasi tambahan yang perlu diperhatikan"
                        value={formExtraNotes}
                        onChange={(e) => setFormExtraNotes(e.target.value)}
                        className="w-full p-3 bg-slate-50/70 border border-slate-200/90 rounded-xl font-semibold text-slate-800 placeholder:text-slate-400 focus:bg-white focus:outline-none focus:border-[#EC167F] transition-all resize-none"
                      />
                      <span className="text-[10px] text-slate-400 font-semibold absolute right-2.5 bottom-2">
                        {formExtraNotes.length}/300
                      </span>
                    </div>
                  </div>
                </div>
              </div>

            </div>

          </div>

          {/* BOTTOM ACTION BUTTONS BAR */}
          <div className="pt-4 border-t border-slate-200/80 flex items-center justify-end gap-3">
            <button
              type="button"
              onClick={() => setSubView('daftar')}
              className="px-6 py-2.5 bg-white hover:bg-slate-50 border border-slate-200/90 text-slate-700 font-extrabold text-xs rounded-xl transition-all cursor-pointer shadow-2xs"
            >
              Batal
            </button>

            <button
              type="submit"
              className="px-6 py-2.5 bg-[#EC167F] hover:bg-[#D41270] text-white font-extrabold text-xs rounded-xl shadow-xs transition-all flex items-center justify-center gap-2 cursor-pointer"
            >
              <Save className="w-4 h-4" />
              <span>Simpan Pelanggan</span>
            </button>
          </div>
        </form>

      </div>
    );
  }

  // ==========================================
  // RENDER: SUB-VIEW "DAFTAR PELANGGAN"
  // ==========================================
  return (
    <div className="space-y-5 animate-in fade-in duration-300 text-slate-800">
      
      {/* 1. TOP PAGE HEADER & ACTION BUTTONS */}
      <div className="flex flex-col lg:flex-row lg:items-center justify-between gap-4">
        <div>
          {/* Breadcrumb */}
          <div className="flex items-center gap-1.5 text-xs text-slate-500 font-medium mb-1">
            <span>Dashboard</span>
            <ChevronRight className="w-3 h-3 text-slate-400" />
            <span>Pelanggan</span>
            <ChevronRight className="w-3 h-3 text-slate-400" />
            <span className="font-extrabold text-[#EC167F]">Daftar Pelanggan</span>
          </div>

          <h1 className="text-xl font-extrabold text-slate-900 tracking-tight">Daftar Pelanggan</h1>
          <p className="text-xs text-slate-500 font-medium mt-0.5">Kelola semua data pelanggan dalam satu tempat</p>
        </div>

        {/* Action Buttons Top Right */}
        <div className="flex items-center gap-2.5 flex-wrap">
          {onNavigateToCreateReservation && (
            <button
              onClick={onNavigateToCreateReservation}
              className="px-4 py-2 bg-[#EC167F] hover:bg-[#D41270] text-white text-xs font-extrabold rounded-full shadow-xs transition-all flex items-center gap-1.5 cursor-pointer"
            >
              <Plus className="w-4 h-4" />
              <span>Buat Reservasi</span>
            </button>
          )}

          <button
            onClick={() => triggerToast('Export data pelanggan ke CSV / Excel')}
            className="px-3.5 py-2 bg-white hover:bg-slate-50 text-slate-700 border border-slate-200 text-xs font-bold rounded-xl transition-all flex items-center gap-1.5 shadow-2xs cursor-pointer"
          >
            <Download className="w-3.5 h-3.5 text-slate-500" />
            <span>Export</span>
          </button>

          <button
            onClick={() => triggerToast('Import data pelanggan dari file')}
            className="px-3.5 py-2 bg-white hover:bg-slate-50 text-slate-700 border border-slate-200 text-xs font-bold rounded-xl transition-all flex items-center gap-1.5 shadow-2xs cursor-pointer"
          >
            <Upload className="w-3.5 h-3.5 text-slate-500" />
            <span>Import</span>
          </button>

          <button
            onClick={() => setSubView('tambah')}
            className="px-4 py-2 bg-[#EC167F] hover:bg-[#D41270] text-white text-xs font-extrabold rounded-xl shadow-xs transition-all flex items-center gap-1.5 cursor-pointer"
          >
            <Plus className="w-4 h-4" />
            <span>Tambah Pelanggan</span>
          </button>
        </div>
      </div>

      {/* 2. TOP METRICS CARDS ROW (5 CARDS) */}
      <div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-5 gap-3.5">
        
        {/* Card 1: Total Pelanggan */}
        <div className="bg-white p-4 rounded-2xl border border-slate-200/80 shadow-2xs space-y-2">
          <div className="flex items-center justify-between">
            <span className="text-[11px] font-bold text-slate-500">Total Pelanggan</span>
            <div className="w-8 h-8 rounded-full bg-pink-50 text-[#EC167F] flex items-center justify-center font-bold">
              <Users className="w-4 h-4" />
            </div>
          </div>
          <div className="text-xl font-extrabold text-slate-900">1.248</div>
          <div className="flex items-center gap-1 text-[10px] font-bold text-emerald-600">
            <ArrowUp className="w-3 h-3" />
            <span>18% dari bulan lalu</span>
          </div>
        </div>

        {/* Card 2: Pelanggan Baru */}
        <div className="bg-white p-4 rounded-2xl border border-slate-200/80 shadow-2xs space-y-2">
          <div className="flex items-center justify-between">
            <span className="text-[11px] font-bold text-slate-500">Pelanggan Baru</span>
            <div className="w-8 h-8 rounded-full bg-purple-50 text-purple-600 flex items-center justify-center font-bold">
              <Star className="w-4 h-4" />
            </div>
          </div>
          <div className="text-xl font-extrabold text-slate-900">86</div>
          <div className="flex items-center gap-1 text-[10px] font-bold text-emerald-600">
            <ArrowUp className="w-3 h-3" />
            <span>12% dari bulan lalu</span>
          </div>
        </div>

        {/* Card 3: Pelanggan Repeat */}
        <div className="bg-white p-4 rounded-2xl border border-slate-200/80 shadow-2xs space-y-2">
          <div className="flex items-center justify-between">
            <span className="text-[11px] font-bold text-slate-500">Pelanggan Repeat</span>
            <div className="w-8 h-8 rounded-full bg-amber-50 text-amber-600 flex items-center justify-center font-bold">
              <RefreshCw className="w-4 h-4" />
            </div>
          </div>
          <div className="text-xl font-extrabold text-slate-900">342</div>
          <div className="flex items-center gap-1 text-[10px] font-bold text-emerald-600">
            <ArrowUp className="w-3 h-3" />
            <span>24% dari bulan lalu</span>
          </div>
        </div>

        {/* Card 4: Pelanggan VIP */}
        <div className="bg-white p-4 rounded-2xl border border-slate-200/80 shadow-2xs space-y-2">
          <div className="flex items-center justify-between">
            <span className="text-[11px] font-bold text-slate-500">Pelanggan VIP</span>
            <div className="w-8 h-8 rounded-full bg-emerald-50 text-emerald-600 flex items-center justify-center font-bold">
              <Gem className="w-4 h-4" />
            </div>
          </div>
          <div className="text-xl font-extrabold text-slate-900">128</div>
          <div className="flex items-center gap-1 text-[10px] font-bold text-emerald-600">
            <ArrowUp className="w-3 h-3" />
            <span>15% dari bulan lalu</span>
          </div>
        </div>

        {/* Card 5: Total Transaksi */}
        <div className="bg-white p-4 rounded-2xl border border-slate-200/80 shadow-2xs space-y-2">
          <div className="flex items-center justify-between">
            <span className="text-[11px] font-bold text-slate-500">Total Transaksi</span>
            <div className="w-8 h-8 rounded-full bg-sky-50 text-sky-600 flex items-center justify-center font-bold">
              <Wallet className="w-4 h-4" />
            </div>
          </div>
          <div className="text-lg font-extrabold text-slate-900 truncate">Rp1.246.500.000</div>
          <div className="flex items-center gap-1 text-[10px] font-bold text-emerald-600">
            <ArrowUp className="w-3 h-3" />
            <span>22% dari bulan lalu</span>
          </div>
        </div>

      </div>

      {/* 3. MAIN TABLE & FILTER LAYOUT */}
      <div className="grid grid-cols-1 lg:grid-cols-12 gap-5">
        
        {/* LEFT / CENTER TABLE AREA */}
        <div className={`${isFilterPanelOpen ? 'lg:col-span-9' : 'lg:col-span-12'} bg-white rounded-3xl border border-slate-200/80 shadow-2xs overflow-hidden flex flex-col transition-all duration-300`}>
          
          {/* Search & Top Filters */}
          <div className="p-4 border-b border-slate-100 space-y-3">
            
            <div className="flex flex-col sm:flex-row items-center gap-2.5">
              {/* Search Field */}
              <div className="relative flex-1 w-full">
                <Search className="w-4 h-4 text-slate-400 absolute left-3 top-3" />
                <input
                  type="text"
                  placeholder="Cari nama, no. telepon, email, atau tag..."
                  value={searchTerm}
                  onChange={(e) => setSearchTerm(e.target.value)}
                  className="w-full pl-9 pr-3 py-2 bg-slate-50 border border-slate-200 rounded-xl text-xs font-semibold focus:bg-white focus:outline-none focus:border-[#EC167F]"
                />
              </div>

              {/* Quick Select Filter Dropdowns */}
              <select 
                value={filterGroup}
                onChange={(e) => setFilterGroup(e.target.value)}
                className="w-full sm:w-auto px-3 py-2 bg-slate-50 border border-slate-200 rounded-xl text-xs font-bold text-slate-700 focus:outline-none cursor-pointer"
              >
                <option>Semua Grup</option>
                <option>Bridal / Wedding</option>
                <option>Graduation</option>
                <option>Event / Party</option>
              </select>

              <select 
                value={filterStatus}
                onChange={(e) => setFilterStatus(e.target.value)}
                className="w-full sm:w-auto px-3 py-2 bg-slate-50 border border-slate-200 rounded-xl text-xs font-bold text-slate-700 focus:outline-none cursor-pointer"
              >
                <option>Semua Status</option>
                <option>Aktif</option>
                <option>Tidak Aktif</option>
              </select>

              <button
                type="button"
                onClick={() => setIsFilterPanelOpen(!isFilterPanelOpen)}
                className={`px-3 py-2 border rounded-xl text-xs font-extrabold transition-all cursor-pointer flex items-center justify-center gap-1.5 ${
                  isFilterPanelOpen 
                    ? 'bg-slate-900 text-white border-slate-900' 
                    : 'bg-white text-slate-700 border-slate-200 hover:bg-slate-50'
                }`}
              >
                <Filter className="w-3.5 h-3.5" />
                <span>Filter</span>
              </button>
            </div>

            {/* Sub Filter Category Tabs */}
            <div className="flex items-center gap-4 text-xs font-bold border-b border-slate-100 pt-1 overflow-x-auto">
              {[
                { key: 'Semua', label: `Semua (${customersList.length})` },
                { key: 'Baru', label: 'Pelanggan Baru (86)' },
                { key: 'Repeat', label: 'Repeat (342)' },
                { key: 'VIP', label: 'VIP (128)' }
              ].map(tab => (
                <button
                  key={tab.key}
                  type="button"
                  onClick={() => setSelectedTab(tab.key as any)}
                  className={`pb-2.5 relative transition-all cursor-pointer whitespace-nowrap ${
                    selectedTab === tab.key 
                      ? 'text-[#EC167F] font-black' 
                      : 'text-slate-500 hover:text-slate-900'
                  }`}
                >
                  <span>{tab.label}</span>
                  {selectedTab === tab.key && (
                    <span className="absolute bottom-0 left-0 right-0 h-0.5 bg-[#EC167F] rounded-full"></span>
                  )}
                </button>
              ))}
            </div>

          </div>

          {/* MAIN CUSTOMER TABLE */}
          <div className="overflow-x-auto">
            <table className="w-full text-left text-xs">
              <thead className="bg-slate-50/70 border-b border-slate-200/80 text-slate-500 font-extrabold text-[10px] uppercase tracking-wider">
                <tr>
                  <th className="py-3.5 px-4 w-10">
                    <input 
                      type="checkbox" 
                      checked={selectedCustomers.length === customersList.length && customersList.length > 0}
                      onChange={toggleSelectAll}
                      className="rounded border-slate-300 text-[#EC167F] focus:ring-pink-500 cursor-pointer" 
                    />
                  </th>
                  <th className="py-3.5 px-4 min-w-[200px]">Pelanggan</th>
                  <th className="py-3.5 px-4 min-w-[180px]">Kontak</th>
                  <th className="py-3.5 px-4 min-w-[160px]">Tag</th>
                  <th className="py-3.5 px-4 text-center">Total Reservasi</th>
                  <th className="py-3.5 px-4">Total Belanja</th>
                  <th className="py-3.5 px-4 min-w-[120px]">Terakhir Reservasi</th>
                  <th className="py-3.5 px-4">Status</th>
                  <th className="py-3.5 px-4 text-center">Aksi</th>
                </tr>
              </thead>
              <tbody className="divide-y divide-slate-100 font-medium">
                {filteredCustomers.map((c) => {
                  const isChecked = selectedCustomers.includes(c.id);
                  const nameInitials = c.name.split(' ').map(n => n[0]).join('').substring(0, 2);

                  return (
                    <tr key={c.id} className={`hover:bg-slate-50/70 transition-colors ${isChecked ? 'bg-pink-50/30' : ''}`}>
                      
                      {/* Checkbox */}
                      <td className="py-3.5 px-4">
                        <input 
                          type="checkbox" 
                          checked={isChecked}
                          onChange={() => toggleSelectCustomer(c.id)}
                          className="rounded border-slate-300 text-[#EC167F] focus:ring-pink-500 cursor-pointer" 
                        />
                      </td>

                      {/* Customer Name & Joined Date */}
                      <td className="py-3.5 px-4">
                        <div className="flex items-center gap-3">
                          {c.avatar ? (
                            <img src={c.avatar} alt={c.name} className="w-9 h-9 rounded-full object-cover shrink-0 border border-slate-200" />
                          ) : (
                            <div className="w-9 h-9 rounded-full bg-pink-100 text-[#EC167F] font-black text-xs flex items-center justify-center shrink-0">
                              {nameInitials}
                            </div>
                          )}
                          <div>
                            <span className="font-extrabold text-slate-900 block text-xs">{c.name}</span>
                            <span className="text-[10px] text-slate-400 font-medium block">
                              Bergabung: {c.joinDate}
                            </span>
                          </div>
                        </div>
                      </td>

                      {/* Contact Info (Phone & Email) */}
                      <td className="py-3.5 px-4">
                        <div className="space-y-0.5">
                          <a 
                            href={`https://wa.me/${c.phone.replace(/\s+/g, '')}`} 
                            target="_blank" 
                            rel="noopener noreferrer"
                            className="font-bold text-slate-800 hover:text-emerald-600 block text-xs font-mono"
                          >
                            {c.phone}
                          </a>
                          <span className="text-[10px] text-slate-400 block">{c.email}</span>
                        </div>
                      </td>

                      {/* Tags Badges */}
                      <td className="py-3.5 px-4">
                        <div className="flex items-center gap-1.5 flex-wrap">
                          {c.tags.map((t, idx) => (
                            <span 
                              key={idx} 
                              className={`px-2 py-0.5 text-[10px] font-extrabold rounded-md border ${getTagBadgeStyle(t.color)}`}
                            >
                              {t.label}
                            </span>
                          ))}
                        </div>
                      </td>

                      {/* Total Bookings */}
                      <td className="py-3.5 px-4 text-center font-extrabold text-slate-900 text-xs">
                        {c.totalBookings}
                      </td>

                      {/* Total Spend */}
                      <td className="py-3.5 px-4 font-black text-slate-900 text-xs">
                        {c.totalSpend}
                      </td>

                      {/* Last Booking Date */}
                      <td className="py-3.5 px-4 text-slate-600 text-xs font-semibold">
                        {c.lastBookingDate}
                      </td>

                      {/* Status */}
                      <td className="py-3.5 px-4">
                        <span className={`px-2.5 py-1 text-[10px] font-extrabold rounded-full ${
                          c.status === 'Aktif' 
                            ? 'bg-emerald-100/80 text-emerald-700' 
                            : 'bg-slate-100 text-slate-500'
                        }`}>
                          {c.status}
                        </span>
                      </td>

                      {/* Actions */}
                      <td className="py-3.5 px-4 text-center">
                        <div className="flex items-center justify-center gap-1 text-slate-400">
                          <button
                            type="button"
                            onClick={() => setSelectedCustomer(c)}
                            className="p-1.5 hover:text-[#EC167F] hover:bg-pink-50 rounded-lg cursor-pointer transition-colors"
                            title="Detail Pelanggan"
                          >
                            <Eye className="w-4 h-4" />
                          </button>
                          <button
                            type="button"
                            onClick={() => triggerToast(`Menu opsi untuk ${c.name}`)}
                            className="p-1.5 hover:text-slate-700 hover:bg-slate-100 rounded-lg cursor-pointer transition-colors"
                          >
                            <MoreVertical className="w-4 h-4" />
                          </button>
                        </div>
                      </td>

                    </tr>
                  );
                })}
              </tbody>
            </table>
          </div>

          {/* TABLE PAGINATION FOOTER */}
          <div className="p-4 border-t border-slate-100 flex flex-col sm:flex-row items-center justify-between gap-3 text-xs text-slate-500 font-medium bg-slate-50/50">
            <div>
              Menampilkan <span className="font-bold text-slate-900">1 - {filteredCustomers.length}</span> dari <span className="font-bold text-slate-900">{customersList.length}</span> pelanggan
            </div>

            <div className="flex items-center gap-1">
              <button 
                type="button"
                className="w-7 h-7 rounded-lg border border-slate-200 bg-white hover:bg-slate-50 flex items-center justify-center text-slate-600 cursor-pointer"
              >
                <ChevronLeft className="w-4 h-4" />
              </button>
              
              <button type="button" className="w-7 h-7 rounded-lg bg-[#EC167F] text-white font-extrabold flex items-center justify-center shadow-xs">1</button>
              <button type="button" className="w-7 h-7 rounded-lg hover:bg-slate-100 text-slate-700 font-bold flex items-center justify-center cursor-pointer">2</button>
              <button type="button" className="w-7 h-7 rounded-lg hover:bg-slate-100 text-slate-700 font-bold flex items-center justify-center cursor-pointer">3</button>

              <button 
                type="button"
                className="w-7 h-7 rounded-lg border border-slate-200 bg-white hover:bg-slate-50 flex items-center justify-center text-slate-600 cursor-pointer"
              >
                <ChevronRight className="w-4 h-4" />
              </button>
            </div>
          </div>

        </div>

        {/* RIGHT FILTER DRAWER PANEL (Cols 3) */}
        {isFilterPanelOpen && (
          <div className="lg:col-span-3 bg-white p-5 rounded-3xl border border-slate-200/80 shadow-2xs space-y-4 animate-in slide-in-from-right duration-300">
            
            {/* Header Filter Panel */}
            <div className="flex items-center justify-between border-b border-slate-100 pb-3">
              <h2 className="text-base font-extrabold text-slate-900">Filter Pelanggan</h2>
              <button 
                type="button"
                onClick={() => setIsFilterPanelOpen(false)}
                className="p-1 text-slate-400 hover:text-slate-700 rounded-lg cursor-pointer"
              >
                <X className="w-4 h-4" />
              </button>
            </div>

            {/* Filter Fields */}
            <div className="space-y-3.5 text-xs">
              
              <div>
                <label className="block font-bold text-slate-700 mb-1">Cari Pelanggan</label>
                <input
                  type="text"
                  placeholder="Nama, no. telp, email..."
                  value={searchTerm}
                  onChange={(e) => setSearchTerm(e.target.value)}
                  className="w-full p-2.5 bg-slate-50 border border-slate-200 rounded-xl font-semibold focus:bg-white focus:outline-none focus:border-[#EC167F]"
                />
              </div>

              <div>
                <label className="block font-bold text-slate-700 mb-1">Grup Pelanggan</label>
                <select 
                  value={filterGroup}
                  onChange={(e) => setFilterGroup(e.target.value)}
                  className="w-full p-2.5 bg-slate-50 border border-slate-200 rounded-xl font-bold text-slate-700 focus:outline-none cursor-pointer"
                >
                  <option>Semua Grup</option>
                  <option>Bridal / Wedding</option>
                  <option>Graduation</option>
                  <option>Event / Party</option>
                </select>
              </div>

              <div>
                <label className="block font-bold text-slate-700 mb-1">Tag</label>
                <select 
                  value={filterTag}
                  onChange={(e) => setFilterTag(e.target.value)}
                  className="w-full p-2.5 bg-slate-50 border border-slate-200 rounded-xl font-bold text-slate-700 focus:outline-none cursor-pointer"
                >
                  <option>Semua Tag</option>
                  <option>VIP</option>
                  <option>Repeat</option>
                  <option>Wedding</option>
                  <option>Graduation</option>
                  <option>Event</option>
                </select>
              </div>

              <div>
                <label className="block font-bold text-slate-700 mb-1">Status</label>
                <select 
                  value={filterStatus}
                  onChange={(e) => setFilterStatus(e.target.value)}
                  className="w-full p-2.5 bg-slate-50 border border-slate-200 rounded-xl font-bold text-slate-700 focus:outline-none cursor-pointer"
                >
                  <option>Semua Status</option>
                  <option>Aktif</option>
                  <option>Tidak Aktif</option>
                </select>
              </div>

              <div>
                <label className="block font-bold text-slate-700 mb-1">Urutkan</label>
                <select 
                  value={filterSort}
                  onChange={(e) => setFilterSort(e.target.value)}
                  className="w-full p-2.5 bg-slate-50 border border-slate-200 rounded-xl font-bold text-slate-700 focus:outline-none cursor-pointer"
                >
                  <option>Terbaru</option>
                  <option>Total Belanja Tertinggi</option>
                  <option>Total Reservasi Terbanyak</option>
                  <option>Nama A - Z</option>
                </select>
              </div>

            </div>

            {/* Filter Action Buttons */}
            <div className="pt-3 border-t border-slate-100 grid grid-cols-2 gap-2">
              <button 
                type="button"
                onClick={() => {
                  setSearchTerm('');
                  setFilterGroup('Semua Grup');
                  setFilterTag('Semua Tag');
                  setFilterStatus('Semua Status');
                  triggerToast('Filter telah direset');
                }}
                className="w-full py-2.5 border border-slate-200 hover:bg-slate-50 text-slate-700 font-bold text-xs rounded-xl cursor-pointer"
              >
                Reset
              </button>

              <button 
                type="button"
                onClick={() => triggerToast('Filter pelanggan diterapkan')}
                className="w-full py-2.5 bg-[#EC167F] hover:bg-[#D41270] text-white font-extrabold text-xs rounded-xl shadow-xs cursor-pointer"
              >
                Terapkan Filter
              </button>
            </div>

          </div>
        )}

      </div>

      {/* MODAL DETAIL PELANGGAN */}
      {selectedCustomer && (
        <div className="fixed inset-0 bg-slate-900/60 backdrop-blur-xs z-50 flex items-center justify-center p-4 animate-in fade-in duration-200">
          <div className="bg-white max-w-md w-full rounded-3xl p-6 shadow-2xl space-y-5 relative border border-slate-100">
            <button
              onClick={() => setSelectedCustomer(null)}
              className="absolute top-4 right-4 p-1 rounded-xl text-slate-400 hover:text-slate-700 hover:bg-slate-100 cursor-pointer"
            >
              <X className="w-5 h-5" />
            </button>

            <div className="flex items-center gap-4">
              {selectedCustomer.avatar ? (
                <img src={selectedCustomer.avatar} alt={selectedCustomer.name} className="w-14 h-14 rounded-full object-cover border-2 border-pink-500/20" />
              ) : (
                <div className="w-14 h-14 rounded-full bg-pink-100 text-[#EC167F] font-black text-base flex items-center justify-center">
                  {selectedCustomer.name.charAt(0)}
                </div>
              )}
              <div>
                <h3 className="text-lg font-black text-slate-900">{selectedCustomer.name}</h3>
                <span className="text-xs text-slate-500 font-medium block">Bergabung: {selectedCustomer.joinDate}</span>
                <span className="mt-1 px-2.5 py-0.5 text-[10px] font-extrabold bg-emerald-100 text-emerald-700 rounded-full inline-block">
                  {selectedCustomer.status}
                </span>
              </div>
            </div>

            <div className="space-y-3 pt-3 border-t border-slate-100 text-xs">
              <div className="flex items-center justify-between">
                <span className="text-slate-400 font-bold">Nomor WhatsApp:</span>
                <a 
                  href={`https://wa.me/${selectedCustomer.phone.replace(/\s+/g, '')}`} 
                  target="_blank" 
                  rel="noopener noreferrer"
                  className="font-extrabold text-emerald-600 hover:underline flex items-center gap-1"
                >
                  <Phone className="w-3.5 h-3.5" />
                  <span>{selectedCustomer.phone}</span>
                </a>
              </div>

              <div className="flex items-center justify-between">
                <span className="text-slate-400 font-bold">Email:</span>
                <span className="font-extrabold text-slate-800">{selectedCustomer.email}</span>
              </div>

              <div className="flex items-center justify-between">
                <span className="text-slate-400 font-bold">Total Reservasi:</span>
                <span className="font-extrabold text-slate-900">{selectedCustomer.totalBookings} Kali</span>
              </div>

              <div className="flex items-center justify-between">
                <span className="text-slate-400 font-bold">Total Belanja:</span>
                <span className="font-black text-[#EC167F] text-sm">{selectedCustomer.totalSpend}</span>
              </div>

              <div className="flex items-center justify-between">
                <span className="text-slate-400 font-bold">Reservasi Terakhir:</span>
                <span className="font-bold text-slate-800">{selectedCustomer.lastBookingDate}</span>
              </div>

              <div>
                <span className="text-slate-400 font-bold block mb-1">Tag Pelanggan:</span>
                <div className="flex items-center gap-1.5 flex-wrap">
                  {selectedCustomer.tags.map((t, idx) => (
                    <span key={idx} className={`px-2.5 py-1 text-[11px] font-extrabold rounded-md border ${getTagBadgeStyle(t.color)}`}>
                      {t.label}
                    </span>
                  ))}
                </div>
              </div>
            </div>

            <div className="pt-2 flex items-center gap-2">
              <a
                href={`https://wa.me/${selectedCustomer.phone.replace(/\s+/g, '')}`}
                target="_blank"
                rel="noopener noreferrer"
                className="flex-1 py-2.5 bg-emerald-500 hover:bg-emerald-600 text-white font-extrabold text-xs rounded-xl transition-all cursor-pointer flex items-center justify-center gap-1.5 shadow-xs"
              >
                <MessageCircle className="w-4 h-4" />
                <span>Chat WhatsApp</span>
              </a>

              <button
                type="button"
                onClick={() => setSelectedCustomer(null)}
                className="px-4 py-2.5 border border-slate-200 hover:bg-slate-50 text-slate-700 font-bold text-xs rounded-xl cursor-pointer"
              >
                Tutup
              </button>
            </div>

          </div>
        </div>
      )}

    </div>
  );
};



Zerion Mini Shell 1.0