/* ==============================
   Structure globale
============================== */

body {
    font-family: 'Inter', 'Segoe UI', Roboto, Arial, sans-serif;
    margin: 0;
    padding: 2rem;
    background: linear-gradient(135deg, #f8fafc 0%, #e0e7ff 100%);
    color: #23272f;
    min-height: 100vh;
    letter-spacing: 0.01em;
    -webkit-font-smoothing: antialiased;
}

h1, h2 {
    text-align: center;
    color: #2d3a4a;
    font-weight: 800;
    letter-spacing: 0.03em;
    margin-bottom: 1.5rem;
}

form {
    max-width: 900px;
    margin: auto;
    background: rgba(255,255,255,0.95);
    padding: 2.5rem 2rem;
    border-radius: 18px;
    box-shadow: 0 8px 32px rgba(60,72,100,0.10);
    border: 1.5px solid #e0e7ff;
}

/* ==============================
   Champs de formulaire
============================== */

fieldset {
    border: 2px solid #d1d5db;
    border-radius: 14px;
    padding: 1.5rem 1.2rem;
    margin-bottom: 2rem;
    background: #f4f7fb;
}

fieldset {
    min-width: 0;
}

legend {
    padding: 0 1.2rem;
    font-size: 1.15rem;
    font-weight: 700;
    color: #6366f1;
}

legend {
    display: block;
    width: 100%;
    white-space: normal;
    word-break: break-word;
}

label {
    display: block;
    margin-top: 1.1rem;
    font-weight: 600;
    color: #374151;
}

label.gras {
    font-weight: bold;
}

input[type="text"],
select {
    padding: 0.6rem 1rem;
    font-size: 1.05rem;
    border: 1.5px solid #c7d2fe;
    border-radius: 8px;
    margin-top: 0.3rem;
    background-color: #f8fafc;
}

/* ==============================
   Numérotation verticale alignée
============================== */

.num-range-vertical {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.num-range-vertical .num-row {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    align-items: baseline;
}

.num-range-vertical .num-row label {
    width: 40px;
}

.num-range-vertical .num-row input[type="text"] {
    flex-shrink: 0;
    height: 1.5rem;
    line-height: 1.2rem;
    padding: 0.2rem 0.4rem;
    font-size: 0.9rem;
}

/* ==============================
   Largeurs
============================== */

.w-70 { width: 90%; }
.w-60 { width: 60%; }
.w-50 { width: 70px; }
.w-10 { width: 45px; }

/* ==============================
   Focus
============================== */

input:focus,
select:focus {
    border-color: #6366f1;
    outline: none;
    box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}

select[multiple] {
    min-height: 180px;
    background: #f1f5f9;
}

/* ==============================
   Radios
============================== */

input[type="radio"] {
    margin-right: 0.5rem;
}

label input[type="radio"] {
    display: inline-block;
    width: auto;
    margin-top: 0;
}

/* ==============================
   Layout
============================== */

.row {
    display: flex;
    flex-wrap: nowrap;
    justify-content: center;
}

.form-group1,
.form-group2,
.form-group-wide,
.form-group-inline {
    display: flex;
    flex-direction: column;
}

.form-group1,
.form-group-wide,
.form-group-inline {
    align-items: center;
}

.form-group1 { flex: 1 1 30%; }
.form-group2 { flex: 1 1 30%; }
.form-group-wide { flex: 2 1 40%; }
.form-group-inline { flex: 1 1 45%; text-align: center; }

.separator {
    width: 1px;
    background-color: #ccc;
    margin: 0 0.5rem;
    align-self: stretch;
}

.separator2 {
    height: 1px;
    background-color: #ccc;
    width: 100%;
    margin: 1rem 0;
}

/* ==============================
   Select actions
============================== */

.select-actions {
    margin-top: 4px;
    display: flex;
    gap: 6px;
}

.btn-mini {
    font-size: 0.85em;
    padding: 3px 8px;
    cursor: pointer;
}

/* ==============================
   Alignement compact
============================== */

.row-compact {
    justify-content: center;
    align-items: center;
    margin-top: 1rem;
}

.inline-options {
    display: flex;
    gap: 1rem;
    margin-top: 0.4rem;
}

/* ==============================
   Admin
============================== */

.admin-wrapper {
    width: 100%;
    margin: 40px auto 0 auto;
    display: flex;
    justify-content: center;
}

.admin-section {
    text-align: center;
    padding: 28px 36px;
    max-width: 600px;
    width: 100%;
    background: rgba(236,239,255,0.98);
    border: 1.5px solid #c7d2fe;
    border-radius: 18px;
}

.admin-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 20px;
}

.admin-buttons .btn {
    padding: 13px 28px;
    background: linear-gradient(90deg,#22c55e 0%,#4ade80 100%);
}

/* Wrapper pour aligner select + alphabet */
.commune-wrapper {
    display: flex;
    gap: 8px; /* espace entre select et alphabet */
    align-items: flex-start; /* alignement en haut */
}

.editeur-wrapper {
	display: flex;
	gap: 8px;
	align-items: flex-start;
}

/* Select Communes - largeur et hauteur fixes */
#commune,
#editeur{
    width: 300px;  /* largeur fixe comme avant */
    height: 200px; /* hauteur fixe */
    overflow-y: auto;
    box-sizing: border-box; /* éviter élargissement par padding */
}

/* Alphabet sur 2 colonnes à droite du select */
.alphabet-bar {
    display: grid;
    grid-template-columns: repeat(2, 1fr); /* 2 colonnes */
    gap: 2px;
    height: 200px; /* même hauteur que le select */
}

/* Lettres normales */
.alphabet-bar .letter {
    cursor: pointer;
    font-size: 0.7rem;
    padding: 2px 4px;
    text-align: center;
    border-radius: 3px;
    background: #e5e7eb;
    line-height: 1;
    transition: all 0.15s ease;
}

/* Hover pour lettres cliquables seulement */
.alphabet-bar .letter:not(.disabled):hover {
    background: #3b82f6;
    color: #fff;
    transform: scale(1.05);
}

/* Lettre active */
.alphabet-bar .letter.active {
    background: #2563eb;
    color: white;
}

/* Lettres désactivées (aucune commune) */
.alphabet-bar .letter.disabled {
    background: #fff0f0 !important; /* fond très clair */
    color: red !important;          /* texte rouge */
    cursor: not-allowed;
    transform: none !important;
}

/* ==============================
   Responsive
============================== */
@media (max-width: 768px) {

	legend {
	        font-size: 1rem;
	        padding: 0 0.5rem;
	        text-align: center;
	}
	
    .alphabet-bar {
        display: none;
    }
    
    #search-commune,
    #search-editeur {
        display: none;
    }

    .commune-wrapper, .editeur-wrapper {
        flex-direction: column;
        align-items: stretch;
    }

    #commune,
    #editeur {
        width: 100%;
        height: auto;
        min-height: 120px;
    }

    form {
        padding: 1.1rem;
    }

    .row {
        flex-wrap: wrap;
    }

    .form-group1,
    .form-group2,
    .form-group-wide,
    .form-group-inline {
        flex: 1 1 100%;
    }

    .separator {
        display: none;
    }

    select[multiple] {
        min-height: 90px;
    }

    .actions-bar {
        flex-direction: column;
        align-items: center;
    }

    .actions-bar .btn {
        display: block;
        margin: 0.4rem auto;
        min-width: 140px;
    }

    .admin-section {
        padding: 18px 8px;
    }
}