/* =========================
   VARIABLES
========================= */
:root {
    --primary-color: #1f7955;
    --secondary-color: #063127;
    --accent-color: #ff9800;
    --error-color: #c62828;

    --text-color: #2c2c2c;
    --muted-text: #6b7280;

    --bg-page: #f4f6f8;
    --card-bg: #ffffff;
    --section-bg: #f9fafb;

    --border-color: #e3e6ea;
    --input-border: #cfd6dd;

    --shadow-soft: 0 2px 8px rgba(0,0,0,0.04);

    --radius-small: 3px;
}

/* =========================
   RESET
========================= */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* =========================
   BODY
========================= */
body {
    font-family: 'Segoe UI', Roboto, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-color);
    background: var(--bg-page);
    padding: 40px 20px;
}

/* =========================
   H1 PRINCIPAL
========================= */
h1 {
    font-size: 32px;
    margin: auto;
    margin-bottom: 10px;
    text-align: center;
    color: var(--primary-color);
    letter-spacing: 0.5px;
}

h1::after {
    content: "";
    display: block;
    width: 70px;
    height: 3px;
    background: var(--primary-color);
    margin-top: 12px;
    margin: auto;
    text-align: center;

}

/* =========================
   MESSAGE COMPACT
========================= */
.alert-compact {
    margin: auto;
    text-align: center;
    margin-top: 15px;
    margin-bottom: 35px;
    padding: 14px 18px;
    background: #eef3f8;
    font-size: 1em;
}

.alert-compact a {
    color: var(--primary-color);
    font-weight: 500;
    text-decoration: none;
}

.alert-compact a:hover {
    text-decoration: underline;
}

/* =========================
   FORM
========================= */
form {
    max-width: 1100px;
    margin: auto;
}

/* =========================
   FIELDSET (SECTION)
========================= */
fieldset {
    border: 1px solid var(--border-color);
    background: var(--card-bg);
    padding: 40px 35px 35px 35px;
    margin-bottom: 45px;
    position: relative;
    box-shadow: var(--shadow-soft);
}

/* ===== NOUVEAU STYLE TITRE SECTION ===== */
legend {
    position: absolute;
    top: -14px;
    left: 0;
    background: var(--bg-page);
    padding: 0 15px 0 20px;
    font-size: 20px;
    font-weight: 600;
    color: var(--primary-color);
    border-left: 5px solid var(--primary-color);
    line-height: 28px;
}

/* =========================
   STRUCTURE INTERNE
========================= */
.form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 25px;
    margin-bottom: 22px;
}

.form-group {
    flex: 1;
    min-width: 220px;
}

.form-group.full-width {
    flex: 0 0 100%;
}

/* =========================
   LABELS
========================= */
.form-group label {
    display: block;
    margin-bottom: 4px;
    font-weight: 600;
    font-size: 0.95em;
    color: #2c2c2c;
}

.required:after {
    content: " *";
    color: var(--error-color);
}

.form-group .hint {
    font-size: 0.8rem;
    color: #7f8c8d;
    font-style: italic;
    margin-top: 0.2rem;
}
/* =========================
   INPUTS
========================= */
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--input-border);
    background: #fff;
    font-size: 0.95em;
    transition: 0.15s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 0 1px var(--primary-color);
}

input:required,
select:required,
textarea:required {
    border-left: 3px solid var(--accent-color);
}

textarea {
    resize: vertical;
    min-height: 80px;
}

/* =========================
   BOUTON PRINCIPAL
========================= */
.btn-submit {
    display: block;
    margin: 45px auto;
    padding: 12px 40px;
    background: var(--primary-color);
    color: #fff;
    font-size: 1em;
    border: none;
    cursor: pointer;
    transition: 0.2s ease;
}

.btn-submit:hover {
    background: var(--secondary-color);
}

/* =========================
   RESPONSIVE
========================= */
@media (max-width: 768px) {
    .form-row {
        flex-direction: column;
    }

    fieldset {
        padding: 30px 20px;
    }
}

/* ===============================
   SECTIONS INTERNES PLUS STRUCTURÉES
================================= */

.section {
    background: #fbfcfd;
    border: 1px solid #e6e9ee;
    padding: 30px;
    margin-bottom: 30px;
}

/* ===============================
   TITRES DE SECTION (H2)
================================= */

.section-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 20px;
    padding-bottom: 8px;
    border-bottom: 2px solid #e6e9ee;
    color: #1f4e79;
}

/* ===============================
   BLOC HELP (explications)
================================= */

.help {
    background: #f1f5f9;
    border-left: 4px solid #1f4e79;
    padding: 15px 18px;
    font-size: 0.9em;
    margin-bottom: 20px;
    line-height: 1.5;
}

.help ul {
    margin-top: 8px;
    margin-left: 20px;
}

.help p {
    margin-bottom: 8px;
}

/* ===============================
   LIGNES DYNAMIQUES (RÈGLES / INCLUS / OPTIONS)
================================= */
.regle-row,
.inclus-row,
.option-row {
    display: flex;
    gap: 12px;
    align-items: stretch;
    padding: 15px;
    border: 1px solid #e2e6ea;
    background: #ffffff;
    margin-bottom: 12px;
    transition: 0.2s ease;
}

/* Petit effet au hover */
.regle-row:hover,
.inclus-row:hover,
.option-row:hover {
    border-color: #cfd6dd;
    background: #fcfdff;
}

