'use client';

interface FlightsEmptyStateProps {
  title?: string;
  description?: string;
  /** Hide the "Modify Search" action, e.g. for a single empty leg tab within an otherwise non-empty multi-city result. */
  showAction?: boolean;
}

function NoFlightsIllustration() {
  return (
    <svg width={220} height={150} viewBox="0 0 220 150" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
      {/* soft backdrop */}
      <ellipse cx={110} cy={128} rx={70} ry={8} fill="var(--color-first, #2f6271)" opacity={0.08} />

      {/* clouds */}
      <path d="M28 46c-5 0-9-4-9-9s4-9 9-9c1-6 6-10 12-10s11 4 12 10h2c6 0 10 4 10 9s-4 9-10 9H28Z" fill="var(--color-first, #2f6271)" opacity={0.12} />
      <path d="M168 88c-4 0-6-3-6-6s2-6 6-6c1-4 4-7 9-7s8 3 9 7h1c4 0 7 2 7 6s-3 6-7 6h-19Z" fill="var(--color-second, #f45d6b)" opacity={0.12} />

      {/* dashed flight path */}
      <path
        d="M36 108C70 60 140 60 182 34"
        stroke="var(--color-first, #2f6271)"
        strokeOpacity={0.35}
        strokeWidth={2}
        strokeDasharray="1 8"
        strokeLinecap="round"
        fill="none"
      />

      {/* paper plane */}
      <g transform="translate(150 30) rotate(28)">
        <path
          d="M0 14 30 0 6 28 3 18Z"
          fill="var(--color-first, #2f6271)"
        />
        <path d="M0 14 14 16 3 18Z" fill="var(--color-second, #f45d6b)" />
      </g>

      {/* empty-search marker at the trail's start */}
      <circle cx={36} cy={108} r={13} stroke="var(--color-second, #f45d6b)" strokeWidth={2} fill="#fff" />
      <path d="M31 108h10M36 103v10" stroke="var(--color-second, #f45d6b)" strokeWidth={2} strokeLinecap="round" transform="rotate(45 36 108)" />
    </svg>
  );
}

/** Shown wherever a flight search comes back with zero results — one-way, round-trip, and multi-city (whole itinerary). */
export default function FlightsEmptyState({
  title = 'No flights found',
  description = "We couldn't find any flights for this route. Try different dates or a nearby airport.",
  showAction = false, // hidden for now
}: FlightsEmptyStateProps) {
  return (
    <div
      className="flights-empty-state bgColor-white rounded-3 text-center px-3"
      style={{ border: '1px solid #E5E7EB', paddingTop: '4rem', paddingBottom: '4rem' }}
    >
      <NoFlightsIllustration />
      <h4 className="text-xxl fw-600 color-text-dark mb-2 mt-4">{title}</h4>
      <p className="text-md flight-detail-label mb-0 mx-auto" style={{ maxWidth: 480, lineHeight: 1.6 }}>
        {description}
      </p>
      {showAction && (
        <button
          type="button"
          className="buttons btnColor-second text-center rounded-2 px-4 py-2 fw-normal text-sm mt-4 mx-auto cursor-pointer"
          onClick={() => window.scrollTo({ top: 0, behavior: 'smooth' })}
        >
          Modify Search
        </button>
      )}
    </div>
  );
}
