/* ── CSFV Forms — Front-end ───────────────────────── */
/* Design fidèle aux maquettes CSFV                   */

:root {
    --csfv-primary: #004b66;
    --csfv-primary-hover: #006b8f;
    --csfv-accent: #e8f4f8;
    --csfv-border: #e2e8f0;
    --csfv-text: #1e293b;
    --csfv-label: #64748b;
    --csfv-placeholder: #94a3b8;
    --csfv-req: #f87171;
    --csfv-radius: 12px;
}

/* ── Layout grid ─────────────────────────────────── */
.csfv-form {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 20px;
    font-family: 'Inter', sans-serif;
}
.csfv-field.csfv-w-full  { grid-column: span 6; }
.csfv-field.csfv-w-half  { grid-column: span 3; }
.csfv-field.csfv-w-third { grid-column: span 2; }

@media (max-width: 640px) {
    .csfv-field.csfv-w-half,
    .csfv-field.csfv-w-third { grid-column: span 6; }
}

/* ── Labels ──────────────────────────────────────── */
.csfv-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--csfv-label);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 6px;
}
.csfv-req { color: var(--csfv-req); }

/* ── Inputs & Textareas & Selects ────────────────── */
.csfv-input {
    width: 100%;
    background: #fff;
    border: 1.5px solid var(--csfv-border);
    border-radius: var(--csfv-radius);
    padding: 12px 16px;
    font-size: 14px;
    color: var(--csfv-text);
    font-family: 'Inter', sans-serif;
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
    box-sizing: border-box;
    -webkit-appearance: none;
    appearance: none;
}
.csfv-input:focus {
    border-color: var(--csfv-primary);
    box-shadow: 0 0 0 3px rgba(0, 75, 102, 0.08);
}
.csfv-input::placeholder { color: var(--csfv-placeholder); }

textarea.csfv-input { resize: none; }

select.csfv-input {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
}

/* ── Invalid state ───────────────────────────────── */
.csfv-input.csfv-invalid,
.csfv-pill-wrap.csfv-invalid { border-color: var(--csfv-req) !important; }

/* ── Pills ───────────────────────────────────────── */
.csfv-pills-grid {
    display: grid;
    gap: 8px;
}
.csfv-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f8fafc;
    border: 1.5px solid var(--csfv-border);
    border-radius: var(--csfv-radius);
    padding: 10px 12px;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s, color 0.2s;
    user-select: none;
}
.csfv-pill:hover {
    border-color: var(--csfv-primary);
    background: var(--csfv-accent);
}
.csfv-pill-icon {
    font-size: 18px;
    color: var(--csfv-label);
    transition: color 0.2s;
}
.csfv-pill-text {
    font-size: 12px;
    font-weight: 500;
    color: #475569;
    transition: color 0.2s;
}

/* Pill checked */
.csfv-pill:has(input:checked) {
    background: var(--csfv-accent);
    border-color: var(--csfv-primary);
}
.csfv-pill:has(input:checked) .csfv-pill-icon { color: var(--csfv-primary); }
.csfv-pill:has(input:checked) .csfv-pill-text { color: var(--csfv-primary); font-weight: 600; }

/* Pills sans icône — style "time-pill" soins */
.csfv-pill:not(:has(.csfv-pill-icon)) {
    justify-content: center;
    text-align: center;
    padding: 10px 12px;
}
.csfv-pill:not(:has(.csfv-pill-icon)):has(input:checked) {
    background: var(--csfv-primary);
    border-color: var(--csfv-primary);
}
.csfv-pill:not(:has(.csfv-pill-icon)):has(input:checked) .csfv-pill-text {
    color: #fff;
}

/* sr-only (hidden inputs) */
.sr-only {
    position: absolute; width: 1px; height: 1px;
    padding: 0; margin: -1px; overflow: hidden;
    clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ── Checkbox (RGPD) ────────────────────────────── */
.csfv-checkbox {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    cursor: pointer;
}
.csfv-checkbox input[type="checkbox"] {
    margin-top: 2px;
    width: 16px; height: 16px;
    border-radius: 4px;
    border: 1.5px solid var(--csfv-border);
    accent-color: var(--csfv-primary);
    flex-shrink: 0;
    cursor: pointer;
}
.csfv-checkbox-text {
    font-size: 12px;
    color: var(--csfv-label);
    line-height: 1.6;
}
.csfv-checkbox-text a { color: var(--csfv-primary); text-decoration: underline; }

/* ── Submit button ───────────────────────────────── */
.csfv-submit {
    width: 100%;
    background: var(--csfv-primary);
    color: #fff;
    border: none;
    padding: 16px 24px;
    border-radius: var(--csfv-radius);
    font-size: 14px;
    font-weight: 700;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.csfv-submit:hover { background: var(--csfv-primary-hover); }
.csfv-submit:disabled { opacity: 0.6; cursor: wait; }
.csfv-submit .material-symbols-outlined { font-size: 18px; }

/* ── Loading spinner ─────────────────────────────── */
@keyframes csfv-spin { to { transform: rotate(360deg); } }
.csfv-spinner {
    display: inline-block; width: 18px; height: 18px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff; border-radius: 50%;
    animation: csfv-spin 0.6s linear infinite;
}

/* ── Success overlay ─────────────────────────────── */
.csfv-form-wrap { position: relative; }
.csfv-overlay {
    position: absolute; inset: 0; z-index: 10;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(4px);
    border-radius: var(--csfv-radius);
    display: flex; align-items: center; justify-content: center;
    opacity: 0;
    transition: opacity 0.4s ease;
}
.csfv-overlay.csfv-visible { opacity: 1; }

.csfv-overlay-card { text-align: center; padding: 40px; }
.csfv-overlay-icon {
    width: 56px; height: 56px; margin: 0 auto 16px;
    background: #dcfce7; border-radius: 16px;
    display: flex; align-items: center; justify-content: center;
}
.csfv-overlay-icon .material-symbols-outlined { font-size: 28px; color: #16a34a; }
.csfv-overlay-title { font-size: 18px; font-weight: 700; color: var(--csfv-text); margin: 0 0 6px; }
.csfv-overlay-msg { font-size: 14px; color: var(--csfv-label); margin: 0; }

/* ── Honeypot ────────────────────────────────────── */
.csfv-hp { position: absolute; left: -9999px; opacity: 0; height: 0; overflow: hidden; }

/* ── Error message ───────────────────────────────── */
.csfv-error-msg {
    grid-column: span 6;
    background: #fef2f2; border: 1px solid #fecaca; border-radius: var(--csfv-radius);
    padding: 12px 16px; color: #991b1b; font-size: 13px;
    display: none;
}
.csfv-error-msg.csfv-visible { display: block; }
