// recap-screen.jsx — Étape /recap
// Récap final avant paiement. Iso fonctionnel RecapView.vue, restylé charte clear Van-Away.
// Expose : RecapScreen
// Tweaks : fidelity (iso/free), layout (single/sidebar/sections), ctaStrategy (dual/single/toggle), trustBlock, cautionStyle

const R_TEAL = '#11978f';
const R_TEAL_HV = '#1c7d77';
const R_INK = '#042828';
const R_MUTED = '#5B7A82';
const R_CREAM = '#F4F2EC';
const R_SURFACE = '#FFFFFF';
const R_BORDER = 'rgba(4,40,40,0.08)';
const R_BORDER_S = 'rgba(4,40,40,0.14)';
const R_DANGER = '#C0392B';
const R_BG_TEAL = '#e7fcfb';

// ─── Mock data ────────────────────────────────────────────────
const RC_VEHICLE = {
  id: 1,
  display_name: 'Volkswagen California Ocean',
  category_name: 'Campervans',
  brand: 'Volkswagen',
  model: 'California Ocean',
  nb_places: 4,
  gearbox: 'Automatique',
  energy: 'Diesel',
  pricePerDay: 120,
  picture: 'https://www.van-away.com/wp-content/uploads/malaga-2p-1600x923-1-1024x591.png'
};

const RC_SEARCH = {
  agencyName: 'Van-Away Bordeaux - Bordeaux',
  agencyAddress: '12 rue des Vignerons · 33000 Bordeaux',
  agencyPhone: '05 56 00 00 00',
  agencyEmail: 'bordeaux@van-away.com',
  startDate: '2026-07-12',
  endDate: '2026-07-20',
  days: 8
};

const RC_CONFIG = {
  mileageLabel: 'Confort',
  mileageKm: 200,
  mileageUnlimited: false,
  mileageAmount: 4.90,
  insuranceLabel: 'Confort',
  insuranceTagline: 'Recommandé',
  insuranceAmount: 14.90,
  insurancePerDay: true,
  insuranceFranchise: 1000,
  insuranceCaution: 1000
};

const RC_OPTIONS_INCLUDED = [
{ id: 11, name: 'Kit lit (draps + couette)' },
{ id: 12, name: 'Vaisselle de base' }];

const RC_OPTIONS_PAID = [
{ id: 1, name: 'Conducteur supplémentaire', amount: 49, pricing: 'total', qty: 1 },
{ id: 2, name: 'Pack vélos électriques', amount: 19.90, pricing: 'per_day', qty: 2 },
{ id: 3, name: 'Pack apéro (table + chaises)', amount: 25, pricing: 'total', qty: 1 }];


const RC_CUSTOMER = {
  firstName: 'Téo',
  lastName: 'Marchand',
  email: 'teo@gmail.com',
  phone: '06 12 34 56 78',
  birthdate: '1992-03-14',
  address: '34 cours de la Marne',
  postcode: '33800',
  city: 'Bordeaux',
  country: 'France'
};

const RC_PROMO = { code: 'SUMMER10', discount: 87 };

// ─── Helpers ──────────────────────────────────────────────────
function rfmtPrice(n, dec = 2) {
  return (n ?? 0).toFixed(dec).replace('.', ',') + ' €';
}
function rfmtDate(iso) {
  if (!iso) return '';
  const d = new Date(iso);
  return d.toLocaleDateString('fr-FR', { day: 'numeric', month: 'short', year: 'numeric' });
}
function rfmtDateLong(iso) {
  if (!iso) return '';
  const d = new Date(iso);
  return d.toLocaleDateString('fr-FR', { weekday: 'long', day: 'numeric', month: 'long' });
}

function computeTotals() {
  const v = RC_VEHICLE.pricePerDay * RC_SEARCH.days;
  const m = RC_CONFIG.mileageAmount * RC_SEARCH.days;
  const i = RC_CONFIG.insurancePerDay ? RC_CONFIG.insuranceAmount * RC_SEARCH.days : RC_CONFIG.insuranceAmount;
  const opts = RC_OPTIONS_PAID.reduce((s, o) => s + (o.pricing === 'per_day' ? o.amount * o.qty * RC_SEARCH.days : o.amount * o.qty), 0);
  const subtotal = v + m + i + opts;
  const discount = RC_PROMO.discount;
  const total = subtotal - discount;
  const tva = total * 0.20 / 1.20;
  const deposit = Math.round(total * 0.30 * 100) / 100;
  return { v, m, i, opts, subtotal, discount, total, tva, deposit };
}

// ─── Atoms ────────────────────────────────────────────────────
function RCheck({ size = 14, color = R_TEAL }) {
  return (
    <svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke={color} strokeWidth="3" strokeLinecap="round" strokeLinejoin="round">
      <path d="M5 13l4 4L19 7" />
    </svg>);

}
function REditLink({ onClick, label = 'Modifier' }) {
  return (
    <button type="button" className="va-edit" onClick={onClick}>
      <svg width="12" height="12" fill="none" stroke="currentColor" strokeWidth="2.4" strokeLinecap="round" strokeLinejoin="round" viewBox="0 0 24 24">
        <path d="M12 20h9" />
        <path d="M16.5 3.5a2.121 2.121 0 113 3L7 19l-4 1 1-4L16.5 3.5z" />
      </svg>
      {label}
      <style>{`
        .va-edit{display:inline-flex;align-items:center;gap:5px;background:none;border:none;color:${R_TEAL};font-family:inherit;font-size:12.5px;font-weight:700;cursor:pointer;padding:4px 8px;border-radius:8px;transition:all .2s ease}
        .va-edit:hover{background:${R_BG_TEAL};color:${R_TEAL_HV}}
      `}</style>
    </button>);

}

// ─── Section header (numéroté, avec lien Modifier) ────────────
function SectionHead({ num, title, onEdit }) {
  return (
    <div className="va-rsh">
      {num != null && <div className="va-rsh-num">{num}</div>}
      <h2 className="va-rsh-title" style={{ fontWeight: "900" }}>{title}</h2>
      {onEdit && <div className="va-rsh-edit"><REditLink onClick={onEdit} /></div>}
      <style>{`
        .va-rsh{display:flex;align-items:center;gap:12px;margin-bottom:14px}
        .va-rsh-num{flex-shrink:0;width:28px;height:28px;border-radius:50%;background:${R_BG_TEAL};color:${R_TEAL};font-size:13px;font-weight:900;display:flex;align-items:center;justify-content:center}
        .va-rsh-title{margin:0;font-size:17px;font-weight:900;color:${R_INK};letter-spacing:-.01em;flex:1}
        .va-rsh-edit{flex-shrink:0}
      `}</style>
    </div>);

}

