{#
  _modal_confirma_trimitere.html — modal REAL de confirmare tipata (PRD 5.19 D4/F4/F5).

  `hx-confirm` nativ (doar OK/Cancel) NU e suficient pentru o actiune ireversibila care
  trimite N prezentari catre RAR. Acest modal arata numarul + mediul tinta (Testare /
  PRODUCTIE) si — pentru PRODUCTIE — cere o confirmare tipata ("TRIMIT") inainte de a
  activa butonul. Reutilizat din:
    - _auto_send_toggle.html (auto-release OFF->ON), injectat OOB in #modal-confirma-slot;
    - _coada.html (bulk "Trimite toate (N)"), randat inline ascuns si aratat la click.

  Parametri (context):
    cf_id, cf_titlu, cf_count, cf_env ('prod'/'test'), cf_url, cf_vals (json string),
    cf_target, cf_swap, cf_confirm_label, cf_deschis (bool), csrf_token.
#}
{% set _prod = (cf_env == 'prod') %}
{% set _eb = eticheta_env(cf_env) %}
<div id="{{ cf_id }}" class="modal-overlay" role="dialog" aria-modal="true"
     aria-labelledby="{{ cf_id }}-titlu"{% if not cf_deschis %} hidden{% endif %}>
  <div class="modal-backdrop"
       onclick="this.closest('.modal-overlay').hidden=true"></div>
  <div class="modal-dialog" role="document" style="max-width:440px;">
    <button type="button" class="modal-close" aria-label="Anuleaza"
            onclick="this.closest('.modal-overlay').hidden=true">&times;</button>
    <h2 id="{{ cf_id }}-titlu" style="margin:0 0 10px; font-size:var(--fs-lg);">{{ cf_titlu }}</h2>
    <p style="margin:0 0 8px; font-size:var(--fs-sm);">
      Se trimit imediat <strong>{{ cf_count }}</strong>
      {{ 'prezentare' if cf_count == 1 else 'prezentari' }} catre
      <span class="{{ _eb[1] }}">{{ _eb[0] }}</span>.
    </p>
    <p style="margin:0 0 12px; font-size:var(--fs-sm); color:var(--warn); font-weight:600;">
      Declararea la RAR este ireversibila (FINALIZATA nu se poate anula).
    </p>

    {% if _prod %}
    {# Type-to-confirm DOAR pe PRODUCTIE: butonul ramane dezactivat pana se scrie TRIMIT. #}
    <label for="{{ cf_id }}-typ" style="display:block; font-size:var(--fs-xs); color:var(--muted); margin-bottom:4px;">
      Scrie <strong>TRIMIT</strong> pentru a confirma:
    </label>
    <input type="text" id="{{ cf_id }}-typ" autocomplete="off" autocapitalize="characters"
           style="width:100%; margin-bottom:12px; font-size:14px; padding:5px 8px;
                  border:1px solid var(--line); border-radius:5px; background:var(--card2); color:var(--ink);"
           oninput="document.getElementById('{{ cf_id }}-ok').disabled = (this.value.trim().toUpperCase() !== 'TRIMIT');">
    {% endif %}

    <div style="display:flex; gap:8px; justify-content:flex-end; flex-wrap:wrap;">
      <button type="button"
              onclick="this.closest('.modal-overlay').hidden=true"
              style="background:var(--card); color:var(--muted); border:1px solid var(--line);
                     padding:6px 14px; border-radius:6px; cursor:pointer; font-size:13px;">
        Anuleaza
      </button>
      <button type="button" id="{{ cf_id }}-ok"{% if _prod %} disabled{% endif %}
              hx-post="{{ cf_url }}"
              hx-vals='{{ cf_vals }}'
              hx-target="{{ cf_target }}"
              hx-swap="{{ cf_swap }}"
              hx-include="#{{ cf_id }}-csrf"
              onclick="this.closest('.modal-overlay').hidden=true"
              style="background:{% if _prod %}var(--err){% else %}var(--accent){% endif %};
                     color:#fff; border:none; padding:6px 14px; border-radius:6px;
                     cursor:pointer; font-size:13px; font-weight:600;">
        {{ cf_confirm_label }}
      </button>
      <input type="hidden" id="{{ cf_id }}-csrf" name="csrf_token" value="{{ csrf_token }}">
    </div>
  </div>
</div>
