"use client";

/**
 * InvestmentClearance — bottom-grid «Investment Clearance» card. The §23 finance
 * model is NOT in the backend, so every bignum (GDV / Cost / Profit / ROI / IRR)
 * is an honest «—» placeholder with a «после финмодели (§23)» caption — NO
 * fabricated numbers. The bignum layout matches the prototype. "Подробнее" opens
 * the finance drawer.
 */

import styles from "@/app/site-finder/analysis/[cad]/ptica/ptica.module.css";
import { adaptInvestmentClearance } from "@/components/site-finder/ptica/ptica-adapt";
import type { DrawerKey } from "@/components/site-finder/ptica/drawers/drawer-keys";

interface Props {
  onOpenDrawer: (key: DrawerKey) => void;
}

export function InvestmentClearance({ onOpenDrawer }: Props) {
  const { bignums, caption } = adaptInvestmentClearance();

  return (
    <div className={styles.card}>
      <div className={styles.cardHead}>
        <h3 className={styles.cardTitle}>
          Investment Clearance
          <span className={styles.cardTitleSub}>финансовая модель</span>
        </h3>
        <button
          type="button"
          className={styles.detailBtn}
          onClick={() => onOpenDrawer("finance")}
          title="Открыть финансовую модель"
        >
          Подробнее
        </button>
      </div>

      <div className={styles.bignumRow}>
        {bignums.map((b) => (
          <div key={b.label} className={styles.bignum}>
            <div className={styles.bignumLabel}>{b.label}</div>
            <div
              className={`${styles.bignumValue} ${
                b.isReal ? "" : styles.bignumValuePlaceholder
              }`}
              title={b.caption}
            >
              {b.value}
            </div>
            {b.unit && <span className={styles.bignumUnit}>{b.unit}</span>}
          </div>
        ))}
      </div>

      <p className={styles.bignumCaption}>{caption}</p>
    </div>
  );
}