// ─── Bloc voyage (agence + dates) ─────────────────────────────
function TripBlock({ compact, fidelity }) {
  return (
    <div className={`va-rtrip ${compact ? 'is-compact' : ''} fid-${fidelity}`}>
      <div className="va-rtrip-row">
        <div className="va-rtrip-leg">
          <span className="va-rtrip-eyebrow">Départ</span>
          <strong className="va-rtrip-date">{rfmtDateLong(RC_SEARCH.startDate)}</strong>
          <span className="va-rtrip-place">
            <svg width="12" height="12" fill="none" stroke={R_TEAL} strokeWidth="2.2" viewBox="0 0 24 24">
              <path strokeLinecap="round" strokeLinejoin="round" d="M17.657 16.657L13.414 20.9a2 2 0 01-2.827 0l-4.244-4.243a8 8 0 1111.314 0z" />
              <circle cx="12" cy="11" r="2.5" />
            </svg>
            {RC_SEARCH.agencyName.split(' - ')[1] || RC_SEARCH.agencyName}
          </span>
        </div>
        <div className="va-rtrip-arrow">
          <span className="va-rtrip-days">{RC_SEARCH.days} jours</span>
          <svg width="100%" height="18" viewBox="0 0 100 18" preserveAspectRatio="none" style={{ maxWidth: compact ? 80 : 180 }}>
            <line x1="0" y1="9" x2="92" y2="9" stroke={R_TEAL} strokeWidth="1.5" strokeDasharray="4 3" />
            <path d="M88 4 L96 9 L88 14" fill="none" stroke={R_TEAL} strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round" />
          </svg>
        </div>
        <div className="va-rtrip-leg va-rtrip-leg-end">
          <span className="va-rtrip-eyebrow">Retour</span>
          <strong className="va-rtrip-date">{rfmtDateLong(RC_SEARCH.endDate)}</strong>
          <span className="va-rtrip-place">
            <svg width="12" height="12" fill="none" stroke={R_TEAL} strokeWidth="2.2" viewBox="0 0 24 24">
              <path strokeLinecap="round" strokeLinejoin="round" d="M17.657 16.657L13.414 20.9a2 2 0 01-2.827 0l-4.244-4.243a8 8 0 1111.314 0z" />
              <circle cx="12" cy="11" r="2.5" />
            </svg>
            {RC_SEARCH.agencyName.split(' - ')[1] || RC_SEARCH.agencyName}
          </span>
        </div>
      </div>
      <style>{`
        .va-rtrip{background:${R_SURFACE};border:1px solid ${R_BORDER};border-radius:18px;padding:18px 20px;box-shadow:0 1px 2px rgba(4,40,40,.04)}
        .va-rtrip.fid-free{background:linear-gradient(160deg,#fbfffe 0%,${R_SURFACE} 60%);border-color:${R_TEAL}26}
        .va-rtrip-row{display:grid;grid-template-columns:1fr auto 1fr;align-items:center;gap:18px}
        .va-rtrip.is-compact .va-rtrip-row{grid-template-columns:1fr;gap:14px}
        .va-rtrip-leg{display:flex;flex-direction:column;gap:3px}
        .va-rtrip-leg-end{text-align:right;align-items:flex-end}
        .va-rtrip.is-compact .va-rtrip-leg-end{text-align:left;align-items:flex-start}
        .va-rtrip-eyebrow{font-size:10px;font-weight:900;color:${R_MUTED};text-transform:uppercase;letter-spacing:1.4px}
        .va-rtrip-date{font-size:15px;font-weight:900;color:${R_INK};letter-spacing:-.01em;text-transform:capitalize}
        .va-rtrip-place{display:inline-flex;align-items:center;gap:5px;font-size:12.5px;color:${R_MUTED};font-weight:600;margin-top:2px}
        .va-rtrip-leg-end .va-rtrip-place{justify-content:flex-end}
        .va-rtrip.is-compact .va-rtrip-leg-end .va-rtrip-place{justify-content:flex-start}
        .va-rtrip-arrow{display:flex;flex-direction:column;align-items:center;gap:4px}
        .va-rtrip.is-compact .va-rtrip-arrow{flex-direction:row;justify-content:flex-start;gap:10px;padding-left:2px}
        .va-rtrip-days{font-size:11px;font-weight:900;color:${R_TEAL};text-transform:uppercase;letter-spacing:1.2px;background:${R_BG_TEAL};padding:3px 10px;border-radius:999px;white-space:nowrap}
      `}</style>
    </div>);

}

// ─── Bloc véhicule ────────────────────────────────────────────
function VehicleBlock({ compact, fidelity }) {
  return (
    <div className={`va-rveh ${compact ? 'is-compact' : ''} fid-${fidelity}`}>
      <div className="va-rveh-photo">
        <img src={RC_VEHICLE.picture} alt={RC_VEHICLE.display_name} />
        <span className="va-rveh-cat">{RC_VEHICLE.category_name}</span>
      </div>
      <div className="va-rveh-body">
        <h3 className="va-rveh-name">{RC_VEHICLE.display_name}</h3>
        <ul className="va-rveh-specs">
          <li>{RC_VEHICLE.nb_places} places</li>
          <li>{RC_VEHICLE.gearbox}</li>
          <li>{RC_VEHICLE.energy}</li>
        </ul>
        <div className="va-rveh-price">
          <span>{rfmtPrice(RC_VEHICLE.pricePerDay)} / jour</span>
          <span className="va-rveh-times">×</span>
          <span>{RC_SEARCH.days} jours</span>
          <strong>{rfmtPrice(RC_VEHICLE.pricePerDay * RC_SEARCH.days)}</strong>
        </div>
      </div>
      <style>{`
        .va-rveh{display:grid;grid-template-columns:200px 1fr;gap:16px;background:${R_SURFACE};border:1px solid ${R_BORDER};border-radius:18px;padding:14px;box-shadow:0 1px 2px rgba(4,40,40,.04)}
        .va-rveh.is-compact{grid-template-columns:1fr;padding:12px}
        .va-rveh-photo{position:relative;border-radius:14px;overflow:hidden;aspect-ratio:16/10;background:${R_CREAM}}
        .va-rveh-photo img{width:100%;height:100%;object-fit:cover;display:block}
        .va-rveh-cat{position:absolute;top:10px;left:10px;background:${R_SURFACE};color:${R_TEAL};font-size:10.5px;font-weight:900;letter-spacing:.6px;padding:4px 10px;border-radius:999px;text-transform:uppercase}
        .va-rveh-body{display:flex;flex-direction:column;justify-content:center;gap:8px;padding:6px 4px}
        .va-rveh.is-compact .va-rveh-body{padding:0 2px 4px}
        .va-rveh-name{margin:0;font-size:18px;font-weight:900;color:${R_INK};letter-spacing:-.01em}
        .va-rveh-specs{list-style:none;padding:0;margin:0;display:flex;flex-wrap:wrap;gap:6px}
        .va-rveh-specs li{font-size:11.5px;font-weight:600;color:${R_MUTED};padding:3px 9px;background:${R_BG_TEAL};border-radius:999px}
        .va-rveh-price{display:flex;align-items:baseline;gap:6px;font-size:13px;color:${R_MUTED};font-weight:600;margin-top:2px}
        .va-rveh-price strong{margin-left:auto;font-size:18px;font-weight:900;color:${R_TEAL};letter-spacing:-.02em}
        .va-rveh-times{opacity:.5}
      `}</style>
    </div>);

}

