/* ============================================================
   Formulaire de signature [formulaire_signature]
   Cible les classes générées par rp2027-signatures/templates/form.php
   ============================================================ */

/* Card wrapper */
.rp2027-form {
    background: var(--paper-0);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: var(--space-8);
    max-width: 640px;
    margin: 0 auto;
    font-family: var(--font-text);
}

/* ---- Champs ---- */

.rp2027-field {
    margin-bottom: var(--space-6);
}

.rp2027-field label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--ink-900);
    margin-bottom: var(--space-2);
}

.rp2027-field input[type="text"],
.rp2027-field input[type="email"],
.rp2027-field select {
    display: block;
    width: 100%;
    padding: var(--space-3) var(--space-4);
    border: 1.5px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--paper-0);
    font-family: var(--font-text);
    font-size: 1rem;
    color: var(--ink-900);
    transition: border-color .15s ease, box-shadow .15s ease;
}

.rp2027-field input:focus-visible,
.rp2027-field select:focus-visible {
    outline: none;
    border-color: var(--blue-600);
    box-shadow: var(--shadow-focus);
}

/* Ligne 2 colonnes (prénom / nom) */
.rp2027-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-4);
}

/* ---- Checkboxes ---- */

.rp2027-field--checkbox label {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    cursor: pointer;
    font-weight: 400;
}

.rp2027-field--checkbox input[type="checkbox"] {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    accent-color: var(--red-600);
    margin-top: 2px;
    cursor: pointer;
}

.rp2027-field--checkbox input[type="checkbox"]:focus-visible {
    outline: 3px solid rgba(27, 77, 143, .35);
    outline-offset: 2px;
}

/* ---- État erreur ---- */

.rp2027-field--error input,
.rp2027-field--error select {
    border-color: var(--red-600);
}

.rp2027-field-error {
    font-size: 0.8125rem;
    color: var(--red-600);
    margin-top: var(--space-1);
}

.rp2027-error {
    background: #fff0f0;
    border: 1px solid var(--red-600);
    border-radius: var(--radius-sm);
    padding: var(--space-4);
    color: var(--red-600);
    font-size: 0.9375rem;
    margin-bottom: var(--space-6);
}

/* ---- Hints & notes ---- */

.rp2027-field-hint,
.rp2027-note {
    display: block;
    font-size: 0.8125rem;
    color: var(--ink-500);
    margin-top: var(--space-1);
}

/* ---- Section 2 (accordéon — géré par plugin form.js avec hidden) ---- */

.rp2027-section2-wrapper {
    margin-bottom: var(--space-6);
}

.rp2027-accordion-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: var(--space-3) var(--space-4);
    background: var(--ink-900);
    color: var(--paper-0);
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-text);
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s ease;
}

.rp2027-accordion-toggle:hover {
    background: var(--ink-700);
}

.rp2027-accordion-toggle:focus-visible {
    outline: none;
    box-shadow: var(--shadow-focus);
}

.rp2027-accordion-icon {
    font-size: 1.25rem;
    line-height: 1;
}

.rp2027-section2 {
    border: 1px solid var(--line);
    border-top: none;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    padding: var(--space-6);
}

.rp2027-section2-intro {
    font-size: 0.875rem;
    color: var(--ink-500);
    margin-bottom: var(--space-4);
}

/* ---- Badge public ---- */

.rp2027-badge-public {
    font-size: 0.75rem;
    background: var(--blue-50);
    color: var(--blue-700);
    padding: 1px 6px;
    border-radius: var(--radius-pill);
    font-style: normal;
    font-weight: 600;
    vertical-align: middle;
}

/* ---- Bouton Signer ---- */

.rp2027-submit {
    display: block;
    width: 100%;
    padding: var(--space-4) var(--space-6);
    background: var(--red-600);
    color: var(--paper-0);
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-display);
    font-size: 1.0625rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: var(--shadow-accent);
    transition: filter .15s ease, box-shadow .15s ease;
    margin-bottom: var(--space-4);
}

.rp2027-submit:hover {
    filter: brightness(1.08);
}

.rp2027-submit:focus-visible {
    outline: none;
    box-shadow: var(--shadow-focus);
}

/* ---- Note RGPD ---- */

.rp2027-rgpd {
    font-size: 0.75rem;
    color: var(--ink-500);
    text-align: center;
    line-height: 1.5;
}

/* ---- Messages flash / succès / fermé ---- */

.rp2027-flash,
.rp2027-success {
    border-radius: var(--radius-sm);
    padding: var(--space-6);
    margin-bottom: var(--space-6);
    font-family: var(--font-text);
}

.rp2027-flash--success,
.rp2027-success {
    background: #f0faf5;
    border: 1px solid var(--green-600);
    color: #0f5132;
}

.rp2027-flash--error {
    background: #fff0f0;
    border: 1px solid var(--red-600);
    color: var(--red-600);
}

.rp2027-flash--info {
    background: var(--blue-50);
    border: 1px solid var(--blue-600);
    color: var(--blue-700);
}

.rp2027-closed {
    background: var(--paper-50);
    border-radius: var(--radius-sm);
    padding: var(--space-6);
    color: var(--ink-500);
    text-align: center;
    font-family: var(--font-text);
}

/* ---- Mobile ---- */

@media (max-width: 600px) {
    .rp2027-form {
        border-radius: 0;
        padding: var(--space-6) var(--space-4);
    }

    .rp2027-row {
        grid-template-columns: 1fr;
    }
}

/* ============================================================
   Bouton déclencheur (widget sidebar)
   ============================================================ */

.rp2027-widget-trigger {
    display: block;
    width: 100%;
    padding: var(--space-4) var(--space-6);
    background: var(--red-600);
    color: var(--paper-0);
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: var(--shadow-accent);
    transition: filter .15s ease;
    text-align: center;
    letter-spacing: 0.01em;
}

.rp2027-widget-trigger:hover {
    filter: brightness(1.08);
}

.rp2027-widget-trigger:focus-visible {
    outline: none;
    box-shadow: var(--shadow-focus);
}

/* ============================================================
   Overlay modal
   ============================================================ */

.rp2027-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(20, 35, 59, 0.55);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-4);
    backdrop-filter: blur(2px);
}

.rp2027-modal-overlay[hidden] {
    display: none;
}

/* ---- Dialog ---- */

.rp2027-modal {
    position: relative;
    background: var(--paper-0);
    border-radius: var(--radius-md);
    padding: var(--space-8);
    width: 100%;
    max-width: 560px;
    max-height: 92vh;
    overflow-y: auto;
    box-shadow: 0 24px 64px rgba(20, 35, 59, 0.28);
}

/* Formulaire dans la modale : supprimer l'enveloppe redondante */
.rp2027-modal .rp2027-form {
    box-shadow: none;
    padding: 0;
    max-width: none;
    margin: 0;
    border-radius: 0;
    background: transparent;
}

/* ---- Bouton fermer ---- */

.rp2027-modal__close {
    position: absolute;
    top: var(--space-3);
    right: var(--space-3);
    width: 32px;
    height: 32px;
    background: var(--paper-50);
    border: 1px solid var(--line);
    border-radius: var(--radius-pill);
    cursor: pointer;
    font-size: 1rem;
    color: var(--ink-700);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s ease;
    line-height: 1;
}

.rp2027-modal__close:hover {
    background: var(--paper-100);
    color: var(--ink-900);
}

.rp2027-modal__close:focus-visible {
    outline: none;
    box-shadow: var(--shadow-focus);
}

@media (max-width: 600px) {
    .rp2027-modal {
        padding: var(--space-6) var(--space-4);
        max-height: 96vh;
    }
}
