/**
 * Styles d'administration du plugin CSE Listes.
 */

.cse-listes-wrap .cse-actions-bar {
	margin: 16px 0 24px;
}

/* Sous-listes (titulaires / suppléants) */
.cse-sublist {
	margin-bottom: 32px;
	background: #fff;
	border: 1px solid #dcdcde;
	border-radius: 4px;
	padding: 12px 16px 16px;
}

.cse-sublist-head {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
	margin-bottom: 8px;
}

.cse-sublist-head h3 {
	margin: 0 8px 0 0;
	font-size: 15px;
}

/* Badges d'indicateurs */
.cse-badge {
	display: inline-block;
	padding: 3px 10px;
	border-radius: 12px;
	font-size: 12px;
	line-height: 1.6;
	background: #f0f0f1;
	color: #1d2327;
	white-space: nowrap;
}

.cse-badge-info {
	background: #e5f0fb;
	color: #0a4b78;
}

.cse-badge-ok {
	background: #e6f4ea;
	color: #14622b;
}

.cse-badge-warning {
	background: #fcf3d7;
	color: #7a5b00;
}

.cse-badge-danger {
	background: #fce8e8;
	color: #8a1f1f;
	font-weight: 600;
}

/* Tableau des candidats */
.cse-table .cse-col-handle {
	width: 28px;
	text-align: center;
}

.cse-table .cse-col-ordre {
	width: 56px;
	text-align: center;
}

.cse-handle {
	cursor: move;
	color: #787c82;
}

.cse-handle:hover {
	color: #135e96;
}

/* Ligne en rupture d'alternance */
.cse-table tr.cse-rupture td {
	background: #fcf3d7 !important;
}

.cse-table tr.cse-rupture .cse-col-ordre::after {
	content: " ⚠";
}

/* Ligne en cours de glissement */
.cse-sortable tr.cse-dragging {
	background: #f6f7f7;
	outline: 2px dashed #2271b1;
}

.cse-sortable .ui-sortable-placeholder {
	visibility: visible !important;
	background: #f0f6fc;
	height: 40px;
}

.cse-row-actions .button {
	margin-bottom: 2px;
}

.cse-move-select {
	max-width: 150px;
	vertical-align: middle;
}

.cse-empty {
	color: #787c82;
	font-style: italic;
}

/* ------------------------------------------------------------------ */
/* Vue par collège en deux colonnes (Titulaires | Suppléants)         */
/* ------------------------------------------------------------------ */
.cse-two-col {
	display: flex;
	gap: 20px;
	align-items: flex-start;
	margin-top: 16px;
}

.cse-col {
	flex: 1 1 0;
	min-width: 0;
	background: #fff;
	border: 1px solid #dcdcde;
	border-radius: 6px;
	padding: 12px 14px 14px;
}

.cse-col-head {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px;
	margin-bottom: 10px;
}

.cse-col-head h3 {
	margin: 0 6px 0 0;
	font-size: 14px;
}

/* Liste de cartes */
.cse-cards {
	margin: 0;
	padding: 0;
	list-style: none;
	min-height: 70px;
}

.cse-cards:empty::after {
	content: "Glissez un candidat ici";
	display: block;
	color: #787c82;
	font-style: italic;
	text-align: center;
	padding: 22px 10px;
	border: 2px dashed #dcdcde;
	border-radius: 4px;
}

.cse-card {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 8px 10px;
	margin: 0 0 8px;
	background: #f6f7f7;
	border: 1px solid #dcdcde;
	border-left: 4px solid #2271b1;
	border-radius: 4px;
}

/* Repère visuel du sexe via la bordure gauche */
.cse-card[data-sexe="F"] {
	border-left-color: #a7457f;
}

.cse-card.cse-rupture {
	background: #fcf3d7;
	border-left-color: #dba617;
}

.cse-card-order {
	font-weight: 600;
	min-width: 20px;
	text-align: center;
	color: #50575e;
}

.cse-card .cse-handle {
	cursor: move;
	color: #787c82;
	min-width: 20px;
	min-height: 20px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	touch-action: none;
}

.cse-card .cse-handle:hover {
	color: #135e96;
}

.cse-card-body {
	flex: 1 1 auto;
	min-width: 0;
}

.cse-card-name {
	font-weight: 600;
}

.cse-card-meta {
	display: block;
	color: #646970;
	font-size: 12px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.cse-sex {
	font-size: 11px;
	padding: 1px 6px;
	border-radius: 8px;
	background: #e0e0e0;
	color: #1d2327;
}

.cse-sex-F {
	background: #f3dbe9;
	color: #7a2e5e;
}

.cse-card-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 4px;
	align-items: center;
	justify-content: flex-end;
}

.cse-card-actions .cse-move-select {
	max-width: 130px;
}