// ─── Bloc kilométrage ─────────────────────────────────────────
function MileageBlock() {
  const total = RC_CONFIG.mileageAmount * RC_SEARCH.days;
  return (
    <div className="va-rline">
      <div className="va-rline-head">
        <strong>Forfait {RC_CONFIG.mileageLabel}</strong>
        <span>
          {RC_CONFIG.mileageUnlimited ? 'Kilométrage illimité' : `${RC_CONFIG.mileageKm} km/jour`}
          {!RC_CONFIG.mileageUnlimited && ` · ${RC_CONFIG.mileageKm * RC_SEARCH.days} km inclus pour ${RC_SEARCH.days} jours`}
        </span>
      </div>
      <div className="va-rline-amount">
        {RC_CONFIG.mileageAmount === 0 ? <span className="is-free">Inclus</span> :
        <>
            <span className="va-rline-per">{rfmtPrice(RC_CONFIG.mileageAmount)}/j</span>
            <strong>{rfmtPrice(total)}</strong>
          </>
        }
      </div>
      <style>{`
        .va-rline{display:flex;align-items:center;gap:12px;padding:14px 16px;background:${R_SURFACE};border:1px solid ${R_BORDER};border-radius:14px}
        .va-rline-head{flex:1;display:flex;flex-direction:column;gap:2px;min-width:0}
        .va-rline-head strong{font-size:14px;font-weight:900;color:${R_INK}}
        .va-rline-head span{font-size:12.5px;color:${R_MUTED};font-weight:500}
        .va-rline-amount{display:flex;flex-direction:column;align-items:flex-end;gap:1px}
        .va-rline-per{font-size:11.5px;color:${R_MUTED};font-weight:600}
        .va-rline-amount strong{font-size:15px;font-weight:900;color:${R_TEAL}}
        .va-rline-amount .is-free{font-size:12px;font-weight:900;color:${R_TEAL};text-transform:uppercase;letter-spacing:1px;background:${R_BG_TEAL};padding:5px 10px;border-radius:999px}
      `}</style>
    </div>);

}

// ─── Bloc assurance ───────────────────────────────────────────
function InsuranceBlock() {
  const total = RC_CONFIG.insurancePerDay ? RC_CONFIG.insuranceAmount * RC_SEARCH.days : RC_CONFIG.insuranceAmount;
  return (
    <div className="va-rline">
      <div className="va-rline-head">
        <strong>
          Assurance {RC_CONFIG.insuranceLabel}
          {RC_CONFIG.insuranceTagline && <span className="va-rline-tag">{RC_CONFIG.insuranceTagline}</span>}
        </strong>
        <span>Franchise {rfmtPrice(RC_CONFIG.insuranceFranchise, 0)} · Caution {rfmtPrice(RC_CONFIG.insuranceCaution, 0)}</span>
      </div>
      <div className="va-rline-amount">
        <span className="va-rline-per">{rfmtPrice(RC_CONFIG.insuranceAmount)}/j</span>
        <strong>{rfmtPrice(total)}</strong>
      </div>
      <style>{`
        .va-rline-tag{display:inline-block;background:${R_TEAL};color:#fff;font-size:9.5px;font-weight:900;text-transform:uppercase;letter-spacing:.8px;padding:2px 7px;border-radius:999px;margin-left:8px;vertical-align:middle}
      `}</style>
    </div>);

}

// ─── Bloc options ─────────────────────────────────────────────
function OptionsBlock() {
  return (
    <div className="va-ropts">
      {RC_OPTIONS_INCLUDED.map((o) =>
      <div className="va-ropts-row va-ropts-row-inc" key={`inc-${o.id}`}>
          <span className="va-ropts-name"><RCheck size={12} color={R_TEAL} /> {o.name}</span>
          <span className="va-ropts-badge">Inclus</span>
        </div>
      )}
      {RC_OPTIONS_PAID.map((o) => {
        const total = o.pricing === 'per_day' ? o.amount * o.qty * RC_SEARCH.days : o.amount * o.qty;
        return (
          <div className="va-ropts-row" key={o.id}>
            <span className="va-ropts-name">
              {o.name}
              {o.qty > 1 && <span className="va-ropts-qty"> ×{o.qty}</span>}
              {o.pricing === 'per_day' && <span className="va-ropts-per"> · {rfmtPrice(o.amount)}/jour</span>}
            </span>
            <strong>{rfmtPrice(total)}</strong>
          </div>);

      })}
      <style>{`
        .va-ropts{display:flex;flex-direction:column;gap:6px}
        .va-ropts-row{display:flex;justify-content:space-between;align-items:center;gap:10px;padding:10px 14px;background:${R_SURFACE};border:1px solid ${R_BORDER};border-radius:12px}
        .va-ropts-row-inc{background:${R_BG_TEAL};border-color:${R_TEAL}33}
        .va-ropts-name{font-size:13px;color:${R_INK};font-weight:600;display:inline-flex;align-items:center;gap:6px;flex:1;min-width:0}
        .va-ropts-qty{color:${R_MUTED};font-weight:600}
        .va-ropts-per{color:${R_MUTED};font-weight:500;font-size:12px}
        .va-ropts-row strong{font-size:14px;font-weight:900;color:${R_TEAL};white-space:nowrap}
        .va-ropts-badge{font-size:10px;font-weight:900;color:${R_TEAL};text-transform:uppercase;letter-spacing:1px;background:${R_SURFACE};padding:3px 9px;border-radius:999px;border:1px solid ${R_TEAL}33}
      `}</style>
    </div>);

}

