/**
 * Chabo Live Search – Styles front-end.
 *
 * Design calqué sur la barre de recherche existante du site
 * (searchBarCefHome / Elementor search widget).
 *
 * @package Chabo_Live_Search
 * @since   1.0.0
 */

/* -------------------------------------------------------------------------
   Conteneur principal
   ------------------------------------------------------------------------- */
.chabo-live-search {
	position: relative;
	font-family: Outfit, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
		Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
	font-size: 16px;
	color: #143127;
	max-width: 600px;
	width: 100%;
}

/* -------------------------------------------------------------------------
   Wrapper du champ de recherche
   ------------------------------------------------------------------------- */
.chabo-ls-input-wrapper {
	position: relative;
}

.chabo-ls-input-inner {
	position: relative;
	display: flex;
	align-items: center;
	background: #fff;
	border: 1px solid #cdcdcd;
	border-radius: 20px;
	box-shadow: none;
	transition: box-shadow 0.25s ease, border-color 0.25s ease;
}

.chabo-ls-input-inner:hover {
	border-color: #b3b3b3;
}

.chabo-ls-input-inner:focus-within {
	box-shadow: 0 0 10px rgba(0, 0, 0, 0.24);
	border-color: #cdcdcd;
	outline: 1.5px solid #143127;
	outline-offset: -1px;
}

/* -------------------------------------------------------------------------
   Champ de saisie
   ------------------------------------------------------------------------- */
.chabo-ls-search-input {
	flex: 1;
	border: none;
	outline: none;
	padding: 20px !important;
	padding-right: 52px; /* espace pour l'icône loupe + bouton X */
	font-family: inherit;
	font-size: 35px;
	font-weight: 700;
	line-height: 1.3;
	background: transparent;
	color: #143127;
	min-width: 0;
	border-radius: 20px !important;
}

.chabo-ls-search-input::placeholder {
	color: #143127;
	opacity: 1;
}

/* Autocomplete : texte fantôme superposé à l'input */
.chabo-ls-suggestion {
	position: absolute;
	top: 0;
	left: 0;
	right: 52px;
	bottom: 0;
	padding: 20px;
	font-family: inherit;
	font-size: 35px;
	font-weight: 700;
	line-height: 1.3;
	color: transparent;
	pointer-events: none;
	white-space: nowrap;
	overflow: hidden;
	z-index: 0;
}

.chabo-ls-suggestion-ghost {
	color: #aaa;
}

/* -------------------------------------------------------------------------
   Icône loupe (à droite)
   ------------------------------------------------------------------------- */
.chabo-ls-search-icon {
	flex-shrink: 0;
	position: absolute;
	right: 18px;
	top: 50%;
	transform: translateY(-50%);
	color: #bfbfbf;
	pointer-events: none;
	z-index: 1;
	font-size: 35px;
	line-height: 1;
}

/* Cacher la loupe quand le bouton X est visible */
.chabo-ls-clear-btn:not([hidden]) ~ .chabo-ls-search-icon {
	display: none;
}

/* -------------------------------------------------------------------------
   Bouton effacer (X)
   ------------------------------------------------------------------------- */
.chabo-ls-clear-btn {
	flex-shrink: 0;
	position: absolute;
	right: 14px;
	top: 50%;
	transform: translateY(-50%);
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 4px;
	border: none;
	border-radius: 50%;
	background: transparent;
	color: #143127;
	cursor: pointer;
	z-index: 2;
	transition: background 0.15s ease;
}

.chabo-ls-clear-btn:hover,
.chabo-ls-clear-btn:focus-visible {
	background: rgba(20, 49, 39, 0.08);
}

.chabo-ls-clear-btn:focus-visible {
	outline: 2px solid #143127;
	outline-offset: 1px;
}

.chabo-ls-clear-btn[hidden] {
	display: none;
}

/* -------------------------------------------------------------------------
   Résultats
   ------------------------------------------------------------------------- */
.chabo-ls-results {
	position: absolute;
	top: calc(100% + 8px);
	left: 0;
	right: 0;
	background: #fff;
	border-radius: 12px;
	box-shadow: 0 4px 24px rgba(32, 33, 36, 0.18);
	z-index: 9999;
	overflow: hidden;
	max-height: 70vh;
	overflow-y: auto;
}

.chabo-ls-results[hidden] {
	display: none;
}

.chabo-ls-results-inner {
	padding: 8px 0;
}

/* -------------------------------------------------------------------------
   Éléments de résultat
   ------------------------------------------------------------------------- */
.chabo-ls-result-item {
	display: block;
	padding: 12px 20px;
	text-decoration: none;
	color: inherit;
	cursor: pointer;
	transition: background 0.1s ease;
	outline: none;
}

.chabo-ls-result-item:hover,
.chabo-ls-result-item:focus-visible,
.chabo-ls-result-item.chabo-ls-active {
	background: rgba(20, 49, 39, 0.05);
}

.chabo-ls-result-item:focus-visible {
	box-shadow: inset 0 0 0 2px #143127;
}

/* URL affichée en haut */
.chabo-ls-result-url {
	font-size: 12px;
	line-height: 1.4;
	color: #5f6368;
	margin-bottom: 2px;
	word-break: break-all;
}

.chabo-ls-result-url .chabo-ls-external-icon {
	margin-left: 5px;
	vertical-align: middle;
	font-size: 12px;
	color: #5f6368;
}

/* Titre */
.chabo-ls-result-title {
	font-size: 16px;
	line-height: 1.4;
	color: #143127;
	margin-bottom: 4px;
	word-break: break-word;
}

.chabo-ls-result-item:hover .chabo-ls-result-title,
.chabo-ls-result-item:focus-visible .chabo-ls-result-title,
.chabo-ls-result-item.chabo-ls-active .chabo-ls-result-title {
	text-decoration: underline;
}

