/* ══════════════════════════════════════
   CHR Forms — Frontend CSS (v2)
   Aligné sur le design system CHR Avenir
   Breakpoint unique : 768px (md)
══════════════════════════════════════ */

/* ── Carte du formulaire ── */
.chr-form-wrap { max-width: 48rem; margin: 0 auto; }

.chr-form {
    background: rgba(255, 255, 255, 0.55);
    backdrop-filter: blur(16px) saturate(160%);
    -webkit-backdrop-filter: blur(16px) saturate(160%);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 16px;
    padding: 32px;
    box-shadow: 0 8px 32px rgba(27, 58, 92, 0.06);
    position: relative;
    overflow: hidden;
}
@media (min-width: 768px) {
    .chr-form { padding: 40px; }
}
/* (barre d'accent navy supprimée — ::before retiré) */

/* ── Section / fieldset ── */
.chr-form-section { margin-bottom: 40px; border: none; padding: 0; }
.chr-form-section:last-of-type { margin-bottom: 0; }

/* ── Légende de section ── */
.chr-field-heading {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.875rem;          /* 14px */
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--primary, #1B3A5C);
    margin-bottom: 4px;
    width: 100%;
}
.chr-heading-icon,
.chr-field-heading svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    color: var(--primary, #1B3A5C);
    stroke: var(--primary, #1B3A5C);
}

/* ── Grilles de champs ── */
.chr-form-fields { display: flex; flex-wrap: wrap; gap: 20px; }

/* Variantes de largeur (≥768px) */
.chr-field-w100 { width: 100%; }
.chr-field-w50  { width: calc(50% - 10px); }
.chr-field-w33  { width: calc(33.333% - 13.333px); }

/* ── Labels de champ ── */
.chr-form-field label {
    display: block;
    font-size: 0.75rem;           /* 12px */
    font-weight: 500;
    color: var(--muted-foreground, #8F8F8F);
    margin-bottom: 4px;
    text-transform: none;         /* sentence case */
}
.chr-req { color: var(--muted-foreground, #8F8F8F); margin-left: 2px; }

/* ── Inputs / select / textarea (base partagée) ── */
.chr-form-field input[type="text"],
.chr-form-field input[type="email"],
.chr-form-field input[type="tel"],
.chr-form-field input[type="number"],
.chr-form-field select,
.chr-form-field textarea {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border, #DDE1E6);
    border-radius: 8px;
    font-family: var(--font-main, 'Plus Jakarta Sans', sans-serif);
    font-size: 0.875rem;          /* 14px */
    color: var(--foreground, #1B3A5C);
    background: var(--background, #FAFAFA);
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}
.chr-form-field input:focus,
.chr-form-field select:focus,
.chr-form-field textarea:focus {
    outline: none;
    border-color: var(--primary, #1B3A5C);
    box-shadow: 0 0 0 2px rgba(27, 58, 92, 0.45);   /* ring 2px navy */
}
.chr-form-field input::placeholder,
.chr-form-field textarea::placeholder {
    color: var(--muted-foreground, #8F8F8F);
}

/* Textarea */
.chr-form-field textarea { resize: vertical; }
.chr-char-count { display: block; text-align: right; font-size: 0.75rem; color: var(--muted-foreground, #8F8F8F); margin-top: 4px; }

/* Flèche du select */
.chr-form-field select {
    appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238F8F8F' stroke-width='2.5'><path d='m6 9 6 6 6-6'/></svg>");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

/* ── Inputs avec icône à gauche (Email + Téléphone) ── */
/* Le wrapper n'entoure QUE l'input (le label reste au-dessus) */
.chr-input-icon { position: relative; }
.chr-input-icon .chr-field-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--muted-foreground, #8F8F8F);
    stroke: var(--muted-foreground, #8F8F8F);
    pointer-events: none;
}
.chr-input-icon input { padding-left: 40px; }

/* ── Radio & Checkbox ── */
.chr-radio-group, .chr-checkbox-group { display: flex; flex-direction: column; gap: 8px; }
.chr-radio-label, .chr-checkbox-label { display: flex; align-items: center; gap: 8px; font-size: 0.875rem; color: var(--foreground, #1B3A5C); cursor: pointer; padding: 6px 10px; border: 1px solid var(--border, #DDE1E6); border-radius: 8px; transition: border-color 0.2s; }
.chr-radio-label:hover, .chr-checkbox-label:hover { border-color: var(--primary, #1B3A5C); }
.chr-radio-label input, .chr-checkbox-label input { accent-color: var(--primary, #1B3A5C); }

/* ══════════════════════════════════════
   Équipements souhaités — Repeater
══════════════════════════════════════ */
.chr-woo-repeater { width: 100%; }

/* En-têtes de colonnes (≥768px uniquement) */
.chr-repeater-header { display: none; }
@media (min-width: 768px) {
    .chr-repeater-header {
        display: grid;
        grid-template-columns: 1fr 1.8fr 5rem 2.5rem;
        gap: 12px;
        margin-bottom: 5px;
        padding: 0 4px;
    }
}
.chr-repeater-header span {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--muted-foreground, #8F8F8F);
}

.chr-repeater-rows { display: flex; flex-direction: column; gap: 12px; }

/* Ligne — mobile = carte empilée */
.chr-repeater-row {
    position: relative;
    border: 1px solid rgba(221, 225, 230, 0.5);
    background: rgba(250, 250, 250, 0.5);
    border-radius: 8px;
    padding: 14px;
}
.chr-repeater-row > * + * { margin-top: 12px; }

/* Labels par champ (visibles en mobile, masqués en desktop) */
.chr-rr-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--muted-foreground, #8F8F8F);
    margin-bottom: 6px;
}

/* Ligne — desktop = grille nue */
@media (min-width: 768px) {
    .chr-repeater-row {
        display: grid;
        grid-template-columns: 1fr 1.8fr 5rem 2.5rem;
        gap: 12px;
        align-items: center;
        border: none;
        background: none;
        padding: 0;
    }
    .chr-repeater-row > * + * { margin-top: 0; }
    .chr-rr-label { display: none; }
}

/* Contrôles internes */
.chr-repeater-row select,
.chr-repeater-row input[type="number"],
.chr-repeater-row input[type="text"] {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border, #DDE1E6);
    border-radius: 8px;
    font-size: 0.875rem;
    background: var(--background, #FAFAFA);
    color: var(--foreground, #1B3A5C);
    box-sizing: border-box;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.chr-repeater-row select:focus,
.chr-repeater-row input:focus {
    outline: none;
    border-color: var(--primary, #1B3A5C);
    box-shadow: 0 0 0 2px rgba(27, 58, 92, 0.45);
}
.chr-repeater-row select {
    appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%238F8F8F' stroke-width='2.5'><path d='m6 9 6 6 6-6'/></svg>");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 30px;
}
.chr-repeater-row input[type="number"] { text-align: center; -moz-appearance: textfield; }
.chr-repeater-row input::-webkit-outer-spin-button,
.chr-repeater-row input::-webkit-inner-spin-button { -webkit-appearance: none; }

/* État désactivé (input produit sans catégorie sélectionnée) */
.chr-repeater-row input:disabled,
.chr-repeater-row select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ── Autocomplete produit ── */
.chr-autocomplete { position: relative; }
.chr-autocomplete-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 30;
    max-height: 256px;
    overflow-y: auto;
    border: 1px solid var(--border, #DDE1E6);
    border-radius: 8px;
    background: var(--card, #fff);
    box-shadow: 0 12px 32px rgba(27, 58, 92, 0.14);
}
.chr-suggestion {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px 12px;
    background: none;
    border: none;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s;
}
.chr-suggestion:hover,
.chr-suggestion:focus {
    background: rgba(27, 58, 92, 0.05);
    outline: none;
}
.chr-suggestion-thumb {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    border-radius: 6px;
    border: 1px solid rgba(221, 225, 230, 0.5);
    object-fit: cover;
}
.chr-suggestion-text { min-width: 0; }   /* permet le truncate */
.chr-suggestion-name {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--foreground, #1B3A5C);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.chr-suggestion-meta {
    font-size: 0.75rem;
    color: var(--muted-foreground, #8F8F8F);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.chr-suggestion-more {
    font-size: 0.75rem;
    color: var(--muted-foreground, #8F8F8F);
    padding: 8px 12px;
    border-top: 1px solid rgba(221, 225, 230, 0.4);
}

/* ── Bouton supprimer la ligne ── */
.chr-repeater-del {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 10px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--muted-foreground, #8F8F8F);
    border-radius: 8px;
    transition: background 0.2s, color 0.2s;
}
.chr-repeater-del svg { width: 15px; height: 15px; }
.chr-repeater-del:hover { background: rgba(239, 68, 68, 0.1); color: #EF4444; }
.chr-repeater-del:disabled { opacity: 0.3; pointer-events: none; }

/* Position du bouton supprimer en mobile (coin haut-droit de la carte) */
@media (max-width: 767px) {
    .chr-repeater-row .chr-repeater-del {
        position: absolute;
        top: 12px;
        right: 12px;
        margin-top: 0;
    }
    .chr-repeater-row { padding-right: 56px; }
}

/* ── Bouton "+ Ajouter un équipement" (ghost dashed) ── */
.chr-repeater-add {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 16px;
    padding: 10px 16px;
    border: 1px dashed rgba(27, 58, 92, 0.4);
    border-radius: 8px;
    background: rgba(27, 58, 92, 0.05);
    font-family: var(--font-main, sans-serif);
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--primary, #1B3A5C);
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}
.chr-repeater-add svg { width: 14px; height: 14px; }
.chr-repeater-add:hover { background: rgba(27, 58, 92, 0.1); }

/* ── Délai souhaité ── */
.chr-delai { margin-top: 24px; }
.chr-delai .chr-cal-icon {
    display: inline-block;
    width: 13px;
    height: 13px;
    margin-right: 4px;
    margin-top: -2px;
    vertical-align: middle;
    color: var(--muted-foreground, #8F8F8F);
    stroke: var(--muted-foreground, #8F8F8F);
}

/* ══════════════════════════════════════
   Submit / Messages / Loader
══════════════════════════════════════ */
.chr-form-submit { margin-top: 24px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.chr-form-btn { display: inline-flex; align-items: center; gap: 8px; padding: 13px 28px; background: var(--primary, #1B3A5C); color: #fff; border: none; border-radius: 9999px; font-family: var(--font-main, sans-serif); font-size: 0.9375rem; font-weight: 600; cursor: pointer; transition: background 0.2s, box-shadow 0.2s; }
.chr-form-btn:hover { background: var(--primary-light, #2a5080); box-shadow: 0 4px 16px rgba(27, 58, 92, 0.25); }
.chr-form-note { font-size: 0.75rem; color: var(--muted-foreground, #8F8F8F); }

.chr-form-message { padding: 14px 18px; border-radius: 8px; margin-top: 16px; font-size: 0.875rem; font-weight: 500; }
.chr-form-message.chr-msg-success { background: rgba(34, 197, 94, 0.08); border-left: 3px solid #22c55e; color: #166534; }
.chr-form-message.chr-msg-error { background: rgba(239, 68, 68, 0.08); border-left: 3px solid #EF4444; color: #991b1b; }

.chr-form-loader { margin-top: 16px; font-size: 0.875rem; color: var(--muted-foreground, #8F8F8F); display: flex; align-items: center; gap: 8px; }
.chr-form-spinner { width: 16px; height: 16px; border: 2px solid var(--border, #DDE1E6); border-top-color: var(--primary, #1B3A5C); border-radius: 50%; animation: chr-f-spin 0.6s linear infinite; }
@keyframes chr-f-spin { to { transform: rotate(360deg); } }

/* ══════════════════════════════════════
   Responsive < 768px
══════════════════════════════════════ */
@media (max-width: 767px) {
    .chr-field-w50, .chr-field-w33 { width: 100%; }
    .chr-form-submit { flex-direction: column; align-items: stretch; }
    .chr-form-btn { justify-content: center; }
    .chr-form-note { text-align: center; }
}