// ─── Bloc client ──────────────────────────────────────────────
function CustomerBlock() {
  const c = RC_CUSTOMER;
  return (
    <div className="va-rcust">
      <div className="va-rcust-row">
        <span className="va-rcust-key">Nom</span>
        <span className="va-rcust-val">{c.firstName} {c.lastName}</span>
      </div>
      <div className="va-rcust-row">
        <span className="va-rcust-key">Email</span>
        <span className="va-rcust-val">{c.email}</span>
      </div>
      <div className="va-rcust-row">
        <span className="va-rcust-key">Téléphone</span>
        <span className="va-rcust-val">{c.phone}</span>
      </div>
      <div className="va-rcust-row">
        <span className="va-rcust-key">Adresse</span>
        <span className="va-rcust-val">{c.address}, {c.postcode} {c.city}, {c.country}</span>
      </div>
      <style>{`
        .va-rcust{display:grid;grid-template-columns:1fr 1fr;gap:14px 24px;padding:18px 20px;background:${R_SURFACE};border:1px solid ${R_BORDER};border-radius:18px}
        .va-rcust-row{display:flex;flex-direction:column;gap:2px;min-width:0}
        .va-rcust-key{font-size:10.5px;font-weight:900;color:${R_MUTED};text-transform:uppercase;letter-spacing:1.2px}
        .va-rcust-val{font-size:13.5px;color:${R_INK};font-weight:600;word-break:break-word}
      `}</style>
    </div>);

}

// ─── Bloc caution (style "bloc dédié") ────────────────────────
function CautionBlock({ cautionStyle }) {
  if (cautionStyle === 'line') {
    return (
      <div className="va-rcaut va-rcaut-line">
        <div>
          <strong>Caution</strong>
          <span>Empreinte bancaire bloquée — restituée intégralement au retour.</span>
        </div>
        <strong className="va-rcaut-amount">{rfmtPrice(RC_CONFIG.insuranceCaution, 0)}</strong>
        <style>{`
          .va-rcaut-line{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:14px 18px;background:${R_SURFACE};border:1px dashed ${R_BORDER_S};border-radius:14px}
          .va-rcaut-line strong{font-size:13.5px;font-weight:900;color:${R_INK};display:block}
          .va-rcaut-line span{font-size:12px;color:${R_MUTED};font-weight:500}
          .va-rcaut-amount{font-size:15px !important;color:${R_TEAL} !important}
        `}</style>
      </div>);

  }
  return (
    <div className="va-rcaut va-rcaut-block">
      <div className="va-rcaut-icon">
        <svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke={R_TEAL} strokeWidth="2.2" strokeLinecap="round" strokeLinejoin="round">
          <path d="M12 22s-8-4.5-8-11.8A8 8 0 0112 2a8 8 0 018 8.2C20 17.5 12 22 12 22z" />
          <path d="M9 12l2 2 4-4" />
        </svg>
      </div>
      <div className="va-rcaut-body">
        <strong>Caution restituée au retour</strong>
        <span>Une empreinte bancaire de <strong>{rfmtPrice(RC_CONFIG.insuranceCaution, 0)}</strong> sera bloquée à la prise du véhicule. Aucun débit n'est effectué — le montant est restitué intégralement après inspection au retour.</span>
      </div>
      <style>{`
        .va-rcaut-block{display:flex;align-items:flex-start;gap:14px;padding:16px 18px;background:${R_BG_TEAL};border:1px solid ${R_TEAL}26;border-radius:16px}
        .va-rcaut-icon{flex-shrink:0;width:40px;height:40px;border-radius:50%;background:${R_SURFACE};display:flex;align-items:center;justify-content:center;border:1px solid ${R_TEAL}33}
        .va-rcaut-body{flex:1;display:flex;flex-direction:column;gap:4px}
        .va-rcaut-body strong{font-size:14px;font-weight:900;color:${R_INK};letter-spacing:-.01em}
        .va-rcaut-body span{font-size:12.5px;color:${R_MUTED};font-weight:500;line-height:1.5}
        .va-rcaut-body span strong{display:inline;font-size:12.5px;color:${R_INK}}
      `}</style>
    </div>);

}

// ─── Bloc réassurance avant CTA ───────────────────────────────
function TrustBlock({ compact }) {
  const items = [
  {
    icon: <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke={R_TEAL} strokeWidth="2.2" strokeLinecap="round" strokeLinejoin="round"><rect x="3" y="11" width="18" height="11" rx="2" /><path d="M7 11V7a5 5 0 0110 0v4" /></svg>,
    title: 'Paiement 100% sécurisé',
    desc: 'Carte bancaire chiffrée via Stripe — leader européen.'
  },
  {
    icon: <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke={R_TEAL} strokeWidth="2.2" strokeLinecap="round" strokeLinejoin="round"><path d="M21 15a2 2 0 01-2 2H7l-4 4V5a2 2 0 012-2h14a2 2 0 012 2z" /></svg>,
    title: 'Paiement 100% sécurisé',
    desc: 'Transactions chiffrées · 3D Secure · CB / Visa / Mastercard.'
  },
  {
    icon: <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke={R_TEAL} strokeWidth="2.2" strokeLinecap="round" strokeLinejoin="round"><path d="M12 22s-8-4.5-8-11.8A8 8 0 0112 2a8 8 0 018 8.2C20 17.5 12 22 12 22z" /><path d="M9 12l2 2 4-4" /></svg>,
    title: 'Paiement 100% sécurisé',
    desc: 'Transactions chiffrées · 3D Secure · CB / Visa / Mastercard.'
  }];

  return (
    <div className={`va-rtrust ${compact ? 'is-compact' : ''}`}>
      {items.map((it, i) =>
      <div className="va-rtrust-item" key={i}>
          <div className="va-rtrust-icon">{it.icon}</div>
          <div className="va-rtrust-text">
            <strong style={{ fontWeight: "900" }}>{it.title}</strong>
            <span>{it.desc}</span>
          </div>
        </div>
      )}
      <style>{`
        .va-rtrust{display:grid;grid-template-columns:repeat(3,1fr);gap:12px;padding:18px;background:${R_SURFACE};border:1px solid ${R_BORDER};border-radius:18px}
        .va-rtrust.is-compact{grid-template-columns:1fr}
        .va-rtrust-item{display:flex;align-items:flex-start;gap:10px}
        .va-rtrust-icon{flex-shrink:0;width:36px;height:36px;border-radius:10px;background:${R_BG_TEAL};display:flex;align-items:center;justify-content:center}
        .va-rtrust-text{display:flex;flex-direction:column;gap:2px}
        .va-rtrust-text strong{font-size:13px;font-weight:900;color:${R_INK}}
        .va-rtrust-text span{font-size:11.5px;color:${R_MUTED};font-weight:500;line-height:1.4}
      `}</style>
    </div>);

}