/* Extrait */
.chabo-ls-result-excerpt {
	font-size: 14px;
	line-height: 1.5;
	color: #5f6368;
	word-break: break-word;
}

/* Type de contenu (badge) */
.chabo-ls-result-type {
	display: inline-block;
	margin-top: 6px;
	font-size: 11px;
	font-weight: 500;
	text-transform: uppercase;
	letter-spacing: 0.5px;
	color: #143127;
	background: rgba(20, 49, 39, 0.08);
	padding: 2px 8px;
	border-radius: 4px;
}

/* -------------------------------------------------------------------------
   États : chargement, vide, erreur
   ------------------------------------------------------------------------- */
.chabo-ls-status {
	margin-top: 8px;
	padding: 12px 20px;
	background: #fff;
	border-radius: 12px;
	box-shadow: 0 4px 24px rgba(32, 33, 36, 0.12);
	font-size: 14px;
	color: #5f6368;
	text-align: center;
}

.chabo-ls-status[hidden] {
	display: none;
}

.chabo-ls-status-spinner {
	display: inline-block;
	width: 16px;
	height: 16px;
	border: 2px solid #e8eaed;
	border-top-color: #143127;
	border-radius: 50%;
	animation: chabo-ls-spin 0.6s linear infinite;
	margin-right: 8px;
	vertical-align: middle;
}

@keyframes chabo-ls-spin {
	to {
		transform: rotate(360deg);
	}
}

/* Aucun résultat */
.chabo-ls-empty {
	padding: 24px 20px;
	text-align: center;
	color: #5f6368;
	font-size: 14px;
}

/* -------------------------------------------------------------------------
   Surlignage des mots-clés
   ------------------------------------------------------------------------- */
.chabo-ls-highlight {
	background: #fff3b0;
	color: #143127;
	padding: 1px 2px;
	border-radius: 2px;
	font-weight: 600;
}

/* -------------------------------------------------------------------------
   Responsive
   ------------------------------------------------------------------------- */
@media (max-width: 600px) {
	.chabo-live-search {
		font-size: 15px;
		max-width: 100%;
	}

	.chabo-ls-search-input {
		font-size: 25px;
		padding: 16px;
		padding-right: 48px;
	}

	.chabo-ls-suggestion {
		font-size: 25px;
		padding: 16px;
		right: 48px;
	}

	.chabo-ls-search-icon {
		right: 14px;
		font-size: 25px;
	}

	.chabo-ls-clear-btn {
		right: 10px;
	}

	.chabo-ls-results {
		border-radius: 8px;
		position: relative;
		top: 8px;
		box-shadow: 0 2px 12px rgba(32, 33, 36, 0.12);
	}

	.chabo-ls-result-item {
		padding: 10px 16px;
	}

	.chabo-ls-result-title {
		font-size: 15px;
	}

	.chabo-ls-result-excerpt {
		font-size: 13px;
	}

	.chabo-ls-result-url {
		font-size: 11px;
	}
}

/* -------------------------------------------------------------------------
   Accessibilité : focus visible global
   ------------------------------------------------------------------------- */
.chabo-live-search *:focus-visible {
	outline: 2px solid #143127;
	outline-offset: 1px;
}

/* Message de correction orthographique */
.chabo-ls-correction {
	padding: 8px 20px 4px;
	font-size: 13px;
	color: #5f6368;
	border-bottom: 1px solid #f0f0f1;
}

.chabo-ls-correction strong {
	color: #143127;
}

/* Supprimer l'outline par défaut pour les éléments qui ont focus-visible */
.chabo-live-search *:focus:not(:focus-visible) {
	outline: none;
}

/* -------------------------------------------------------------------------
   Load More / Infinite Scroll
   ------------------------------------------------------------------------- */
.chabo-ls-loadmore {
	display: flex;
	flex-direction: column;
	align-items: center;
	padding: 16px 20px 20px;
	gap: 10px;
}

.chabo-ls-loadmore-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 10px 28px;
	font-family: inherit;
	font-size: 14px;
	font-weight: 500;
	color: #143127;
	background: rgba(20, 49, 39, 0.06);
	border: 1px solid rgba(20, 49, 39, 0.12);
	border-radius: 20px;
	cursor: pointer;
	transition: background 0.2s ease, box-shadow 0.2s ease;
}

.chabo-ls-loadmore-btn:hover {
	background: rgba(20, 49, 39, 0.10);
	box-shadow: 0 2px 8px rgba(20, 49, 39, 0.10);
}

.chabo-ls-loadmore-btn[hidden] {
	display: none;
}

/* Spinner à 3 points (style moderne) */
.chabo-ls-spinner {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	padding: 6px 0;
}

.chabo-ls-spinner[hidden] {
	display: none;
}

.chabo-ls-spinner > div {
	width: 8px;
	height: 8px;
	background: #143127;
	border-radius: 50%;
	animation: chabo-ls-bounce 1.2s infinite ease-in-out both;
}

.chabo-ls-spinner > div:nth-child(1) { animation-delay: -0.32s; }
.chabo-ls-spinner > div:nth-child(2) { animation-delay: -0.16s; }
.chabo-ls-spinner > div:nth-child(3) { animation-delay: 0s; }

@keyframes chabo-ls-bounce {
	0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
	40% { transform: scale(1); opacity: 1; }
}

/* Animation d'apparition des nouveaux résultats */
.chabo-ls-result-item.chabo-ls-fade-in {
	animation: chabo-ls-fadeIn 0.35s ease-out both;
}

@keyframes chabo-ls-fadeIn {
	from { opacity: 0; transform: translateY(8px); }
	to   { opacity: 1; transform: translateY(0); }
}
