/* ============================================================
   CALLBACK FORM — Composant partagé (DRY)
   Utilisé par : landing.php, services.php
   ============================================================ */

/* --- Availability indicator (landing) --- */
.cbf-availability {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 13px;
    font-weight: var(--weight-medium);
    color: var(--success-green);
    margin-bottom: 10px;
    white-space: nowrap;
}

.cbf-availability-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: var(--success-green-light);
    border-radius: 50%;
    animation: cbf-pulse-green 2s ease-in-out infinite;
}

@keyframes cbf-pulse-green {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.5); opacity: 0.5; }
}

/* --- Error banner (server-side) --- */
.cbf-error-banner {
    background: var(--error-bg);
    color: var(--error-red-dark);
    border: 1px solid var(--error-border);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    font-size: 14px;
    margin-bottom: 16px;
    text-align: center;
}

/* --- Civility toggle --- */
.cbf-civility-group {
    margin-bottom: 16px;
    text-align: left;
}

.cbf-civility-toggle {
    display: flex;
    gap: 10px;
}

.cbf-civility-option {
    flex: 1;
    position: relative;
    cursor: pointer;
}

.cbf-civility-option input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.cbf-civility-option span {
    display: block;
    text-align: center;
    padding: 11px 16px;
    border: 2px solid #cbd5e1;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 16px;
    font-weight: var(--weight-medium);
    color: var(--text-dark);
    background: rgba(230, 243, 252, 0.3);
    transition: all 0.2s ease;
    user-select: none;
}

.cbf-civility-option:hover span {
    border-color: var(--primary-blue);
    color: var(--primary-blue);
    background: var(--surface);
}

.cbf-civility-option input[type="radio"]:checked + span {
    border-color: var(--primary-blue);
    background: var(--primary-blue);
    color: white;
    box-shadow: 0 2px 8px rgba(12, 113, 195, 0.25);
}

.cbf-civility-option input[type="radio"]:focus-visible + span {
    box-shadow: 0 0 0 4px rgba(12, 113, 195, 0.15);
}

/* Civility — field error */
.cbf-civility-group .cbf-field-error {
    display: block;
    font-size: 13px;
    color: var(--error-red);
    margin-top: 4px;
    font-weight: var(--weight-normal);
    min-height: 17px;
    visibility: visible;
}

.cbf-civility-group .cbf-field-error:empty {
    visibility: hidden;
}

.cbf-civility-option.cbf-civ-invalid span {
    border-color: var(--error-red);
    animation: cbf-shake 0.3s ease;
}

/* --- Fields row (name + phone + submit) --- */
.cbf-fields {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: flex-end;
    text-align: left;
}

.cbf-group {
    flex: 1;
    min-width: 180px;
}

.cbf-group label {
    display: block;
    font-size: 14px;
    font-weight: var(--weight-medium);
    color: var(--text-dark);
    margin-bottom: 6px;
}

.cbf-group input {
    width: 100%;
    padding: 12px 16px 12px 42px;
    border: 1.5px solid rgba(12, 113, 195, 0.25);
    border-radius: 14px;
    font-size: 15px;
    font-family: inherit;
    transition: var(--transition);
    background: rgba(230, 243, 252, 0.3);
    color: var(--text-dark);
    box-sizing: border-box;
}

.cbf-group input:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 4px rgba(12, 113, 195, 0.1);
}

/* Input icon */
.cbf-input-wrap {
    position: relative;
}

.cbf-input-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--primary-blue);
    opacity: 0.5;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.cbf-input-wrap input:focus ~ .cbf-input-icon,
.cbf-input-wrap:focus-within .cbf-input-icon {
    opacity: 1;
}

/* Field errors */
.cbf-fields .cbf-field-error {
    display: block;
    font-size: 13px;
    line-height: 1.3;
    color: var(--error-red);
    margin-top: 4px;
    font-weight: var(--weight-normal);
    min-height: 17px;
    visibility: visible;
}

.cbf-fields .cbf-field-error:empty {
    visibility: hidden;
}

.cbf-fields input.cbf-invalid {
    border-color: var(--error-red);
    animation: cbf-shake 0.3s ease;
}

@keyframes cbf-shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-4px); }
    40% { transform: translateX(4px); }
    60% { transform: translateX(-3px); }
    80% { transform: translateX(2px); }
}

/* --- Green CTA button --- */
.cbf-submit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    white-space: nowrap;
    flex-basis: 100%;
    background: var(--success-green);
    color: white;
    padding: 16px 32px;
    border-radius: var(--radius-pill);
    font-weight: var(--weight-bold);
    font-size: 17px;
    border: none;
    cursor: pointer;
    font-family: inherit;
    box-shadow: 0 4px 14px rgba(22, 163, 74, 0.35);
    transition: all 0.25s ease;
}

.cbf-submit:hover {
    background: color-mix(in srgb, var(--success-green) 85%, black);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(22, 163, 74, 0.45);
}

/* --- Submitting state --- */
.cbf-submitting {
    opacity: 0.75;
    cursor: not-allowed;
    pointer-events: none;
}

.cbf-spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 3px solid rgba(255, 255, 255, 0.35);
    border-top-color: white;
    border-radius: 50%;
    animation: cbf-spin 0.65s linear infinite;
    vertical-align: middle;
    margin-right: 6px;
}

@keyframes cbf-spin {
    to { transform: rotate(360deg); }
}

/* --- Reassurance --- */
.cbf-reassurance {
    margin-top: 16px;
    font-size: 12px;
    color: var(--text-muted);
    text-align: center;
}

/* --- Trust badges --- */
.cbf-badges {
    display: flex;
    gap: 20px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 16px;
}

.cbf-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: var(--weight-medium);
    color: var(--primary-blue);
    opacity: 0.7;
}

.cbf-badge svg {
    flex-shrink: 0;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 768px) {
    .cbf-fields {
        flex-direction: column;
    }

    .cbf-group {
        min-width: 0;
        width: 100%;
    }

    .cbf-group label {
        text-align: center;
    }

    .cbf-submit {
        width: 100%;
        font-size: 16px;
        padding: 14px 24px;
    }

    .cbf-input-icon {
        width: 16px;
        height: 16px;
    }
}

@media (max-width: 640px) {
    .cbf-civility-option span {
        padding: 10px 12px;
        font-size: 15px;
    }
}

@media (max-width: 540px) {
    /* Réduit le gap entre champs en colonne */
    .cbf-fields {
        gap: 8px;
    }

    /* Réduit la marge sous le bloc civilité */
    .cbf-civility-group {
        margin-bottom: 10px;
    }

    /* Supprime les blocs fantômes (3×17px = 51px invisible) quand aucune erreur */
    .cbf-field-error:empty {
        display: none;
        min-height: 0;
    }

    /* Réduit la marge sous le formulaire */
    .cbf-reassurance {
        margin-top: 10px;
    }
}