// ─── Détail prix (utilisé en sidebar et bottom bar) ───────────
function PriceDetail({ totals, expandable }) {
  const [open, setOpen] = React.useState(!expandable);
  return (
    <div className="va-rpd">
      {expandable &&
      <button type="button" className="va-rpd-toggle" onClick={() => setOpen(!open)}>
          {open ? 'Masquer le détail' : 'Voir le détail'}
          <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.4" strokeLinecap="round" strokeLinejoin="round" style={{ transform: open ? 'rotate(180deg)' : 'none', transition: 'transform .2s' }}>
            <path d="M6 9l6 6 6-6" />
          </svg>
        </button>
      }
      <div className="va-rpd-rows" style={{ display: open ? 'flex' : 'none' }}>
        <div className="va-rpd-row"><span>Véhicule · {RC_SEARCH.days}j</span><strong>{rfmtPrice(totals.v)}</strong></div>
        <div className="va-rpd-row"><span>Forfait km</span><strong>{rfmtPrice(totals.m)}</strong></div>
        <div className="va-rpd-row"><span>Assurance</span><strong>{rfmtPrice(totals.i)}</strong></div>
        <div className="va-rpd-row"><span>Options</span><strong>{rfmtPrice(totals.opts)}</strong></div>
        {totals.discount > 0 &&
        <div className="va-rpd-row va-rpd-promo">
            <span>Code {RC_PROMO.code}</span>
            <strong>−{rfmtPrice(totals.discount)}</strong>
          </div>
        }
        <div className="va-rpd-sep" />
      </div>
      <div className="va-rpd-total">
        <div>
          <span>Total TTC</span>
          <em>dont {rfmtPrice(totals.tva)} de TVA</em>
        </div>
        <strong>{rfmtPrice(totals.total)}</strong>
      </div>
      <style>{`
        .va-rpd{display:flex;flex-direction:column;gap:0}
        .va-rpd-rows{flex-direction:column;gap:6px;margin-bottom:10px}
        .va-rpd-row{display:flex;justify-content:space-between;align-items:baseline;font-size:12.5px;color:${R_MUTED};font-weight:600}
        .va-rpd-row strong{color:${R_INK};font-weight:700}
        .va-rpd-promo{color:${R_TEAL}}
        .va-rpd-promo strong{color:${R_TEAL};font-weight:900}
        .va-rpd-sep{height:1px;background:${R_BORDER};margin:6px 0 0}
        .va-rpd-toggle{align-self:flex-start;background:none;border:none;color:${R_TEAL};font-family:inherit;font-size:12px;font-weight:700;display:inline-flex;align-items:center;gap:4px;cursor:pointer;padding:4px 0;margin-bottom:8px}
        .va-rpd-toggle:hover{color:${R_TEAL_HV}}
        .va-rpd-total{display:flex;justify-content:space-between;align-items:flex-start;padding:14px 16px;background:${R_BG_TEAL};border-radius:14px;border:1px solid ${R_TEAL}33}
        .va-rpd-total span{font-size:11px;font-weight:900;color:${R_INK};text-transform:uppercase;letter-spacing:1.2px;display:block}
        .va-rpd-total em{font-size:10.5px;color:${R_MUTED};font-style:normal;font-weight:500;display:block;margin-top:2px}
        .va-rpd-total strong{font-size:24px;font-weight:900;color:${R_TEAL};letter-spacing:-.02em;line-height:1}
      `}</style>
    </div>);

}

// ─── Sidebar récap (layout B) ─────────────────────────────────
function RecapSidebar({ totals, ctaStrategy, paymentMode, onChangePaymentMode }) {
  return (
    <aside className="va-rside">
      <div className="va-rside-vehicle">
        <img src={RC_VEHICLE.picture} alt={RC_VEHICLE.display_name} />
        <div>
          <strong>{RC_VEHICLE.display_name}</strong>
          <span>{RC_SEARCH.agencyName.split(' - ')[1]} · {RC_SEARCH.days}j</span>
        </div>
      </div>
      <div className="va-rside-detail"><PriceDetail totals={totals} expandable /></div>
      <ActionButtons compact={false} totals={totals} ctaStrategy={ctaStrategy} paymentMode={paymentMode} onChangePaymentMode={onChangePaymentMode} sidebar />
      {ctaStrategy !== 'request' &&
      <p className="va-rside-secure">
          <svg width="12" height="12" fill="none" stroke="currentColor" strokeWidth="2.2" viewBox="0 0 24 24"><rect x="3" y="11" width="18" height="11" rx="2" /><path d="M7 11V7a5 5 0 0110 0v4" /></svg>
          Paiement sécurisé Stripe
        </p>
      }
      <style>{`
        .va-rside{background:${R_SURFACE};border:1px solid ${R_BORDER};border-radius:20px;padding:18px;box-shadow:0 1px 2px rgba(4,40,40,.04),0 8px 24px rgba(4,40,40,.06)}
        .va-rside-vehicle{display:flex;gap:12px;padding-bottom:14px;margin-bottom:14px;border-bottom:1px dashed ${R_BORDER}}
        .va-rside-vehicle img{width:72px;height:48px;border-radius:10px;object-fit:cover}
        .va-rside-vehicle strong{display:block;font-size:14px;font-weight:900;color:${R_INK};letter-spacing:-.01em;line-height:1.2}
        .va-rside-vehicle span{display:block;font-size:11.5px;color:${R_MUTED};font-weight:600;margin-top:3px}
        .va-rside-detail{margin-bottom:14px}
        .va-rside-secure{display:flex;align-items:center;justify-content:center;gap:5px;font-size:11px;color:${R_MUTED};font-weight:600;margin:10px 0 0}
      `}</style>
    </aside>);

}

// ─── Boutons d'action (3 stratégies) ──────────────────────────
function ActionButtons({ compact, totals, ctaStrategy, paymentMode, onChangePaymentMode, sidebar }) {
  const stack = sidebar || compact;
  if (ctaStrategy === 'dual') {
    return (
      <div className={`va-rcta ${stack ? 'is-stack' : ''}`}>
        <button type="button" className="va-rcta-primary">
          <svg width="16" height="16" fill="none" stroke="currentColor" strokeWidth="2.2" viewBox="0 0 24 24"><rect x="2" y="6" width="20" height="13" rx="2" /><path d="M2 10h20" /></svg>
          Payer {rfmtPrice(totals.deposit)} d'acompte
        </button>
        <button type="button" className="va-rcta-secondary">Demande de réservation sans paiement</button>
        <ActionStyles />
      </div>);

  }
  if (ctaStrategy === 'single') {
    return (
      <div className={`va-rcta ${stack ? 'is-stack' : ''}`}>
        <button type="button" className="va-rcta-primary">
          <svg width="16" height="16" fill="none" stroke="currentColor" strokeWidth="2.2" viewBox="0 0 24 24"><rect x="2" y="6" width="20" height="13" rx="2" /><path d="M2 10h20" /></svg>
          Payer {rfmtPrice(totals.deposit)} et réserver
        </button>
        <a href="#" className="va-rcta-link" onClick={(e) => e.preventDefault()}>Préférer une demande de réservation sans paiement</a>
        <ActionStyles />
      </div>);

  }
  // Mode "request" : demande de réservation sans paiement CB
  if (ctaStrategy === 'request') {
    return (
      <div className={`va-rcta ${stack ? 'is-stack' : ''}`}>
        <button type="button" className="va-rcta-primary va-rcta-request">
          Envoyer ma demande de réservation
        </button>
        <p className="va-rcta-request-note">
          Aucun paiement à cette étape. Un acompte de <strong style={{ fontWeight: "700" }}>{rfmtPrice(totals.deposit)}</strong> sera demandé après confirmation. <strong style={{ fontWeight: "700" }}>Notre équipe revient vers vous sous 24h</strong> pour valider votre réservation.
        </p>
        <ActionStyles />
      </div>);
  }
  // toggle mode
  return (
    <div className={`va-rcta ${stack ? 'is-stack' : ''}`}>
      <div className="va-rcta-toggle">
        <button type="button" className={`va-rcta-toggle-opt ${paymentMode === 'pay' ? 'is-on' : ''}`} onClick={() => onChangePaymentMode('pay')}>
          <strong>Payer maintenant</strong>
          <span>Acompte 30% — {rfmtPrice(totals.deposit)}</span>
        </button>
        <button type="button" className={`va-rcta-toggle-opt ${paymentMode === 'request' ? 'is-on' : ''}`} onClick={() => onChangePaymentMode('request')}>
          <strong>Demande sans paiement</strong>
          <span>L'agence vous recontacte sous 24h</span>
        </button>
      </div>
      <button type="button" className="va-rcta-primary">
        {paymentMode === 'pay' ?
        <>
            <svg width="16" height="16" fill="none" stroke="currentColor" strokeWidth="2.2" viewBox="0 0 24 24"><rect x="2" y="6" width="20" height="13" rx="2" /><path d="M2 10h20" /></svg>
            Confirmer et payer {rfmtPrice(totals.deposit)}
          </> :
        'Envoyer ma demande de réservation'}
      </button>
      <ActionStyles />
    </div>);

}

