/* Buscador IA — overlay (Fase 1). Todo el CSS va prefijado .ais- para no chocar con Journal. */

html.ais-open { overflow: hidden; }

.ais-overlay {
	position: fixed;
	inset: 0;
	z-index: 99999;
	background: rgba(17, 24, 39, .45);
	backdrop-filter: blur(2px);
	display: flex;
	align-items: flex-start;
	justify-content: center;
	padding: 24px 16px;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
}

.ais-panel {
	width: 100%;
	max-width: 1180px;
	background: #fff;
	border-radius: 16px;
	box-shadow: 0 24px 60px rgba(0, 0, 0, .25);
	overflow: hidden;
	animation: ais-in .18s ease-out;
}

@keyframes ais-in {
	from { opacity: 0; transform: translateY(-8px); }
	to   { opacity: 1; transform: translateY(0); }
}

/* Cabecera */
.ais-header {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 16px 18px;
	border-bottom: 1px solid #eef0f4;
}

.ais-input-wrap {
	position: relative;
	flex: 1;
	display: flex;
	align-items: center;
}

.ais-input-icon {
	position: absolute;
	left: 14px;
	width: 18px;
	height: 18px;
	border: 2px solid #9ca3af;
	border-radius: 50%;
	pointer-events: none;
}
.ais-input-icon::after {
	content: '';
	position: absolute;
	right: -6px;
	bottom: -5px;
	width: 8px;
	height: 2px;
	background: #9ca3af;
	transform: rotate(45deg);
}

.ais-input {
	width: 100%;
	height: 48px;
	padding: 0 70px 0 44px;
	border: 1px solid #e5e7eb;
	border-radius: 10px;
	font-size: 17px;
	outline: none;
	transition: border-color .15s, box-shadow .15s;
}
.ais-input:focus {
	border-color: #2563eb;
	box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}

