/*!
 * Bibliothèque documentaire - frontend.css
 * (c) 2026 Jérôme Riboulet
 *
 * Variables CSS pour personnalisation thème : --bd-primary, --bd-bg-card, etc.
 */

.bd-library {
	--bd-primary: #2563eb;
	--bd-bg: transparent;
	--bd-bg-card: #ffffff;
	--bd-text: #1a1a1a;
	--bd-text-muted: #6b7280;
	--bd-border: #e5e7eb;
	--bd-radius: 8px;
	--bd-shadow: 0 1px 3px rgba(0,0,0,.08);
	--bd-shadow-hover: 0 8px 24px rgba(0,0,0,.1);

	display: grid;
	grid-template-columns: minmax(0, 220px) minmax(0, 1fr);
	grid-template-areas:
		"toolbar  toolbar"
		"filters  results";
	gap: 1.5rem;
	width: 100%;
	max-width: 100%;
	box-sizing: border-box;
	font-family: inherit;
	color: var(--bd-text);
}

.bd-library * { box-sizing: border-box; }

@media (max-width: 860px) {
	.bd-library {
		grid-template-columns: 1fr;
		grid-template-areas: "toolbar" "filters" "results";
	}
}

/* Pleine largeur : sort du conteneur du thème */
.bd-library--fullwidth {
	width: 100vw;
	max-width: 100vw;
	margin-left: calc(50% - 50vw);
	margin-right: calc(50% - 50vw);
	padding-left: clamp(1rem, 4vw, 3.5rem);
	padding-right: clamp(1rem, 4vw, 3.5rem);
	box-sizing: border-box;
}

/* ===== Toolbar ===== */
.bd-library__toolbar {
	grid-area: toolbar;
	display: flex;
	flex-wrap: wrap;
	gap: .75rem;
	align-items: center;
	padding: 0 0 1rem;
	border-bottom: 1px solid var(--bd-border);
}

.bd-library__search { flex: 1 1 220px; min-width: 200px; }

.bd-search-input {
	width: 100%;
	padding: .6rem .9rem;
	border: 1px solid var(--bd-border);
	border-radius: var(--bd-radius);
	font: inherit;
	background: var(--bd-bg-card);
}

.bd-search-input:focus { outline: 2px solid var(--bd-primary); outline-offset: 1px; }

.bd-library__view-toggle {
	display: inline-flex;
	border: 1px solid var(--bd-border);
	border-radius: var(--bd-radius);
	overflow: hidden;
	background: var(--bd-bg-card);
}

.bd-view-btn {
	background: transparent;
	border: 0;
	padding: .5rem .75rem;
	cursor: pointer;
	color: var(--bd-text-muted);
}

.bd-view-btn.is-active {
	background: var(--bd-primary);
	color: #fff;
}

.bd-sort-select {
	padding: .55rem .8rem;
	border: 1px solid var(--bd-border);
	border-radius: var(--bd-radius);
	font: inherit;
	background: var(--bd-bg-card);
}

/* ===== Boutons ===== */
.bd-btn {
	display: inline-flex;
	align-items: center;
	gap: .35rem;
	padding: .55rem 1rem;
	border-radius: var(--bd-radius);
	border: 1px solid var(--bd-border);
	background: var(--bd-bg-card);
	color: var(--bd-text);
	font: inherit;
	font-weight: 600;
	cursor: pointer;
	text-decoration: none;
	transition: background .15s, color .15s, border-color .15s, transform .15s;
}