function ActionStyles() {
  return (
    <style>{`
      .va-rcta{display:flex;flex-direction:column;gap:10px}
      .va-rcta:not(.is-stack){flex-direction:row;flex-wrap:wrap;align-items:center}
      .va-rcta:not(.is-stack) .va-rcta-primary{flex:1;min-width:280px}
      .va-rcta:not(.is-stack) .va-rcta-secondary{flex:1;min-width:280px}
      .va-rcta-primary{display:inline-flex;align-items:center;justify-content:center;gap:8px;background:${R_TEAL};color:#fff;border:none;font-family:inherit;font-size:14.5px;font-weight:700;padding:14px 22px;border-radius:999px;cursor:pointer;transition:all .2s ease;box-shadow:0 4px 14px rgba(17,151,143,.25)}
      .va-rcta-primary:hover{background:${R_TEAL_HV};transform:translateY(-1px);box-shadow:0 6px 20px rgba(17,151,143,.35)}
      .va-rcta-secondary{display:inline-flex;align-items:center;justify-content:center;background:transparent;color:${R_INK};border:1.5px solid ${R_BORDER_S};font-family:inherit;font-size:13.5px;font-weight:600;padding:13px 18px;border-radius:999px;cursor:pointer;transition:all .2s ease;line-height:1.2;text-align:center}
      .va-rcta-secondary:hover{border-color:${R_TEAL};color:${R_TEAL}}
      .va-rcta-link{align-self:center;font-size:12.5px;color:${R_MUTED};font-weight:600;text-decoration:underline;text-underline-offset:3px}
      .va-rcta-link:hover{color:${R_TEAL}}
      .va-rcta-toggle{display:grid;grid-template-columns:1fr 1fr;gap:8px;background:#fafaf6;padding:6px;border-radius:14px;border:1px solid ${R_BORDER}}
      .va-rcta-toggle-opt{background:transparent;border:1.5px solid transparent;border-radius:10px;padding:10px 12px;cursor:pointer;font-family:inherit;text-align:left;display:flex;flex-direction:column;gap:2px;transition:all .2s ease}
      .va-rcta-toggle-opt:hover{background:${R_SURFACE}}
      .va-rcta-toggle-opt.is-on{background:${R_SURFACE};border-color:${R_TEAL};box-shadow:0 0 0 3px rgba(17,151,143,.1)}
      .va-rcta-toggle-opt strong{font-size:13px;font-weight:900;color:${R_INK}}
      .va-rcta-toggle-opt span{font-size:11px;color:${R_MUTED};font-weight:600}
      .va-rcta-request-note{margin:6px 0 0;font-size:12.5px;color:${R_INK};line-height:1.5;text-align:center;padding:12px 14px;background:#fafaf6;border:1px dashed ${R_BORDER};border-radius:12px}
      .va-rcta-request-note strong{color:${R_INK};font-weight:900}
    `}</style>);

}

// ─── Bottom bar (layout C) ────────────────────────────────────
function RecapBottomBar({ compact, totals, ctaStrategy, paymentMode, onChangePaymentMode }) {
  return (
    <div className={`va-rbar ${compact ? 'is-compact' : ''}`}>
      <div className="va-rbar-inner">
        <div className="va-rbar-left">
          <span className="va-rbar-eyebrow">Total TTC</span>
          <strong className="va-rbar-amount">{rfmtPrice(totals.total)}</strong>
          <em>dont {rfmtPrice(totals.tva)} de TVA</em>
        </div>
        <div className="va-rbar-right">
          <ActionButtons compact={compact} totals={totals} ctaStrategy={ctaStrategy} paymentMode={paymentMode} onChangePaymentMode={onChangePaymentMode} />
        </div>
      </div>
      <style>{`
        .va-rbar{position:sticky;bottom:0;background:${R_SURFACE};border-top:1px solid ${R_BORDER_S};box-shadow:0 -8px 24px rgba(4,40,40,.06);z-index:30}
        .va-rbar-inner{max-width:1200px;margin:0 auto;display:flex;align-items:center;justify-content:space-between;gap:20px;padding:14px 24px}
        .va-rbar.is-compact .va-rbar-inner{flex-direction:column;align-items:stretch;gap:10px;padding:14px 16px}
        .va-rbar-left{display:flex;flex-direction:column;gap:0}
        .va-rbar-eyebrow{font-size:10.5px;font-weight:900;color:${R_MUTED};text-transform:uppercase;letter-spacing:1.2px}
        .va-rbar-amount{font-size:24px;font-weight:900;color:${R_TEAL};letter-spacing:-.02em;line-height:1.1}
        .va-rbar-left em{font-size:10.5px;color:${R_MUTED};font-style:normal;font-weight:500}
        .va-rbar-right{flex:1;max-width:560px}
        .va-rbar.is-compact .va-rbar-right{max-width:100%}
      `}</style>
    </div>);

}

