import { Pencil, Trash2 } from "lucide-react";
import { Property } from "@/types";

interface PropertyExpandedDetailsProps {
  property: Property;
  onEdit?: () => void;
  onDelete?: () => void;
}

export function PropertyExpandedDetails({ property, onEdit, onDelete }: PropertyExpandedDetailsProps) {
  return (
    <div className="border-t border-gray-100 bg-gray-50 px-4 py-4 space-y-6">
      {/* Action Buttons */}
      <div className="flex items-center gap-2">
        <button
          onClick={onEdit}
          className="flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium border border-gray-200 rounded-lg hover:bg-white transition-colors text-gray-600"
        >
          <Pencil className="w-3 h-3" /> Edit
        </button>
        <button
          onClick={onDelete}
          className="flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium border border-red-100 rounded-lg hover:bg-red-50 transition-colors text-red-500"
        >
          <Trash2 className="w-3 h-3" /> Remove
        </button>
      </div>

      {/* Property Details Grid */}
      <div>
        <h4 className="text-[10px] font-semibold uppercase tracking-widest text-gray-500 mb-3">Property Details</h4>
        <div className="grid grid-cols-3 gap-4">
          <div>
            <p className="text-[10px] text-gray-400 mb-1">Owned By</p>
            <p className="text-sm font-medium text-gray-900">{property.ownedBy}</p>
          </div>
          <div>
            <p className="text-[10px] text-gray-400 mb-1">Property Type</p>
            <p className="text-sm font-medium text-gray-900 capitalize">{property.propertyType}</p>
          </div>
          <div>
            <p className="text-[10px] text-gray-400 mb-1">Address</p>
            <p className="text-sm font-medium text-gray-900 line-clamp-2">{property.propertyAddress}</p>
          </div>
        </div>
      </div>

      {/* Valuation Section */}
      <div>
        <h4 className="text-[10px] font-semibold uppercase tracking-widest text-gray-500 mb-3">Valuation Details</h4>
        <div className="grid grid-cols-3 gap-4">
          <div>
            <p className="text-[10px] text-gray-400 mb-1">Valuation Amount (Cr)</p>
            <p className="text-sm font-medium text-gray-900">₹{property.valuationAmount} Cr</p>
          </div>
          <div>
            <p className="text-[10px] text-gray-400 mb-1">Basis of Valuation</p>
            <p className="text-sm text-gray-700">{property.basisOfValuation}</p>
          </div>
          <div>
            <p className="text-[10px] text-gray-400 mb-1">Valuation Date</p>
            <p className="text-sm font-medium text-gray-900">{property.basisOfValuationDate}</p>
          </div>
        </div>
      </div>

      {/* Title Search Section */}
      <div>
        <h4 className="text-[10px] font-semibold uppercase tracking-widest text-gray-500 mb-3">Title Search Report</h4>
        <div className="grid grid-cols-3 gap-4">
          <div>
            <p className="text-[10px] text-gray-400 mb-1">Report Details</p>
            <p className="text-sm text-gray-700">{property.titleSearchReport}</p>
          </div>
          <div>
            <p className="text-[10px] text-gray-400 mb-1">Search Date</p>
            <p className="text-sm font-medium text-gray-900">{property.titleSearchDate}</p>
          </div>
        </div>
      </div>

      {/* Bank Charges Section */}
      {property.mortgagedBanks && property.mortgagedBanks.length > 0 && (
        <div>
          <h4 className="text-[10px] font-semibold uppercase tracking-widest text-gray-500 mb-3">Mortgaged Banks</h4>
          <div className="space-y-2">
            {property.mortgagedBanks.map((bank, idx) => (
              <div key={idx} className="flex items-center justify-between p-2 bg-white rounded-lg border border-gray-200">
                <div>
                  <p className="text-sm font-medium text-gray-900">{bank.bankName}</p>
                  <p className="text-xs text-gray-500">Loan: ₹{bank.loanAmount} Cr</p>
                </div>
                {bank.document && (
                  <span className="text-[10px] px-2 py-1 bg-blue-50 text-blue-700 rounded">
                    {bank.document.split('_').pop()}
                  </span>
                )}
              </div>
            ))}
          </div>
        </div>
      )}

      {/* Security & Charge Details */}
      <div>
        <h4 className="text-[10px] font-semibold uppercase tracking-widest text-gray-500 mb-3">Security & Charges</h4>
        <div className="grid grid-cols-2 gap-4">
          <div>
            <p className="text-[10px] text-gray-400 mb-1">Type of Charge</p>
            <p className="text-sm font-medium text-gray-900 capitalize">{property.typeOfCharge?.replace(/_/g, ' ')}</p>
          </div>
          <div>
            <p className="text-[10px] text-gray-400 mb-1">Security Details</p>
            <p className="text-sm text-gray-700 line-clamp-2">{property.securityDetails}</p>
          </div>
        </div>
      </div>

      {/* Status Badges */}
      {/* <div className="flex flex-wrap items-center gap-2">
        {property.cersaiRegistered && (
          <span className="flex items-center gap-1 px-2 py-1 bg-green-50 text-green-700 border border-green-200 rounded-md text-xs font-medium">
            <span className="w-2 h-2 rounded-full bg-green-500" />
            CERSAI Registered
          </span>
        )}
        {property.rocChargeFiled && (
          <span className="flex items-center gap-1 px-2 py-1 bg-green-50 text-green-700 border border-green-200 rounded-md text-xs font-medium">
            <span className="w-2 h-2 rounded-full bg-green-500" />
            ROC Charge Filed
          </span>
        )}
      </div> */}

      {/* Documents Section */}
      {(property.titleSearchReportDocument || property.valuationDocument || property.addressDocument || property.additionalDoc1 || property.additionalDoc2) && (
        <div>
          <h4 className="text-[10px] font-semibold uppercase tracking-widest text-gray-500 mb-3">Documents</h4>
          <div className="grid grid-cols-4 gap-3">
            {property.titleSearchReportDocument && (
              <div className="flex items-center gap-2 px-3 py-2.5 bg-white border border-gray-200 rounded-lg hover:border-gray-300 transition-all">
                <svg className="w-5 h-5 text-gray-600 flex-shrink-0" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
                  <path d="M13 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z"></path>
                  <polyline points="13 2 13 9 20 9"></polyline>
                </svg>
                <div className="flex-1 min-w-0">
                  <p className="text-xs font-semibold text-gray-900 truncate">Title Search</p>
                  <p className="text-[10px] text-gray-500">PDF • Latest</p>
                </div>
              </div>
            )}
            {property.valuationDocument && (
              <div className="flex items-center gap-2 px-3 py-2.5 bg-white border border-gray-200 rounded-lg hover:border-gray-300 transition-all">
                <svg className="w-5 h-5 text-gray-600 flex-shrink-0" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
                  <path d="M13 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z"></path>
                  <polyline points="13 2 13 9 20 9"></polyline>
                </svg>
                <div className="flex-1 min-w-0">
                  <p className="text-xs font-semibold text-gray-900 truncate">Valuation</p>
                  <p className="text-[10px] text-gray-500">PDF • Latest</p>
                </div>
              </div>
            )}
            {property.addressDocument && (
              <div className="flex items-center gap-2 px-3 py-2.5 bg-white border border-gray-200 rounded-lg hover:border-gray-300 transition-all">
                <svg className="w-5 h-5 text-gray-600 flex-shrink-0" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
                  <path d="M13 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z"></path>
                  <polyline points="13 2 13 9 20 9"></polyline>
                </svg>
                <div className="flex-1 min-w-0">
                  <p className="text-xs font-semibold text-gray-900 truncate">Address Proof</p>
                  <p className="text-[10px] text-gray-500">PDF • Latest</p>
                </div>
              </div>
            )}
            {property.additionalDoc1 && (
              <div className="flex items-center gap-2 px-3 py-2.5 bg-white border border-gray-200 rounded-lg hover:border-gray-300 transition-all">
                <svg className="w-5 h-5 text-gray-600 flex-shrink-0" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
                  <path d="M13 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z"></path>
                  <polyline points="13 2 13 9 20 9"></polyline>
                </svg>
                <div className="flex-1 min-w-0">
                  <p className="text-xs font-semibold text-gray-900 truncate">Additional</p>
                  <p className="text-[10px] text-gray-500">PDF • Latest</p>
                </div>
              </div>
            )}
          </div>
        </div>
      )}
    </div>
  );
}
