import type { HotelRequestSelection } from "./types";

/**
 * LEIS-988 — the "Price Breakup" sidebar, ported from leisure-ui's
 * PriceBreakupSidebarServer. No discount line and no per-line tax dropdown —
 * search-service's offer carries one flat taxesAndFeesPerNight figure, not
 * the itemised hotelier-charge/GST/service-fee breakdown a priced-offer
 * response gives the Personal-mode page; a dropdown over one number would be
 * decoration, not information.
 */
export function PriceBreakupSidebarHotel({ selection }: { selection: HotelRequestSelection }) {
  const basePrice = selection.nightlyRate * selection.nights;
  const taxes = selection.taxesAndFeesPerNight * selection.nights;
  const total = Math.round((basePrice + taxes) * 100) / 100;

  return (
    <div className="card rounded-3 border-0 shadow-sm">
      <div className="card-header pt-3 bgColor-white border-0">
        <h3 className="subHeading mb-0 text-lg fw-bold">Price Breakup</h3>
      </div>

      <div className="card-body bgColor-white">
        <ul className="d-flex justify-content-between passenger-price-summary ps-0 py-1 mb-0">
          <li className="passenger-number text-sm">
            Base Price
            <br />
            <small>
              [ 1 Room x {selection.nights} night{selection.nights === 1 ? "" : "s"} ]
            </small>
          </li>
          <li className="passenger-fare text-sm text-end">
            {selection.currency} {basePrice.toFixed(2)}
          </li>
        </ul>

        <ul className="d-flex justify-content-between passenger-price-summary ps-0 py-1 mb-0">
          <li className="passenger-number text-sm">Taxes &amp; Service Fees</li>
          <li className="passenger-fare text-sm text-end">
            {selection.currency} {taxes.toFixed(2)}
          </li>
        </ul>
      </div>

      <div className="card-footer bgColor-white pt-1 border-0 border-top">
        <ul className="d-flex justify-content-between passenger-price-summary passenger-price-summary-total ps-0 py-1 mb-0">
          <li className="passenger-number text-md fw-semibold">Total (est.)</li>
          <li className="passenger-fare text-md text-right fw-semibold">
            {selection.currency} {total.toFixed(2)}
          </li>
        </ul>
        <small className="text-xs">Final price is confirmed at booking, after your request is approved.</small>
      </div>
    </div>
  );
}