/* Emplacement de dépôt pendant le glisser-déposer */
.cse-card-placeholder {
	border: 2px dashed #2271b1;
	background: #f0f6fc;
	border-radius: 4px;
	height: 48px;
	margin: 0 0 8px;
	list-style: none;
}

/* Empilement sur petit écran */
@media (max-width: 782px) {
	.cse-two-col {
		flex-direction: column;
	}
}

/* ------------------------------------------------------------------ */
/* Affichage front-office (shortcode [cse_listes])                    */
/* ------------------------------------------------------------------ */
.cse-listes-frontend {
	margin: 1em 0;
}

.cse-listes-frontend .cse-tabs {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	margin: 0 0 14px;
	border-bottom: 2px solid #dcdcde;
}

.cse-listes-frontend .cse-tab-btn {
	cursor: pointer;
	background: #f0f0f1;
	border: 1px solid #dcdcde;
	border-bottom: none;
	border-radius: 6px 6px 0 0;
	padding: 8px 14px;
	font-size: 14px;
	line-height: 1.4;
	color: #1d2327;
}

.cse-listes-frontend .cse-tab-btn.is-active {
	background: #fff;
	font-weight: 600;
	box-shadow: inset 0 -2px 0 #2271b1;
}

/* Habillage minimal des contrôles hors admin (les classes .button du
   back-office n'y sont pas stylées par défaut). */
.cse-listes-frontend .button {
	display: inline-block;
	padding: 3px 9px;
	border: 1px solid #2271b1;
	border-radius: 3px;
	background: #f6f7f7;
	color: #2271b1;
	text-decoration: none;
	font-size: 12px;
	line-height: 1.8;
	cursor: pointer;
}

.cse-listes-frontend .button-link-delete {
	border-color: #d63638;
	color: #d63638;
}

.cse-listes-frontend .cse-alert {
	background: #fce8e8;
	border: 1px solid #d63638;
	color: #8a1f1f;
	padding: 6px 10px;
	border-radius: 4px;
	margin: 0 0 8px;
}

.cse-listes-frontend .cse-alert p {
	margin: 0;
}

/* ------------------------------------------------------------------ */
/* Accès gestionnaire caché (hotspot + fenêtre de connexion)          */
/* ------------------------------------------------------------------ */
.cse-access-bar {
	margin: 0 0 12px;
}

/* Zone tactile invisible dans le coin supérieur gauche de l'écran */
.cse-access-hotspot {
	position: fixed;
	top: 0;
	left: 0;
	width: 64px;
	height: 64px;
	z-index: 99998;
	background: transparent;
	cursor: default;
}

/* Fenêtre modale de connexion */
.cse-access-modal {
	position: fixed;
	inset: 0;
	z-index: 99999;
	background: rgba(0, 0, 0, 0.5);
	display: flex;
	align-items: center;
	justify-content: center;
}