// ─── RecapScreen (main) ───────────────────────────────────────
function RecapScreen({ compact = false, tweaks = {} }) {
  const fidelity = tweaks.fidelity || 'free'; // iso | free
  const layout = tweaks.layout || 'sidebar'; // single | sidebar | sections
  const ctaStrategy = tweaks.ctaStrategy || 'dual'; // dual | single | toggle
  const trustBlock = tweaks.trustBlock !== false; // bool
  const cautionStyle = tweaks.cautionStyle || 'block'; // block | line

  const [paymentMode, setPaymentMode] = React.useState('pay');
  const totals = React.useMemo(() => computeTotals(), []);

  // En mobile : on passe toujours en "sections + bottom bar" (layout C)
  const effectiveLayout = compact ? 'sections' : layout;

  const back =
  <a href="#" onClick={(e) => e.preventDefault()} className="va-rback">
      <svg width="14" height="14" fill="none" stroke="currentColor" strokeWidth="2.2" viewBox="0 0 24 24">
        <path strokeLinecap="round" strokeLinejoin="round" d="M15 19l-7-7 7-7" />
      </svg>
      Retour aux coordonnées
    </a>;


  const header = fidelity === 'free' ?
  <header className="va-rhero">
      <div className="va-rhero-bg" style={{ backgroundImage: `url(${RC_VEHICLE.picture})` }} />
      <div className="va-rhero-grad" />
      <div className="va-rhero-body">
        {back}
        <span className="va-rhero-eyebrow">Dernière étape avant le départ</span>
        <h1>Vous êtes prêt·e à prendre la route.</h1>
        <p>Une dernière vérification — puis on vous remet les clés.</p>
        <div className="va-rhero-pills">
          <span className="va-rhero-pill"><svg width="12" height="12" fill="none" stroke="currentColor" strokeWidth="2.2" viewBox="0 0 24 24"><circle cx="12" cy="12" r="10" /><path d="M12 6v6l4 2" /></svg>{RC_SEARCH.days} jours</span>
          <span className="va-rhero-pill"><svg width="12" height="12" fill="none" stroke="currentColor" strokeWidth="2.2" viewBox="0 0 24 24"><path strokeLinecap="round" strokeLinejoin="round" d="M17.657 16.657L13.414 20.9a2 2 0 01-2.827 0l-4.244-4.243a8 8 0 1111.314 0z" /><circle cx="12" cy="11" r="2.5" /></svg>{RC_SEARCH.agencyName.split(' - ')[1]}</span>
          <span className="va-rhero-pill">{RC_VEHICLE.display_name}</span>
        </div>
      </div>
      <style>{`
        .va-rhero{position:relative;border-radius:24px;overflow:hidden;min-height:${compact ? 220 : 260}px;display:flex;align-items:flex-end;color:#fff;box-shadow:0 1px 2px rgba(4,40,40,.08),0 18px 50px rgba(4,40,40,.18)}
        .va-rhero-bg{position:absolute;inset:0;background-size:cover;background-position:center;filter:saturate(1.05)}
        .va-rhero-grad{position:absolute;inset:0;background:linear-gradient(180deg,rgba(4,40,40,.15) 0%,rgba(4,40,40,.55) 60%,rgba(4,40,40,.85) 100%)}
        .va-rhero-body{position:relative;padding:${compact ? '20px 18px' : '32px 36px'};display:flex;flex-direction:column;gap:${compact ? '8px' : '10px'};max-width:760px}
        .va-rhero-body .va-rback{color:#cfeae8;background:rgba(255,255,255,.08);backdrop-filter:blur(6px);margin-bottom:6px}
        .va-rhero-body .va-rback:hover{color:#fff;background:rgba(255,255,255,.16)}
        .va-rhero-eyebrow{font-size:11px;font-weight:900;color:${R_BG_TEAL};text-transform:uppercase;letter-spacing:1.6px}
        .va-rhero h1{margin:0;font-size:${compact ? 26 : 36}px;font-weight:900;letter-spacing:-.02em;line-height:1.05;color:#fff;text-wrap:pretty}
        .va-rhero p{margin:0;font-size:14px;color:rgba(255,255,255,.85);font-weight:500}
        .va-rhero-pills{display:flex;flex-wrap:wrap;gap:6px;margin-top:6px}
        .va-rhero-pill{display:inline-flex;align-items:center;gap:5px;font-size:11.5px;font-weight:700;color:#fff;background:rgba(255,255,255,.14);border:1px solid rgba(255,255,255,.18);backdrop-filter:blur(8px);padding:5px 11px;border-radius:999px}
      `}</style>
    </header> :

  <header className="va-rheader">
      {back}
      <h1>Récapitulatif de votre commande</h1>
      <p>Vérifiez les détails ci-dessous, puis confirmez votre réservation.</p>
    </header>;


  // Sections (réutilisées par tous les layouts)
  const sections =
  <>
      <section className="va-rsec">
        <SectionHead num={1} title="Votre voyage" onEdit={() => {}} />
        <TripBlock compact={compact} fidelity={fidelity} />
      </section>

      <section className="va-rsec">
        <SectionHead num={2} title="Votre véhicule" onEdit={() => {}} />
        <VehicleBlock compact={compact} fidelity={fidelity} />
      </section>

      <section className="va-rsec">
        <SectionHead num={3} title="Configuration" onEdit={() => {}} />
        <div className="va-rsec-stack">
          <MileageBlock />
          <InsuranceBlock />
        </div>
      </section>

      {RC_OPTIONS_INCLUDED.length + RC_OPTIONS_PAID.length > 0 &&
    <section className="va-rsec">
          <SectionHead num={4} title={`Options (${RC_OPTIONS_INCLUDED.length + RC_OPTIONS_PAID.length})`} onEdit={() => {}} />
          <OptionsBlock />
        </section>
    }

      <section className="va-rsec">
        <SectionHead num={5} title="Votre voyage" onEdit={() => {}} />
        <CustomerBlock />
      </section>

      <section className="va-rsec">
        <CautionBlock cautionStyle={cautionStyle} />
      </section>

      {trustBlock &&
    <section className="va-rsec">
          <TrustBlock compact={compact} />
        </section>
    }
    </>;


  // Layout A — colonne unique centrée + total inline + boutons
  if (effectiveLayout === 'single') {
    return (
      <>
        <div className={`va-recap is-single fid-${fidelity} ${compact ? 'is-compact' : ''}`}>
          {header}
          {sections}

          <section className="va-rsec va-rsec-total-inline">
            <div className="va-rtotal-inline">
              <span>Montant total TTC</span>
              <strong>{rfmtPrice(totals.total)}</strong>
            </div>
            <div className="va-rtotal-detail">
              <span>Véhicule {rfmtPrice(totals.v)} · Km {rfmtPrice(totals.m)} · Assurance {rfmtPrice(totals.i)} · Options {rfmtPrice(totals.opts)}{totals.discount > 0 ? ` · Promo −${rfmtPrice(totals.discount)}` : ''}</span>
              <em>dont {rfmtPrice(totals.tva)} de TVA incluse</em>
            </div>
          </section>

          <section className="va-rsec va-rsec-actions">
            <ActionButtons compact={compact} totals={totals} ctaStrategy={ctaStrategy} paymentMode={paymentMode} onChangePaymentMode={setPaymentMode} />
          </section>
        </div>
        <RecapStyles />
      </>);

  }

  // Layout B — main + sidebar sticky (desktop only — mobile fallback C)
  if (effectiveLayout === 'sidebar') {
    return (
      <>
        <div className={`va-recap is-sidebar fid-${fidelity} ${compact ? 'is-compact' : ''}`}>
          <main className="va-recap-main">
            {header}
            {sections}
          </main>
          <aside className="va-recap-side">
            <div className="va-recap-side-sticky">
              <RecapSidebar totals={totals} ctaStrategy={ctaStrategy} paymentMode={paymentMode} onChangePaymentMode={setPaymentMode} />
            </div>
          </aside>
        </div>
        <RecapStyles />
      </>);

  }

  // Layout C — sections + bottom bar sticky (default mobile, et option desktop)
  return (
    <>
      <div className={`va-recap is-sections fid-${fidelity} ${compact ? 'is-compact' : ''}`}>
        {header}
        {sections}
      </div>
      <RecapBottomBar compact={compact} totals={totals} ctaStrategy={ctaStrategy} paymentMode={paymentMode} onChangePaymentMode={setPaymentMode} />
      <RecapStyles />
    </>);

}