.bd-btn:hover { background: #f3f4f6; }

.bd-btn--primary {
	background: var(--bd-primary);
	border-color: var(--bd-primary);
	color: #fff;
}

.bd-btn--primary:hover {
	color: #fff;
	filter: brightness(1.05);
	transform: translateY(-1px);
}

.bd-btn--ghost { background: transparent; }

.bd-btn--danger { background: #dc2626; border-color: #dc2626; color: #fff; }

/* ===== Filtres latéraux ===== */
.bd-library__filters {
	grid-area: filters;
	display: flex;
	flex-direction: column;
	gap: 1.5rem;
}

/* Barre de filtres déroulants : masquée sur desktop */
.bd-library__mobile-filters { display: none; }

@media (max-width: 860px) {
	/* On masque la colonne de pills et on affiche les listes déroulantes compactes */
	.bd-library__filters { display: none; }

	.bd-library__mobile-filters {
		display: flex;
		flex-wrap: wrap;
		gap: .4rem;
		flex-basis: 100%;
		width: 100%;
		order: 5; /* sous la recherche / les toggles */
	}

	.bd-mobile-filter {
		flex: 1 1 0;
		min-width: 0;
		padding: .5rem .6rem;
		font: inherit;
		font-size: .85rem;
		border: 1px solid var(--bd-border);
		border-radius: var(--bd-radius);
		background: var(--bd-bg-card);
		color: var(--bd-text);
		max-width: 100%;
	}
}

.bd-filter-group__title {
	font-size: .8rem;
	font-weight: 700;
	letter-spacing: .05em;
	text-transform: uppercase;
	color: var(--bd-text-muted);
	margin: 0 0 .5rem;
}

.bd-cat-list { list-style: none; margin: 0; padding: 0; }

.bd-cat-link {
	display: flex;
	align-items: center;
	gap: .4rem;
	width: 100%;
	padding: .4rem .5rem;
	background: transparent;
	border: 0;
	border-radius: 6px;
	cursor: pointer;
	font: inherit;
	color: inherit;
	text-align: left;
	transition: background .15s;
}

.bd-cat-link:hover { background: rgba(0,0,0,.04); }

.bd-cat-link.is-active {
	background: var(--bd-cat-color, var(--bd-primary));
	color: #fff !important;
}

.bd-cat-link.is-active .dashicons { color: #fff !important; }

.bd-cat-link__name { flex: 1; }
.bd-cat-link__count {
	font-size: .75rem;
	color: var(--bd-text-muted);
	padding: 2px 6px;
	background: rgba(0,0,0,.05);
	border-radius: 999px;
}

.bd-cat-link.is-active .bd-cat-link__count {
	background: rgba(255,255,255,.25);
	color: #fff;
}

.bd-type-pills, .bd-tag-pills {
	display: flex;
	flex-wrap: wrap;
	gap: .35rem;
}

.bd-press-filter-pills {
	display: flex;
	flex-wrap: wrap;
	gap: .35rem;
}

.bd-press-filter-pill {
	background: var(--bd-bg-card);
	border: 1px solid var(--bd-border);
	border-radius: 999px;
	padding: .35rem .8rem;
	font: inherit;
	font-size: .85rem;
	cursor: pointer;
	color: var(--bd-text-muted);
	transition: background .15s, color .15s, border-color .15s;
}

.bd-press-filter-pill:hover { color: #9333ea; border-color: #9333ea; }

.bd-press-filter-pill.is-active {
	background: #9333ea;
	color: #fff;
	border-color: #9333ea;
}

.bd-type-pill, .bd-tag-pill {
	background: var(--bd-bg-card);
	border: 1px solid var(--bd-border);
	border-radius: 999px;
	padding: .35rem .8rem;
	font: inherit;
	font-size: .85rem;
	cursor: pointer;
	color: var(--bd-text-muted);
	transition: background .15s, color .15s, border-color .15s;
}

.bd-type-pill:hover, .bd-tag-pill:hover { color: var(--bd-text); border-color: var(--bd-text); }

.bd-type-pill.is-active, .bd-tag-pill.is-active {
	background: var(--bd-primary);
	color: #fff;
	border-color: var(--bd-primary);
}

/* ===== Résultats ===== */
.bd-library__results { grid-area: results; min-width: 0; }

.bd-results__header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 1rem;
}

.bd-results__count {
	font-size: .9rem;
	color: var(--bd-text-muted);
}

.bd-loading { padding: 3rem 0; text-align: center; color: var(--bd-text-muted); }

/* Grille */
.bd-results__items[data-view="grid"] {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr));
	gap: 1.25rem;
}

.bd-results__items[data-view="grid"] .bd-card {
	position: relative;
	background: var(--bd-bg-card);
	border: 1px solid var(--bd-border);
	border-radius: var(--bd-radius);
	overflow: hidden;
	box-shadow: var(--bd-shadow);
	transition: transform .15s, box-shadow .15s;
	display: flex;
	flex-direction: column;
}

.bd-results__items[data-view="grid"] .bd-card:hover {
	transform: translateY(-2px);
	box-shadow: var(--bd-shadow-hover);
}

/* Icône de catégorie : badge en haut à gauche de la vignette (grille) */
.bd-results__items[data-view="grid"] .bd-card__caticon {
	position: absolute;
	top: .5rem; left: .5rem;
	z-index: 2;
	width: 34px; height: 34px;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(255,255,255,.95);
	border-radius: 50%;
	box-shadow: 0 1px 4px rgba(0,0,0,.18);
}
.bd-results__items[data-view="grid"] .bd-card__caticon .dashicons { font-size: 19px; width: 19px; height: 19px; line-height: 19px; }
.bd-results__items[data-view="grid"] .bd-card__caticon--empty { color: var(--bd-text-muted); }

.bd-card__thumb {
	position: relative;
	aspect-ratio: 4 / 3;
	background: #f3f4f6;
	display: flex;
	align-items: center;
	justify-content: center;
	overflow: hidden;
}

.bd-card__thumb img { width: 100%; height: 100%; object-fit: cover; }
.bd-card__thumb-placeholder {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%; height: 100%;
}

.bd-card__type-icon svg { width: 64px; height: 64px; }

.bd-card__type-badge {
	position: absolute;
	top: .5rem; right: .5rem;
	background: rgba(255,255,255,.95);
	border-radius: 4px;
	padding: 2px 8px;
	font-size: .7rem;
	font-weight: 700;
	letter-spacing: .04em;
	text-transform: uppercase;
}

.bd-card__body { padding: .85rem 1rem 1rem; display: flex; flex-direction: column; flex: 1; gap: .35rem; }

.bd-card__cats {
	display: flex;
	flex-wrap: wrap;
	gap: .25rem;
	margin-bottom: .25rem;
}

.bd-card__cat {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	padding: 2px 8px;
	border-radius: 999px;
	color: #fff;
	font-size: .72rem;
	font-weight: 700;
	letter-spacing: .02em;
	text-transform: uppercase;
}

.bd-card__cat .dashicons { font-size: 13px; width: 13px; height: 13px; line-height: 13px; }

/* Badge titre de presse (à côté des catégories) */
.bd-card__press {
	display: inline-flex;
	align-items: center;
	gap: 3px;
	padding: 2px 8px;
	border-radius: 999px;
	background: #9333ea;
	color: #fff;
	font-size: .72rem;
	font-weight: 700;
	letter-spacing: .02em;
	text-transform: uppercase;
}

.bd-card__press .dashicons { font-size: 13px; width: 13px; height: 13px; line-height: 13px; }

.bd-card__title { margin: 0; font-size: 1.1rem; line-height: 1.3; }

.bd-card__title a { color: inherit; text-decoration: none; }
.bd-card__title a:hover { text-decoration: underline; }

.bd-card__meta {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: .55rem;
	font-size: .9rem;
	color: var(--bd-text-muted);
}

.bd-card__type-text {
	font-weight: 700;
	color: var(--bd-text);
	text-transform: uppercase;
	letter-spacing: .02em;
}

/* Séparateur discret entre tous les éléments meta (Type · Date · Taille · Catégorie · Presse) */
.bd-card__meta > span + span::before {
	content: "·";
	margin-right: .55rem;
	color: var(--bd-text-muted);
	opacity: .6;
}

.bd-card__cat-text,
.bd-card__press-text { color: var(--bd-text-muted); }

/* Tags : ligne isolée, entre la meta et les actions */
.bd-card__tags {
	display: flex;
	flex-wrap: wrap;
	gap: .3rem;
}

.bd-card__tag {
	font-size: .78rem;
	color: var(--bd-text-muted);
	background: rgba(0,0,0,.05);
	padding: 2px 9px;
	border-radius: 999px;
	line-height: 1.5;
}

.bd-card__actions {
	display: flex;
	gap: .15rem;
	margin-top: auto;
	padding-top: .55rem;
	border-top: 1px solid var(--bd-border);
}

.bd-card__action {
	flex: 1;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: .4rem .25rem;
	background: transparent;
	border: 0;
	border-radius: 4px;
	cursor: pointer;
	color: var(--bd-text-muted);
	transition: background .15s, color .15s;
	text-decoration: none;
	font: inherit;
}

.bd-card__action:hover { background: rgba(0,0,0,.05); color: var(--bd-primary); }
.bd-card__action--danger:hover { color: #dc2626; }

.bd-card__action .dashicons { font-size: 17px; width: 17px; height: 17px; line-height: 17px; }

/* Liste condensée */
.bd-results__items[data-view="list"] {
	display: flex;
	flex-direction: column;
	gap: .3rem;
}

.bd-results__items[data-view="list"] .bd-card {
	display: grid;
	grid-template-columns: auto 1fr;
	gap: .75rem;
	align-items: center;
	padding: .5rem .7rem;
	background: var(--bd-bg-card);
	border: 1px solid var(--bd-border);
	border-radius: var(--bd-radius);
}

/* En liste : pas de miniature, mais une icône de catégorie à gauche */
.bd-results__items[data-view="list"] .bd-card__thumb { display: none; }

.bd-results__items[data-view="list"] .bd-card__caticon {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	flex: 0 0 40px;
}
.bd-results__items[data-view="list"] .bd-card__caticon .dashicons {
	font-size: 26px; width: 26px; height: 26px; line-height: 26px;
}
.bd-results__items[data-view="list"] .bd-card__caticon--empty { color: var(--bd-text-muted); opacity: .55; }

.bd-results__items[data-view="list"] .bd-card__body {
	padding: 0;
	gap: .2rem;
	flex-direction: column;
	justify-content: center;
}

/* En liste : titre + meta + tags sur des lignes serrées (mais lisibles) */
.bd-results__items[data-view="list"] .bd-card__title { font-size: 1.05rem; line-height: 1.25; }
.bd-results__items[data-view="list"] .bd-card__meta { font-size: .85rem; gap: .45rem; }
.bd-results__items[data-view="list"] .bd-card__tags { gap: .25rem; }

.bd-results__items[data-view="list"] .bd-card__actions {
	padding-top: 0;
	border-top: 0;
	gap: .05rem;
}

.bd-results__items[data-view="list"] .bd-card__action {
	flex: 0 0 auto;
	width: 34px;
	padding: .4rem;
}

/* Pagination */
.bd-results__pagination {
	display: flex;
	gap: .35rem;
	justify-content: center;
	margin-top: 1.5rem;
	flex-wrap: wrap;
}

.bd-page-btn {
	padding: .4rem .7rem;
	border: 1px solid var(--bd-border);
	background: var(--bd-bg-card);
	border-radius: 6px;
	font: inherit;
	cursor: pointer;
	min-width: 34px;
}

.bd-page-btn.is-active {
	background: var(--bd-primary);
	color: #fff;
	border-color: var(--bd-primary);
}

.bd-page-btn:disabled { opacity: .5; cursor: not-allowed; }

/* ===== Modal viewer ===== */
.bd-modal {
	position: fixed;
	inset: 0;
	z-index: 99999;
	display: flex;
	align-items: center;
	justify-content: center;
}

.bd-modal[hidden] { display: none; }

.bd-modal__backdrop {
	position: absolute;
	inset: 0;
	background: rgba(15, 23, 42, 0.85);
	backdrop-filter: blur(4px);
}

.bd-modal__panel {
	position: relative;
	z-index: 1;
	width: 92%;
	max-width: 1100px;
	max-height: 92vh;
	background: #fff;
	border-radius: 12px;
	display: flex;
	flex-direction: column;
	box-shadow: 0 24px 60px rgba(0,0,0,.4);
	overflow: hidden;
}

.bd-modal__panel--narrow { max-width: 520px; }

/* ===== Viewer en volet latéral droit (desktop) ===== */
@media (min-width: 861px) {
	.bd-modal--viewer {
		justify-content: flex-end;
	}
	.bd-modal--viewer .bd-modal__panel {
		width: 48%;
		max-width: 760px;
		height: 100vh;
		max-height: 100vh;
		border-radius: 0;
		box-shadow: -12px 0 40px rgba(0,0,0,.35);
		animation: bd-slide-in-right .25s ease;
	}
}

@keyframes bd-slide-in-right {
	from { transform: translateX(100%); }
	to   { transform: translateX(0); }
}

.bd-modal__header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 1rem;
	padding: 1rem 1.25rem;
	border-bottom: 1px solid var(--bd-border);
}

.bd-modal__title { margin: 0; font-size: 1.1rem; line-height: 1.3; }

.bd-modal__close {
	background: transparent;
	border: 0;
	cursor: pointer;
	padding: .35rem;
	border-radius: 6px;
	color: #6b7280;
}

.bd-modal__close:hover { background: #f3f4f6; color: #1a1a1a; }

.bd-modal__body {
	flex: 1;
	overflow: auto;
	background: #1a1a1a;
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 50vh;
}

.bd-modal__body iframe,
.bd-modal__body video,
.bd-modal__body img {
	width: 100%;
	height: 100%;
	max-height: 80vh;
	min-height: 60vh;
	border: 0;
	display: block;
}

.bd-modal__body img { object-fit: contain; background: #1a1a1a; }

.bd-modal__body--message {
	display: flex;
	flex-direction: column;
	gap: 1rem;
	text-align: center;
	padding: 3rem 2rem;
	background: #f9fafb;
	color: #1a1a1a;
}

.bd-modal__footer {
	display: flex;
	gap: .5rem;
	padding: .85rem 1.25rem;
	background: #f9fafb;
	border-top: 1px solid var(--bd-border);
	flex-wrap: wrap;
}

.bd-modal--form .bd-modal__body { background: #fff; padding: 1.25rem; min-height: auto; display: block; }

/* Form : marges internes (les champs ne touchent plus les bords) */
.bd-form {
	padding: 1.5rem 1.75rem 1.75rem;
	overflow-y: auto;
	min-height: 0;
	flex: 1 1 auto;
}

.bd-modal--form .bd-modal__header { flex-shrink: 0; }

@media (max-width: 520px) {
	.bd-form { padding: 1.25rem 1.25rem 1.5rem; }
}

.bd-modal--form .bd-modal__header {
	padding: 1.1rem 1.75rem;
}

/* Tags existants cliquables dans le formulaire */
.bd-form__taglist {
	display: flex;
	flex-wrap: wrap;
	gap: .4rem;
	margin-top: .6rem;
}

.bd-form__tag {
	background: #f3f4f6;
	border: 1px solid var(--bd-border, #e5e7eb);
	border-radius: 999px;
	padding: .3rem .8rem;
	font: inherit;
	font-size: .82rem;
	cursor: pointer;
	color: var(--bd-text-muted, #6b7280);
	transition: background .15s, color .15s, border-color .15s;
}

.bd-form__tag:hover {
	border-color: var(--bd-primary, #2563eb);
	color: var(--bd-primary, #2563eb);
}

.bd-form__tag.is-active {
	background: var(--bd-primary, #2563eb);
	border-color: var(--bd-primary, #2563eb);
	color: #fff;
}

/* Étiquettes de presse (sélection unique) */
.bd-form__presslist {
	display: flex;
	flex-wrap: wrap;
	gap: .4rem;
	margin-top: .6rem;
}

.bd-form__press {
	background: #fff;
	border: 1px solid var(--bd-border, #e5e7eb);
	border-radius: var(--bd-radius, 8px);
	padding: .3rem .8rem;
	font: inherit;
	font-size: .82rem;
	cursor: pointer;
	color: var(--bd-text-muted, #6b7280);
	transition: background .15s, color .15s, border-color .15s;
}

.bd-form__press:hover {
	border-color: #9333ea;
	color: #9333ea;
}

.bd-form__press.is-active {
	background: #9333ea;
	border-color: #9333ea;
	color: #fff;
}

/* Form */
.bd-form__field { margin-bottom: 1rem; }
.bd-form__field label { display: block; font-weight: 600; margin-bottom: .35rem; }
.bd-form__field input[type="text"],
.bd-form__field input[type="email"],
.bd-form__field input[type="file"],
.bd-form__field textarea,
.bd-form__field select {
	width: 100%;
	padding: .55rem .8rem;
	border: 1px solid var(--bd-border);
	border-radius: var(--bd-radius);
	font: inherit;
	background: #fff;
}

.bd-form__hint { font-size: .8rem; color: var(--bd-text-muted); margin: .35rem 0 0; }
.bd-form__current { font-size: .85rem; color: var(--bd-text-muted); margin: .35rem 0 0; }
.bd-required { color: #dc2626; }

.bd-form__categories {
	max-height: 180px;
	overflow-y: auto;
	padding: .5rem;
	border: 1px solid var(--bd-border);
	border-radius: var(--bd-radius);
	background: #f9fafb;
}

.bd-form__check {
	display: flex;
	align-items: center;
	gap: .5rem;
	padding: .25rem 0;
	font-weight: 400;
}

.bd-form__actions {
	display: flex;
	gap: .5rem;
	margin-top: 1.25rem;
	padding-top: 1rem;
	border-top: 1px solid var(--bd-border);
}

.bd-form__error {
	margin-top: .75rem;
	padding: .6rem .85rem;
	background: #fee2e2;
	color: #991b1b;
	border-radius: var(--bd-radius);
	font-size: .9rem;
}

/* ===== Login required ===== */
.bd-locked {
	text-align: center;
	padding: 3rem 1.5rem;
	background: var(--bd-bg-card, #fff);
	border: 1px solid var(--bd-border, #e5e7eb);
	border-radius: 12px;
	max-width: 480px;
	margin: 2rem auto;
}

.bd-locked__icon { font-size: 3rem; color: #9ca3af; margin-bottom: 1rem; }
.bd-locked__icon .dashicons { font-size: 3rem; width: 3rem; height: 3rem; }

.bd-locked__title { margin: 0 0 .5rem; font-size: 1.35rem; }
.bd-locked__text { color: var(--bd-text-muted, #6b7280); margin: 0 0 1.5rem; }

.bd-locked__actions { display: flex; gap: .5rem; justify-content: center; flex-wrap: wrap; }

/* Screen reader */
.screen-reader-text {
	position: absolute !important;
	height: 1px; width: 1px;
	overflow: hidden;
	clip: rect(1px,1px,1px,1px);
}

/* Empty state */
.bd-empty {
	text-align: center;
	padding: 4rem 1rem;
	color: var(--bd-text-muted);
	font-style: italic;
}
