/* Reset & Base */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen,
        Ubuntu, Cantarell, sans-serif;
    background-color: #f0f2f5;
    color: #333;
    line-height: 1.6;
    min-height: 100vh;
    padding: 2rem 1rem;
}

/* Container */
.container {
    max-width: 720px;
    margin: 0 auto;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.08);
    padding: 2.5rem;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 2rem;
}

header h1 {
    font-size: 1.8rem;
    color: #1a1a2e;
    margin-bottom: 0.5rem;
}

.subtitle {
    color: #666;
    font-size: 1rem;
}

/* Form Layout */
form {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.2rem;
}

.form-row-3 {
    grid-template-columns: 1fr 1.5fr 1fr;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

/* Labels */
label {
    font-weight: 600;
    font-size: 0.9rem;
    color: #444;
}

.required {
    color: #e74c3c;
}

/* Inputs */
input[type="text"],
input[type="email"],
select,
textarea {
    width: 100%;
    padding: 0.7rem 0.9rem;
    border: 1.5px solid #ddd;
    border-radius: 8px;
    font-size: 0.95rem;
    font-family: inherit;
    color: #333;
    background: #fafafa;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.15);
    background: #fff;
}

input.invalid,
select.invalid {
    border-color: #e74c3c;
    box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.1);
}

textarea {
    resize: vertical;
    min-height: 100px;
}

select {
    cursor: pointer;
    appearance: none;
    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='%23666' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.9rem center;
    padding-right: 2.5rem;
}

/* Fieldset */
.form-fieldset {
    border: 1.5px solid #ddd;
    border-radius: 8px;
    padding: 1rem 1.2rem;
    transition: border-color 0.2s;
}

.form-fieldset.invalid {
    border-color: #e74c3c;
}

.form-fieldset legend {
    font-weight: 600;
    font-size: 0.9rem;
    color: #444;
    padding: 0 0.4rem;
}

/* Champ "Autre" conditionnel */
.autre-group {
    margin-top: 0.5rem;
}

/* Checkbox Grid (Type de structure) */
.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.6rem;
    margin-top: 0.5rem;
}

/* Checkbox & Radio */
.checkbox-label,
.radio-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 400;
    cursor: pointer;
    font-size: 0.9rem;
}

.checkbox-label input[type="checkbox"],
.radio-label input[type="radio"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #3498db;
}

/* Radio Group (Mode de gestion) */
.radio-group {
    display: flex;
    gap: 1.5rem;
    margin-top: 0.5rem;
}

/* Standalone checkbox (Projet d'ouverture) */
.checkbox-group {
    margin-top: 0.5rem;
}

.checkbox-standalone {
    font-size: 0.95rem;
    font-weight: 500;
}

/* Error Messages */
.error-message {
    font-size: 0.8rem;
    color: #e74c3c;
    min-height: 1rem;
}

.error-banner {
    margin-top: 1.5rem;
    padding: 1rem 1.5rem;
    background: #fdecea;
    border: 1px solid #f5c6cb;
    border-radius: 8px;
    color: #721c24;
    text-align: center;
}

/* Submit Button */
button[type="submit"] {
    margin-top: 0.5rem;
    padding: 0.85rem 2rem;
    background: #3498db;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

button[type="submit"]:hover {
    background: #2980b9;
}

button[type="submit"]:active {
    transform: scale(0.98);
}

button[type="submit"]:disabled {
    background: #95c4e8;
    cursor: not-allowed;
    transform: none;
}

/* Spinner */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    vertical-align: middle;
    margin-right: 0.4rem;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.btn-loader {
    align-items: center;
}

/* Success Message */
.success-message {
    text-align: center;
    padding: 2rem 1rem;
}

.success-icon {
    width: 64px;
    height: 64px;
    background: #27ae60;
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    margin: 0 auto 1rem;
}

.success-message h2 {
    color: #27ae60;
    margin-bottom: 0.5rem;
}

.success-message p {
    color: #666;
    margin-bottom: 1.5rem;
}

.btn-reset {
    padding: 0.7rem 1.5rem;
    background: #3498db;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-reset:hover {
    background: #2980b9;
}

/* Responsive */
@media (max-width: 600px) {
    body {
        padding: 1rem 0.5rem;
    }

    .container {
        padding: 1.5rem;
        border-radius: 8px;
    }

    header h1 {
        font-size: 1.4rem;
    }

    .form-row,
    .form-row-3 {
        grid-template-columns: 1fr;
    }

    .checkbox-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .radio-group {
        flex-direction: column;
        gap: 0.6rem;
    }
}
