/* Formulaires : composants FormField, Input, Textarea, Select et Checkbox du design system.
   Classes posées par le thème Twig templates/form/theme.html.twig. */

.form {
    display: grid;
    gap: var(--space-5);
}

.form > .button {
    justify-self: start;
}

/* Champ : libellé, contrôle, puis erreur ou aide */
.field {
    display: grid;
    align-content: start;
    gap: 6px;
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
}

.field__label {
    display: flex;
    gap: 6px;
    align-items: baseline;
    padding: 0;
    font: var(--type-label);
    color: var(--text-primary);
}

/* Légende d'un groupe de cases : hors de la grille du fieldset, d'où la marge */
legend.field__label {
    margin-bottom: var(--space-2);
}

.field__hint {
    font: var(--type-body-sm);
    color: var(--text-secondary);
}

.field__error {
    font: var(--type-body-sm);
    font-weight: var(--weight-medium);
    color: var(--status-error);
}

/* Contrôle (Input) */
.control {
    width: 100%;
    height: var(--control-h-md);
    padding: 0 14px;
    border: var(--border-width) solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface-card);
    font: var(--type-body);
    color: var(--text-primary);
    appearance: none;
    transition:
        border-color var(--duration-fast) var(--ease-out),
        box-shadow var(--duration-fast) var(--ease-out);
}

.control::placeholder {
    color: var(--text-tertiary);
}

.control:hover {
    border-color: var(--steel-400);
}

.control:focus-visible {
    outline: none;
    border-color: var(--border-focus);
    border-radius: var(--radius-sm);
    box-shadow: 0 0 0 1px var(--border-focus);
}

.control[aria-invalid="true"],
.field--invalid .control {
    border-color: var(--status-error);
}

.control[aria-invalid="true"]:focus-visible,
.field--invalid .control:focus-visible {
    box-shadow: 0 0 0 1px var(--status-error);
}

.control:disabled {
    background: var(--surface-muted);
    color: var(--text-tertiary);
}

/* Sélecteur de fichier : le bouton du navigateur, centré dans le contrôle, à l'allure d'un bouton contour */
.control[type="file"] {
    height: auto;
    padding: var(--space-2) 14px;
}

.control[type="file"]::file-selector-button {
    margin-right: var(--space-3);
    padding: var(--space-2) var(--space-4);
    font: inherit;
    font-weight: var(--weight-semibold);
    color: var(--text-primary);
    background: var(--surface-card);
    border: var(--border-width) solid var(--border-strong);
    border-radius: var(--radius-sm);
    cursor: pointer;
}

.control[type="file"]::file-selector-button:hover {
    border-color: var(--text-primary);
}

.control--textarea {
    height: auto;
    min-height: 120px;
    padding: 12px 14px;
    line-height: var(--leading-normal);
    resize: vertical;
}

/* Liste déroulante : le chevron du design system (Lucide chevron-down), l'apparence native étant retirée */
.control--select {
    padding-right: 40px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%234A5157' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 18px;
    cursor: pointer;
}

/* Code de vérification : chiffres espacés, en police à chasse fixe */
.control--code {
    max-width: 12ch;
    font: var(--weight-medium) var(--text-xl) / 1 var(--font-mono);
    letter-spacing: 0.2em;
}

/* Case à cocher (Checkbox) : la vraie case reste dans le DOM, invisible, pour le clavier et les lecteurs d'écran */
.choices {
    display: grid;
    gap: var(--space-3);
}

.choice {
    position: relative;
    display: inline-flex;
    align-items: flex-start;
    gap: 10px;
    font: var(--type-body);
    color: var(--text-primary);
    cursor: pointer;
    user-select: none;
}

.choice__input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.choice__box {
    display: flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    margin-top: 2px;
    border: var(--border-width) solid var(--border-strong);
    border-radius: var(--radius-xs);
    background: var(--surface-card);
    color: var(--text-inverse);
    font-size: 14px;
    transition:
        background-color var(--duration-fast) var(--ease-out),
        border-color var(--duration-fast) var(--ease-out);
}

.choice__box svg {
    opacity: 0;
    stroke-width: 3;
}

.choice:hover .choice__box {
    border-color: var(--steel-500);
}

.choice__input:focus-visible + .choice__box {
    box-shadow: var(--shadow-focus);
}

.choice__input:checked + .choice__box {
    border-color: var(--steel-900);
    background: var(--steel-900);
}

.choice__input:checked + .choice__box svg {
    opacity: 1;
}

.choice__box--round {
    border-radius: 50%;
}

.choice__dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-inverse);
    opacity: 0;
}

.choice__input:checked + .choice__box .choice__dot {
    opacity: 1;
}

/* Choix exclusifs (boutons radio) sur une ligne, comme dans QuoteForm */
.choices:has(.choice__box--round):not(.choices--stacked) {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3) var(--space-6);
}

/* Champ piège (HoneypotType) : hors de l'écran plutôt que masqué, pour que les robots le remplissent */
.honeypot {
    position: absolute;
    left: -10000px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

.choice__text {
    display: grid;
    gap: 2px;
}

.choice__desc {
    font: var(--type-body-sm);
    color: var(--text-secondary);
}

/* Bouton d'action secondaire présenté comme un lien (renvoi d'un code…) */
.link-button {
    padding: 0;
    border: 0;
    background: none;
    font: inherit;
    color: var(--text-link);
    text-decoration: underline;
    text-decoration-color: var(--steel-300);
    text-underline-offset: 3px;
    cursor: pointer;
}

.link-button:hover {
    color: var(--text-link-hover);
    text-decoration-color: currentColor;
}