function RecapStyles() {
  return (
    <style>{`
      .va-recap{font-family:'Barlow',Helvetica,sans-serif;color:${R_INK}}
      .va-recap.is-single{max-width:760px;margin:0 auto;padding:28px 24px 60px;display:flex;flex-direction:column;gap:24px}
      .va-recap.is-sidebar{max-width:1200px;margin:0 auto;padding:28px 24px 60px;display:grid;grid-template-columns:1fr 360px;gap:32px;align-items:start}
      .va-recap.is-sections{max-width:920px;margin:0 auto;padding:28px 24px 24px;display:flex;flex-direction:column;gap:20px}
      .va-recap.is-compact.is-sections{padding:18px 16px 24px;gap:18px}

      /* Fidelity: free — sections en cards généreuses avec accent teal latéral */
      .va-recap.fid-free .va-rsec:not(.va-rsec-actions):not(.va-rsec-total-inline){background:${R_SURFACE};border:1px solid ${R_BORDER};border-radius:20px;padding:22px 24px;box-shadow:0 1px 2px rgba(4,40,40,.04),0 6px 24px rgba(4,40,40,.05);position:relative;overflow:hidden}
      .va-recap.fid-free .va-rsec:not(.va-rsec-actions):not(.va-rsec-total-inline)::before{content:'';position:absolute;left:0;top:0;bottom:0;width:4px;background:${R_TEAL};opacity:.85;border-radius:4px 0 0 4px}
      .va-recap.fid-free.is-compact .va-rsec:not(.va-rsec-actions):not(.va-rsec-total-inline){padding:18px 18px 18px 22px}
      /* Dans une card "free", les blocs internes deviennent flat (pas de double bordure) */
      .va-recap.fid-free .va-rsec .va-rtrip,
      .va-recap.fid-free .va-rsec .va-rveh,
      .va-recap.fid-free .va-rsec .va-rline,
      .va-recap.fid-free .va-rsec .va-rcust,
      .va-recap.fid-free .va-rsec .va-ropts-row{box-shadow:none;border:none;background:transparent;padding-left:0;padding-right:0}
      .va-recap.fid-free .va-rsec .va-ropts-row{padding:10px 0;border-bottom:1px dashed ${R_BORDER};border-radius:0}
      .va-recap.fid-free .va-rsec .va-ropts-row:last-child{border-bottom:none}
      .va-recap.fid-free .va-rsec .va-ropts-row-inc{background:${R_BG_TEAL};border:1px solid ${R_TEAL}33;padding:10px 14px;border-radius:12px;margin:2px 0}
      .va-recap.fid-free .va-rsec .va-rline{padding:12px 0;border-bottom:1px dashed ${R_BORDER};border-radius:0}
      .va-recap.fid-free .va-rsec .va-rline:last-child{border-bottom:none}
      .va-recap.fid-free .va-rsec .va-rveh{padding:0;gap:18px}
      .va-recap.fid-free .va-rsec .va-rcust{padding:0;background:transparent;border:none}

      /* Total inline plus impactant en mode libre */
      .va-recap.fid-free .va-rsec-total-inline{background:linear-gradient(135deg,#fbfffe 0%,${R_BG_TEAL} 100%);border:1px solid ${R_TEAL}40;padding:24px 28px;box-shadow:0 8px 28px rgba(17,151,143,.12)}
      .va-recap.fid-free .va-rtotal-inline strong{font-size:36px}

      .va-recap-main{display:flex;flex-direction:column;gap:24px}
      .va-recap-side{position:relative}
      .va-recap-side-sticky{position:sticky;top:96px}

      .va-rback{display:inline-flex;align-items:center;gap:5px;color:${R_MUTED};font-size:12.5px;font-weight:700;text-decoration:none;padding:4px 8px;border-radius:8px;transition:all .2s ease;margin-bottom:10px}
      .va-rback:hover{color:${R_TEAL};background:${R_BG_TEAL}}

      .va-rheader{display:flex;flex-direction:column;gap:6px}
      .va-rheader h1{margin:0;font-size:32px;font-weight:900;color:${R_INK};letter-spacing:-.02em;line-height:1.1}
      .va-recap.is-compact .va-rheader h1{font-size:24px}
      .va-rheader p{margin:0;font-size:14px;color:${R_MUTED};font-weight:500}

      .va-rsec{display:flex;flex-direction:column;gap:0}
      .va-rsec-stack{display:flex;flex-direction:column;gap:8px}

      .va-rsec-total-inline{padding:18px 22px;background:${R_BG_TEAL};border:1px solid ${R_TEAL}33;border-radius:18px;display:flex;flex-direction:column;gap:6px}
      .va-rtotal-inline{display:flex;justify-content:space-between;align-items:baseline}
      .va-rtotal-inline span{font-size:13px;font-weight:900;color:${R_INK};text-transform:uppercase;letter-spacing:1.2px}
      .va-rtotal-inline strong{font-size:30px;font-weight:900;color:${R_TEAL};letter-spacing:-.02em}
      .va-rtotal-detail{display:flex;flex-direction:column;gap:2px}
      .va-rtotal-detail span{font-size:11.5px;color:${R_MUTED};font-weight:600}
      .va-rtotal-detail em{font-size:10.5px;color:${R_MUTED};font-style:normal;font-weight:500}
    `}</style>);

}

Object.assign(window, { RecapScreen });