/* ==========================================================================
   Contracting Modal — multi-step lead form for /entreprises/financement-energetique
   ========================================================================== */

/* Overlay */
.cm-modal { position: fixed; inset: 0; z-index: 9999; display: none; align-items: flex-start; justify-content: center; padding: 40px 20px; overflow-y: auto; }
.cm-modal.is-open { display: flex; }
.cm-overlay { position: fixed; inset: 0; background: rgba(14, 36, 56, 0.78); backdrop-filter: blur(2px); z-index: 1; }
.cm-card { position: relative; z-index: 2; background: #fff; border-radius: 16px; max-width: 920px; width: 100%; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3); padding: 24px 36px 22px; margin: auto; }

/* Close button */
.cm-close { position: absolute; top: 16px; right: 16px; background: rgba(14,36,56,0.06); border: none; width: 36px; height: 36px; border-radius: 50%; cursor: pointer; font-size: 18px; color: #0e2438; display: flex; align-items: center; justify-content: center; transition: background .2s; }
.cm-close:hover { background: rgba(14,36,56,0.14); }

/* Progress bar */
.cm-progress { display: grid; grid-template-columns: repeat(5, 1fr); gap: 0; margin-bottom: 20px; padding-top: 6px; }
.cm-step { position: relative; text-align: center; padding: 0 8px; }
.cm-step::after { content: ""; position: absolute; top: 14px; left: 50%; right: -50%; height: 2px; background: #e2e6eb; z-index: 0; }
.cm-step:last-child::after { display: none; }
.cm-step.is-completed::after { background: #B22222; }
.cm-step-num { position: relative; z-index: 1; width: 28px; height: 28px; margin: 0 auto 6px; border-radius: 50%; background: #fff; border: 2px solid #e2e6eb; color: #98a3b0; font-weight: 700; font-size: 12.5px; display: flex; align-items: center; justify-content: center; transition: background .2s, border-color .2s, color .2s; }
.cm-step.is-active .cm-step-num { background: #B22222; border-color: #B22222; color: #fff; }
.cm-step.is-completed .cm-step-num { background: #B22222; border-color: #B22222; color: #fff; }
.cm-step-label { font-size: 12.5px; color: #98a3b0; font-weight: 500; }
.cm-step.is-active .cm-step-label, .cm-step.is-completed .cm-step-label { color: #0e2438; font-weight: 600; }
.cm-step.is-active .cm-step-label { border-bottom: 2px solid #B22222; padding-bottom: 4px; display: inline-block; }

.cm-step-meta { text-align: right; font-size: 12px; color: #98a3b0; margin-bottom: 10px; }

/* Panels */
.cm-panel { display: none; }
.cm-panel.is-active { display: block; animation: cm-fade .25s ease-out; }
@keyframes cm-fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.cm-panel-title { font-size: 24px; font-weight: 700; color: #0e2438; margin: 0 0 6px; }
.cm-panel-sub { font-size: 14px; color: #5a6573; margin: 0 0 20px; }
.cm-panel-section-label { display: block; font-size: 14px; font-weight: 600; color: #0e2438; margin: 22px 0 12px; }
.cm-panel-section-label .opt { font-weight: 400; color: #98a3b0; font-size: 13px; }

/* Radio grid (Step 1 project type, Step 3 financing model) */
.cm-radio-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
.cm-radio-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.cm-radio-card { position: relative; border: 2px solid #e2e6eb; border-radius: 10px; padding: 22px 14px 18px; text-align: center; cursor: pointer; transition: border-color .15s, background .15s, transform .1s; background: #fff; }
.cm-radio-card:hover { border-color: #c7ccd2; transform: translateY(-1px); }
.cm-radio-card input { position: absolute; opacity: 0; pointer-events: none; }
.cm-radio-card-icon { width: 44px; height: 44px; margin: 0 auto 10px; color: #B22222; font-size: 22px; display: flex; align-items: center; justify-content: center; }
.cm-radio-card-label { font-size: 13px; font-weight: 600; color: #0e2438; line-height: 1.3; }
.cm-radio-card-desc { font-size: 11.5px; color: #98a3b0; line-height: 1.4; margin-top: 6px; padding: 0 4px; }
.cm-radio-card-check { position: absolute; top: 10px; right: 10px; width: 22px; height: 22px; background: #B22222; color: #fff; border-radius: 50%; display: none; align-items: center; justify-content: center; font-size: 11px; }
.cm-radio-card input:checked ~ .cm-radio-card-check { display: flex; }
.cm-radio-card:has(input:checked) { border-color: #B22222; background: #fdf5f5; }

/* Financing model card (Step 3) — bigger, with bullets and ribbon */
.cm-radio-card.cm-model-card { padding: 28px 24px 22px; text-align: left; }
.cm-radio-card.cm-model-card .cm-radio-card-icon { margin: 0 0 14px; }
.cm-radio-card.cm-model-card .cm-model-title { font-size: 17px; font-weight: 700; color: #0e2438; margin: 0 0 8px; }
.cm-radio-card.cm-model-card .cm-model-desc { font-size: 13px; color: #5a6573; line-height: 1.5; margin: 0 0 14px; }
.cm-radio-card.cm-model-card .cm-model-bullets { list-style: none; padding: 0; margin: 0; }
.cm-radio-card.cm-model-card .cm-model-bullets li { font-size: 13px; color: #2c3e50; padding-left: 22px; position: relative; line-height: 1.45; margin-bottom: 6px; }
.cm-radio-card.cm-model-card .cm-model-bullets li::before { content: "\f00c"; font-family: "Font Awesome 6 Free"; font-weight: 900; color: #B22222; position: absolute; left: 0; top: 1px; font-size: 11px; }
.cm-radio-card.cm-model-card .cm-model-ribbon { position: absolute; top: 10px; right: 36px; background: #fbeaea; color: #B22222; font-size: 10.5px; font-weight: 700; letter-spacing: 0.6px; padding: 4px 9px; border-radius: 12px; }

/* Chip group (multi or single select) */
.cm-chip-group { display: flex; flex-wrap: wrap; gap: 10px; }
.cm-chip { position: relative; cursor: pointer; }
.cm-chip input { position: absolute; opacity: 0; pointer-events: none; }
.cm-chip-label { display: inline-flex; align-items: center; gap: 8px; padding: 10px 18px; border: 1.5px solid #e2e6eb; border-radius: 999px; font-size: 13.5px; color: #2c3e50; transition: border-color .15s, background .15s, color .15s; background: #fff; }
.cm-chip:hover .cm-chip-label { border-color: #c7ccd2; }
.cm-chip input:checked + .cm-chip-label { border-color: #B22222; background: #fdf5f5; color: #B22222; font-weight: 600; }
.cm-chip-label i { color: #B22222; font-size: 14px; }
.cm-chip input:checked + .cm-chip-label i { color: #B22222; }

/* Form row + inputs */
.cm-form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 22px; margin-bottom: 16px; }
.cm-form-group label { display: block; font-size: 13px; font-weight: 600; color: #0e2438; margin-bottom: 6px; }
.cm-form-group .req { color: #B22222; }
.cm-form-group input[type="text"], .cm-form-group input[type="email"], .cm-form-group input[type="tel"], .cm-form-group select, .cm-form-group textarea { width: 100%; padding: 11px 14px; border: 1.5px solid #e2e6eb; border-radius: 8px; font-size: 14px; color: #2c3e50; background: #fff; transition: border-color .15s, box-shadow .15s; box-sizing: border-box; font-family: inherit; }
.cm-form-group select { padding-left: 38px; appearance: none; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'><path d='M1 1L6 6L11 1' stroke='%2398a3b0' stroke-width='1.6' stroke-linecap='round'/></svg>"); background-repeat: no-repeat; background-position: right 14px center; }
.cm-form-group input:focus, .cm-form-group select:focus, .cm-form-group textarea:focus { outline: none; border-color: #B22222; box-shadow: 0 0 0 3px rgba(178,34,34,0.12); }
.cm-form-group textarea { resize: vertical; min-height: 110px; }
.cm-form-group .cm-input-with-icon { position: relative; }
.cm-form-group .cm-input-with-icon input, .cm-form-group .cm-input-with-icon select { padding-left: 38px; }
.cm-form-group .cm-input-with-icon i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: #98a3b0; font-size: 14px; pointer-events: none; }
.cm-charcount { font-size: 11.5px; color: #98a3b0; text-align: right; margin-top: 6px; }

/* Summary card (Step 4 + 5) */
.cm-summary { border: 1.5px solid #e2e6eb; border-radius: 10px; padding: 18px 22px; margin: 18px 0; }
.cm-summary-title { font-size: 15px; font-weight: 700; color: #0e2438; margin: 0 0 14px; }
.cm-summary-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px 18px; }
.cm-summary-item { display: flex; gap: 10px; align-items: flex-start; }
.cm-summary-item-icon { width: 32px; height: 32px; border-radius: 8px; background: #fbeaea; color: #B22222; display: flex; align-items: center; justify-content: center; font-size: 13px; flex-shrink: 0; }
.cm-summary-item-body small { display: block; font-size: 11.5px; color: #98a3b0; margin-bottom: 1px; }
.cm-summary-item-body strong { display: block; font-size: 13px; color: #0e2438; font-weight: 600; line-height: 1.3; }

/* Step 4 consent + secured */
.cm-consent { display: flex; align-items: flex-start; gap: 10px; margin: 18px 0 20px; font-size: 13px; color: #2c3e50; cursor: pointer; }
.cm-consent input { margin-top: 2px; accent-color: #B22222; }
.cm-secured { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: #98a3b0; }
.cm-secured i { color: #B22222; }
.cm-trust-note { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: #5a6573; margin: 8px 0 0; padding: 10px 14px; background: #f7f9fb; border-radius: 8px; }
.cm-trust-note i { color: #B22222; font-size: 12px; }

/* Step 5 success */
.cm-success-icon { width: 48px; height: 48px; background: #e6f5d4; color: #4a8a2a; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 22px; vertical-align: middle; margin-right: 12px; flex-shrink: 0; }
.cm-success-block { display: flex; align-items: center; margin-bottom: 14px; }
.cm-success-text h2 { font-size: 19px; color: #0e2438; margin: 0 0 2px; font-weight: 700; line-height: 1.25; }
.cm-success-text p { font-size: 13px; color: #5a6573; margin: 0; line-height: 1.4; }

.cm-summary-table { border: 1.5px solid #e2e6eb; border-radius: 10px; padding: 10px 18px; margin-bottom: 14px; display: grid; grid-template-columns: 1fr 1fr; column-gap: 24px; }
.cm-summary-table-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid #eef0f3; min-width: 0; }
.cm-summary-table-row:nth-last-child(-n+2) { border-bottom: none; }
.cm-summary-table-row > i { color: #B22222; font-size: 13px; width: 18px; flex-shrink: 0; }
.cm-summary-table-row > .label { color: #5a6573; font-size: 12px; flex: 1; min-width: 0; }
.cm-summary-table-row > .value { font-size: 12px; color: #0e2438; font-weight: 600; text-align: right; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.cm-next-steps { margin-top: 14px; }
.cm-next-steps-title { font-size: 14px; font-weight: 700; color: #0e2438; margin: 0 0 10px; }
.cm-next-steps-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.cm-next-step { background: #f7f9fb; border-radius: 8px; padding: 12px 14px; }
.cm-next-step-num { width: 24px; height: 24px; background: #fbeaea; color: #B22222; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px; margin-bottom: 6px; }
.cm-next-step strong { display: block; font-size: 13px; color: #0e2438; margin-bottom: 3px; }
.cm-next-step span { font-size: 12px; color: #5a6573; line-height: 1.4; }

/* Footer (Retour / Continuer / Help) */
.cm-footer { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-top: 14px; margin-top: 14px; border-top: 1px solid #eef0f3; flex-wrap: wrap; }
.cm-help { font-size: 13px; color: #5a6573; flex: 1; text-align: center; }
.cm-help a { color: #B22222; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.cm-btn-back, .cm-btn-next { padding: 12px 24px; border-radius: 8px; font-weight: 600; font-size: 14px; cursor: pointer; border: none; display: inline-flex; align-items: center; gap: 8px; transition: background .2s, opacity .2s; font-family: inherit; }
.cm-btn-back { background: #f0f2f5; color: #5a6573; }
.cm-btn-back:hover { background: #e2e6eb; }
.cm-btn-back:disabled { opacity: 0.4; cursor: not-allowed; }
.cm-btn-next { background: #B22222; color: #fff; }
.cm-btn-next:hover { background: #8b1a1a; }
.cm-btn-next:disabled { opacity: 0.5; cursor: not-allowed; }
.cm-btn-secondary { background: #fff; color: #0e2438; border: 1.5px solid #e2e6eb; padding: 12px 24px; border-radius: 8px; font-weight: 600; font-size: 14px; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; font-family: inherit; }
.cm-btn-secondary:hover { background: #f7f9fb; }

.cm-error { color: #B22222; font-size: 12.5px; margin-top: 6px; display: none; }
.cm-form-group.has-error input, .cm-form-group.has-error select, .cm-form-group.has-error textarea { border-color: #B22222; }
.cm-form-group.has-error .cm-error { display: block; }

.cm-loading { display: none; align-items: center; gap: 8px; }
.cm-loading.is-active { display: inline-flex; }
.cm-loading::before { content: ""; width: 14px; height: 14px; border: 2px solid #fff; border-top-color: transparent; border-radius: 50%; animation: cm-spin .7s linear infinite; }
@keyframes cm-spin { to { transform: rotate(360deg); } }

/* Mobile */
@media (max-width: 720px) {
    .cm-modal { padding: 0; }
    .cm-card { border-radius: 0; padding: 28px 20px 24px; min-height: 100vh; }
    .cm-progress { grid-template-columns: repeat(5, 1fr); margin-bottom: 24px; }
    .cm-step-label { font-size: 10.5px; }
    .cm-step-num { width: 28px; height: 28px; font-size: 12px; }
    .cm-radio-grid { grid-template-columns: repeat(2, 1fr); }
    .cm-radio-grid.cols-3 { grid-template-columns: 1fr; }
    .cm-form-row { grid-template-columns: 1fr; }
    .cm-summary-grid { grid-template-columns: repeat(2, 1fr); }
    .cm-summary-table { grid-template-columns: 1fr; column-gap: 0; }
    .cm-summary-table-row:nth-last-child(-n+2) { border-bottom: 1px solid #eef0f3; }
    .cm-summary-table-row:last-child { border-bottom: none; }
    .cm-next-steps-grid { grid-template-columns: 1fr; }
    .cm-panel-title { font-size: 22px; }
    .cm-footer { flex-direction: column-reverse; }
    .cm-help { order: 3; }
    .cm-btn-back, .cm-btn-next, .cm-btn-secondary { width: 100%; justify-content: center; }
}

/* Body scroll lock */
body.cm-open { overflow: hidden; }