/* ===============================
   TEXTAREA STYLE PREMIUM
================================= */
.regle-description,
.inclus-description {
    flex: 1;
    border: 1px solid #d5dbe3;
    padding: 10px 12px;
    font-size: 0.95em;
    resize: vertical;
    min-height: 60px;
    transition: 0.15s ease;
}

.regle-description:focus,
.inclus-description:focus {
    border-color: #1f4e79;
    box-shadow: 0 0 0 1px #1f4e79;
    outline: none;
}

/* ===============================
   INPUTS OPTIONS
================================= */

.option-libelle {
    flex: 2;
    border: 1px solid #d5dbe3;
    padding: 10px 12px;
}

.option-row input[type="number"] {
    width: 120px;
    border: 1px solid #d5dbe3;
    padding: 10px 12px;
}

/* ===============================
   BOUTONS SUPPRESSION
================================= */

.remove_niveau,
.ligne-row .remove_ligne,
.remove_regle,
.remove_inclus,
.remove_option {
    background: #ffebee; 
    color: var(--error-color);
    width: 24px;
    height: 24px;
    border: 1px solid var(--error-color);
    border-radius: var(--radius-small);
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s ease;
    margin-left: 10px;
}

.remove_niveau:hover,
.ligne-row .remove_ligne:hover,
.remove_regle:hover,
.remove_inclus:hover,
.remove_option:hover {
    background: var(--error-color);
    color: white;
}


/* ===============================
   BOUTONS AJOUT
================================= */

.add-option {
    margin-top: 10px;
    padding: 10px 18px;
    background: #1f4e79;
    color: white;
    border: none;
    cursor: pointer;
    transition: 0.2s ease;
}

.add-option:hover {
    background: #163a5f;
}

/* ===============================
   CHECKBOX
================================= */

.checkbox-group {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
}

.checkbox-item {
    border: 1px solid #e5e7eb;
    padding: 8px 12px;
    cursor: pointer;
    transition: 0.15s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.checkbox-item input {
    display: none;
}

.checkbox-item:has(input:checked) {
    border-color: #1f4e79;
    background: #eef3f9;
}

/* ===============================
   SECTION DESCRIPTION DU LOGEMENT
================================= */

/* Conteneur des niveaux */
#niveaux_container {
    margin-top: 15px;
}

/* Style des sections de niveau */
.niveau-section {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    padding: 20px;
    margin-bottom: 20px;
    border-radius: var(--radius-small);
    box-shadow: var(--shadow-soft);
}

/* En-tête du niveau */
.niveau-header {
    display: flex;
    /* justify-content: space-between; */
    align-items: center;
    margin-bottom: 15px;
}

.niveau-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: #1f4e79;
;
    margin: 0;
}


/* Conteneur des lignes de description */
.lignes-container {
    margin-top: 10px;
}

/* Ligne de description */
.ligne-row {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    align-items: stretch;
}

.ligne-row textarea {
    flex: 1;
    border: 1px solid var(--input-border);
    padding: 10px 12px;
    font-size: 0.95em;
    resize: vertical;
    min-height: 40px;
    transition: 0.15s ease;
    border-radius: var(--radius-small);
}

.ligne-row textarea:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 1px var(--primary-color);
    outline: none;
}


/* Bouton d'ajout d'une ligne */
.add_ligne {
    margin-top: 10px;
    padding: 8px 15px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius-small);
    cursor: pointer;
    font-size: 0.9em;
    transition: 0.2s ease;
}

.add_ligne:hover {
    background: var(--secondary-color);
}

/* Bouton d'ajout d'un niveau */
/* #add_niveau {
    margin-top: 15px;
    padding: 10px 18px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius-small);
    cursor: pointer;
    font-size: 0.95em;
    transition: 0.2s ease;
}

#add_niveau:hover {
    background: var(--secondary-color);
} */






/* Bouton de suppression d'une ligne */
/* .ligne-row .remove_ligne {
    background: #ffebee; /* Fond clair rouge */
    /* color: var(--error-color);
    width: 24px;
    height: 24px;
    border: 1px solid var(--error-color);
    border-radius: var(--radius-small);
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s ease;
    margin-top: auto;
    margin-bottom: auto;
} */

/* .ligne-row .remove_ligne:hover {
    background: var(--error-color);
    color: white;
}  */

/*-------------------OPTIONS---------------*/
.options-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.option-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    border-radius: 8px;
    border: 1px solid #ddd;
    background-color: #fafafa;
    transition: all 0.2s ease;
}

.option-card:hover {
    border-color: #3498db;
    background-color: #f4faff;
}

.option-main {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    flex: 1;
}

.option-checkbox {
    transform: scale(1.2);
}

.option-info {
    display: flex;
    flex-direction: column;
}

.option-title {
    font-size: 1rem;
    color: #2c3e50;
}

.option-meta {
    font-size: 0.85rem;
    color: #7f8c8d;
}

.option-controls {
    display: flex;
    align-items: center;
    gap: 16px;
}

.option-qty,
.option-total {
    display: flex;
    flex-direction: column;
    font-size: 0.75rem;
    color: #555;
}

.option-qty input,
.option-total input {
    width: 70px;
    padding: 4px 6px;
    font-size: 0.9rem;
    text-align: right;
    border-radius: 4px;
    border: 1px solid #ccc;
}

/* Désactivé visuellement */
.option-card:not(.active) .option-controls {
    opacity: 0.4;
    pointer-events: none;
}

.option-card.active {
    border-color: #2ecc71;
    background-color: #f3fcf7;
}


.option-row {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 10px;
}

.option-row select {
    flex: 2;
    padding: 8px;
}

.option-row input[type="number"] {
    flex: 1;
    padding: 8px;
}