.ais-clear {
	position: absolute;
	right: 12px;
	visibility: hidden;
	background: none;
	border: 0;
	color: #6b7280;
	font-size: 13px;
	cursor: pointer;
	padding: 6px;
}
.ais-clear:hover { color: #111827; }

.ais-close {
	flex: 0 0 auto;
	width: 40px;
	height: 40px;
	border: 0;
	border-radius: 50%;
	background: #f3f4f6;
	color: #374151;
	font-size: 22px;
	line-height: 1;
	cursor: pointer;
}
.ais-close:hover { background: #e5e7eb; }

/* Cuerpo: 20 / 80 */
.ais-body {
	display: flex;
	min-height: 280px;
	max-height: calc(100vh - 220px);
}

.ais-col-left {
	flex: 0 0 20%;
	max-width: 20%;
	padding: 20px 18px;
	border-right: 1px solid #eef0f4;
	overflow-y: auto;
}

.ais-col-right {
	flex: 1 1 80%;
	padding: 20px 22px;
	overflow-y: auto;
}

.ais-left-block h3 {
	margin: 0 0 12px;
	font-size: 12px;
	letter-spacing: .04em;
	text-transform: uppercase;
	color: #6b7280;
}

.ais-recent { list-style: none; margin: 0; padding: 0; }
.ais-recent li { margin-bottom: 10px; }
.ais-recent a {
	display: flex;
	align-items: center;
	gap: 10px;
	color: #1f2937;
	text-decoration: none;
	font-size: 13px;
}
.ais-recent img { width: 34px; height: 34px; object-fit: contain; border-radius: 6px; background: #f9fafb; }
.ais-recent a:hover { color: #2563eb; }

.ais-left-block { margin-bottom: 22px; }
.ais-cats { list-style: none; margin: 0; padding: 0; }
.ais-cats li { margin-bottom: 4px; }
.ais-cats a {
	display: block;
	padding: 7px 10px;
	border-radius: 8px;
	color: #1f2937;
	text-decoration: none;
	font-size: 13px;
	transition: background .12s, color .12s;
}
.ais-cats a:hover { background: #f3f4f6; color: #2563eb; }

.ais-terms { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.ais-terms li { margin: 0; }
.ais-terms a {
	display: inline-block;
	padding: 6px 12px;
	border: 1px solid #e5e7eb;
	border-radius: 999px;
	color: #374151;
	text-decoration: none;
	font-size: 12px;
	transition: background .12s, border-color .12s, color .12s;
}
.ais-terms a:hover { background: #eef2ff; border-color: #c7d2fe; color: #2563eb; }

.ais-right-head {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	flex-wrap: wrap;
	gap: 8px;
	margin: 0 0 16px;
	font-size: 13px;
	font-weight: 700;
	letter-spacing: .03em;
	text-transform: uppercase;
	color: #374151;
}

.ais-view-all {
	font-weight: 600;
	text-transform: none;
	letter-spacing: 0;
	color: #2563eb;
	text-decoration: none;
}
.ais-view-all:hover { text-decoration: underline; }

/* Rejilla de productos */
.ais-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
	gap: 16px;
}

.ais-card {
	display: flex;
	flex-direction: column;
	padding: 12px;
	border: 1px solid #eef0f4;
	border-radius: 12px;
	text-decoration: none;
	color: #111827;
	transition: box-shadow .15s, border-color .15s, transform .1s;
}
.ais-card:hover {
	border-color: #dbe1ea;
	box-shadow: 0 8px 20px rgba(0, 0, 0, .08);
	transform: translateY(-2px);
}

.ais-card-img {
	display: flex;
	align-items: center;
	justify-content: center;
	height: 130px;
	margin-bottom: 10px;
}
.ais-card-img img { max-width: 100%; max-height: 130px; object-fit: contain; }

.ais-card-name {
	font-size: 13px;
	line-height: 1.35;
	margin-bottom: 8px;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.ais-price { font-weight: 700; font-size: 15px; color: #111827; }
.ais-old { color: #9ca3af; font-weight: 500; text-decoration: line-through; font-size: 13px; }
.ais-new { color: #dc2626; }

.ais-card.ais-oos { opacity: .55; }

.ais-empty, .ais-loading {
	padding: 40px 0;
	text-align: center;
	color: #6b7280;
	font-size: 15px;
}

/* Banner */
.ais-banner {
	border-top: 1px solid #eef0f4;
	padding: 14px 18px;
	text-align: center;
}
.ais-banner img { max-width: 100%; height: auto; border-radius: 10px; }

/* Responsive */
@media (max-width: 768px) {
	.ais-overlay { padding: 0; }
	.ais-panel { max-width: 100%; min-height: 100vh; border-radius: 0; }
	.ais-body { flex-direction: column; max-height: none; }
	/* En móvil: primero los productos (lo importante), luego categorías/últimos vistos */
	.ais-col-right { flex-basis: auto; order: 1; }
	.ais-col-left { flex-basis: auto; max-width: 100%; order: 2; border-right: 0; border-top: 1px solid #eef0f4; }
	.ais-grid { grid-template-columns: repeat(2, 1fr); }

	/* Populares en móvil: SLIDER horizontal (una fila, deslizable con el dedo) */
	.ais-grid.ais-slider {
		display: flex;
		grid-template-columns: none;
		overflow-x: auto;
		gap: 12px;
		padding-bottom: 8px;
		scroll-snap-type: x mandatory;
		-webkit-overflow-scrolling: touch;
		scrollbar-width: none;
	}
	.ais-grid.ais-slider::-webkit-scrollbar { display: none; }
	.ais-grid.ais-slider .ais-card {
		flex: 0 0 150px;
		scroll-snap-align: start;
	}
	.ais-grid.ais-slider .ais-card-img { height: 110px; }
	.ais-grid.ais-slider .ais-card-img img { max-height: 110px; }
}

/* Flecha del slider de populares (la muestra/oculta el JS según haya más contenido) */
.ais-slider-wrap { position: relative; }
.ais-slider-next {
	position: absolute;
	right: 2px;
	top: 50%;
	transform: translateY(-50%);
	width: 38px; height: 38px;
	border-radius: 50%;
	border: 1px solid #e5e7eb;
	background: rgba(255, 255, 255, .95);
	box-shadow: 0 4px 12px rgba(0, 0, 0, .18);
	color: #374151;
	font-size: 16px;
	line-height: 1;
	cursor: pointer;
	display: none;
	align-items: center;
	justify-content: center;
	z-index: 2;
}
.ais-slider-next:active { transform: translateY(-50%) scale(.94); }