.cse-access-box {
	position: relative;
	background: #fff;
	color: #1d2327;
	width: 320px;
	max-width: 90vw;
	padding: 22px 22px 16px;
	border-radius: 8px;
	box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.cse-access-box h3 {
	margin: 0 0 12px;
}

.cse-access-box label {
	display: block;
	font-size: 13px;
	margin-bottom: 4px;
}

.cse-access-box input[type="text"],
.cse-access-box input[type="password"] {
	width: 100%;
	box-sizing: border-box;
	padding: 6px 8px;
}

.cse-access-close {
	position: absolute;
	top: 8px;
	right: 10px;
	border: none;
	background: none;
	font-size: 22px;
	line-height: 1;
	cursor: pointer;
	color: #646970;
}

.cse-access-error {
	background: #fce8e8;
	border: 1px solid #d63638;
	color: #8a1f1f;
	padding: 6px 10px;
	border-radius: 4px;
	font-size: 13px;
}

/* ------------------------------------------------------------------ */
/* Boutons de réordonnancement (alternative tactile au glisser-déposer)*/
/* ------------------------------------------------------------------ */
.cse-reorder {
	display: inline-flex;
	flex-direction: column;
	justify-content: center;
	margin-right: 2px;
}

.cse-reorder button {
	width: 28px;
	height: 22px;
	line-height: 20px;
	padding: 0;
	margin: 1px 0;
	border: 1px solid #dcdcde;
	background: #fff;
	color: #50575e;
	font-size: 11px;
	border-radius: 3px;
	cursor: pointer;
}

.cse-reorder button:hover {
	border-color: #2271b1;
	color: #2271b1;
}

.cse-card-actions .cse-toggle-col {
	white-space: nowrap;
}

/* Sur mobile, cibles tactiles plus confortables. */
@media (max-width: 782px) {
	.cse-reorder button {
		width: 34px;
		height: 30px;
		font-size: 13px;
	}
	.cse-card-actions .button {
		padding: 5px 10px;
	}
}

/* Boutons de déplacement de collège */
.cse-move-btns {
	display: inline-flex;
	flex-wrap: wrap;
	gap: 4px;
}
@media (max-width: 782px) {
	.cse-move-btns .button {
		padding: 5px 10px;
	}
}

/* Cible tactile agrandie du coin caché sur mobile */
@media (max-width: 782px) {
	.cse-access-hotspot {
		width: 84px;
		height: 84px;
	}
}

/* ------------------------------------------------------------------ */
/* Mise en page mobile des cartes : éviter tout débordement horizontal */
/* ------------------------------------------------------------------ */
.cse-col,
.cse-card {
	box-sizing: border-box;
	max-width: 100%;
}

@media (max-width: 782px) {
	/* La carte passe en multi-lignes : les actions descendent sous le nom. */
	.cse-card {
		flex-wrap: wrap;
	}
	.cse-card-body {
		flex: 1 1 auto;
		min-width: 0;
	}
	.cse-card-actions {
		flex: 1 1 100%;
		justify-content: flex-start;
		margin-top: 6px;
	}
	/* Le méta (magasin — poste) peut revenir à la ligne au lieu d'être tronqué. */
	.cse-card-meta {
		white-space: normal;
		overflow: visible;
		text-overflow: clip;
	}
}

/* ------------------------------------------------------------------ */
/* Cases vides (emplacements vacants)                                 */
/* ------------------------------------------------------------------ */
.cse-blank-tools {
	margin: 0 0 8px;
	font-size: 12px;
	color: #646970;
}

.cse-card-blank {
	background: repeating-linear-gradient(
		45deg,
		#fafafa,
		#fafafa 8px,
		#f0f0f1 8px,
		#f0f0f1 16px
	);
	border-style: dashed !important;
}

.cse-card-blank .cse-blank-label {
	color: #787c82;
	font-style: italic;
	font-weight: 500;
}

/* ------------------------------------------------------------------ */
/* Admin uniquement : fond très léger rose (F) / bleu (H)             */
/* (.wrap est propre aux écrans d'administration WordPress)           */
/* ------------------------------------------------------------------ */
.wrap.cse-listes-wrap .cse-card:not(.cse-rupture):not(.cse-card-blank)[data-sexe="F"] {
	background: #FCEFF5;
}

.wrap.cse-listes-wrap .cse-card:not(.cse-rupture):not(.cse-card-blank)[data-sexe="H"] {
	background: #EEF4FC;
}

/* ------------------------------------------------------------------ */
/* Alignement des rangs entre les deux colonnes (titulaire ↔ suppléant)*/
/* Toutes les cartes ont la même hauteur → le rang N d'une colonne fait */
/* face au rang N de l'autre.                                          */
/* ------------------------------------------------------------------ */
.cse-two-col .cse-card {
	height: 62px;
	overflow: hidden;
}

/* Les actions restent sur une seule ligne (sinon la carte grandit et casse
   l'alignement des rangs entre colonnes). */
.cse-two-col .cse-card-actions {
	flex-wrap: nowrap;
}

/* En-têtes de colonne de hauteur homogène pour que les listes démarrent
   à la même position verticale. */
.cse-two-col .cse-col-head {
	min-height: 54px;
	align-content: flex-start;
}

/* Sur mobile les colonnes sont empilées : l'alignement n'a plus de sens,
   on retire la hauteur fixe pour ne pas gaspiller d'espace ni rogner. */
@media (max-width: 782px) {
	.cse-two-col .cse-card {
		height: auto;
		overflow: visible;
	}
	.cse-two-col .cse-card-actions {
		flex-wrap: wrap;
	}
	.cse-two-col .cse-col-head {
		min-height: 0;
	}
}

/* ------------------------------------------------------------------ */
/* Desktop : hauteur de carte STRICTEMENT identique pour aligner les   */
/* rangs des deux colonnes. Les boutons restent sur une seule ligne,   */
/* le texte magasin/poste est tronqué si besoin.                       */
/* ------------------------------------------------------------------ */
@media (min-width: 783px) {
	.cse-two-col .cse-card {
		height: 60px;
		min-height: 60px;
		overflow: hidden;
	}

	.cse-two-col .cse-card-body {
		min-width: 0;
		overflow: hidden;
	}

	.cse-two-col .cse-card-name {
		white-space: nowrap;
	}

	.cse-two-col .cse-card-meta {
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
		max-width: 100%;
	}

	/* Actions : jamais sur deux lignes, boutons compacts. */
	.cse-two-col .cse-card-actions {
		flex-wrap: nowrap;
		flex: 0 0 auto;
	}

	.cse-two-col .cse-card-actions .button {
		padding: 2px 8px;
		font-size: 12px;
		line-height: 1.7;
		white-space: nowrap;
	}
}
